Skip to content

Commit

Permalink
handle NoTangent in copyto!
Browse files Browse the repository at this point in the history
  • Loading branch information
oxinabox committed Feb 1, 2024
1 parent ee0dcb7 commit 96db615
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/rulesets/Base/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,14 @@ _instantiate_zeros(ẋs::AbstractArray{<:AbstractArray}, xs) = ẋs
#####

function frule((_, ẏ, ẋ), ::typeof(copyto!), y::AbstractArray, x)
return copyto!(y, x), copyto!(ẏ, ẋ)
ifisa AbstractZero
# it's allowed to have an imutable zero tangent for ẏ as long as ẋ is zero
# TODO should this be handled here or in the AD?
@assert iszero(ẋ)
else
copyto!(ẏ, ẋ)
end
return copyto!(y, x), ẏ
end

function frule((_, ẏ, _, ẋ), ::typeof(copyto!), y::AbstractArray, i::Integer, x, js::Integer...)
Expand Down

0 comments on commit 96db615

Please sign in to comment.