Skip to content

Instantly share code, notes, and snippets.

@alsrgv
Created Jan 30, 2020
Embed
What would you like to do?
Numba CUDA jitclass question
import numba
import numba.cuda
import numpy as np
@numba.jitclass([
("x", numba.types.int32)
])
class XYZ:
def __init__(self, x):
self.x = x
@numba.cuda.jit
def set_x(a: np.ndarray, xyz: XYZ) -> np.ndarray:
x = numba.cuda.grid(1)
if x >= a.shape[0]:
return
a[x] = xyz.x
a = np.zeros(5)
xyz = XYZ(10)
set_x(a, xyz)
print(a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment