Skip to content

Commit

Permalink
fix model outputs test (huggingface#6593)
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickvonplaten authored and Zigur committed Oct 26, 2020
1 parent 810ba9d commit c608def
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tests/test_modeling_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -704,10 +704,13 @@ def recursive_check(tuple_object, dict_object):
recursive_check(tuple_iterable_value, dict_iterable_value)
elif tuple_object is None:
return
elif torch.isinf(tuple_object).any() and torch.isinf(dict_object).any():
# TODO: (Lysandre) - maybe take a look if that's ok here
return
else:
self.assertTrue(
torch.allclose(tuple_object, dict_object, atol=1e-5),
msg=f"Tuple and dict output are not equal. Difference: {torch.max(torch.abs(tuple_object - dict_object))}",
msg=f"Tuple and dict output are not equal. Difference: {torch.max(torch.abs(tuple_object - dict_object))}. Tuple has `nan`: {torch.isnan(tuple_object).any()} and `inf`: {torch.isinf(tuple_object)}. Dict has `nan`: {torch.isnan(dict_object).any()} and `inf`: {torch.isinf(dict_object)}.",
)

recursive_check(tuple_output, dict_output)
Expand Down

0 comments on commit c608def

Please sign in to comment.