MCPcopy
hub / github.com/tinygrad/tinygrad / test_simple_add

Method test_simple_add

test/null/test_uops_stats.py:105–114  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

103
104class TestUOpsStats(unittest.TestCase):
105 def test_simple_add(self):
106 a = Tensor.empty(100,100)
107 b = Tensor.empty(100,100)
108 c = a+b
109 ops, mem = get_stats(c)
110 expected_ops = c.numel()
111 expected_mem = a.nbytes() + b.nbytes() + c.nbytes()
112 self.assertEqual(mem, expected_mem)
113 # NOTE; ops also include indexing ops
114 assert expected_ops <= ops and ops <= expected_ops * 2
115
116 def test_simple_add_sq(self):
117 a = Tensor.empty(100,100)

Callers

nothing calls this directly

Calls 4

get_statsFunction · 0.85
numelMethod · 0.80
emptyMethod · 0.45
nbytesMethod · 0.45

Tested by

no test coverage detected