warp.func#

warp.func(
f: Callable[[_FuncParams], _FuncReturn],
) Callable[[_FuncParams], _FuncReturn][source]#
warp.func(
f: None = None,
*,
name: str | None = None,
module: Module | Literal['unique'] | str | None = None,
inline: bool | None = None,
) Callable[[Callable[[_FuncParams], _FuncReturn]], Callable[[_FuncParams], _FuncReturn]]

Decorator to define a Warp function callable from kernels and other Warp functions.

Parameters:
  • f (Callable | None) – The Python callable to register as a Warp function.

  • name (str | None) – Sets the function key used for registration and native code generation. If None, Warp derives the key from f.

  • module (Module | Literal['unique'] | str | None) – The Warp module in which to register the function. If None, Warp infers the module from f. Pass "unique" to create a new module, or a string to register the function in a named module.

  • inline (bool | None) – Whether the function is inlined into its call sites. None leaves the choice to the backend compiler. True requires inlining (CUDA __forceinline__), overriding the compiler’s own heuristic. False keeps the function out of line (CUDA __noinline__).

The inline hint covers the generated adjoint as well as the forward function, and is lowered per backend so the decorated function stays valid for CPU and CUDA.

See also

warp.kernel() for defining kernels that can be launched on devices.