Function arm_svdf_s8_output_ctx_get_buffer_size

Function Documentation

int32_t arm_svdf_s8_output_ctx_get_buffer_size(const cmsis_nn_svdf_params *svdf_params, const cmsis_nn_dims *input_dims, const cmsis_nn_dims *weights_feature_dims)

Get size of the output_ctx staging buffer required by arm_svdf_s8().

Returns input_dims->n * (weights_feature_dims->n / svdf_params->rank) * sizeof(int32_t). The division truncates, matching the kernel’s own unit count. As with arm_svdf_s8_input_ctx_get_buffer_size(), the figure is the same on every build target and the validation runs on every target.

Note

Same degenerate-0 contract as arm_svdf_s8_input_ctx_get_buffer_size(), including that a 0 does not license passing { NULL, 0 }. A rank greater than weights_feature_dims->n truncates the unit count to 0 and so returns 0.

Note

arm_svdf_s8() narrows svdf_params->rank to int16_t before dividing by it, so a rank outside int16_t range would make this query and the kernel disagree - 65538 narrows to 2. The kernel can then write unboundedly more than the untruncated formula reports, because that formula truncates to 0 whenever weights_feature_dims->n < 65538: at weights_feature_dims->n = 100 it would report 0 bytes while the kernel writes 50 units, i.e. 200 bytes. Such a rank returns -1 rather than a number the kernel will not honour. Ranks that survive the int16_t round trip, that is within [-32768, 32767], are unaffected; this library does not otherwise constrain svdf_params->rank.

Parameters:
  • svdf_params[in] SVDF parameters; only svdf_params->rank is read

  • input_dims[in] Input tensor dimensions, i.e. the same cmsis_nn_dims passed to arm_svdf_s8()

  • weights_feature_dims[in] Weights (feature) tensor dimensions, i.e. the same cmsis_nn_dims passed to arm_svdf_s8()

Returns:

The function returns required buffer size in bytes, or -1 if any pointer is NULL, if svdf_params->rank is zero, negative or outside int16_t range, if input_dims->n or weights_feature_dims->n is negative, or if the required size would not fit in an int32_t