Skip to content

operator

Classes

Conv2DOperator

Conv2DOperator(op: AirOperator, model: AirModel, platform: SocPlatform, prefix: str = 'aot', attributes: dict[str, str] = {})

CONV_2D operator.

This operator performs 2D convolution on the input tensor with the given filter tensor.

Parameters:

  • op

    (AirOperator) –

    The AIR operator to wrap.

  • model

    (AirModel) –

    The AIR model.

  • platform

    (SocPlatform) –

    The target platform for code generation.

  • prefix

    (str, default: 'aot' ) –

    Prefix for generated code files. Defaults to "aot".

  • attributes

    (dict[str, str], default: {} ) –

    Attributes for template values. Defaults to {}.

Functions

ctx_buf_required
ctx_buf_required() -> bool

Whether the selected convolution kernel dereferences a context buf.

Keyed on the kernel actually chosen in :meth:on_resolve, because CONV_2D's dispatch table mixes kernels that require an im2col buffer, kernels that require only the weight-sum buffer, and kernels that ignore the context entirely. Two independent conditions:

  • :data:_CTX_BUF_KERNELS -- the kernel's entry point hard-requires ctx->buf.
  • :data:_WEIGHT_SUM_BUF_KERNELS_MVE -- the kernel ignores ctx but forwards weight_sum_ctx->buf into a routine that indexes it unchecked under MVE.

Both are satisfied by the same any-of backing check, since :attr:CTX_BUF_BACKING_TENSOR_NAMES covers both tensor roles.

Returns:

  • bool

    True if the selected kernel needs a non-NULL context buffer.

  • bool

    False when no kernel has been selected yet.

compute_values
compute_values() -> dict[str, str]

Compute the values for the operator.

Returns:

  • dict[str, str]

    dict[str, str]: Computed values for the operator.

emit
emit(save_path: Path)

Generate the source code for the operator.

Parameters:

  • save_path
    (Path) –

    Path to save the generated code.

Functions