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

[Bug] [Relay] attribute track_running_stats of InstanceNorm lead to wrong inference results #14926

Closed
jikechao opened this issue May 23, 2023 · 0 comments · Fixed by #14963
Closed
Labels
needs-triage PRs or issues that need to be investigated by maintainers to find the right assignees to address it type: bug

Comments

@jikechao
Copy link
Contributor

jikechao commented May 23, 2023

For the layer InstanceNorm1d or InstanceNorm3d, if attribute track_running_stats was set as True, TVM will give different inference results with PyTorch.

Expected behavior

For the same input data, TVM and PyTorch give the same inference results.

Actual behavior

image

Steps to reproduce

import torch
from tvm import relay
import tvm
import numpy as np

m = torch.nn.InstanceNorm1d(3, track_running_stats=True).eval()
input_data = [torch.randn([1, 3, 5], dtype=torch.float32)]

torch_outputs = m(*[input_.clone() for input_ in input_data ])
trace = torch.jit.trace(m, input_data)
input_shapes = [('input0', torch.Size([1,3,5]))]

mod, params = relay.frontend.from_pytorch(trace, input_shapes)

with tvm.transform.PassContext(opt_level=3):
    exe = relay.create_executor('aot', mod=mod, params=params, device=tvm.cpu(0), target='llvm').evaluate()
input_tvm = {'input0': np.array(input_data[0], dtype='float32')}
tvm_outputs = exe(**input_tvm).asnumpy()

np.testing.assert_allclose(torch_outputs, tvm_outputs, rtol=1e-3, atol=1e-3)

Triage

  • frontend:torch
  • needs-triage

cc @shingjan

@jikechao jikechao added needs-triage PRs or issues that need to be investigated by maintainers to find the right assignees to address it type: bug labels May 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-triage PRs or issues that need to be investigated by maintainers to find the right assignees to address it type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant