Skip to content

Instantly share code, notes, and snippets.

@gmarkall
Created October 21, 2022 11:35
Show Gist options
  • Save gmarkall/20c677707218896a63d99e5b0b540a66 to your computer and use it in GitHub Desktop.
Save gmarkall/20c677707218896a63d99e5b0b540a66 to your computer and use it in GitHub Desktop.
Example overloading a method in Numba's CUDA target
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