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

Function mlx_to_nd_array_impl

python/src/convert.cpp:100–115  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

98
99template <typename T, typename... NDParams>
100nb::ndarray<NDParams...> mlx_to_nd_array_impl(
101 mx::array a,
102 std::optional<nb::dlpack::dtype> t = {}) {
103 {
104 nb::gil_scoped_release nogil;
105 a.eval();
106 }
107 std::vector<size_t> shape(a.shape().begin(), a.shape().end());
108 return nb::ndarray<NDParams...>(
109 a.data<T>(),
110 a.ndim(),
111 shape.data(),
112 /* owner= */ nb::none(),
113 a.strides().data(),
114 t.value_or(nb::dtype<T>()));
115}
116
117template <typename... NDParams>
118nb::ndarray<NDParams...> mlx_to_nd_array(const mx::array& a) {

Callers

nothing calls this directly

Calls 4

evalMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected