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

Add shortcut to find out if an AbstractArray is differentiable #784

Merged
merged 4 commits into from
Dec 20, 2024

Conversation

HGSilveri
Copy link
Collaborator

  • Adds AbstractArray.is_differentiable, which checks if the stored array is a tensor with requires_grad=True

@HGSilveri HGSilveri added this to the v1.2 milestone Dec 16, 2024
@HGSilveri HGSilveri self-assigned this Dec 16, 2024
@HGSilveri HGSilveri requested a review from a-corni December 16, 2024 17:44
Copy link
Collaborator

@a-corni a-corni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It really looks good to me, but I would really much prefer having this property be named requires_grad, because that's how we use it in all our tests. However, if having is_differentiable is needed to improve the user experience, I suggest we have two properties requires_grad and is_differentiable, with is_differentiable simply returning requires_grad.

@HGSilveri
Copy link
Collaborator Author

It really looks good to me, but I would really much prefer having this property be named requires_grad, because that's how we use it in all our tests. However, if having is_differentiable is needed to improve the user experience, I suggest we have two properties requires_grad and is_differentiable, with is_differentiable simply returning requires_grad.

Our tests were written with requires_grad because we were accessing the torch tensor directly. I don't think they should have a big influence on this naming decision.
That being said, I'm not strongly opinionated on this and I'm willing to change the name. I'm just puzzled as to what cases you feel that requires_grad covers and is_differentiable doesn't.

@a-corni
Copy link
Collaborator

a-corni commented Dec 18, 2024

It really looks good to me, but I would really much prefer having this property be named requires_grad, because that's how we use it in all our tests. However, if having is_differentiable is needed to improve the user experience, I suggest we have two properties requires_grad and is_differentiable, with is_differentiable simply returning requires_grad.

Our tests were written with requires_grad because we were accessing the torch tensor directly. I don't think they should have a big influence on this naming decision. That being said, I'm not strongly opinionated on this and I'm willing to change the name. I'm just puzzled as to what cases you feel that requires_grad covers and is_differentiable doesn't.

As I said above, I think we can have two properties. I am just saying that having a property requires_grad could be useful, but since the issue is the user-friendliness, then adding is_differentiable as well would make sense

Copy link
Collaborator

@a-corni a-corni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM ! Thanks :)

@HGSilveri HGSilveri merged commit 8db708e into develop Dec 20, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants