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

   The Pytorch model with a `dropout` layer gave inconsistent inference results 
between PyTorch and TVM.
   
   The RelayIR arising from the PyTorch model is here:
   ```
   def @main(%input0: Tensor[(5), float64] /* 
span=aten::alpha_dropout_0.input0:0:0 */) {
     %0 = nn.dropout(%input0, rate=0.2f) /* span=aten::alpha_dropout_0:0:0 */;
     %0.0 /* span=aten::alpha_dropout_0:0:0 */
   }
   ```
   
   ### Actual behavior
   
   
![image](https://github.com/apache/tvm/assets/29506758/d8e31802-445d-461b-987b-a0f8d174d1c3)
   
   
   ### Steps to reproduce
   
   ```
   import torch
   from tvm import relay
   import tvm
   import numpy as np
   from torch.nn import Module
   
   input_data = torch.randn([5], dtype=torch.float64)
   class alpha_dropout(Module):
           def forward(self, *args):
               return torch.nn.functional.alpha_dropout(args[0], 0.2,True)
   m = alpha_dropout().float().eval()
   
   torch_outputs = m(input_data)
   
   trace = torch.jit.trace(m, input_data)
   input_shapes = [('input0', torch.Size([5]))]
   
   mod, params = relay.frontend.from_pytorch(trace, input_shapes)
   print(mod)
   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': np.array(input_data, dtype='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
   
   cc @shingjan  @echuraev @Hzfengsy 
   Could you help me review this exception?
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to