(self)
| 268 | np.testing.assert_allclose(padded.cpu().numpy(), expected) |
| 269 | |
| 270 | def test_pad_circular_backward(self): |
| 271 | a = torch.arange(4, dtype=torch.float32, device=device).reshape(1,1,2,2).requires_grad_(True) |
| 272 | padded = torch.nn.functional.pad(a, (1,1,1,1), mode="circular") |
| 273 | loss = padded.sum() |
| 274 | loss.backward() |
| 275 | expected_grad = np.array([[[[4., 4.], [4., 4.]]]], dtype=np.float32) |
| 276 | np.testing.assert_allclose(a.grad.cpu().numpy(), expected_grad) |
| 277 | |
| 278 | |
| 279 | def test_matmul_backward(self): |