Skip to content

Commit

Permalink
Ensure pullback of exp works for immutable arrays (#381)
Browse files Browse the repository at this point in the history
* Ensure exp cotangent is mutable

* Increment version number

* Use convert and inplaceable trait
  • Loading branch information
sethaxen authored Mar 1, 2021
1 parent 439f482 commit 99c58a9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "ChainRules"
uuid = "082447d4-558c-5d27-93f4-14fc19e9eca2"
version = "0.7.52"
version = "0.7.53"

[deps]
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
Expand Down
5 changes: 4 additions & 1 deletion src/rulesets/LinearAlgebra/matfun.jl
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,10 @@ function rrule(::typeof(exp), A0::StridedMatrix{<:BlasFloat})
A = copy(A0)
X, intermediates = _matfun!(exp, A)
function exp_pullback(ΔX)
∂A = _matfun_frechet_adjoint!(exp, ΔX, A, X, intermediates)
# Ensures ∂X is mutable. The outer `adjoint` is unwrapped without copy by
# the default _matfun_frechet_adjoint!
∂X = ChainRulesCore.is_inplaceable_destination(ΔX) ? ΔX : convert(Matrix, ΔX')'
∂A = _matfun_frechet_adjoint!(exp, ∂X, A, X, intermediates)
return NO_FIELDS, ∂A
end
return X, exp_pullback
Expand Down

2 comments on commit 99c58a9

@sethaxen
Copy link
Member Author

Choose a reason for hiding this comment

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

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request created: JuliaRegistries/General/30994

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.7.53 -m "<description of version>" 99c58a9139939eb04d17dd88926d5c0c84570d9a
git push origin v0.7.53

Please sign in to comment.