Skip to content

The resize operator's behavior may use Round instead of Floor #25417

@sgbihu

Description

@sgbihu

Describe the issue

The test case in https://github.com/microsoft/onnxruntime/blob/main/onnxruntime/test/providers/cpu/tensor/resize_op_test.cc#L266 , the expected results are this:

  std::vector<float> Y = {2.66666651f, 4.3333331f};

And in https://github.com/microsoft/onnxruntime/blob/main/onnxruntime/test/providers/cpu/tensor/resize_op_test.cc#L292, the expected results are this:

  std::vector<uint8_t> Y = {2, 4};

All the inputs are same, but from the result, it seems convert 2.66666651f to 2. I think 3 is more reasonable for this case.

It used this way to calculate the result:
https://github.com/microsoft/onnxruntime/blob/main/onnxruntime/core/providers/cpu/tensor/upsample.h#L311
So it will lose precision.

To reproduce

execute the onnxruntime_test_all.exe --gtest_filter=ResizeOpTest.NhwcResizeOpLinearDownSampleTest_4DBilinear_uint8

Urgency

No response

Platform

Windows

OS Version

Win11

ONNX Runtime Installation

Built from Source

ONNX Runtime Version or Commit ID

master

ONNX Runtime API

C++

Architecture

X64

Execution Provider

Default CPU

Execution Provider Library Version

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    staleissues that have not been addressed in a while; categorized by a bot

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions