(idtype)
| 181 | |
| 182 | @parametrize_idtype |
| 183 | def test_batch_setter_autograd(idtype): |
| 184 | g = generate_graph(idtype, grad=True) |
| 185 | h1 = g.ndata["h"] |
| 186 | # partial set |
| 187 | v = F.tensor([1, 2, 8], g.idtype) |
| 188 | hh = F.attach_grad(F.zeros((len(v), D))) |
| 189 | with F.record_grad(): |
| 190 | g.nodes[v].data["h"] = hh |
| 191 | h2 = g.ndata["h"] |
| 192 | F.backward(h2, F.ones((10, D)) * 2) |
| 193 | assert F.array_equal( |
| 194 | F.grad(h1)[:, 0], |
| 195 | F.tensor([2.0, 0.0, 0.0, 2.0, 2.0, 2.0, 2.0, 2.0, 0.0, 2.0]), |
| 196 | ) |
| 197 | assert F.array_equal(F.grad(hh)[:, 0], F.tensor([2.0, 2.0, 2.0])) |
| 198 | |
| 199 | |
| 200 | def _test_nx_conversion(): |
nothing calls this directly
no test coverage detected