Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resize with mode linear is missing output elements #12019

Open
diyessi opened this issue Jun 28, 2022 · 4 comments
Open

Resize with mode linear is missing output elements #12019

diyessi opened this issue Jun 28, 2022 · 4 comments
Labels
core runtime issues related to core runtime

Comments

@diyessi
Copy link

diyessi commented Jun 28, 2022

Describe the bug
Resize with mode="linear" and a specified output shape has garbage in the last output tensor elements. I see this for multiple coordinate transformation modes and input and output shapes. For a trivial example, with an input size of [1,1,1,1] on a float input tensor whose single element is 1.0, resizing to [1, 2, 2, 1] I get output

[[[[[ 1.]
    [ 1.]]

   [[ 5.]
    [10.]]]]]

where the [5, 10] is wrong. I am running a number of these tests, using i^2+1 as inputs, so these particular outputs seem likely to be uninitialized memory from earlier inputs. I also see bunches of NaNs in the bad elements.

Urgency
None

System information

  • Ubuntu 20.04.4 LTS (GNU/Linux 5.11.0-1028-azure x86_64)
  • ONNX Runtime installed from binary (pip onnxruntime 1.11.1)
  • ONNX Runtime version: 1.11.1
  • Python version: 3.8.10
  • CUDA/cuDNN version: None
  • GPU model and memory: None

To Reproduce
I can give you a branch of a simple repo if you need one.

Expected behavior
In this case, all elements should be 1.

Additional context
nearest mode doesn't seem to have any problems. I was actually trying to use ONNX Runtime to generate gold values for testing my own implementation for an accelerator and for creating a doc PR for the ONNX specification.

@ytaous
Copy link
Contributor

ytaous commented Jul 12, 2022

@hariharans29 @yihonglyu - any comment/feedback is more than welcome.

@yihonglyu
Copy link
Contributor

@diyessi Could you provide simple reproducer? Thanks.

@diyessi
Copy link
Author

diyessi commented Jul 14, 2022

import onnxruntime as ort
import numpy as np

model = b'\x08\x08\x12\x0cONNX Builder:\xd7\x01\nF\x12\nConstant_1\x1a\nConstant_0"\x08Constant*"\n\x05value*\x16\x08\x04\x10\x07:\x04\x01\x02\x02\x01B\nConstant_1\xa0\x01\x04\nD\n\x05input\n\x00\n\x00\n\nConstant_1\x12\x06output\x1a\x08Resize_2"\x06Resize*\x11\n\x04mode"\x06linear\xa0\x01\x03\x12\x04testZ\x1f\n\x05input\x12\x16\n\x14\x08\x01\x12\x10\n\x02\x08\x01\n\x02\x08\x01\n\x02\x08\x01\n\x02\x08\x01b \n\x06output\x12\x16\n\x14\x08\x01\x12\x10\n\x02\x08\x01\n\x02\x08\x02\n\x02\x08\x02\n\x02\x08\x01B\x02\x10\x10'
sess = ort.InferenceSession(model)
sess.run(['output'], {'input': ort.OrtValue.ortvalue_from_numpy(np.ones([1,1,1,1], dtype=np.float32))})

produces

[array([[[[1.],
          [1.]],
 
         [[0.],
          [0.]]]], dtype=float32)]

I've also seen NaN's in the output where those 0s are.
It also happens for more realistic shapes.

@satyajandhyala
Copy link
Contributor

Could not reproduce using onnxruntime 1.14 or 1.15.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core runtime issues related to core runtime
Projects
None yet
Development

No branches or pull requests

6 participants