Skip to content

Commit 3f0a3dd

Browse files
committed
Merge branch 'master' into cub_header2
2 parents 03f4964 + 9ed1d0d commit 3f0a3dd

149 files changed

Lines changed: 12217 additions & 1000 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.mergify.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@ pull_request_rules:
55
- label=st:test-and-merge
66
- status-success=Jenkins
77
- status-success=continuous-integration/travis-ci/pr
8-
- status-success=pfn-public-ci/cupy.py2.cv.examples
9-
- status-success=pfn-public-ci/cupy.py2.cv.gpu
108
- status-success=pfn-public-ci/cupy.py3.amd
11-
- status-success=pfn-public-ci/cupy.py3.cv.examples
12-
- status-success=pfn-public-ci/cupy.py3.cv.gpu
139
actions:
1410
merge:
1511
method: merge

.pfnci/config.pbtxt

Lines changed: 8 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -107,39 +107,26 @@ configs {
107107
}
108108
}
109109
110-
# Nightly wheels for ChainerCV tests
110+
# ROCm build test
111111
configs {
112-
key: "cupy.wheel.nightly"
112+
key: "cupy.py37.amd"
113113
value {
114114
requirement {
115115
cpu: 2
116-
memory: 12
116+
memory: 10
117117
}
118-
time_limit {
119-
seconds: 1800
118+
time_limit: {
119+
seconds: 3600
120120
}
121-
command: "sh .pfnci/wheel_nightly.sh"
121+
command: "bash .pfnci/script.sh py37.amd"
122122
}
123123
}
124124
125-
# Python 2 tests are disabled in the master branch, but configs can be removed
126-
# only after removing web hooks.
127-
# TODO(niboshi): Completely remove them after discontinuing v6 series.
128-
configs {
129-
key: "cupy.py2.cv.gpu"
130-
value {
131-
command: "true"
132-
}
133-
}
134-
configs {
135-
key: "cupy.py2.cv.examples"
136-
value {
137-
command: "true"
138-
}
139-
}
140125
141126
# ChainerCV's tests are disabled in the master branch, but configs can be removed
142127
# only after removing web hooks.
128+
# TODO(maehashi): when discontinuing v7 branch, remove the web hooks and remove
129+
# configurations below.
143130
configs {
144131
key: "cupy.py3.cv.gpu"
145132
value {
@@ -152,18 +139,3 @@ configs {
152139
command: "true"
153140
}
154141
}
155-
156-
# ROCm build test
157-
configs {
158-
key: "cupy.py37.amd"
159-
value {
160-
requirement {
161-
cpu: 2
162-
memory: 10
163-
}
164-
time_limit: {
165-
seconds: 3600
166-
}
167-
command: "bash .pfnci/script.sh py37.amd"
168-
}
169-
}

cupy/__init__.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,13 @@ def is_available():
5656
import cupy.core.fusion # NOQA
5757
from cupy import creation # NOQA
5858
from cupy import fft # NOQA
59+
from cupy import functional # NOQA
5960
from cupy import indexing # NOQA
6061
from cupy import io # NOQA
6162
from cupy import linalg # NOQA
6263
from cupy import manipulation # NOQA
6364
from cupy import padding # NOQA
65+
from cupy import polynomial # NOQA
6466
from cupy import random # NOQA
6567
from cupy import _sorting # NOQA
6668
from cupy import sparse # NOQA
@@ -278,11 +280,17 @@ def is_available():
278280
from cupy.creation.matrix import tril # NOQA
279281
from cupy.creation.matrix import triu # NOQA
280282

283+
# -----------------------------------------------------------------------------
284+
# Functional routines
285+
# -----------------------------------------------------------------------------
286+
from cupy.functional.piecewise import piecewise # NOQA
287+
281288
# -----------------------------------------------------------------------------
282289
# Array manipulation routines
283290
# -----------------------------------------------------------------------------
284291
from cupy.manipulation.basic import copyto # NOQA
285292

293+
from cupy.manipulation.shape import shape # NOQA
286294
from cupy.manipulation.shape import ravel # NOQA
287295
from cupy.manipulation.shape import reshape # NOQA
288296

@@ -320,6 +328,7 @@ def is_available():
320328
from cupy.manipulation.tiling import tile # NOQA
321329

322330
from cupy.manipulation.add_remove import unique # NOQA
331+
from cupy.manipulation.add_remove import trim_zeros # NOQA
323332

324333
from cupy.manipulation.rearrange import flip # NOQA
325334
from cupy.manipulation.rearrange import fliplr # NOQA
@@ -643,6 +652,7 @@ def isscalar(element):
643652
# -----------------------------------------------------------------------------
644653
from cupy.misc import may_share_memory # NOQA
645654
from cupy.misc import shares_memory # NOQA
655+
from cupy.misc import who # NOQA
646656

647657

648658
# -----------------------------------------------------------------------------
@@ -670,6 +680,7 @@ def isscalar(element):
670680
from cupy._sorting.sort import argsort # NOQA
671681
from cupy._sorting.sort import lexsort # NOQA
672682
from cupy._sorting.sort import msort # NOQA
683+
from cupy._sorting.sort import sort_complex # NOQA
673684
from cupy._sorting.sort import partition # NOQA
674685
from cupy._sorting.sort import sort # NOQA
675686

cupy/_environment.py

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,36 @@
77
import shutil
88

99

10-
_cuda_path = None
11-
_nvcc_path = None
10+
# '' for uninitialized, None for non-existing
11+
_cuda_path = ''
12+
_nvcc_path = ''
13+
_cub_path = ''
1214

1315

1416
def get_cuda_path():
1517
# Returns the CUDA installation path or None if not found.
1618
global _cuda_path
17-
if _cuda_path is None:
19+
if _cuda_path == '':
1820
_cuda_path = _get_cuda_path()
1921
return _cuda_path
2022

2123

2224
def get_nvcc_path():
2325
# Returns the path to the nvcc command or None if not found.
2426
global _nvcc_path
25-
if _nvcc_path is None:
27+
if _nvcc_path == '':
2628
_nvcc_path = _get_nvcc_path()
2729
return _nvcc_path
2830

2931

32+
def get_cub_path():
33+
# Returns the CUB header path or None if not found.
34+
global _cub_path
35+
if _cub_path == '':
36+
_cub_path = _get_cub_path()
37+
return _cub_path
38+
39+
3040
def _get_cuda_path():
3141
# Use environment variable
3242
cuda_path = os.environ.get('CUDA_PATH', '') # Nvidia default on Windows
@@ -59,6 +69,24 @@ def _get_nvcc_path():
5969
return shutil.which('nvcc', path=os.path.join(cuda_path, 'bin'))
6070

6171

72+
def _get_cub_path():
73+
# runtime discovery of CUB headers
74+
cuda_path = get_cuda_path()
75+
current_dir = os.path.dirname(os.path.abspath(__file__))
76+
77+
if 'CUPY_CUB_PATH' in os.environ:
78+
_cub_path = os.environ['CUPY_CUB_PATH']
79+
elif os.path.isdir(os.path.join(current_dir, 'core/include/cupy/cub')):
80+
_cub_path = '<bundle>'
81+
elif cuda_path is not None and os.path.isdir(
82+
os.path.join(cuda_path, 'include/cub')):
83+
# use built-in CUB for CUDA 11+
84+
_cub_path = '<CUDA>'
85+
else:
86+
_cub_path = None
87+
return _cub_path
88+
89+
6290
def _setup_win32_dll_directory():
6391
cuda_path = get_cuda_path()
6492
if cuda_path is None:

cupy/_sorting/sort.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,25 @@ def msort(a):
127127
return sort(a, axis=0)
128128

129129

130-
# TODO(okuta): Implement sort_complex
130+
def sort_complex(a):
131+
"""Sort a complex array using the real part first,
132+
then the imaginary part.
133+
134+
Args:
135+
a (cupy.ndarray): Array to be sorted.
136+
137+
Returns:
138+
cupy.ndarray: sorted complex array.
139+
140+
.. seealso:: :func:`numpy.sort_complex`
141+
142+
"""
143+
if a.dtype.char in 'bhBHF':
144+
a = a.astype('F')
145+
else:
146+
a = a.astype('D')
147+
a.sort()
148+
return a
131149

132150

133151
def partition(a, kth, axis=-1):

cupy/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '8.0.0b2'
1+
__version__ = '8.0.0b4'

cupy/core/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,11 @@
6262
from cupy.core.internal import get_size # NOQA
6363
from cupy.core.raw import RawKernel # NOQA
6464
from cupy.core.raw import RawModule # NOQA
65+
66+
67+
# Whether to use reduction kernels based on cub::BlockReduce
68+
import os
69+
cub_block_reduction_enabled = False
70+
if int(os.getenv('CUPY_CUB_BLOCK_REDUCTION_DISABLED', 1)) == 0:
71+
cub_block_reduction_enabled = True
72+
del os

cupy/core/_cub_reduction.pxd

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from cupy.core._carray cimport shape_t
2+
from cupy.core.core cimport ndarray
3+
4+
5+
cdef bint _try_to_call_cub_reduction(
6+
self, list in_args, list out_args, const shape_t& a_shape,
7+
stream, optimize_context, tuple key,
8+
map_expr, reduce_expr, post_map_expr, reduce_type, type_map,
9+
tuple reduce_axis, tuple out_axis, const shape_t& out_shape,
10+
ndarray ret)

0 commit comments

Comments
 (0)