Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API to query whether a field needs gradients #5274

Closed
ifsheldon opened this issue Jun 27, 2022 · 2 comments
Closed

API to query whether a field needs gradients #5274

ifsheldon opened this issue Jun 27, 2022 · 2 comments
Assignees
Labels
autodiff This issue is related to automatic differentiation system feature request Suggest an idea on this project

Comments

@ifsheldon
Copy link

Concisely describe the proposed feature
I would like to request an API to query whether a field needs gradients.

Describe the solution you'd like (if any)
An attribute or property attached to a field object, which states whether a field needs gradients in backward-mode differentiation.

Additional comments
This feature request dates back to #2498 whose conversation was in the old Slack community channel. In my use case, I need it to check whether a field passed by the user of my library stannum needs gradients or not, and based on that my library creates different tensors. Besides my use case, it is a common need to check if a field needs gradients or not.

@ifsheldon ifsheldon added the feature request Suggest an idea on this project label Jun 27, 2022
@taichi-ci-bot taichi-ci-bot moved this to Untriaged in Taichi Lang Jun 27, 2022
@erizmr erizmr added the autodiff This issue is related to automatic differentiation system label Jun 28, 2022
@erizmr erizmr self-assigned this Jun 28, 2022
@erizmr erizmr moved this from Untriaged to In Progress in Taichi Lang Jul 1, 2022
@erizmr
Copy link
Contributor

erizmr commented Jul 1, 2022

Hi @ifsheldon , we are implementing this feature and want to double check: if the API you request is to check whether a field is annotated with needs_grad (but may has been or has not been allocated with a grad field) or to check whether the field has been allocated a grad field?

@ifsheldon
Copy link
Author

Yeah, it's sufficient I think. As the name needs_grad suggests, a field needs gradients may not have been allocated with gradients, which is fine.

Repository owner moved this from In Progress to Done in Taichi Lang Jul 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autodiff This issue is related to automatic differentiation system feature request Suggest an idea on this project
Projects
Status: Done
Development

No branches or pull requests

2 participants