diff options
| author | mattip <matti.picus@gmail.com> | 2023-03-30 10:49:36 +0300 |
|---|---|---|
| committer | mattip <matti.picus@gmail.com> | 2023-03-30 10:49:36 +0300 |
| commit | 18de0a5903d209be456e05b41a5a9bdcfbb7e529 (patch) | |
| tree | ae7579497f0cebeec78c185b7b0b43e177f56f98 /numpy/core | |
| parent | 5e6e58636610ce3b2e31eefe324ba861d051eb36 (diff) | |
| download | numpy-18de0a5903d209be456e05b41a5a9bdcfbb7e529.tar.gz | |
BUG: only check PyErr_Occurred if Python C-API is needed
Diffstat (limited to 'numpy/core')
| -rw-r--r-- | numpy/core/src/multiarray/einsum.c.src | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/numpy/core/src/multiarray/einsum.c.src b/numpy/core/src/multiarray/einsum.c.src index 1b3dbd90b..e673437ef 100644 --- a/numpy/core/src/multiarray/einsum.c.src +++ b/numpy/core/src/multiarray/einsum.c.src @@ -532,11 +532,12 @@ unbuffered_loop_nop1_ndim2(NpyIter *iter) * Since the iterator wasn't tracking coordinates, the * loop provided by the iterator is in Fortran-order. */ + int needs_api = NpyIter_IterationNeedsAPI(iter); NPY_BEGIN_THREADS_THRESHOLDED(shape[1] * shape[0]); for (coord = shape[1]; coord > 0; --coord) { sop(1, ptrs[0], strides[0], shape[0]); - if(PyErr_Occurred()){ + if(needs_api && PyErr_Occurred()){ return -1; } @@ -590,12 +591,13 @@ unbuffered_loop_nop1_ndim3(NpyIter *iter) * Since the iterator wasn't tracking coordinates, the * loop provided by the iterator is in Fortran-order. */ + int needs_api = NpyIter_IterationNeedsAPI(iter); NPY_BEGIN_THREADS_THRESHOLDED(shape[2] * shape[1] * shape[0]); for (coords[1] = shape[2]; coords[1] > 0; --coords[1]) { for (coords[0] = shape[1]; coords[0] > 0; --coords[0]) { sop(1, ptrs[0], strides[0], shape[0]); - if(PyErr_Occurred()){ + if(needs_api && PyErr_Occurred()){ return -1; } @@ -651,11 +653,12 @@ unbuffered_loop_nop2_ndim2(NpyIter *iter) * Since the iterator wasn't tracking coordinates, the * loop provided by the iterator is in Fortran-order. */ + int needs_api = NpyIter_IterationNeedsAPI(iter); NPY_BEGIN_THREADS_THRESHOLDED(shape[1] * shape[0]); for (coord = shape[1]; coord > 0; --coord) { sop(2, ptrs[0], strides[0], shape[0]); - if(PyErr_Occurred()){ + if(needs_api && PyErr_Occurred()){ return -1; } @@ -711,12 +714,13 @@ unbuffered_loop_nop2_ndim3(NpyIter *iter) * Since the iterator wasn't tracking coordinates, the * loop provided by the iterator is in Fortran-order. */ + int needs_api = NpyIter_IterationNeedsAPI(iter); NPY_BEGIN_THREADS_THRESHOLDED(shape[2] * shape[1] * shape[0]); for (coords[1] = shape[2]; coords[1] > 0; --coords[1]) { for (coords[0] = shape[1]; coords[0] > 0; --coords[0]) { sop(2, ptrs[0], strides[0], shape[0]); - if(PyErr_Occurred()){ + if(needs_api && PyErr_Occurred()){ return -1; } |
