summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorMatti Picus <matti.picus@gmail.com>2021-11-14 09:12:08 +0200
committerGitHub <noreply@github.com>2021-11-14 09:12:08 +0200
commitbbe51bde46cad1ecf1f4cf2c17eb7475d0df8e5d (patch)
tree642975be960942d2d6ed7586aa79a4e0fda48d5c /numpy
parent20a2a70129e3b29907e2298c0906d9910fbcbd8c (diff)
parent10ac74940b1e6b1a9e9525f1aaa68fb1e096b326 (diff)
downloadnumpy-bbe51bde46cad1ecf1f4cf2c17eb7475d0df8e5d.tar.gz
Merge pull request #20364 from seberg/issue-19806
BUG: Relax unary ufunc (sqrt, etc.) stride assert
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/src/umath/loops_trigonometric.dispatch.c.src2
-rw-r--r--numpy/core/src/umath/loops_umath_fp.dispatch.c.src4
-rw-r--r--numpy/core/src/umath/loops_unary_fp.dispatch.c.src2
3 files changed, 4 insertions, 4 deletions
diff --git a/numpy/core/src/umath/loops_trigonometric.dispatch.c.src b/numpy/core/src/umath/loops_trigonometric.dispatch.c.src
index 8c2c83e7c..cd9b2ed54 100644
--- a/numpy/core/src/umath/loops_trigonometric.dispatch.c.src
+++ b/numpy/core/src/umath/loops_trigonometric.dispatch.c.src
@@ -209,7 +209,7 @@ NPY_NO_EXPORT void NPY_CPU_DISPATCH_CURFX(FLOAT_@func@)
const npy_intp ssrc = steps[0] / lsize;
const npy_intp sdst = steps[1] / lsize;
npy_intp len = dimensions[0];
- assert(steps[0] % lsize == 0 && steps[1] % lsize == 0);
+ assert(len <= 1 || (steps[0] % lsize == 0 && steps[1] % lsize == 0));
#if NPY_SIMD_FMA3
if (is_mem_overlap(src, steps[0], dst, steps[1], len) ||
!npyv_loadable_stride_f32(ssrc) || !npyv_storable_stride_f32(sdst)
diff --git a/numpy/core/src/umath/loops_umath_fp.dispatch.c.src b/numpy/core/src/umath/loops_umath_fp.dispatch.c.src
index 852604655..a8289fc51 100644
--- a/numpy/core/src/umath/loops_umath_fp.dispatch.c.src
+++ b/numpy/core/src/umath/loops_umath_fp.dispatch.c.src
@@ -96,7 +96,7 @@ NPY_NO_EXPORT void NPY_CPU_DISPATCH_CURFX(@TYPE@_@func@)
const npy_intp ssrc = steps[0] / lsize;
const npy_intp sdst = steps[1] / lsize;
const npy_intp len = dimensions[0];
- assert(steps[0] % lsize == 0 && steps[1] % lsize == 0);
+ assert(len <= 1 || (steps[0] % lsize == 0 && steps[1] % lsize == 0));
if (!is_mem_overlap(src, steps[0], dst, steps[1], len) &&
npyv_loadable_stride_@sfx@(ssrc) &&
npyv_storable_stride_@sfx@(sdst)) {
@@ -125,7 +125,7 @@ NPY_NO_EXPORT void NPY_CPU_DISPATCH_CURFX(DOUBLE_@func@)
const npy_intp ssrc = steps[0] / lsize;
const npy_intp sdst = steps[1] / lsize;
const npy_intp len = dimensions[0];
- assert(steps[0] % lsize == 0 && steps[1] % lsize == 0);
+ assert(len <= 1 || (steps[0] % lsize == 0 && steps[1] % lsize == 0));
if (!is_mem_overlap(src, steps[0], dst, steps[1], len) &&
npyv_loadable_stride_f64(ssrc) &&
npyv_storable_stride_f64(sdst)) {
diff --git a/numpy/core/src/umath/loops_unary_fp.dispatch.c.src b/numpy/core/src/umath/loops_unary_fp.dispatch.c.src
index 789733fb6..93761b98c 100644
--- a/numpy/core/src/umath/loops_unary_fp.dispatch.c.src
+++ b/numpy/core/src/umath/loops_unary_fp.dispatch.c.src
@@ -263,7 +263,7 @@ NPY_NO_EXPORT void NPY_CPU_DISPATCH_CURFX(@TYPE@_@kind@)
npy_intp len = dimensions[0];
#if @VCHK@
const int lsize = sizeof(npyv_lanetype_@sfx@);
- assert(src_step % lsize == 0 && dst_step % lsize == 0);
+ assert(len <= 1 || (src_step % lsize == 0 && dst_step % lsize == 0));
if (is_mem_overlap(src, src_step, dst, dst_step, len)) {
goto no_unroll;
}