This file contains hidden or 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
import dpnp as np | |
x = np.asarray([1.0, 2.0, 3.0], device="gpu").astype(np.float32) | |
y = np.float32(1.0) / x | |
print(type(x)) | |
print(type(y)) | |
assert isinstance(y, np.dpnp_array.dpnp_array) |
This file contains hidden or 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 import njit, prange | |
import numpy as np | |
from time import time | |
import math | |
@njit(parallel=False) | |
def foo(m): | |
pos = np.empty_like(m) | |
for i in prange(len(m)): |
This file contains hidden or 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 import njit, prange | |
import numpy as np | |
import math | |
from time import time | |
SOFTENING_SQ = 0.001 | |
G = 1.0 | |
@njit(parallel=True) |
This file contains hidden or 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.typed import Dict | |
from numba import types, njit | |
import numpy as np | |
# Using Numba dictionary is more efficient for passing into compiled region due to lower unboxing overheads | |
# The Dict.empty() constructs a typed dictionary. | |
# The key and value typed must be explicitly declared. | |
nd = Dict.empty( | |
key_type=types.int64, | |
value_type=types.float64[:] |
This file contains hidden or 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 import jitclass | |
from numba import types | |
from numba.typed import Dict | |
@jitclass([('d', types.DictType(types.intp, types.float64))]) | |
class DictWrapper(object): | |
def __init__(self): | |
d = Dict() | |
d[1] = 1.2 |