add rule for copy
Fixes https://github.com/FluxML/Zygote.jl/issues/1037
no idea why Zygote is failing
Codecov Report
Merging #472 (b4663c7) into master (0d55c54) will increase coverage by
0.00%. The diff coverage is100.00%.
@@ Coverage Diff @@
## master #472 +/- ##
=======================================
Coverage 98.12% 98.13%
=======================================
Files 22 22
Lines 2350 2353 +3
=======================================
+ Hits 2306 2309 +3
Misses 44 44
| Impacted Files | Coverage Δ | |
|---|---|---|
| src/rulesets/Base/base.jl | 100.00% <100.00%> (ø) |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing dataPowered by Codecov. Last update 0d55c54...b4663c7. Read the comment docs.
Should this be here or in Zygote? i.e. is this a mathematical property of copy or something more specific?
Within Zygote, copy(::Array) could presumably be a no-op, since you can't mutate them. That's Zygote-specific. But copy(::Buffer) means something else...
Finally, testing this by finite-differences doesn't achieve much. But testing that it does what you want on a Dict would at least ensure that an over-zealous cleanup doesn't (say) restrict this to ::AbstractArray.
Not much of a review, but maybe things to think about.
Should this be here or in Zygote? i.e. is this a mathematical property of
copyor something more specific?
I would say it is a convention of the language, the Base's docstring reads
copy(x)
Create a shallow copy of x: the outer structure is copied, but not all
internal values. For example, copying an array produces a new array with
identically-same elements as the original.
Within Zygote,
copy(::Array)could presumably be a no-op, since you can't mutate them. That's Zygote-specific. Butcopy(::Buffer)means something else...
copy(::Buffer) kind of breaks the convention above since it returns the underlying array. But maybe the rrule defined here is still reasonable since Buffer itself is an AbstactArray therefore it is ok it gets an array-like sensitivity?
Finally, testing this by finite-differences doesn't achieve much. But testing that it does what you want on a
Dictwould at least ensure that an over-zealous cleanup doesn't (say) restrict this to::AbstractArray.
agree
Not much of a review, but maybe things to think about.
I think we should do this. But the Zygote error in "nested AD hitting identity(::Tuple) pullback " is weird.