MCPcopy
hub / github.com/tinygrad/tinygrad / test_size

Method test_size

test/backend/test_tensor.py:336–343  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

334 with self.assertRaises(TypeError): len(Tensor(3))
335
336 def test_size(self):
337 t1, t2 = torch.zeros(10,20), Tensor.zeros(10,20)
338 assert t1.size() == t2.size()
339 assert t1.size(0) == t2.size(0)
340 assert t1.size(1) == t2.size(1)
341 assert t1.size(-1) == t2.size(-1)
342 assert t1.size(-2) == t2.size(-2)
343 with self.assertRaises(IndexError): t2.size(2)
344
345 def test_tolist(self):
346 # NOTE: float16 Tensor.tolist() requires python 3.12

Callers

nothing calls this directly

Calls 2

zerosMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected