jikechao opened a new issue, #14998: URL: https://github.com/apache/tvm/issues/14998
For the op `torch.nn.functional.avg_pool1d()`, if the attribute `ceil_mode=True`, the PyTorch and TVM give different output results and the output_shape is different. For [pytorch official documentation], we can know that: **"ceil_mode – when True, will use ceil instead of floor to compute the output shape. Default: False"**. To figure out this exception. I further check the source code in Lines 66-78 in the file: [src/relay/op/nn/pooling.cc ](https://github.com/apache/tvm/blob/main/src/relay/op/nn/pooling.cc)  It seems that the source code takes into consideration about handling the `ceil_mode=True` ### Expected behavior PyTorch and TVM have the same inference results ### Actual behavior  ### Environment TVM: 0.13.dev0 PyTorch: 1.13.1+cu117 ### Steps to reproduce ``` import torch from tvm import relay import tvm import numpy as np from torch.nn import Module para_0 = torch.randn([1, 6, 4], dtype=torch.float64) class avg_pool1d(Module): def forward(self, *args): return torch.nn.functional.avg_pool1d(args[0], kernel_size=[1], stride=2, ceil_mode=True) m = avg_pool1d().float().eval() input_data = para_0 torch_outputs = m(input_data) trace = torch.jit.trace(m, input_data) input_shapes = [('input0', torch.Size([1, 6, 4]))] 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 * 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
