Fix np bfloat16 misinterpreted as complex (#3146)

Co-authored-by: Cheng <git@zcbenz.com>
This commit is contained in:
Kellen Sun
2026-03-30 19:04:55 -04:00
committed by GitHub
parent 0ff1115a46
commit 8a6d28713c
6 changed files with 118 additions and 56 deletions
+2 -2
View File
@@ -296,7 +296,7 @@ void init_array(nb::module_& m) {
nb::is_weak_referenceable())
.def(
"__init__",
[](mx::array* aptr, ArrayInitType v, std::optional<mx::Dtype> t) {
[](mx::array* aptr, nb::object v, std::optional<mx::Dtype> t) {
new (aptr) mx::array(create_array(v, t));
},
"val"_a,
@@ -492,7 +492,7 @@ void init_array(nb::module_& m) {
reinterpret_cast<const size_t*>(nd.shape_ptr()),
owner,
nullptr,
nb::bfloat16),
nb::dtype<mx::bfloat16_t>()),
mx::bfloat16));
} else {
new (&arr) mx::array(nd_array_to_mlx(nd, std::nullopt));