Function arm_depthwise_convolve_weight_sum¶
Defined in File arm_nnfunctions.h
Function Documentation¶
-
arm_cmsis_nn_status arm_depthwise_convolve_weight_sum(int32_t *vector_sum_buf, int8_t *scratch_buf, const int8_t *rhs, const cmsis_nn_dw_conv_params *dw_conv_params, 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-channel weight sums for a depthwise convolution.
Supported framework : TensorFlow Lite Micro
Layout: one int32 per channel, sized by arm_convolve_s8_get_weights_sum_size(). Entry j holds
bias_data[j] + lhs_offset * sum(kernel values of channel j).Reuse and invalidation follow the same rules as arm_convolve_weight_sum(): the contents depend only on
rhs,bias_dataandlhs_offset, so they may be computed once and reused until one of those changes, and they are specific to a single layer.Returns
ARM_CMSIS_NN_NO_IMPL_ERRORon builds without the MVE extension, where the sums are currently not consumed.Not interchangeable with arm_convolve_weight_sum(): this function walks the channel-interleaved depthwise layout
[1, KH, KW, C_OUT]with a stride of C_OUT, whereas arm_convolve_weight_sum() sums contiguous runs ofKH * KW * C_INweights. The two agree only by coincidence. Several in-tree tests do fill a depthwise weight_sum_ctx with arm_convolve_weight_sum() and are still correct, for one of three unrelated reasons: arm_depthwise_conv_wrapper_s8() does not consume the buffer on that route at all (ch_mult != 1, batches != 1 or dilation != 1); the wrapper converts the layer to a regular convolution, so conv-style sums are what is wanted; or C_OUT is 1, which collapses the stride-C_OUT walk to a contiguous one and makes the two helpers compute identical values. None of those generalise, so do not read them as licence to substitute one helper for the other. Use this function wherever the sums are actually read.
- Parameters:
vector_sum_buf – [out] Buffer to hold the computed weight sums.
scratch_buf – [inout] Currently unused: the implementation does not read or write it on any build, so NULL is accepted. Retained for signature compatibility; if a real buffer is passed, the caller is expected to clear it for security reasons.
rhs – [in] Depthwise convolution weights. Data type: int8
dw_conv_params – [in] Depthwise-convolution parameters (stride, dilation, pad, etc.)
input_dims – [in] Input tensor dimensions. Format: [N, H, W, C_IN]
filter_dims – [in] Filter tensor dimensions. Format: [1, KH, KW, C_OUT]
output_dims – [in] Output tensor dimensions. Format: [N, H, W, C_OUT]
lhs_offset – [in] Input-offset applied 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.