numba_dpex.core.kernel_interface.func module
_summary_
- class numba_dpex.core.kernel_interface.func.DpexFunction(pyfunc, debug=False)
Bases:
objectClass to materialize dpex function
Helper class to eager compile a specialized numba_dpex.func decorated Python function into a LLVM function with spir_func calling convention.
A specialized numba_dpex.func decorated Python function is one where the user has specified a signature or a list of signatures for the function. The function gets compiled as soon as the Python program is loaded, i.e., eagerly, instead of JIT compilation once the function is invoked.
- compile(arg_types, return_types)
The actual compilation function.
- Args:
arg_types (tuple): Function argument types in a tuple. return_types (numba.core.types.scalars.Integer):
An integer value to specify the return type.
- Returns:
numba.core.compiler.CompileResult: The compiled result
- class numba_dpex.core.kernel_interface.func.DpexFunctionTemplate(pyfunc, debug=False, enable_cache=True)
Bases:
objectHelper class to compile an unspecialized numba_dpex.func
A helper class to JIT compile an unspecialized numba_dpex.func decorated Python function into an LLVM function with spir_func calling convention.
- property cache
Cache accessor
- property cache_hits
Cache hit count accessor
- compile(args)
Compile a numba_dpex.func decorated function
Compile a numba_dpex.func decorated Python function with the given argument types. Each signature is compiled once by caching the compiled function inside this object.
- Args:
args (tuple): Function argument types in a tuple.
- Returns:
- numba.core.typing.templates.Signature: Signature of the
compiled result.
- numba_dpex.core.kernel_interface.func.compile_func(pyfunc, signature, debug=False)
Compiles a specialized numba_dpex.func
Compiles a specialized numba_dpex.func decorated function to native binary library function and returns the library wrapped inside a numba_dpex.core.kernel_interface.func.DpexFunction object.
- Args:
pyfunc (function): A python function to be compiled. signature (list): A list of numba.core.typing.templates.Signature’s debug (bool, optional): Debug options. Defaults to False.
- Returns:
- numba_dpex.core.kernel_interface.func.DpexFunction: A DpexFunction
object
- numba_dpex.core.kernel_interface.func.compile_func_template(pyfunc, debug=False, enable_cache=True)
Converts a numba_dpex.func function to an AbstractTemplate
Converts a numba_dpex.func decorated function to a Numba AbstractTemplate and returns the object wrapped inside a numba_dpex.core.kernel_interface.func.DpexFunctionTemplate object.
A DpexFunctionTemplate object is an abstract representation for a native function with spir_func calling convention that is to be JIT compiled once the argument types are resolved.
- Args:
pyfunc (function): A python function to be compiled. debug (bool, optional): Debug options. Defaults to False.
- Raises:
- AssertionError: Raised if keyword arguments are supplied in
the inner generic function.
- Returns:
- numba_dpex.core.kernel_interface.func.DpexFunctionTemplate:
A DpexFunctionTemplate object.