You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by "Thrsu (via GitHub)" <gi...@apache.org> on 2023/07/24 16:18:07 UTC

[GitHub] [tvm] Thrsu opened a new issue, #15394: [Bug] [PyTorch] Pad produced inconsistent inference results with PyTorch

Thrsu opened a new issue, #15394:
URL: https://github.com/apache/tvm/issues/15394

   Pad produced inconsistent inference results with PyTorch because numerical overflow when setting padding values.
   
   ### Expected behavior
   
   TVM and PyTorch have the consistent inference results.
   
   ### Actual behavior
   
   ```
   Traceback (most recent call last):
     ...
       np.testing.assert_allclose(torch_outputs, tvm_outputs, rtol=1e-3, atol=1e-3)
     File "/workplace/software/miniconda3/envs/torch/lib/python3.7/site-packages/numpy/testing/_private/utils.py", line 1528, in assert_allclose
       verbose=verbose, header=header, equal_nan=equal_nan)
     File "/workplace/software/miniconda3/envs/torch/lib/python3.7/site-packages/numpy/testing/_private/utils.py", line 769, in assert_array_compare
       hasval='+inf')
     File "/workplace/software/miniconda3/envs/torch/lib/python3.7/site-packages/numpy/testing/_private/utils.py", line 740, in func_assert_same_pos
       raise AssertionError(msg)
   AssertionError: 
   Not equal to tolerance rtol=0.001, atol=0.001
   
   x and y +inf location mismatch:
    x: array([[[[3.477122e+307, 3.477122e+307, 3.477122e+307, ...,
             3.477122e+307, 3.477122e+307, 3.477122e+307],
            [3.477122e+307, 3.477122e+307, 3.477122e+307, ...,...
    y: array([[[[inf, inf, inf, ..., inf, inf, inf],
            [inf, inf, inf, ..., inf, inf, inf],
            [inf, inf, inf, ..., inf, inf, inf],..
   ```
   
   ### Environment
   
   - TVM version: latest
   - PyTorch: 1.13.1+cu117
   
   ### Steps to reproduce
   
   ```Python
   import torch
   from tvm import relay
   import tvm
   import numpy as np
   from torch.nn import Module
   
   para_0 = torch.randn([20, 20, 20, 5], dtype=torch.float64)
   para_1 = (107, 107)
   para_2 = 'constant'
   para_3 = 3.4771218336380595e+307
   class pad(Module):
       def forward(self, *args):
           return torch.nn.functional.pad(args[0], para_1,para_2,para_3,)
   m = pad().float().eval()
   input_data = torch.tensor(para_0)
   torch_outputs = m(input_data)
   trace = torch.jit.trace(m, input_data)
   input_shapes = [('input0', torch.Size([20, 20, 20, 5]))]
   
   mod, params = relay.frontend.from_pytorch(trace, input_shapes)
   input_data_np = input_data.numpy()
   with tvm.transform.PassContext(opt_level=3):
       exe = relay.create_executor('graph', mod=mod, params=params, device=tvm.device('llvm', 0), target='llvm').evaluate()
   input_tvm = {'input0': tvm.nd.array(input_data_np.astype(np.float64))}
   tvm_outputs = exe(**input_tvm).asnumpy()
   np.testing.assert_allclose(torch_outputs, tvm_outputs, rtol=1e-3, atol=1e-3)
   ```
   
   ### Triage
   * needs-triage
   * frontend:pytorch
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug] [PyTorch] Pad produced inconsistent inference results with PyTorch [tvm]

Posted by "tqchen (via GitHub)" <gi...@apache.org>.
tqchen closed issue #15394: [Bug] [PyTorch] Pad produced inconsistent inference results with PyTorch
URL: https://github.com/apache/tvm/issues/15394


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org