Skip to content

Commit 099a61e

Browse files
committed
comment-out PyArray_TypeNumFromName
1 parent 3993f56 commit 099a61e

1 file changed

Lines changed: 20 additions & 16 deletions

File tree

ml_dtypes/_src/custom_float.h

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -878,22 +878,26 @@ bool RegisterFloatDtype(PyObject* numpy, bool* already_registered = nullptr) {
878878
// writing is this one (distributed in TF and JAX).
879879
// TODO(phawkins): distribute the bfloat16 extension as its own pip package,
880880
// so we can unambiguously refer to a single canonical definition of bfloat16.
881-
int typenum =
882-
PyArray_TypeNumFromName(const_cast<char*>(TypeDescriptor<T>::kTypeName));
883-
if (typenum != NPY_NOTYPE) {
884-
PyArray_Descr* descr = PyArray_DescrFromType(typenum);
885-
// The test for an argmax function here is to verify that the
886-
// bfloat16 implementation is sufficiently new, and, say, not from
887-
// an older version of TF or JAX.
888-
if (descr && descr->f && descr->f->argmax) {
889-
TypeDescriptor<T>::npy_type = typenum;
890-
TypeDescriptor<T>::type_ptr = reinterpret_cast<PyObject*>(descr->typeobj);
891-
if (already_registered != nullptr) {
892-
*already_registered = true;
893-
}
894-
return true;
895-
}
896-
}
881+
882+
// TODO(jakevdp): comment this out for now to enable testing against numpy upstream.
883+
// We should NOT merge before uncommenting this.
884+
885+
// int typenum =
886+
// PyArray_TypeNumFromName(const_cast<char*>(TypeDescriptor<T>::kTypeName));
887+
// if (typenum != NPY_NOTYPE) {
888+
// PyArray_Descr* descr = PyArray_DescrFromType(typenum);
889+
// // The test for an argmax function here is to verify that the
890+
// // bfloat16 implementation is sufficiently new, and, say, not from
891+
// // an older version of TF or JAX.
892+
// if (descr && descr->f && descr->f->argmax) {
893+
// TypeDescriptor<T>::npy_type = typenum;
894+
// TypeDescriptor<T>::type_ptr = reinterpret_cast<PyObject*>(descr->typeobj);
895+
// if (already_registered != nullptr) {
896+
// *already_registered = true;
897+
// }
898+
// return true;
899+
// }
900+
// }
897901

898902
// It's important that we heap-allocate our type. This is because tp_name
899903
// is not a fully-qualified name for a heap-allocated type, and

0 commit comments

Comments
 (0)