We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e1c7c7e commit 09589cdCopy full SHA for 09589cd
src/extra_rules.jl
@@ -172,9 +172,14 @@ function ChainRules.rrule(::DiffractorRuleConfig, ::Type{SArray{S, T, N, L}}, x:
172
end
173
174
function ChainRules.frule((_, ∂x), ::Type{SArray{S, T, N, L}}, x::NTuple{L,T}) where {S, T, N, L}
175
- SArray{S, T, N, L}(x), SArray{S, T, N, L}(∂x.backing)
+ #TODO: we really shouldn't actually see the isa(∂x, AbstractZero) case since the frule should be called then
176
+ Δx = isa(∂x, AbstractZero) ? ∂x : SArray{S, T, N, L}(ChainRulesCore.backing(∂x))
177
+ SArray{S, T, N, L}(x), Δx
178
179
180
+Base.view(t::Tangent{T}, inds) where T<:SVector = view(T(ChainRulesCore.backing(t.data)), inds)
181
+Base.getindex(t::Tangent{<:SVector, <:NamedTuple}, ind::Int) = ChainRulesCore.backing(t.data)[ind]
182
+
183
function ChainRules.frule((_, ∂x), ::Type{SArray{S, T, N, L}}, x::NTuple{L,Any}) where {S, T, N, L}
184
SArray{S, T, N, L}(x), SArray{S}(∂x)
185
0 commit comments