-
Notifications
You must be signed in to change notification settings - Fork 62
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
Bools have no tangent #667
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #667 +/- ##
==========================================
- Coverage 93.62% 93.54% -0.09%
==========================================
Files 15 15
Lines 989 991 +2
==========================================
+ Hits 926 927 +1
- Misses 63 64 +1 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I 100% agree that it should always hold that tangent_type(Bool) == NoTangent
.
@@ -178,6 +179,8 @@ end | |||
|
|||
# Sad heauristic methods we need because of unassigned values | |||
guess_zero_tangent_type(::Type{T}) where {T<:Number} = T | |||
guess_zero_tangent_type(::Type{Bool}) = NoTangent() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this not just be NoTangent
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are correct
Should I go wider and do all Integers |
I think that would be a good idea if you target the concrete subtypes, rather than the abstract type |
merging this now. |
Doing this improves type stability of Diffractor's forwards mode since if you have code that is like
then the first branch would get a tangent of
NoTangent()
due to the fact that we have@non_differentiable Base.:>(::Any, ::Any)
.But the second would (without this PR) get a tangent of
false
.I am tempted to make this Integers.
But seemed starting conservative with Bool might be better
@willtebbutt you have thought about this a lot, what do you think?