MCPcopy Create free account
hub / github.com/Elsaam2y/DINet_optimized / assertTensorClose

Method assertTensorClose

sync_batchnorm/unittest.py:17–27  ·  view source on GitHub ↗
(self, x, y)

Source from the content-addressed store, hash-verified

15
16class TorchTestCase(unittest.TestCase):
17 def assertTensorClose(self, x, y):
18 adiff = float((x - y).abs().max())
19 if (y == 0).all():
20 rdiff = "NaN"
21 else:
22 rdiff = float((adiff / y).abs().max())
23
24 message = ("Tensor close check failed\n" "adiff={}\n" "rdiff={}\n").format(
25 adiff, rdiff
26 )
27 self.assertTrue(torch.allclose(x, y, atol=1e-5, rtol=1e-3), message)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected