Skip to content

Commit f4e8fe9

Browse files
committed
chore: remove duplicate bert test case
1 parent 8674a3c commit f4e8fe9

File tree

1 file changed

+0
-53
lines changed

1 file changed

+0
-53
lines changed

tests/py/dynamo/models/test_models_export.py

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -105,55 +105,6 @@ def test_efficientnet_b0(ir):
105105
torch._dynamo.reset()
106106

107107

108-
@pytest.mark.unit
109-
def test_bert_base_uncased(ir):
110-
model = BertModel.from_pretrained("bert-base-uncased").cuda().eval()
111-
input = torch.randint(0, 1, (1, 14), dtype=torch.int32).to("cuda")
112-
input2 = torch.randint(0, 1, (1, 14), dtype=torch.int32).to("cuda")
113-
model = (
114-
transformers_trace(model, input_names=["input_ids", "attention_mask"])
115-
.eval()
116-
.cuda()
117-
)
118-
119-
compile_spec = {
120-
"inputs": [
121-
torchtrt.Input(
122-
input.shape,
123-
dtype=input.dtype,
124-
format=torch.contiguous_format,
125-
),
126-
torchtrt.Input(
127-
input.shape,
128-
dtype=input.dtype,
129-
format=torch.contiguous_format,
130-
),
131-
],
132-
"device": torchtrt.Device("cuda:0"),
133-
"enabled_precisions": {torch.float},
134-
"truncate_long_and_double": True,
135-
"ir": ir,
136-
"min_block_size": 10,
137-
}
138-
trt_mod = torchtrt.compile(model, **compile_spec)
139-
model_outputs = model(input, input2)
140-
trt_model_outputs = trt_mod(input, input2)
141-
assertions.assertTrue(
142-
len(model_outputs) == len(trt_model_outputs),
143-
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.",
144-
)
145-
for index, key in enumerate(model_outputs):
146-
out, trt_out = model_outputs[key], trt_model_outputs[index]
147-
cos_sim = cosine_similarity(out, trt_out)
148-
assertions.assertTrue(
149-
cos_sim > COSINE_THRESHOLD,
150-
msg=f"HF BERT base-uncased TRT outputs don't match with the original model. Cosine sim score: {cos_sim} Threshold: {COSINE_THRESHOLD}",
151-
)
152-
153-
# Clean up model env
154-
torch._dynamo.reset()
155-
156-
157108
@pytest.mark.unit
158109
def test_bert_base_uncased(ir):
159110
model = BertModel.from_pretrained("bert-base-uncased").cuda().eval()
@@ -183,7 +134,6 @@ def test_bert_base_uncased(ir):
183134
"truncate_long_and_double": True,
184135
"ir": ir,
185136
"min_block_size": 15,
186-
"debug": True,
187137
}
188138
trt_mod = torchtrt.compile(model, **compile_spec)
189139
model_outputs = model(input, input2)
@@ -204,9 +154,6 @@ def test_bert_base_uncased(ir):
204154
# Clean up model env
205155
torch._dynamo.reset()
206156

207-
with torch.no_grad():
208-
torch.cuda.empty_cache()
209-
210157

211158
@pytest.mark.unit
212159
def test_resnet18_half(ir):

0 commit comments

Comments
 (0)