MCPcopy
hub / github.com/tinygrad/tinygrad / test_pad_circular_backward

Method test_pad_circular_backward

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 6

reshapeMethod · 0.80
arangeMethod · 0.80
sumMethod · 0.80
padMethod · 0.45
backwardMethod · 0.45
numpyMethod · 0.45

Tested by

no test coverage detected