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

Function assert_all_approx_close

tests/test_functional.py:39–47  ·  view source on GitHub ↗
(a, b, rtol=1e-3, atol=1e-3, count=0, throw=True)

Source from the content-addressed store, hash-verified

37
38
39def assert_all_approx_close(a, b, rtol=1e-3, atol=1e-3, count=0, throw=True):
40 idx = torch.isclose(a, b, rtol=rtol, atol=atol)
41 sumval = (idx == 0).sum().item()
42 if sumval > count:
43 if throw:
44 print(f"Too many values not close: assert {sumval} < {count}")
45 torch.testing.assert_close(a, b, rtol=rtol, atol=atol)
46
47 return sumval
48
49
50class FFN(torch.nn.Module):

Callers 2

test_dequant_mmMethod · 0.70
test_gemv_4bitMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected