pytorch
71ca3e99 - Only use actually mismatched elements for reporting in `torch.testing` (#57923)

Commit
4 years ago
Only use actually mismatched elements for reporting in `torch.testing` (#57923) Summary: Redo of https://github.com/pytorch/pytorch/issues/57135 out of stack --- Currently all values are used for the reported absolute and relative differences. This usually works fine, but breaks down for the extremals: ```python torch.testing.assert_close(torch.tensor([1.0, 0.0]), torch.tensor([2.0, 0.0])) ``` ``` [...] Greatest absolute difference: 1.0 at 0 (up to 1e-05 allowed) Greatest relative difference: nan at 1 (up to 1.3e-06 allowed) ``` Although the second element is matching it is listed as offender for the greatest relative difference. The `NaN` stems from the `0 / 0` division. To overcome this, we should only use the values that were considered a mismatch for the reported stats. Pull Request resolved: https://github.com/pytorch/pytorch/pull/57923 Reviewed By: ngimel Differential Revision: D28317316 Pulled By: mruberry fbshipit-source-id: 4c604493bbe13b37f41225ea9af9e839a7304161
Author
Parents
Loading