MCPcopy
hub / github.com/tinygrad/tinygrad / test_cumsum_2d

Method test_cumsum_2d

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

Source from the content-addressed store, hash-verified

648 np.testing.assert_equal(b.cpu().numpy(), expected.numpy())
649
650 def test_cumsum_2d(self):
651 a = torch.arange(12, dtype=torch.float32, device=device).reshape(3, 4)
652 b = torch.cumsum(a, dim=0)
653 expected = torch.arange(12, dtype=torch.float32).reshape(3, 4).cumsum(dim=0)
654 np.testing.assert_equal(b.cpu().numpy(), expected.numpy())
655
656 c = torch.cumsum(a, dim=1)
657 expected = torch.arange(12, dtype=torch.float32).reshape(3, 4).cumsum(dim=1)
658 np.testing.assert_equal(c.cpu().numpy(), expected.numpy())
659
660 def test_cumsum_backward(self):
661 a = torch.tensor([1.0, 2.0, 3.0, 4.0], dtype=torch.float32, device=device, requires_grad=True)

Callers

nothing calls this directly

Calls 5

reshapeMethod · 0.80
arangeMethod · 0.80
cumsumMethod · 0.80
assert_equalMethod · 0.80
numpyMethod · 0.45

Tested by

no test coverage detected