Bug Description
Calling an @wp.func function directly from Python fails when a parameter is annotated as wp.Function. The same call works inside a kernel.
import warp as wp
@wp.func
def square(x: float):
return x * x
@wp.func
def apply(f: wp.Function, x: float):
return f(x)
@wp.kernel
def apply_kernel(out: wp.array[float]):
out[0] = apply(square, 3.0)
# Kernel call works.
out = wp.zeros(1, dtype=float)
wp.launch(apply_kernel, dim=1, outputs=[out])
# Python-scope call fails.
apply(square, 3.0)
The Python-scope call raises:
TypeError: Unable to infer the type of argument 'f', got <class 'warp._src.context.Function'>
Expected behavior: apply(square, 3.0) returns 9.0.
Explicit, keyword, and default function arguments encounter the same validation failure. Simple built-in Warp function targets are also affected.
Related to #1424.
System Information
Originally reported against the latest published Warp release. The exact version and platform were not provided.
Reproduced on:
- Warp 1.16.0.dev0 at commit
10a0bb873
- Python 3.12.13
- Linux
Bug Description
Calling an
@wp.funcfunction directly from Python fails when a parameter is annotated aswp.Function. The same call works inside a kernel.The Python-scope call raises:
Expected behavior:
apply(square, 3.0)returns9.0.Explicit, keyword, and default function arguments encounter the same validation failure. Simple built-in Warp function targets are also affected.
Related to #1424.
System Information
Originally reported against the latest published Warp release. The exact version and platform were not provided.
Reproduced on:
10a0bb873