MCPcopy
hub / github.com/tinygrad/tinygrad / _assert_close

Method _assert_close

examples/mlperf/models/test_apply_grad.py:34–36  ·  view source on GitHub ↗
(self, got, expected, atol, rtol)

Source from the content-addressed store, hash-verified

32 return [p.grad for p in get_parameters(model)]
33
34 def _assert_close(self, got, expected, atol, rtol):
35 for g, e in zip(got, expected):
36 self.assertTrue(g.allclose(e, atol=atol, rtol=rtol).item(), f"grad mismatch (max abs diff {(g - e).abs().max().item()})")
37
38 def _assert_match(self, model, xs, atol, rtol):
39 self._assert_close(self._run_with_apply_grad(model, xs), self._run_reference(model, xs), atol, rtol)

Callers 2

_assert_matchMethod · 0.95
test_e2e_jitMethod · 0.95

Calls 4

itemMethod · 0.80
allcloseMethod · 0.80
absMethod · 0.80
maxMethod · 0.45

Tested by

no test coverage detected