Description
Tuple-unpack assignment to wp.ref[T] parameters does not behave like sequential assignment.
wp.ref[T] assignment is documented as mutating the caller's storage, and simple assignment is covered by test_ref_simple_assignment_mutates. Tuple-unpack assignment should preserve the same behavior for each ref target.
Reproducer
import warp as wp
@wp.func
def set_pair(x: wp.ref[wp.float32], y: wp.ref[wp.float32], a: wp.float32, b: wp.float32):
x, y = a, b
@wp.kernel(enable_backward=False)
def kernel(out: wp.array(dtype=wp.float32)):
x = wp.float32(0.0)
y = wp.float32(0.0)
set_pair(x, y, wp.float32(3.0), wp.float32(4.0))
out[0] = x
out[1] = y
out = wp.zeros(2, dtype=wp.float32, device="cpu")
wp.launch(kernel, dim=1, outputs=[out], device="cpu")
print(out.numpy())
Expected behavior
The tuple assignment should be equivalent to:
and out should contain:
Actual behavior
Codegen rejects the assignment:
WarpCodegenTypeError: Error, assigning to existing symbol x (wp.ref[float32]) with different type (<class 'warp._src.types.float32'>)
Verification
Reproduced on main at 57f7a778c8cb08c73b3e6ed820759f9ee26ad10f with a CPU launch.
Related
Follow-up from #1277.
Description
Tuple-unpack assignment to
wp.ref[T]parameters does not behave like sequential assignment.wp.ref[T]assignment is documented as mutating the caller's storage, and simple assignment is covered bytest_ref_simple_assignment_mutates. Tuple-unpack assignment should preserve the same behavior for each ref target.Reproducer
Expected behavior
The tuple assignment should be equivalent to:
and
outshould contain:Actual behavior
Codegen rejects the assignment:
Verification
Reproduced on
mainat57f7a778c8cb08c73b3e6ed820759f9ee26ad10fwith a CPU launch.Related
Follow-up from #1277.