|
4 | 4 | import pytest |
5 | 5 | import timm |
6 | 6 | import torch |
7 | | -import torch_tensorrt as torchtrt |
8 | 7 | import torchvision.models as models |
9 | 8 | from torch_tensorrt.dynamo.utils import COSINE_THRESHOLD, cosine_similarity |
10 | 9 | from transformers import BertModel |
11 | 10 | from transformers.utils.fx import symbolic_trace as transformers_trace |
12 | 11 |
|
| 12 | +import torch_tensorrt as torchtrt |
| 13 | + |
13 | 14 | assertions = unittest.TestCase() |
14 | 15 |
|
15 | 16 |
|
@@ -108,7 +109,9 @@ def test_efficientnet_b0(ir): |
108 | 109 |
|
109 | 110 | @pytest.mark.unit |
110 | 111 | def test_bert_base_uncased(ir): |
111 | | - model = BertModel.from_pretrained("bert-base-uncased").cuda().eval() |
| 112 | + model = ( |
| 113 | + BertModel.from_pretrained("bert-base-uncased", return_dict=False).cuda().eval() |
| 114 | + ) |
112 | 115 | input = torch.randint(0, 1, (1, 14), dtype=torch.int32).to("cuda") |
113 | 116 | input2 = torch.randint(0, 1, (1, 14), dtype=torch.int32).to("cuda") |
114 | 117 |
|
@@ -139,8 +142,8 @@ def test_bert_base_uncased(ir): |
139 | 142 | msg=f"Number of outputs for BERT model compilation is different with Pytorch {len(model_outputs)} and TensorRT {len(trt_model_outputs)}. Please check the compilation.", |
140 | 143 | ) |
141 | 144 |
|
142 | | - for key, _ in model_outputs.items(): |
143 | | - out, trt_out = model_outputs[key], trt_model_outputs[key] |
| 145 | + for index in range(len(model_outputs)): |
| 146 | + out, trt_out = model_outputs[index], trt_model_outputs[index] |
144 | 147 | cos_sim = cosine_similarity(out, trt_out) |
145 | 148 | assertions.assertTrue( |
146 | 149 | cos_sim > COSINE_THRESHOLD, |
|
0 commit comments