Skip to content

Commit b883867

Browse files
committed
stage1: Mark partial and primal helpers as @inline
It's unclear whether this is a compiler bug upstream, but I've observed invokes like this in the wild: ``` %xxx = invoke DAECompiler.partial(%135::Diffractor.TangentBundle{1}, 1::Int64)::Any ``` which are (clearly) very poorly typed. `%135` was a fully concrete type, so I'm not sure why the tangent type parameters ended up getting stripped off. In any case, the implementations here are so small that they are probably best just inlined anyway.
1 parent d0b3e3e commit b883867

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/stage1/forward.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
partial(x::TangentBundle, i) = partial(getfield(x, :tangent), i)
2-
partial(x::ExplicitTangent, i) = getfield(getfield(x, :partials), i)
3-
partial(x::TaylorTangent, i) = getfield(getfield(x, :coeffs), i)
4-
partial(x::UniformTangent, i) = getfield(x, :val)
5-
partial(x::AbstractZero, i) = x
1+
@inline partial(x::TangentBundle, i) = partial(getfield(x, :tangent), i)
2+
@inline partial(x::ExplicitTangent, i) = getfield(getfield(x, :partials), i)
3+
@inline partial(x::TaylorTangent, i) = getfield(getfield(x, :coeffs), i)
4+
@inline partial(x::UniformTangent, i) = getfield(x, :val)
5+
@inline partial(x::AbstractZero, i) = x
66

77

8-
primal(x::AbstractTangentBundle) = x.primal
9-
primal(z::ZeroTangent) = ZeroTangent()
8+
@inline primal(x::AbstractTangentBundle) = x.primal
9+
@inline primal(z::ZeroTangent) = ZeroTangent()
1010

11-
first_partial(x) = partial(x, 1)
11+
@inline first_partial(x) = partial(x, 1)
1212

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

0 commit comments

Comments
 (0)