MCPcopy Create free account
hub / github.com/ml-explore/mlx / index_fn

Method index_fn

python/tests/test_array.py:1128–1129  ·  view source on GitHub ↗
(x, ind)

Source from the content-addressed store, hash-verified

1126 ind = mx.array([0, 1, 0]).astype(mx.float32)
1127
1128 def index_fn(x, ind):
1129 return x[ind.astype(mx.int32)].sum()
1130
1131 grad_x, grad_ind = mx.grad(index_fn, argnums=(0, 1))(x, ind)
1132 expected = mx.array([[2, 2], [1, 1]])

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected