Docs / nablatensor-core / com.nablatensor.engine

interface

AadEngine

A backend able to turn a recorded tape into something replayable.

Implementations are discovered with ServiceLoader, so a backend becomes usable simply by being on the module path. An implementation that depends on an optional runtime capability — a CUDA device, an incubating JDK module — must keep that dependency out of its own class body and report it through isAvailable(), so that merely enumerating engines cannot fail on a machine that lacks it.

Methods

String name()

Stable lower-case identifier used by -Dnablatensor.engine.

int priority()

Higher wins when selecting automatically. CUDA is 100, SIMD 50, scalar 10, so an accelerator is always preferred unless one is named explicitly.

boolean isAvailable()

Whether this engine can run here, right now. Must never throw.

boolean supports(AadOptions options)

Whether this engine can honour these options at all.

String describe()

Short human-readable description of what it will run on.

AadExecutable compile(AadTape tape, AadOptions options)
void requireSupportedTape(AadTape tape)

The two limits every generated-kernel backend currently shares: one stream of standard normals, and one recorded output. Called at the top of compile so that automatic selection falls back to an engine that can take the tape rather than failing the run.

static void requireBasicRandom(AadTape tape, String engine)

Guard for backends that only implement a single stream of standard-normal draws: throws (so automatic selection falls back to one that can) when the tape uses rec.randu() or a named rec.stream(...). A backend that has grown native support for those simply does not call this.

static void requireSingleOutput(AadTape tape, String engine)

Guard for backends that only implement a single output: throws (so automatic selection falls back) when the tape was recorded with several rec.output(name, ...) calls.