| 24 | |
| 25 | template <typename T> |
| 26 | mx::array nd_array_to_mlx_contiguous( |
| 27 | nb::ndarray<nb::ro, nb::c_contig, nb::device::cpu> nd_array, |
| 28 | const mx::Shape& shape, |
| 29 | mx::Dtype dtype) { |
| 30 | // Make a copy of the numpy buffer |
| 31 | // Get buffer ptr pass to array constructor |
| 32 | auto data_ptr = nd_array.data(); |
| 33 | return mx::array(static_cast<const T*>(data_ptr), shape, dtype); |
| 34 | } |
| 35 | |
| 36 | mx::array nd_array_to_mlx( |
| 37 | nb::ndarray<nb::ro, nb::c_contig, nb::device::cpu> nd_array, |