batch_matmul
Classes
BatchMatMulOperator
BatchMatMulOperator(op: AirOperator, model: AirModel, platform: SocPlatform, prefix: str = 'aot', attributes: dict[str, str] = {})
BATCH_MATMUL operator.
This operator computes the batch matrix multiplication of two tensors.
Parameters:
-
(opAirOperator) –The AIR operator to wrap.
-
(modelAirModel) –The AIR model.
-
(platformSocPlatform) –The target platform for code generation.
-
(prefixstr, default:'aot') –Prefix for generated code files. Defaults to "aot".
-
(attributesdict[str, str], default:{}) –Attributes for template values. Defaults to {}.
Functions
ctx_buf_required
Whether the dispatched batch-matmul kernel dereferences ctx->buf.
Stated directly against the upstream preprocessor gate rather than
against :meth:compute_scratch_size, so the resolve-time guard is a
real cross-check of two independent derivations rather than a
tautology: in arm_batch_matmul_s8.c (v7.29.0) the vector-sum buffer
read lives entirely inside #if defined(ARM_MATH_MVEI).
Returns:
-
bool–Truefor an int8 output on an MVE target.
compute_scratch_size
Compute the scratch size for the operator.
Only arm_batch_matmul_s8 consumes a ctx buffer, and only under
MVE: it needs a kernel-sum buffer of rhs_dims.w int32 words, which
arm_vector_sum_s8 clears in full. The LHS never enters the
requirement. arm_batch_matmul_s16 discards ctx outright
((void)ctx;) and the float kernels take no scratch, so every
non-int8 dtype must report 0 rather than reserve dead arena bytes.
Returns:
-
int(int) –Computed scratch size in bytes.
validate
Validate operand dtypes and ranks against the emitted kernel contract.
Raises:
-
ConfigValueError–If a tensor dtype is unsupported, the operand dtypes disagree, or an operand rank falls outside 2..4.
compute_values
emit
Generate the source code for the operator.
Parameters:
-
(save_pathPath) –Path to save the generated code.