Function arm_svdf_f16_input_ctx_get_buffer_size

Function Documentation

int32_t arm_svdf_f16_input_ctx_get_buffer_size(const cmsis_nn_dims *input_dims, const cmsis_nn_dims *weights_feature_dims)

Get size of the input_ctx staging buffer required by arm_svdf_f16().

Note

arm_svdf_f16() stages float16_t, so this is HALF the byte count arm_svdf_f32_input_ctx_get_buffer_size() returns for the same shape. Sizing an f16 layer with the f32 query over-allocates and is safe; sizing an f32 layer with this one under-allocates by half.

Note

This query reports an out-of-range shape as -1, following the SVDF family (arm_svdf_s8_get_buffer_size()), not the 0 used by the float convolution and fully-connected queries in this header. The reason is that arm_svdf_f16() reads ctx->size, and size == 0 is the opt-out signal for its scratch-size check: a 0-on-overflow answer fed straight back as buf = alloc(0), size = 0 would silently disable the check over a zero-byte allocation, whereas alloc((size_t)-1) fails and the NULL check catches it.

Note

0 is still a valid return for a degenerate shape (input_dims->n == 0). Unlike the general rule in README.md, a 0 here does NOT mean you may pass { NULL, 0 }: arm_svdf_f16() rejects a NULL input_ctx->buf with ARM_CMSIS_NN_ARG_ERROR regardless of the size.

Parameters:
Returns:

Required buffer size in bytes: input_dims->n * weights_feature_dims->n * sizeof(float16_t). Returns -1 if either pointer is NULL, if input_dims->n or weights_feature_dims->n is negative, or if the product would not fit in an int32_t. The figure and the validation are the same on every build target, since arm_svdf_f16() stages this buffer on every build rather than only under MVE.