MCPcopy
hub / github.com/tinygrad/tinygrad / test_index_variable

Method test_index_variable

test/backend/test_arange.py:75–84  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 8

ContextClass · 0.90
TensorClass · 0.90
realizeMethod · 0.80
randMethod · 0.80
VariableFunction · 0.50
resetMethod · 0.45
bindMethod · 0.45
numpyMethod · 0.45

Tested by

no test coverage detected