(self)
| 103 | |
| 104 | class 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) |