Skip to content

Commit

Permalink
Merge pull request #291 from topolarity/ct/inline-partial-primal
Browse files Browse the repository at this point in the history
stage1: Mark `partial` and `primal` helpers as `@inline`
  • Loading branch information
oxinabox authored May 3, 2024
2 parents d0b3e3e + b883867 commit 9fcbd0c
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/stage1/forward.jl
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
partial(x::TangentBundle, i) = partial(getfield(x, :tangent), i)
partial(x::ExplicitTangent, i) = getfield(getfield(x, :partials), i)
partial(x::TaylorTangent, i) = getfield(getfield(x, :coeffs), i)
partial(x::UniformTangent, i) = getfield(x, :val)
partial(x::AbstractZero, i) = x
@inline partial(x::TangentBundle, i) = partial(getfield(x, :tangent), i)
@inline partial(x::ExplicitTangent, i) = getfield(getfield(x, :partials), i)
@inline partial(x::TaylorTangent, i) = getfield(getfield(x, :coeffs), i)
@inline partial(x::UniformTangent, i) = getfield(x, :val)
@inline partial(x::AbstractZero, i) = x


primal(x::AbstractTangentBundle) = x.primal
primal(z::ZeroTangent) = ZeroTangent()
@inline primal(x::AbstractTangentBundle) = x.primal
@inline primal(z::ZeroTangent) = ZeroTangent()

first_partial(x) = partial(x, 1)
@inline first_partial(x) = partial(x, 1)

shuffle_down(b::UniformBundle{N, B, U}) where {N, B, U} =
UniformBundle{N-1}(UniformBundle{1, B}(b.primal, b.tangent.val),
Expand Down

0 comments on commit 9fcbd0c

Please sign in to comment.