Function arm_resize_nearest_neighbor_f16¶
Defined in File arm_nnfunctions_flt.h
Function Documentation¶
-
arm_cmsis_nn_status arm_resize_nearest_neighbor_f16(const cmsis_nn_context *ctx, const cmsis_nn_resize_params *resize_params, const cmsis_nn_dims *input_shape, const float16_t *input_data, const cmsis_nn_dims *output_size_shape, const int32_t *output_size_data, const cmsis_nn_dims *output_shape, float16_t *output_data)¶
Nearest-neighbor resize of a float32 NHWC tensor.
Pure data movement: every output element is a bit copy of one input element, so NaN (sign and payload), +/-Inf, -0.0 and subnormals are preserved bit-for-bit on the scalar and MVE legs alike (the MVE copy is a tail-predicated vldr/vstr pair, not an FP operation, so FPSCR flush-to-zero and default-NaN do not apply). No arithmetic is performed on the data; the only float math is the float32 index scale below.
Index semantics are TFLite’s RESIZE_NEAREST_NEIGHBOR reference, evaluated in float32 per axis: scale = (align_corners && out > 1) ? (in - 1) / (out - 1) : in / out idx = align_corners ? roundf((o + offset) * scale) : floorf((o + offset) * scale) idx = min(idx, in - 1); if (half_pixel_centers) idx = max(idx, 0) with offset = half_pixel_centers ? 0.5f : 0.0f; roundf rounds ties away from zero, matching TfLiteRound. All four align_corners/half_pixel_centers combinations were verified bit-for-bit against TFLite 2.20 over a shape sweep (1..16 square, 80 random NHWC shapes up to 40x40, 224->7 and 7->224), including the out == 1 align_corners case, which maps to input index 0.
Note
float16 twin: each element is copied as a 16-bit lane with no widening or conversion, so half-precision NaN payloads and subnormals are preserved exactly and the data is never evaluated in float32. Scratch is sized by arm_resize_nearest_neighbor_f16_get_buffer_size() (same query as f32).
- Parameters:
ctx – [in] Scratch context. ctx->buf must be non-NULL and 4-byte aligned, and ctx->size at least arm_resize_nearest_neighbor_f32_get_buffer_size(output_shape); the kernel writes the x/y index maps here and does not read them after returning.
resize_params – [in] align_corners / half_pixel_centers.
input_shape – [in] Input tensor dimensions in NHWC format; every dimension must be >= 1.
input_data – [in] Input tensor data. Must not overlap
output_data.output_size_shape – [in] Dimensions of the output-size tensor; must hold exactly 2 elements.
output_size_data – [in] Output size as [output_height, output_width], both >= 1.
output_shape – [in] Output tensor dimensions in NHWC format; n and c must equal the input’s and h/w must equal
output_size_data.output_data – [out] Output tensor data.
- Returns:
ARM_CMSIS_NN_SUCCESS, or ARM_CMSIS_NN_ARG_ERROR when any constraint above fails (including a NULL pointer argument); nothing is written on ARG_ERROR.