Skip to content
heliaAOT
HELIA HUB

CtxBufUsage

Machine-readable model

  • CtxBufUsageclassHow an operator's lowering uses cmsisnncontext::buf.
class

How an operator's lowering uses cmsisnncontext::buf.

helia_aot/aot/operators/operator.py:63

CtxBufUsage()

How an operator’s lowering uses cmsis_nn_context::buf.

Every registered operator declares one of these via :attr:AotOperator.CTX_BUF_USAGE. The declaration is the machine-checkable half of a rule that used to live only in reviewers’ heads: a kernel that dereferences ctx->buf must never be handed a context whose buf is NULL. Templates set ctx.buf = NULL whenever the operator allocated no scratch tensor, so an operator whose scratch sizing returns 0 for a dtype/target combination that still reaches a buf-reading kernel emits a guaranteed NULL dereference – either a silent memory-corrupting write (for the kernels with no NULL guard) or a runtime ARM_CMSIS_NN_ARG_ERROR that leaves the output stale. See :meth:AotOperator._assert_ctx_buf_backed for why neither is caught before silicon without a resolve-time check.

constant

NO_CTX

Python

helia_aot/aot/operators/operator.py:92

NO_CTX = 'no_ctx'

The template passes no cmsis_nn_context to any kernel – either it calls no CMSIS-NN kernel at all, or every kernel it dispatches takes no context argument.

constant

helia_aot/aot/operators/operator.py:95

CONDITIONAL = 'conditional'

Whether buf is dereferenced depends on dtype, target capability, or operator options. Subclasses declaring this MUST override :meth:AotOperator.ctx_buf_required.