Function arm_depthwise_conv_wrapper_s8

Function Documentation

arm_cmsis_nn_status arm_depthwise_conv_wrapper_s8(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)

Wrapper function to pick the right optimized s8 depthwise convolution function.

Parameters:
  • ctx[inout] Function context (e.g. temporary buffer). Check the function definition file to see if an additional buffer is required. Optional function {API}_get_buffer_size() provides the buffer size if required. The caller is expected to clear the buffer, if applicable, for security reasons.

  • weight_sum_ctx[in] Per-channel weight sums, supplied by the caller. The selected kernel only reads this buffer and never writes it, so it is filled once and may then be reused for as long as filter, bias and dw_conv_params->input_offset are unchanged - see arm_depthwise_convolve_weight_sum() for the layout and the full reuse rules. Whether the buffer is consumed at all depends on the route this wrapper takes. It is forwarded to arm_depthwise_conv_s8_opt(), which reads it under MVE, only when dw_conv_params->ch_mult == 1, input_dims->n == 1 and both dilations are 1. Outside that case the wrapper calls arm_depthwise_conv_s8(), which has no such parameter and ignores the context entirely - which is why several in-tree tests legitimately pass sums built by arm_convolve_weight_sum(), or none at all, on those routes. On MVE with input_dims->c == 1 and an output channel count above CONVERT_DW_CONV_WITH_ONE_INPUT_CH_AND_OUTPUT_CH_ABOVE_THRESHOLD (8 on armclang, 1 otherwise), the layer is instead converted to a regular convolution, and conv-style sums from arm_convolve_weight_sum() are what that route wants. Where the sums are actually read, fill the buffer with arm_depthwise_convolve_weight_sum(), passing dw_conv_params->input_offset as lhs_offset and the same bias given here, so that entry j holds input_offset * sum(weights of channel j) + bias[j]. That helper returns ARM_CMSIS_NN_NO_IMPL_ERROR on non-MVE builds, which is not a failure. Pass a valid context on every build. On the arm_depthwise_conv_s8_opt() route, a NULL buf is diagnosed with ARM_CMSIS_NN_ARG_ERROR on builds where the buffer is actually read (ARM_MATH_DSP and ARM_MATH_MVEI both defined); on other builds the parameter is unread and NULL is accepted. On MVE with input_dims->c == 1 and an output channel count above CONVERT_DW_CONV_WITH_ONE_INPUT_CH_AND_OUTPUT_CH_ABOVE_THRESHOLD (8 on armclang, 1 otherwise), this wrapper instead diverts to arm_convolve_wrapper_s8(), which can select kernels that do not check the buffer. A NULL buf is not diagnosed on every route, so do not rely on getting an error back. None of this is a guarantee about future versions. Sized by arm_convolve_s8_get_weights_sum_size(): output_dims->c * sizeof(int32_t) where the sums are used, 0 otherwise. The caller is expected to clear the buffer, if applicable, for security reasons.

  • dw_conv_params[in] Depthwise convolution parameters (e.g. strides, dilations, pads,…) dw_conv_params->dilation is not used. Range of dw_conv_params->input_offset : [-127, 128] Range of dw_conv_params->output_offset : [-128, 127]

  • quant_params[in] Per-channel quantization info. It contains the multiplier and shift values to be applied to each output channel

  • input_dims[in] Input (activation) tensor dimensions. Format: [H, W, C_IN] Batch argument N is not used and assumed to be 1.

  • input_data[in] Input (activation) data pointer. Data type: int8

  • filter_dims[in] Filter tensor dimensions. Format: [1, H, W, C_OUT]

  • filter_data[in] Filter data pointer. Data type: int8

  • bias_dims[in] Bias tensor dimensions. Format: [C_OUT]

  • bias_data[in] Bias data pointer. Data type: int32

  • output_dims[in] Output tensor dimensions. Format: [1, H, W, C_OUT]

  • output_data[inout] Output data pointer. Data type: int8

Returns:

The function returns ARM_CMSIS_NN_SUCCESS on successful completion, or ARM_CMSIS_NN_ARG_ERROR on the arm_depthwise_conv_s8_opt() route if ctx->buf is NULL when a scratch buffer is required, or if weight_sum_ctx->buf is NULL on builds where it is read (ARM_MATH_DSP and ARM_MATH_MVEI both defined).