Class anira::EngineContext#

class EngineContext#

Collaboration diagram for anira::EngineContext:

digraph {
    graph [bgcolor="#00000000"]
    node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2]
    edge [color="#1414CE"]
    "1" [label="anira::EngineContext" tooltip="anira::EngineContext" fillcolor="#BFBFBF"]
    "2" [label="anira_engine_ctx" tooltip="anira_engine_ctx"]
    "4" [label="anira_memory_handle" tooltip="anira_memory_handle"]
    "5" [label="anira_sync_token" tooltip="anira_sync_token"]
    "3" [label="anira_tensor" tooltip="anira_tensor"]
    "1" -> "2" [dir=forward tooltip="usage"]
    "2" -> "3" [dir=forward tooltip="usage"]
    "3" -> "4" [dir=forward tooltip="usage"]
    "3" -> "5" [dir=forward tooltip="usage"]
}

What a process or reset call of an Engine::Prepared sees: a view of the anira_engine_ctx anira fills on its own stack for the call, the engine’s twin of ProcessorContext. The tensors are in the record, one descriptor per slot of either side in slot order (the tensor’s position in the model configuration’s input or output list, State tensors included), over the memory the engine reads and writes. Valid until the callback returns, and never kept beyond it. The engine rule of anira/abi/engine.h binds here: read every extent and every memory handle from the tensors of THIS call, never from a value kept at prepare, and never assume a tensor is anira’s own buffer (the halves of a declared State pair alternate between two buffers, unless the engine’s flags() carry ANIRA_ENGINE_FLAG_STATE_ALIAS, where one stable buffer is both halves of every call and the engine updates it in place; a later pre-release hands a caller’s Buffer tensor over in place).

[inference-thread]: every method is noexcept, allocates nothing and reads one field of the record.

Public Functions

inline explicit EngineContext(const anira_engine_ctx *ctx) noexcept#

Wraps the record a process or reset call received; never NULL (anira hands out none).

inline uint32_t instance() const noexcept#

The shared slot of the loaded model this call runs on, 0 .. EngineLoadInfo::instances

  • 1; never two calls at once on one instance. 0 for an exclusive call, which claimed no slot.

inline uint32_t entry() const noexcept#

The chunk’s position in the handler’s chunk pool (ProcessorContext::entry of the same chunk).

inline anira_ticket ticket() const noexcept#

ANIRA_TICKET_INVALID under a Hard contract; the job’s ticket under an Async one.

inline uint32_t flags() const noexcept#

Per-call flags: ANIRA_ENGINE_CALL_EXCLUSIVE for a call of an exclusive handler.

inline bool exclusive() const noexcept#

Whether ANIRA_ENGINE_CALL_EXCLUSIVE is set: the call is an exclusive handler’s, runs on what its Prepared built and claimed no shared slot.

inline void *loaded() const noexcept#

What this loaded model’s load handed back (the C loaded pointer): for an anira::Engine the Engine::Loaded the call runs on, which its Prepared holds already.

inline std::span<const Tensor> inputs() const noexcept#

The model’s input list, State tensors included: the descriptors over the memory the engine reads, the spec’s dtype and the engine-side extents of the load record’s templates, with the data.

inline std::span<Tensor> outputs() const noexcept#

The output twin, over the memory the engine writes.

inline const anira_engine_ctx *native() const noexcept#