(self)
| 73 | np.testing.assert_allclose(real_index, X.numpy()) |
| 74 | |
| 75 | def test_index_variable(self): |
| 76 | dataset = Tensor.rand(DSET, DDIM).realize() |
| 77 | v = Variable("v", 0, DDIM-1) |
| 78 | with Context(NOOPT=1): |
| 79 | GlobalCounters.reset() |
| 80 | vb = Tensor(v.bind(12)) |
| 81 | comp = dataset[vb].numpy() |
| 82 | # no global ops because they are all indexing |
| 83 | self.assertEqual(GlobalCounters.global_ops, 0) |
| 84 | np.testing.assert_allclose(comp, dataset.numpy()[12]) |
| 85 | |
| 86 | def test_index(self): |
| 87 | dataset = Tensor.rand(DSET, DDIM).realize() |