Skip to content

Commit

Permalink
more overloads for StaticArrays
Browse files Browse the repository at this point in the history
  • Loading branch information
oxinabox committed Jan 19, 2024
1 parent b642a9f commit 7eb435b
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/extra_rules.jl
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ function ChainRules.frule((_, ∂x), ::Type{SArray{S, T, N, L}}, x::NTuple{L,T})
end

Base.view(t::Tangent{T}, inds) where T<:SVector = view(T(ChainRulesCore.backing(t.data)), inds)
Base.getindex(t::Tangent{<:SVector, <:NamedTuple}, ind::Int) = ChainRulesCore.backing(t.data)[ind]

function ChainRules.frule((_, ∂x), ::Type{SArray{S, T, N, L}}, x::NTuple{L,Any}) where {S, T, N, L}
SArray{S, T, N, L}(x), SArray{S}(∂x)
Expand Down

0 comments on commit 7eb435b

Please sign in to comment.