Skip to content
heliaCORE
API reference
HELIA HUB

Reshape Functions

Machine-readable model

function

Scratch size in bytes for armresizenearestneighborf32() / armresizenearestneighborf16().

Include/arm_nnfunctions_flt.h:1425

int32_t arm_resize_nearest_neighbor_f32_get_buffer_size(const cmsis_nn_dims *output_dims)

Scratch size in bytes for arm_resize_nearest_neighbor_f32() / arm_resize_nearest_neighbor_f16().

The kernels precompute one int32_t input index per output row and per output column, so the requirement is (output_dims->h + output_dims->w) * sizeof(int32_t). Returns -1 (never 0) when output_dims is NULL, when h or w is less than 1, or when the size does not fit in int32_t; a negative result must not be used to size a buffer, and the kernels reject a { NULL, 0 } context outright (the -1 family of the integer sizers, not the 0-returning family most float sizers use; see the sentinel note on arm_nn_size_mul).

Parameters of arm_resize_nearest_neighbor_f32_get_buffer_size
NameTypeDirectionDescription
output_dimsconst cmsis_nn_dims *inOutput tensor dimensions (only h and w are read).
Returns of arm_resize_nearest_neighbor_f32_get_buffer_size
Description
Required ctx->size in bytes, or -1.
function

Nearest-neighbor resize of a float32 NHWC tensor.

Include/arm_nnfunctions_flt.h:1458

arm_cmsis_nn_status arm_resize_nearest_neighbor_f32(
const cmsis_nn_context *ctx,
const cmsis_nn_resize_params *resize_params,
const cmsis_nn_dims *input_shape,
const float32_t *input_data,
const cmsis_nn_dims *output_size_shape,
const int32_t *output_size_data,
const cmsis_nn_dims *output_shape,
float32_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.

Parameters of arm_resize_nearest_neighbor_f32
NameTypeDirectionDescription
ctxconst cmsis_nn_context *inScratch 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_paramsconst cmsis_nn_resize_params *inalign_corners / half_pixel_centers.
input_shapeconst cmsis_nn_dims *inInput tensor dimensions in NHWC format; every dimension must be >= 1.
input_dataconst float32_t *inInput tensor data. Must not overlap `output_data`.
output_size_shapeconst cmsis_nn_dims *inDimensions of the output-size tensor; must hold exactly 2 elements.
output_size_dataconst int32_t *inOutput size as [output_height, output_width], both >= 1.
output_shapeconst cmsis_nn_dims *inOutput tensor dimensions in NHWC format; n and c must equal the input's and h/w must equal `output_size_data`.
output_datafloat32_t *outOutput tensor data.
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.
function

Scratch size in bytes for armresizenearestneighborf32() / armresizenearestneighborf16().

Include/arm_nnfunctions_flt.h:3294

int32_t arm_resize_nearest_neighbor_f16_get_buffer_size(const cmsis_nn_dims *output_dims)

Scratch size in bytes for arm_resize_nearest_neighbor_f32() / arm_resize_nearest_neighbor_f16().

The kernels precompute one int32_t input index per output row and per output column, so the requirement is (output_dims->h + output_dims->w) * sizeof(int32_t). Returns -1 (never 0) when output_dims is NULL, when h or w is less than 1, or when the size does not fit in int32_t; a negative result must not be used to size a buffer, and the kernels reject a { NULL, 0 } context outright (the -1 family of the integer sizers, not the 0-returning family most float sizers use; see the sentinel note on arm_nn_size_mul).

Parameters of arm_resize_nearest_neighbor_f16_get_buffer_size
NameTypeDirectionDescription
output_dimsconst cmsis_nn_dims *inOutput tensor dimensions (only h and w are read).
Returns of arm_resize_nearest_neighbor_f16_get_buffer_size
Description
Required ctx->size in bytes, or -1.
function

Nearest-neighbor resize of a float32 NHWC tensor.

Include/arm_nnfunctions_flt.h:3302

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.

Parameters of arm_resize_nearest_neighbor_f16
NameTypeDirectionDescription
ctxconst cmsis_nn_context *inScratch 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_paramsconst cmsis_nn_resize_params *inalign_corners / half_pixel_centers.
input_shapeconst cmsis_nn_dims *inInput tensor dimensions in NHWC format; every dimension must be >= 1.
input_dataconst float16_t *inInput tensor data. Must not overlap `output_data`.
output_size_shapeconst cmsis_nn_dims *inDimensions of the output-size tensor; must hold exactly 2 elements.
output_size_dataconst int32_t *inOutput size as [output_height, output_width], both >= 1.
output_shapeconst cmsis_nn_dims *inOutput tensor dimensions in NHWC format; n and c must equal the input's and h/w must equal `output_size_data`.
output_datafloat16_t *outOutput tensor data.
Returns of arm_resize_nearest_neighbor_f16
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.