warp
warp copied to clipboard
Allow passing `None` to kernels with generic arguments
Kernels with generic arguments like wp.array(dtype=Any) currently cannot be provided with None for these generic arguments even though it should be possible.
from typing import Any
import warp as wp
wp.init()
@wp.kernel
def foo(
in_values: wp.array(dtype=Any),
out: wp.array(dtype=Any),
):
tid = wp.tid()
if not in_values:
return
out[tid] = in_values[tid]
out = wp.ones(10, dtype=wp.float32)
values = None
wp.launch(foo, dim=out.shape, inputs=(values,), outputs=(out,))
Output:
File "/home/eshi/code-projects/warp/warp/context.py", line 5490, in launch
kernel = kernel.add_overload(fwd_types)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/eshi/code-projects/warp/warp/context.py", line 715, in add_overload
raise TypeError(
TypeError: Kernel foo argument 'in_values' cannot be generic, got arraytyping.Any
Adding this enhancement may also allow warp.sim.State and warp.sim.Control to be marked as wp.struct and thus passed directly into kernels?