@@ -105,55 +105,6 @@ def test_efficientnet_b0(ir):
105
105
torch ._dynamo .reset ()
106
106
107
107
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
-
157
108
@pytest .mark .unit
158
109
def test_bert_base_uncased (ir ):
159
110
model = BertModel .from_pretrained ("bert-base-uncased" ).cuda ().eval ()
@@ -183,7 +134,6 @@ def test_bert_base_uncased(ir):
183
134
"truncate_long_and_double" : True ,
184
135
"ir" : ir ,
185
136
"min_block_size" : 15 ,
186
- "debug" : True ,
187
137
}
188
138
trt_mod = torchtrt .compile (model , ** compile_spec )
189
139
model_outputs = model (input , input2 )
@@ -204,9 +154,6 @@ def test_bert_base_uncased(ir):
204
154
# Clean up model env
205
155
torch ._dynamo .reset ()
206
156
207
- with torch .no_grad ():
208
- torch .cuda .empty_cache ()
209
-
210
157
211
158
@pytest .mark .unit
212
159
def test_resnet18_half (ir ):
0 commit comments