Function arm_convolve_weight_sum¶
Defined in File arm_nnfunctions.h
Function Documentation¶
-
arm_cmsis_nn_status arm_convolve_weight_sum(int32_t *vector_sum_buf, const int8_t *rhs, const cmsis_nn_dims *input_dims, const cmsis_nn_dims *filter_dims, const cmsis_nn_dims *output_dims, const int32_t lhs_offset, const int32_t *bias_data)¶
Pre-computes per-output-channel weight sums for a standard convolution.
Supported framework : TensorFlow Lite Micro
The buffer pointed to by
vector_sum_bufmust be at leastoutput_dims->c × sizeof(int32_t)bytes. arm_convolve_s8_get_weights_sum_size() returns that size on builds that use the sums, and 0 elsewhere.Layout: one int32 per output channel, indexed 0..
output_dims->c - 1. Entry j holdslhs_offset * sum(weights of output channel j) + bias_data[j], i.e. the bias and the input-offset contribution folded together. For grouped convolution the entries run over all output channels, with the groups laid out consecutively.This is the buffer the
weight_sum_ctxparameter of the s8 convolution kernels carries. Those kernels currently treat it as an input they only read, so it has to be filled before the call - see the individual functions for what each one currently does on MVE and non-MVE builds.Reuse and invalidation: the contents depend only on
rhs,bias_dataandlhs_offset. They do not depend on the activations, so a buffer stays valid across calls and across batches for as long as those three are unchanged - for a static model the sums can be computed once at load time rather than per inference. Recompute whenever the weights, the bias or the input offset change (for example on requantization or a weight reload). The buffer is sized by one layer’soutput_dims->cand is specific to that layer’s weights, so it cannot be shared between layers; give each layer its own.Returns
ARM_CMSIS_NN_NO_IMPL_ERRORon builds without the MVE extension, where the sums are currently not consumed.
- Parameters:
vector_sum_buf – [out] Pointer to the buffer that will hold the weight sums.
rhs – [in] Pointer to the filter weights. Data type: int8
input_dims – [in] Input tensor dimensions. Format: [N, H, W, C_IN]
filter_dims – [in] Filter tensor dimensions. Format: [C_OUT, KH, KW, C_IN]
output_dims – [in] Output tensor dimensions. Format: [N, H, W, C_OUT]
lhs_offset – [in] Input-offset added to every input element before MAC. Range: [-127, 128]
bias_data – [in] Optional bias pointer. Data type: int32
- Returns:
ARM_CMSIS_NN_ARG_ERRORon invalid arguments,ARM_CMSIS_NN_NO_IMPL_ERRORon builds without the MVE extension, where the sums are currently not consumed and the buffer is left untouched, orARM_CMSIS_NN_SUCCESSon success. Portable code should not treat theNO_IMPL_ERRORcase as a failure.