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

Inconsistent inference results between PyTorch and converted TensorRT model with Pad operator #906

Open
hongliyu0716 opened this issue Dec 4, 2023 · 0 comments

Comments

@hongliyu0716
Copy link

Description:

I am encountering an issue when converting Torch models that solely consist of the Pad operator to TensorRT. The problem is that the results obtained after the conversion process are inconsistent with the original Torch implementation.

Reproduce

This issue can be reproduced by the following script:

import torch
from torch.nn import Module
from torch2trt import torch2trt

para_0 = torch.randn([1, 2, 2, 2], dtype=torch.float32).cuda()
para_1 = (2, 2, 2, 2)
para_2 = 'replicate'
class pad(Module):
    def forward(self, *args):
        return torch.nn.functional.pad(args[0], para_1,para_2,)
model = pad().float().eval().cuda()
model_trt = torch2trt(model, [para_0])

output = model(para_0)
output_trt = model_trt(para_0)
print(torch.max(torch.abs(output - output_trt)))

The output is:

tensor(2.1606, device='cuda:0')

Environment

  • torch: 2.1.1
  • torch2trt: 0.4.0
  • tensorrt: 8.6.1
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

1 participant