Skip to content

Commit

Permalink
Ensure GPU is used for input transposing of host arrays (#3835)
Browse files Browse the repository at this point in the history
Closes issue #3832 

Related to #3767 

cc @teju85 and @venkywonka and @vinaydes who are working on RF

Will be profiling the solution before flipping the PR to ready to review

Quick profiling, on a 2070S laptop,average of 10 runs of a simple LinearRegression.fit (that expects data in `F` format), with a `X` matrix of 500 columns with 100000 rows shows:

- Before the fix:
```
common.input_utils.input_to_cuml_array                     :   0.1795 s
```

- After the fix:
```
common.input_utils.input_to_cuml_array                     :   0.0632 s
```

Authors:
  - Dante Gama Dessavre (https://github.com/dantegd)

Approvers:
  - William Hicks (https://github.com/wphicks)
  - Corey J. Nolet (https://github.com/cjnolet)

URL: #3835
  • Loading branch information
dantegd authored May 7, 2021
1 parent 3fdd178 commit 6ba82ef
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions python/cuml/common/input_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,8 @@ def check_order(arr_order):
elif hasattr(X, "__array_interface__") or \
hasattr(X, "__cuda_array_interface__"):

host_array = hasattr(X, "__array_interface__")

# Since we create the array with the correct order here, do the order
# check now if necessary
interface = getattr(X, "__array_interface__", None) or getattr(
Expand All @@ -338,6 +340,11 @@ def check_order(arr_order):
# X = cp.array(X, order=order, copy=True)
make_copy = True

# If we have a host array, we copy it first before changing order
# to transpose using the GPU
if host_array:
X = cp.array(X)

cp_arr = cp.array(X, copy=make_copy, order=order)

X_m = CumlArray(data=cp_arr)
Expand Down
1 change: 1 addition & 0 deletions python/cuml/test/test_train_test_split.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ def test_stratify_retain_index(test_size, train_size):
assert X_test.shape[0] == (int)(X.shape[0] * test_size)


@pytest.mark.skip("See issue https://github.com/rapidsai/cuml/issues/3839")
def test_stratified_binary_classification():
X = cp.array([[0.37487513, -2.3031888, 1.662633, 0.7671007],
[-0.49796826, -1.0621182, -0.32518214, -0.20583323],
Expand Down

0 comments on commit 6ba82ef

Please sign in to comment.