MCPcopy Create free account
hub / github.com/bitsandbytes-foundation/bitsandbytes / assert_most_approx_close

Function assert_most_approx_close

tests/test_optim.py:19–24  ·  view source on GitHub ↗
(a, b, rtol=1e-3, atol=1e-3, max_error_count=0)

Source from the content-addressed store, hash-verified

17
18
19def assert_most_approx_close(a, b, rtol=1e-3, atol=1e-3, max_error_count=0):
20 idx = torch.isclose(a, b, rtol=rtol, atol=atol)
21 error_count = (idx == 0).sum().item()
22 if error_count > max_error_count:
23 print(f"Too many values not close: assert {error_count} < {max_error_count}")
24 torch.testing.assert_close(a, b, rtol=rtol, atol=atol)
25
26
27str2optimizers = {}

Callers 3

test_optimizer32bitFunction · 0.85
test_optimizer8bitFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected