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

Function mlx_get_item_array

python/src/indexing.cpp:108–122  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

106}
107
108mx::array mlx_get_item_array(const mx::array& src, const mx::array& indices) {
109 // Check input and raise error if 0 dim for parity with np
110 if (src.ndim() == 0) {
111 throw std::invalid_argument(
112 "too many indices for array: array is 0-dimensional");
113 }
114
115 if (indices.dtype() == mx::bool_) {
116 throw std::invalid_argument("boolean indices are not yet supported");
117 }
118
119 // If only one input array is mentioned, we set axis=0 in take
120 // for parity with np
121 return take(src, indices, 0);
122}
123
124mx::array mlx_get_item_int(const mx::array& src, const nb::object& idx) {
125 // Check input and raise error if 0 dim for parity with np

Callers 1

mlx_get_itemFunction · 0.85

Calls 1

takeFunction · 0.85

Tested by

no test coverage detected