Skip to content

Support for Calling Device Functions from Ufuncs #193

@PokhodenkoSA

Description

@PokhodenkoSA

dpex ufunc kernels cannot be called from other dpex device functions.

Example:

@dppy.func
def a_device_function(a):
    return a + 1

@vectorize(nopython=True)
def ufunc_kernel(x, y):
    return a_device_function(x) + y

def test_ufunc():
    N = 10
    dtype = np.float64

    A = np.arange(N, dtype=dtype)
    B = np.arange(N, dtype=dtype) * 10

    context = get_context()
    with dpctl.device_context(context):
        C = ufunc_kernel(A, B)

    print(C)

Output:

numba.core.errors.TypingError: Failed in nopython mode pipeline (step: nopython frontend)
Untyped global name 'a_device_function': cannot determine Numba type of <class 'numba_dppy.compiler.DPPYFunctionTemplate'>

File "numba_dppy/examples/vectorize_func.py", line 14:
def ufunc_kernel(x, y):
    return a_device_function(x) + y
    ^

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions