Skip to content

average_pool_2d

Classes

AveragePool2DOperator

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

AVERAGE_POOL_2D operator.

This operator computes the average pooling of a 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 dispatched avgpool kernel dereferences ctx->buf.

Derived from the upstream preprocessor structure rather than from :meth:compute_scratch_size, so the two are independent statements of the same rule and the resolve-time guard actually cross-checks them. In arm_avgpool_s8.c / arm_avgpool_s16.c (v7.29.0) the whole ARM_MATH_MVEI branch opens with (void)ctx;; only the scalar/DSP branch takes int32_t *buffer = (int32_t *)ctx->buf;, and that read sits under #if defined(ARM_MATH_DSP). The float kernels (arm_avg_pool_f32 / _f16) are (void)ctx; outright.

Returns:

  • bool

    True on a non-MVE, DSP-capable target with an integer output.

compute_scratch_size
compute_scratch_size() -> int

Compute the scratch size for the operator in bytes.

Returns:

  • int ( int ) –

    Computed scratch size in bytes.

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