Collapse zeros for Tuple & Ref tangents#565
Conversation
Codecov Report
@@ Coverage Diff @@
## main #565 +/- ##
==========================================
- Coverage 93.14% 93.04% -0.10%
==========================================
Files 15 14 -1
Lines 875 877 +2
==========================================
+ Hits 815 816 +1
- Misses 60 61 +1
Continue to review full report at Codecov.
|
|
Xref discussion at #581, I guess that it would be slightly better for this to return a ZeroTangent than a NoTangent. |
mzgubic
left a comment
There was a problem hiding this comment.
lgtm, just needs a version bump. I wonder whether we can abstract away the collapsing of the tangent somehow. Something like collapse(dy, whatever_it_is_if_not_NoTangent) which would internally check if it is an AbstractZero or a collection of AbstractZeros. Might be an overkill
|
The stronger way to abstract this would just be to make the Tangent constructor return a Zero. I don't quite see why an all-Zero Tangent is ever better. |
This is one way not to make a Tangent with only zero types in it:
You could go further, and make
Tangent{Foo}()andTangent{Foo}(x = NoTangent())all returnNoTangent. But perhaps it's odd to make a a type constructor not return that type... this PR does not do that.