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

Function nd_array_to_mlx_contiguous

python/src/convert.cpp:26–34  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24
25template <typename T>
26mx::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
36mx::array nd_array_to_mlx(
37 nb::ndarray<nb::ro, nb::c_contig, nb::device::cpu> nd_array,

Callers

nothing calls this directly

Calls 2

arrayFunction · 0.50
dataMethod · 0.45

Tested by

no test coverage detected