MCPcopy
hub / github.com/tinygrad/tinygrad / test_repeat_backward

Method test_repeat_backward

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

Source from the content-addressed store, hash-verified

634 np.testing.assert_equal(b.cpu().numpy(), expected.numpy())
635
636 def test_repeat_backward(self):
637 a = torch.tensor([[1.0, 2.0]], dtype=torch.float32, device=device, requires_grad=True)
638 b = a.repeat(3, 2)
639 loss = b.sum()
640 loss.backward()
641 expected_grad = torch.tensor([[6.0, 6.0]], dtype=torch.float32)
642 np.testing.assert_allclose(a.grad.cpu().numpy(), expected_grad.numpy(), rtol=1e-5)
643
644 def test_cumsum_1d(self):
645 a = torch.tensor([1, 2, 3, 4], dtype=torch.float32, device=device)

Callers

nothing calls this directly

Calls 5

tensorMethod · 0.80
repeatMethod · 0.80
sumMethod · 0.80
backwardMethod · 0.45
numpyMethod · 0.45

Tested by

no test coverage detected