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.
Parameters
Parameters of arm_resize_nearest_neighbor_f32| Name | Type | Direction | Description |
|---|
ctx | const cmsis_nn_context * | 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 | const cmsis_nn_resize_params * | in | align_corners / half_pixel_centers. |
|---|
input_shape | const cmsis_nn_dims * | in | Input tensor dimensions in NHWC format; every dimension must be >= 1. |
|---|
input_data | const float32_t * | in | Input tensor data. Must not overlap `output_data`. |
|---|
output_size_shape | const cmsis_nn_dims * | in | Dimensions of the output-size tensor; must hold exactly 2 elements. |
|---|
output_size_data | const int32_t * | in | Output size as [output_height, output_width], both >= 1. |
|---|
output_shape | const cmsis_nn_dims * | 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 | float32_t * | out | Output tensor data. |
|---|
Returns
Returns of arm_resize_nearest_neighbor_f32| Description |
|---|
| 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. |