Hi All,

The existing TOSA specification for RESIZE (in NEAREST mode) is implemented with half up rounding.

ONNX’s RESIZE operation in NEAREST mode supports four different rounding modes. This is specified in section **nearest_mode**: `round_prefer_floor`

, `round_prefer_ceil`

, `floor`

and `ceil`

[0] . We see three out of the four modes in actual models. `round_prefer_ceil`

is the rounding that TOSA currently supports.

If TOSA specification was extended with an additional parameter `nearest_mode`

it would look like:

```
[...]
} else if (mode==NEAREST) {
int32_t iy, ix;
if (is_floating_point(resize_t)) {
if (nearest_mode==ROUND_PREFER_CEIL) {
iy = (dy >= 0.5) ? iy1 : iy0;
ix = (dx >= 0.5) ? ix1 : ix0;
} else if (nearest_mode==ROUND_PREFER_FLOOR) {
iy = (dy < 0.5) ? iy1 : iy0;
ix = (dx < 0.5) ? ix1 : ix0;
} else if (nearest_mode==CEIL) {
iy = iy1;
ix = ix1;
} else {
iy = iy0;
ix = ix0;
}
} else {
if (nearest_mode==ROUND_PREFER_CEIL) {
iy = (2 * dy >= scale_y_n) ? iy1 : iy0;
ix = (2 * dx >= scale_x_n) ? ix1 : ix0;
} else if (nearest_mode==ROUND_PREFER_FLOOR) {
iy = (2 * dy < scale_y_n) ? iy1 : iy0;
ix = (2 * dx < scale_x_n) ? ix1 : ix0;
} else if (nearest_mode==CEIL) {
iy = iy1;
ix = ix1;
} else {
iy = iy0;
ix = ix0;
}
}
in_t v = tensor_read<in_t>(input, [N,IH,IW,C], [n,iy,ix,c]);
tensor_write<out_t>(output, [N,OH,OW,C], [n,oy,ox,c], v);
}
}
```

Would such an extension be appropriate, or are there other ways of implementing these rounding modes in TOSA.

Looking forward hearing from the community,

Robert

[0] Resize - ONNX 1.16.0 documentation - Under **nearest_mode** section.