Function arm_convolve_1x1_out_s8¶
Defined in File arm_nnfunctions.h
Function Documentation¶
-
arm_cmsis_nn_status arm_convolve_1x1_out_s8(const cmsis_nn_context *ctx, const cmsis_nn_context *weight_sum_ctx, const cmsis_nn_conv_params *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)¶
Optimised convolution for 1x1 output images (shape of BX1x1xC_OUT) for 8x8 computations.
Supported framework : TensorFlow Lite Micro
Optimised for Bx1×1xC output CNN layers.
Constraints:
output_dims->handoutput_dims->wmust equal 1output_dims->cis expected to be a multiple of 4 for best performance
- Parameters:
ctx – [inout] Function context that supplies a scratch buffer for activation rearrangement. A NULL buf is diagnosed with ARM_CMSIS_NN_ARG_ERROR. The buffer must hold one 4-byte-aligned GEMM row, that is round_up_4(filter_dims->h * filter_dims->w * filter_dims->c) bytes, as returned by arm_convolve_1x1_out_s8_get_buffer_size(). The requirement does not scale with the group count: the kernel rewinds its im2col cursor to the start of the buffer after each group. Setting ctx->size lets this function reject an undersized buffer with ARM_CMSIS_NN_ARG_ERROR; leaving it at zero opts out of that check, which is what TFLite Micro and derivatives do today. The caller is expected to clear the buffer, if applicable, for security reasons.
weight_sum_ctx – [in] Per-output-channel weight sums, supplied by the caller. This function only reads the buffer and never writes it, so it is filled once and may then be reused for as long as filter_data, bias_data and conv_params->input_offset are unchanged - see arm_convolve_weight_sum() for the layout and the full reuse rules. Fill it with arm_convolve_weight_sum(), passing conv_params->input_offset as lhs_offset and the same bias_data given here. 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. The contents are read only on builds with the MVE extension (ARM_MATH_MVEI), where a NULL buf is diagnosed with ARM_CMSIS_NN_ARG_ERROR; on other builds the parameter is unread and NULL is accepted. An allocated-but-unfilled buffer cannot be diagnosed the same way: on MVE it yields wrong output while still 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. Sized by arm_convolve_s8_get_weights_sum_size(): output_dims->c * sizeof(int32_t) where the sums are used, 0 otherwise, and -1 for an output_dims->c that is negative or too large to size. The caller is expected to clear the buffer, if applicable, for security reasons.
conv_params – [in] Convolution parameters (stride, dilation, pad, offsets). Range of conv_params->input_offset : [-127, 128] Range of conv_params->output_offset : [-128, 127]
quant_params – [in] Per-channel quantisation multipliers and shifts.
input_dims – [in] Input tensor dimensions. Format: [N, H, W, C_IN]
input_data – [in] Pointer to input data. Data type: int8
filter_dims – [in] Filter tensor dimensions. Format: [C_OUT, KH, KW, C_IN]
filter_data – [in] Pointer to filter data. Data type: int8
bias_dims – [in] Bias tensor dimensions. Format: [C_OUT]
bias_data – [in] Optional bias pointer. Data type: int32
output_dims – [in] Output tensor dimensions. Format: [N, 1, 1, C_OUT]
output_data – [out] Pointer to output data. Data type: int8
- Returns:
ARM_CMSIS_NN_ARG_ERRORon bad args, orARM_CMSIS_NN_SUCCESSon success.