@@ -120,7 +120,7 @@ def check_out(out):
120
120
# predictions match.
121
121
expected_file = self ._get_expected_file (name )
122
122
expected = torch .load (expected_file )
123
- self . assertEqual (out .argmax (dim = 1 ), expected .argmax (dim = 1 ), prec = prec )
123
+ torch . testing . assert_close (out .argmax (dim = 1 ), expected .argmax (dim = 1 ), rtol = prec , atol = prec )
124
124
return False # Partial validation performed
125
125
126
126
return True # Full validation performed
@@ -205,7 +205,8 @@ def compute_mean_std(tensor):
205
205
# scores.
206
206
expected_file = self ._get_expected_file (name )
207
207
expected = torch .load (expected_file )
208
- self .assertEqual (output [0 ]["scores" ], expected [0 ]["scores" ], prec = prec )
208
+ torch .testing .assert_close (output [0 ]["scores" ], expected [0 ]["scores" ], rtol = prec , atol = prec ,
209
+ check_device = False , check_dtype = False )
209
210
210
211
# Note: Fmassa proposed turning off NMS by adapting the threshold
211
212
# and then using the Hungarian algorithm as in DETR to find the
@@ -301,10 +302,8 @@ def test_memory_efficient_densenet(self):
301
302
model2 .eval ()
302
303
out2 = model2 (x )
303
304
304
- max_diff = (out1 - out2 ).abs ().max ()
305
-
306
305
self .assertTrue (num_params == num_grad )
307
- self . assertTrue ( max_diff < 1e-5 )
306
+ torch . testing . assert_close ( out1 , out2 , rtol = 0.0 , atol = 1e-5 )
308
307
309
308
def test_resnet_dilation (self ):
310
309
# TODO improve tests to also check that each layer has the right dimensionality
0 commit comments