(self, a, b, atol=1e-3, rtol=1e-3)
| 22 | |
| 23 | class TorchTestCase(unittest.TestCase): |
| 24 | def assertTensorClose(self, a, b, atol=1e-3, rtol=1e-3): |
| 25 | npa, npb = as_numpy(a), as_numpy(b) |
| 26 | self.assertTrue( |
| 27 | np.allclose(npa, npb, atol=atol), |
| 28 | 'Tensor close check failed\n{}\n{}\nadiff={}, rdiff={}'.format(a, b, np.abs(npa - npb).max(), np.abs((npa - npb) / np.fmax(npa, 1e-5)).max()) |
| 29 | ) |
no test coverage detected