CtxBufUsage
PythonHow an operator's lowering uses cmsisnncontext::buf.
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.
NO_CTX
PythonNO_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.
IGNORED
PythonIGNORED = 'ignored'A context is passed, but no dispatchable kernel dereferences
buf (typically an explicit (void)ctx; upstream).
REQUIRED
PythonREQUIRED = 'required'At least one dispatchable kernel dereferences ctx->buf
for every configuration the operator supports.
CONDITIONAL
PythonCONDITIONAL = 'conditional'Whether buf is dereferenced depends on dtype, target
capability, or operator options. Subclasses declaring this MUST
override :meth:AotOperator.ctx_buf_required.