From 084bb9a21b1bc5bbec57c3c48eb50e6a09b621d2 Mon Sep 17 00:00:00 2001 From: Peter Hawkins Date: Thu, 7 Nov 2024 10:09:04 -0500 Subject: [PATCH] Don't set NPY_NEEDS_PYAPI. We don't need NumPy to retain the GIL during access, and it triggers a crash in NumPy: https://github.com/numpy/numpy/issues/27709#issuecomment-2461655819 --- ml_dtypes/_src/custom_float.h | 2 +- ml_dtypes/_src/intn_numpy.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ml_dtypes/_src/custom_float.h b/ml_dtypes/_src/custom_float.h index 9f292eba..8bb7e9b6 100644 --- a/ml_dtypes/_src/custom_float.h +++ b/ml_dtypes/_src/custom_float.h @@ -401,7 +401,7 @@ PyArray_DescrProto GetCustomFloatDescrProto() { /*kind=*/TypeDescriptor::kNpyDescrKind, /*type=*/TypeDescriptor::kNpyDescrType, /*byteorder=*/TypeDescriptor::kNpyDescrByteorder, - /*flags=*/NPY_NEEDS_PYAPI | NPY_USE_SETITEM, + /*flags=*/NPY_USE_SETITEM, /*type_num=*/0, /*elsize=*/sizeof(T), /*alignment=*/alignof(T), diff --git a/ml_dtypes/_src/intn_numpy.h b/ml_dtypes/_src/intn_numpy.h index e184e0b0..7d5dbe6f 100644 --- a/ml_dtypes/_src/intn_numpy.h +++ b/ml_dtypes/_src/intn_numpy.h @@ -413,7 +413,7 @@ PyArray_DescrProto GetIntNDescrProto() { /*kind=*/TypeDescriptor::kNpyDescrKind, /*type=*/TypeDescriptor::kNpyDescrType, /*byteorder=*/TypeDescriptor::kNpyDescrByteorder, - /*flags=*/NPY_NEEDS_PYAPI | NPY_USE_SETITEM, + /*flags=*/NPY_USE_SETITEM, /*type_num=*/0, /*elsize=*/sizeof(T), /*alignment=*/alignof(T),