Skip to content

Commit 692e4f8

Browse files
committed
Merge commit '999c3353f9d90d08607fdfd86cd3428480bfe715'
2 parents 9754d0c + 999c335 commit 692e4f8

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ComponentArrays"
22
uuid = "b0b7db55-cfe3-40fc-9ded-d10e2dbeff66"
33
authors = ["Jonnie Diegelman <47193959+jonniedie@users.noreply.github.com>"]
4-
version = "0.12.2"
4+
version = "0.12.4"
55

66
[deps]
77
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"

src/compat/chainrulescore.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
function ChainRulesCore.rrule(::typeof(getproperty), x::ComponentArray, s::Union{Symbol, Val})
22
function getproperty_adjoint(Δ)
3-
zero_x = zero(x)
3+
zero_x = ComponentArray(zeros(eltype(Δ), size(x)), getaxes(x))
44
setproperty!(zero_x, s, Δ)
55
return (ChainRulesCore.NoTangent(), zero_x, ChainRulesCore.NoTangent())
66
end

test/autodiff_tests.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ truth = ComponentArray(a = [32, 48], x = 156)
4343
(;c...,).x^2
4444
end[1]
4545
end
46+
47+
# Issue #148
48+
ps = ComponentArray(;bias = rand(4))
49+
out = Zygote.gradient(x -> sum(x.^3 .+ ps.bias), Zygote.seed(rand(4),Val(12)))[1]
50+
@test out isa Vector{<:ForwardDiff.Dual}
4651
end
4752

4853

0 commit comments

Comments
 (0)