(a, b, atol=1e-8, rtol=1e-5, count=10)
| 53 | |
| 54 | |
| 55 | def assert_all_approx_close(a, b, atol=1e-8, rtol=1e-5, count=10): |
| 56 | idx = torch.isclose(a, b, rtol=rtol, atol=atol) |
| 57 | sumval = (idx == 0).sum().item() |
| 58 | if sumval > count: |
| 59 | print(f"Too many values not close: assert {sumval} < {count}") |
| 60 | torch.testing.assert_close(a, b, rtol=rtol, atol=atol) |
| 61 | |
| 62 | |
| 63 | @pytest.mark.parametrize("device", get_available_devices()) |
no outgoing calls
no test coverage detected