# helia_aot.aot.operators.operator.CtxBufUsage

## helia_aot.aot.operators.operator.CtxBufUsage

`class` · `python`

```python
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.

Source: `helia_aot/aot/operators/operator.py:63`

### helia_aot.aot.operators.operator.CtxBufUsage.NO_CTX

`constant` · `python`

```python
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.

Source: `helia_aot/aot/operators/operator.py:92`

### helia_aot.aot.operators.operator.CtxBufUsage.IGNORED

`constant` · `python`

```python
IGNORED = 'ignored'
```

A context is passed, but no dispatchable kernel dereferences
``buf`` (typically an explicit ``(void)ctx;`` upstream).

Source: `helia_aot/aot/operators/operator.py:93`

### helia_aot.aot.operators.operator.CtxBufUsage.REQUIRED

`constant` · `python`

```python
REQUIRED = 'required'
```

At least one dispatchable kernel dereferences ``ctx->buf``
for every configuration the operator supports.

Source: `helia_aot/aot/operators/operator.py:94`

### helia_aot.aot.operators.operator.CtxBufUsage.CONDITIONAL

`constant` · `python`

```python
CONDITIONAL = 'conditional'
```

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

Source: `helia_aot/aot/operators/operator.py:95`
