(self)
| 101 | np.testing.assert_allclose(b.grad.numpy(), na.T @ nb + na @ nb) |
| 102 | |
| 103 | def test_grad_implicit(self): |
| 104 | w = Tensor([1., 2., 3.]) |
| 105 | w.realize() # TODO: this is required |
| 106 | @function(allow_implicit=True) |
| 107 | def f(x:Tensor) -> Tensor: return x * w |
| 108 | |
| 109 | x = Tensor([4., 5., 6.]) |
| 110 | f(x).sum().backward() |
| 111 | np.testing.assert_allclose(w.grad.numpy(), [4., 5., 6.]) |
| 112 | |
| 113 | def test_symbolic_index(self): |
| 114 | table = Tensor([10,20,30,40]).contiguous().realize() |