From 8396ad04c4b1d3b5fc9d337a3cc03bcfddc2155d Mon Sep 17 00:00:00 2001 From: Kenichi Maehashi Date: Thu, 5 Apr 2018 19:28:48 +0900 Subject: [PATCH 1/2] add test for 32-bit boundary for cupy.concatenate --- tests/cupy_tests/manipulation_tests/test_join.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/cupy_tests/manipulation_tests/test_join.py b/tests/cupy_tests/manipulation_tests/test_join.py index a4c6dacfaeb..e03a121d595 100644 --- a/tests/cupy_tests/manipulation_tests/test_join.py +++ b/tests/cupy_tests/manipulation_tests/test_join.py @@ -108,6 +108,13 @@ def test_concatenate_many_multi_dptye(self, xp): b = testing.shaped_arange((2, 1), xp, 'f') return xp.concatenate((a, b) * 1024, axis=1) + @testing.numpy_cupy_array_equal() + @testing.slow + def test_concatenate_32bit_boundary(self, xp): + a = xp.zeros((2 ** 30,), dtype=xp.int8) + b = xp.zeros((2 ** 30,), dtype=xp.int8) + return xp.concatenate([a, b]) + def test_concatenate_wrong_ndim(self): a = cupy.empty((2, 3)) b = cupy.empty((2,)) From b3b9835e5cb1a40b61ba7f60de3c51de344356bd Mon Sep 17 00:00:00 2001 From: Kenichi Maehashi Date: Thu, 5 Apr 2018 16:54:16 +0900 Subject: [PATCH 2/2] fix to avoid overflow --- cupy/core/core.pyx | 2 +- cupy/core/internal.pyx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cupy/core/core.pyx b/cupy/core/core.pyx index e71e5e05636..a922754c307 100644 --- a/cupy/core/core.pyx +++ b/cupy/core/core.pyx @@ -2467,7 +2467,7 @@ cpdef ndarray concatenate_method(tup, int axis): cpdef ndarray _concatenate(list arrays, Py_ssize_t axis, tuple shape, dtype): cdef ndarray a, ret - cdef int i + cdef Py_ssize_t i cdef bint all_same_type, same_shape_and_contiguous cdef Py_ssize_t axis_size # If arrays are large, Issuing each copy method is efficient. diff --git a/cupy/core/internal.pyx b/cupy/core/internal.pyx index f3815f46a76..91b48d6e8ef 100644 --- a/cupy/core/internal.pyx +++ b/cupy/core/internal.pyx @@ -143,7 +143,7 @@ cpdef vector.vector[Py_ssize_t] infer_unknown_dimension( @cython.profile(False) -cpdef inline int _extract_slice_element(x) except *: +cpdef inline Py_ssize_t _extract_slice_element(x) except *: try: return x.__index__() except AttributeError: