Skip to content

[REQ] Gradients for composite type in-place array assignments #583

Description

@daedalus5

Description

Add correct gradient propagation for composite type in-place array assignments.

Test

import warp as wp

wp.init()

wp.build.clear_kernel_cache()

@wp.kernel
def vectest(x: wp.array(dtype=wp.vec3), y: wp.array(dtype=float)):
    i = wp.tid()

    x[i].y = y[i]

x = wp.zeros(1, dtype=wp.vec3, requires_grad=True)
y = wp.ones(1, dtype=float, requires_grad=True)

tape = wp.Tape()
with tape:
    wp.launch(kernel=vectest, dim=1, inputs=[x, y])

x.grad = wp.ones_like(x, requires_grad=False)
tape.backward()

# should be [1.0]
print(y.grad)

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions