Skip to content

CUDA: Support passing tuples to ufuncs - #6878

Merged
sklam merged 2 commits into
numba:masterfrom
gmarkall:grm-issue-6563
May 11, 2021
Merged

sklam merged 2 commits into
numba:masterfrom
gmarkall:grm-issue-6563

Conversation

@gmarkall

Copy link
Copy Markdown
Member

This PR adds support for use cases like the following to CUDA ufuncs created with @vectorize:

from numba import vectorize, float64
import math

@vectorize([float64(float64)], target='cuda')
def cuda_cos(x):
    return math.cos(x)

print(cuda_cos((1.0, 2.0, 3.0)))

Passing tuples, namedtuples, tuples of arrays, and nesting of these is supported - tests are added to cover some of these cases.

It seems that this already worked for gufuncs, so some tests are added for the equivalent in gufuncs, but no functional change is made there.

Fixes #6563.

This commit adds support for use cases like the following to CUDA ufuncs
created with `@vectorize`:

```
from numba import vectorize, float64
import math

@vectorize([float64(float64)],)
def cuda_cos(x):
    return math.cos(x)

print(cuda_cos((1.0, 2.0, 3.0)))
```

Passing tuples, namedtuples, tuples of arrays, and nesting of these is
supported - tests are added to cover some of these cases.

It seems that this already worked for gufuncs, so some tests are added
for the equivalent in gufuncs, but no functional change is made there.

Fixes numba#6563.

@stuartarchibald stuartarchibald left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the patch, one minor query else looks good.

Comment thread numba/np/ufunc/deviceufunc.py Outdated
@stuartarchibald stuartarchibald added 4 - Waiting on author Waiting for author to respond to review and removed 3 - Ready for Review labels Apr 9, 2021
@gmarkall gmarkall added 4 - Waiting on reviewer Waiting for reviewer to respond to author and removed 4 - Waiting on author Waiting for author to respond to review labels Apr 13, 2021
@stuartarchibald stuartarchibald added 4 - Waiting on author Waiting for author to respond to review and removed 4 - Waiting on reviewer Waiting for reviewer to respond to author labels Apr 14, 2021
@gmarkall gmarkall added 4 - Waiting on reviewer Waiting for reviewer to respond to author and removed 4 - Waiting on author Waiting for author to respond to review labels Apr 22, 2021

@stuartarchibald stuartarchibald left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the patch and fixes.

@stuartarchibald stuartarchibald added 4 - Waiting on CI Review etc done, waiting for CI to finish and removed 4 - Waiting on reviewer Waiting for reviewer to respond to author labels May 10, 2021
@stuartarchibald

Copy link
Copy Markdown
Contributor

Buildfarm ID: numba_smoketest_cuda_yaml_56.

@stuartarchibald

Copy link
Copy Markdown
Contributor

Buildfarm ID: numba_smoketest_cuda_yaml_56.

Passed

@stuartarchibald stuartarchibald added 5 - Ready to merge Review and testing done, is ready to merge and removed 4 - Waiting on CI Review etc done, waiting for CI to finish labels May 10, 2021
@sklam
sklam merged commit 751dc1a into numba:master May 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

5 - Ready to merge Review and testing done, is ready to merge CUDA CUDA related issue/PR Effort - medium Medium size effort needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CUDA: Add support for passing tuples to kernels via vectorize

3 participants