Created
October 21, 2022 11:35
-
-
Save gmarkall/20c677707218896a63d99e5b0b540a66 to your computer and use it in GitHub Desktop.
Example overloading a method in Numba's CUDA target
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from numba.extending import overload_method | |
from numba import types | |
@overload_method(types.Array, 'sum', target='cuda') | |
def array_sum(arr): | |
if arr.ndim != 1: | |
return None | |
def sum_impl(arr): | |
res = 0 | |
for i in range(len(arr)): | |
res += arr[i] | |
return res | |
return sum_impl |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment