fully_connected
Classes
FullyConnectedOperator
FullyConnectedOperator(op: AirOperator, model: AirModel, platform: SocPlatform, prefix: str = 'aot', attributes: dict[str, str] = {})
FULLY_CONNECTED operator.
This operator performs a fully connected layer operation on the input tensor with the given weight and bias 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 {}.
Attributes
Functions
ctx_buf_required
Whether the dispatched fully-connected kernel dereferences ctx->buf.
Read off ns-cmsis-nn v7.29.0 rather than off
:meth:compute_weight_sum_size, so the resolve-time guard compares two
independent derivations: arm_fully_connected_s8 and
arm_fully_connected_per_channel_s8 read
const int32_t *kernel_sum = (const int32_t *)ctx->buf; only inside
#if defined(ARM_MATH_MVEI), behind a NULL check that returns
ARM_CMSIS_NN_ARG_ERROR. arm_fully_connected_s16 / _s4 and
the float kernels are (void)ctx;.
KNOWN GAP -- deliberately not reported by this guard:
arm_fully_connected_per_channel_s16 requires ctx->buf
unconditionally for its reduced-multiplier table
(arm_fully_connected_per_channel_s16.c: if ((ctx == NULL) ||
(ctx->buf == NULL) || ...) return ARM_CMSIS_NN_ARG_ERROR; then
int32_t *reduced_multiplier = (int32_t *)ctx->buf;, needing
output_ch * sizeof(int32_t) bytes). fully_connected.c.j2 reaches
that kernel on the per-channel int16 path whenever
:meth:_can_use_direct_int16_per_channel declines (e.g. non-zero filter
zero-points), and :meth:compute_weight_sum_size returns 0 for int16 --
so ctx.buf is NULL and the kernel bails out with ARG_ERROR at
runtime. That is a separate, pre-existing defect: it needs a new
scratch allocation and changes the memory plan, not just a declaration.
Returning True here would make it a hard resolve failure for a
configuration that already ships, so it is reported rather than
enforced. Widen this method once that buffer is actually allocated.
Returns:
-
bool–Trueif the selected lowering needs a non-NULLctx.buf.
shared_kernel_helpers
Declare the shared FC kernel when the per-channel int8 path is used.
compute_weight_sum_size
Compute the size of the weight sum tensor.
Returns:
-
int(int) –Size of the weight sum tensor in int32_t.
compute_values
emit
Generate the source code for the operator.
Parameters:
-
(save_pathPath) –Path to save the generated code.