MCPcopy
hub / github.com/tinygrad/tinygrad / test_simple_add_sq

Method test_simple_add_sq

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

Source from the content-addressed store, hash-verified

114 assert expected_ops <= ops and ops <= expected_ops * 2
115
116 def test_simple_add_sq(self):
117 a = Tensor.empty(100,100)
118 b = Tensor.empty(100,100)
119 c = (a+b)*(a+b)
120 ops, mem = get_stats(c)
121 expected_ops = c.numel()*2
122 expected_mem = a.nbytes() + b.nbytes() + c.nbytes()
123 self.assertEqual(mem, expected_mem)
124 # NOTE; ops also include indexing ops
125 assert expected_ops <= ops and ops <= expected_ops * 2
126
127 def test_simple_matmul(self, M=1024, N=1024, K=1024):
128 a = Tensor.empty(M,N)

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