MCPcopy
hub / github.com/tinygrad/tinygrad / test_reshape

Method test_reshape

extra/torch_backend/test.py:44–50  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

42 np.testing.assert_equal(out.cpu().numpy(), [[1,1,1,1],[2,2,2,2],[3,3,3,3],[4,4,4,4]])
43
44 def test_reshape(self):
45 a = torch.Tensor([[1,2],[3,4]]).to(device)
46 np.testing.assert_equal(a.reshape(4).cpu().numpy(), [1,2,3,4])
47 np.testing.assert_equal(a.reshape(2,1,2).cpu().numpy(), [[[1,2]],[[3,4]]])
48 np.testing.assert_equal(a.unsqueeze(1).cpu().numpy(), [[[1,2]],[[3,4]]])
49 np.testing.assert_equal(a.unsqueeze(1).unsqueeze(1).cpu().numpy(), [[[[1,2]]],[[[3,4]]]])
50 np.testing.assert_equal(a.unsqueeze(1).unsqueeze(1).squeeze().cpu().numpy(), [[1,2],[3,4]])
51
52 def test_permute(self):
53 a = torch.Tensor([[1,2],[3,4]]).to(device)

Callers

nothing calls this directly

Calls 6

assert_equalMethod · 0.80
reshapeMethod · 0.80
unsqueezeMethod · 0.80
squeezeMethod · 0.80
toMethod · 0.45
numpyMethod · 0.45

Tested by

no test coverage detected