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 with ConstantPad2d operator #890

Open
Thrsu opened this issue Nov 24, 2023 · 1 comment
Open

Inconsistent inference results with ConstantPad2d operator #890

Thrsu opened this issue Nov 24, 2023 · 1 comment

Comments

@Thrsu
Copy link

Thrsu commented Nov 24, 2023

Description:

I'm experiencing a discrepancy between the inference results of my PyTorch model and the TensorRT model obtained by converting it using the torch2trt tool.

Reproduce

This can be reproduced by the following script:

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

model = torch.nn.ConstantPad2d((1, 2, 3, 4),2.0,).cuda()
input_data = torch.randn([2, 3, 4, 4], dtype=torch.float32).cuda()
model_trt = torch2trt(model, [input_data])
y = model(input_data)
y_trt = model_trt(input_data)

# check the output against PyTorch
print(torch.max(torch.abs(y - y_trt)))

Environment

  • torch: 1.11.0
  • torch2trt: 0.4.0
  • tensorrt: 8.6.1.6
@Thrsu
Copy link
Author

Thrsu commented Dec 8, 2023

The ReflectionPad2d operator has the same problem, which can be reproduced by the following script:

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

model = torch.nn.ReflectionPad2d((1, 2, 3, 4),).eval().cuda()
input_data = torch.randn([2, 3, 8, 8], dtype=torch.float32).cuda()
model_trt = torch2trt(model, [input_data])
output = model(input_data)
output_trt = model_trt(input_data)
print(torch.max(torch.abs(output - output_trt)))

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