Struct anira_processor_desc#

struct anira_processor_desc#

Collaboration diagram for anira_processor_desc:

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

The one processor of a pipeline, handed once to anira_pipeline_add_processor and copied within struct_size into a refcounted carrier that the pipeline and every handler created from it share. Tier 2: struct_size first, user_data third (its offset never moves), no implicit padding (LP64 112 bytes, ILP32 64), growth at the tail. The slots, from the innermost level out: the four phases, reset, prepare, unprepare, init, release; every per-chunk slot receives (ctx, prepared, user_data), prepare hands prepared back per handler and unprepare gets it back, init runs once per registration with the shared init record, the shape the engine descriptor of anira/abi/engine.h shares (with its model level, load and unload, between prepare and init). The processor has no name: a pipeline holds one, so a name identifies nothing, and every record about it says “the processor”. Its optional id names its inference hooks for the model’s figure (below). A NULL phase slot means anira’s default body runs for that phase; a filled slot means the processor owns the phase for every slot with a host end and calls the default itself for what it does not handle. The descriptor carries no domain: the processor works at the host end of every slot, in the host domain the contract declares for that tensor (anira_contract_set_host_domain), and never crosses one.

Public Members

uint32_t struct_size#

sizeof(anira_processor_desc) of the caller’s header.

uint32_t abi_version#

ANIRA_ABI_VERSION the caller compiled against.

void *user_data#

Handed to every callback as it is; never read by anira. One per registration, shared by every handler of the pipeline: what one handler keeps lives behind the prepared pointer its prepare hands back.

const char *const *consumed_kinds#

The extensions the processor reads at prepare, as “<host>:<kind>” strings (hosts: tensor_spec, model, model_config, context, contract), copied; NULL with a count of 0 for none. They join the consumed-or-fail walk of anira_handler_create and anira_handler_prepare, and each consumed slot is an anira_plan_ext row whose consumer reads “processor”.

uint32_t num_consumed_kinds#

The length of consumed_kinds.

uint32_t realtime_phases#

The processor’s real-time promise, per phase: an OR of ANIRA_PHASE_BIT(phase) over the per-chunk phases whose bodies allocate nothing, lock nothing and block on nothing (ANIRA_PHASE_PRE_PROCESS, ANIRA_PHASE_POST_PROCESS, ANIRA_PHASE_BEFORE_INFERENCE, ANIRA_PHASE_AFTER_INFERENCE, ANIRA_PHASE_RESET); 0 promises nothing. anira_handler_prepare checks the promise against the placement: every filled phase that the contract runs on the driving thread must carry its bit, else prepare fails with ANIRA_ERROR_CONFIG naming the phase and realtime_phases. Under a Hard contract those are pre_process, post_process and reset; under an Async contract none. A promised phase that is not filled is no error, and a NULL slot needs no bit (the default bodies are real-time by construction). The bit of any other phase is ANIRA_ERROR_INVALID_ARGUMENT at anira_pipeline_add_processor.

anira_processor_fn pre_process#

ANIRA_PHASE_PRE_PROCESS, on the thread where the host end is produced (the driving thread under a Hard contract): takes the host end of every slot to its model tensor, the chunking and the conversion. A filled slot owns the phase and calls anira_processor_default_pre_process itself for the slots it wants the default fill on. NULL: the default body runs.

anira_processor_fn post_process#

ANIRA_PHASE_POST_PROCESS, on the thread where the host end is consumed: takes the model tensor of every output slot back to its host end; anira_processor_default_post_process is the default push. NULL: the default body runs.

anira_processor_fn before_inference#

ANIRA_PHASE_BEFORE_INFERENCE, on the inference thread behind the State feed and ahead of the edge into the backend’s domain. NULL: not taking part.

anira_processor_fn after_inference#

ANIRA_PHASE_AFTER_INFERENCE, on the inference thread behind the edge out of the backend’s domain and ahead of the State capture. NULL: not taking part.

anira_processor_reset_fn reset#

ANIRA_PHASE_RESET: the first chunk of a new stream, before its pre_process, on the thread that runs pre_process. NULL: nothing to reset.

anira_processor_prepare_fn prepare#

Called at every anira_handler_prepare, per handler, handing the prepared pointer back; NULL for none (prepared is NULL in every later call).

anira_processor_unprepare_fn unprepare#

Called once per successful prepare, at the next anira_handler_prepare and at anira_handler_destroy; NULL for none.

anira_processor_init_fn init#

ANIRA_PHASE_INIT: called once per registration, by the first anira_handler_prepare of a handler of the pipeline, before that handler’s prepare; NULL for none.

anira_processor_release_fn release#

Called once, when the last carrier dies, after every unprepare; NULL for none.

const char *id#

What the processor’s before_inference and after_inference are, for the model’s figure: a prepare’s warm-up pass times them with the engine call, so the figure of a pipeline whose processor fills either hook is the model’s with these hooks, and is shared by every handler whose processor gives the same id (identical plugins register the same id, a reverse-URI name such as “com.example.myplugin.window”, and so report identical latency). NULL or empty: a processor with an inference hook is told apart by its registration, so each one measures its own figure; a processor without one never enters the figure’s key. Copied. A tail field: a caller whose header ends before it registers no id.