怎么对比下ONNX和Pytorch输出结果是否一致呢?可以直接看到输出的数值是多少,但是直接通过肉眼对比转换前后的结果是不理智的。我们可以通过代码简单对比一下:

    1. y = model(x)
    2. y_onnx = model_onnx(x)
    3. # check the output against PyTorch
    4. print(torch.max(torch.abs(y - y_trt)))