| 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) |