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

Function to_array_with_accessor

python/src/utils.cpp:87–98  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

85}
86
87mx::array to_array_with_accessor(nb::object obj) {
88 if (nb::isinstance<mx::array>(obj)) {
89 return nb::cast<mx::array>(obj);
90 } else if (nb::hasattr(obj, "__mlx_array__")) {
91 return nb::cast<mx::array>(obj.attr("__mlx_array__")());
92 } else {
93 std::ostringstream msg;
94 msg << "Invalid type " << nb::type_name(obj.type()).c_str()
95 << " received in array initialization.";
96 throw std::invalid_argument(msg.str());
97 }
98}

Callers 2

create_arrayFunction · 0.85
to_arrayFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected