Function arm_depthwise_conv_s8_opt

Function Documentation

arm_cmsis_nn_status arm_depthwise_conv_s8_opt(const cmsis_nn_context *ctx, const cmsis_nn_context *weight_sum_ctx, const cmsis_nn_dw_conv_params *dw_conv_params, const cmsis_nn_per_channel_quant_params *quant_params, const cmsis_nn_dims *input_dims, const int8_t *input_data, const cmsis_nn_dims *filter_dims, const int8_t *filter_data, const cmsis_nn_dims *bias_dims, const int32_t *bias_data, const cmsis_nn_dims *output_dims, int8_t *output_data)

Optimized s8 depthwise convolution function with constraint that in_channel equals out_channel. Refer arm_depthwise_conv_s8() for the argument details it has in common with this function.

  • Supported framework: TensorFlow Lite

  • The following constrains on the arguments apply

    1. Number of input channel equals number of output channels or ch_mult equals 1

  • Reccomended when number of channels is 4 or greater.

Note

The second argument, weight_sum_ctx, has no counterpart on arm_depthwise_conv_s8(), so it is described here rather than by reference. It carries per-channel weight sums that the caller supplies: this function only reads the buffer and never writes it, so it is filled once and may then be reused for as long as the weights, the bias and dw_conv_params->input_offset are unchanged - see arm_depthwise_convolve_weight_sum() for the layout and the full reuse rules. Fill it with arm_depthwise_convolve_weight_sum(), which walks the channel-interleaved depthwise weight layout; arm_convolve_weight_sum() sums a different set of weights and is not a substitute here. That helper returns ARM_CMSIS_NN_NO_IMPL_ERROR on non-MVE builds, which is not a failure. Size the buffer with arm_convolve_s8_get_weights_sum_size(): output_dims->c * sizeof(int32_t) where the sums are used, 0 otherwise, and clear it afterwards if applicable for security reasons. Pass a valid context on every build. On builds where the buffer is actually read (ARM_MATH_DSP and ARM_MATH_MVEI both defined), a NULL buf is diagnosed and this function returns ARM_CMSIS_NN_ARG_ERROR, matching arm_convolve_s8(). On other builds the parameter is unread and NULL is accepted. An allocated-but-unfilled buffer cannot be diagnosed the same way: it still produces wrong output while returning ARM_CMSIS_NN_SUCCESS, since an all-zero weight-sum vector is a legal result. None of this is a guarantee about future versions.

Note

MVE channel tail loads and stores are predicated, so channel-indexed arrays are not accessed beyond the number of channels.

Returns:

The function returns one of the following ARM_CMSIS_NN_ARG_ERROR - input channel != output channel or ch_mult != 1, or ctx->buf is NULL when a scratch buffer is required, or weight_sum_ctx->buf is NULL on builds where it is read (ARM_MATH_DSP and ARM_MATH_MVEI both defined) ARM_CMSIS_NN_SUCCESS - Successful operation