NVIDIA-AI-IOT / torch2trt

An easy to use PyTorch to TensorRT converter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Inconsistent inference results between PyTorch and converted TensorRT model using with Softplus operator

Thrsu opened this issue · comments

Description:

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

Reproduce

This issue can be reproduced by the following script:

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

model = torch.nn.Softplus(2,-100,).eval().cuda()
input_data = torch.randn([10, 20], 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)))

The output is:

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

Environment

  • torch: 2.1.1
  • torch2trt: 0.4.0
  • tensorrt: 8.6.1