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

Wrong Floor output on very large input #12076

Closed
nnreduce-bot opened this issue Jul 3, 2022 · 1 comment
Closed

Wrong Floor output on very large input #12076

nnreduce-bot opened this issue Jul 3, 2022 · 1 comment

Comments

@nnreduce-bot
Copy link

Describe the bug

When floor's input is very large (say 10**10), it returns very strange outputs that are different to PyTorch and Numpy. This seems to be related to shape. When we first tried a random shape [2, 1] it works fine and we need to exactly use [2, 2] as its input tensor shape to reproduce the issue.

image

Urgency
none.

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): 20.04
  • ONNX Runtime installed from (source or binary): source
  • ONNX Runtime version: 1.12
  • Python version:3.8

To Reproduce

import torch
import numpy as np

class Net(torch.nn.Module):
    def forward(self, i0):
        return torch.floor(i0),

sh = [2, 2] # sh = [2, 1]  # no bug
inputs = (torch.ones(*sh, dtype=torch.float32) * 10**10.,)
model = Net()
model.eval()
outputs_torch = [o.numpy() for o in model(*inputs)]
iname = [f"i{i}" for i in range(len(inputs))]
oname = [f"o{i}" for i in range(len(outputs_torch))]
torch.onnx.export(model, inputs, "output.onnx",
                  input_names=iname, output_names=oname, opset_version=14)
from onnx import checker
import onnxruntime as ort
checker.check_model("output.onnx", full_check=True)
sess = ort.InferenceSession("output.onnx", providers=["CPUExecutionProvider"])
outputs_ort = sess.run(oname, {k: v.numpy() for k, v in zip(iname, inputs)})
np.testing.assert_allclose(outputs_ort, outputs_torch)

Expected behavior

No exception.

@faxu
Copy link
Contributor

faxu commented Jul 8, 2022

For PyTorch export issues, please file in https://github.com/pytorch/pytorch/issues

@faxu faxu closed this as completed Jul 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants