mitsuba-renderer / drjit

Dr.Jit — A Just-In-Time-Compiler for Differentiable Rendering
BSD 3-Clause "New" or "Revised" License
593 stars 43 forks source link

Allows functions in `wrap_ad` context to return nested structures #88

Closed thomasw21 closed 2 years ago

thomasw21 commented 2 years ago

torch.autograd.backward only supports list of tensors: https://pytorch.org/docs/stable/generated/torch.autograd.backward.html . This causes the previous assumption to break as self.res_torch could be a nested structure.

We propose to recursively flatten eveything to be passed to the backward step. We also add a test demonstrating that it works.

Speierers commented 2 years ago

Great! Please squash those commits into a single one and then we can merge this PR.

thomasw21 commented 2 years ago

I can do this. Though GH usually should have an option to prevent merge commits in settings. I usually have the following deactivated.

image
Speierers commented 2 years ago

Thanks for your contribution! 🚀