JuliaGPU / Adapt.jl

Other
86 stars 24 forks source link

remove unused type parameters that cause inlining issues #26

Closed vchuravy closed 4 years ago

vchuravy commented 4 years ago

Before:

julia> f(a) = eltype(a)
f (generic function with 1 method)

julia> @code_typed f(B)
CodeInfo(
1 ─     return Float64
) => Type{Float64}

julia> using Adapt
[ Info: Precompiling Adapt [79e6a3ab-5dfb-504d-930d-738a2a938a0e]

julia> @code_typed f(B)
CodeInfo(
1 ─ %1 = invoke Main.eltype(_2::SubArray{Float64,1,Array{Float64,2},Tuple{Base.Slice{Base.OneTo{Int64}},Int64},true})::Core.Compiler.Const(Float64, false)
└──      return %1
) => Type{Float64}

After:

julia> using Adapt
[ Info: Precompiling Adapt [79e6a3ab-5dfb-504d-930d-738a2a938a0e]

julia> @code_typed f(B)
CodeInfo(
1 ─     return Float64
) => Type{Float64}

x-ref: https://github.com/JuliaGPU/Adapt.jl/pull/23/commits/2a8e74d640c846aacc762cf68227958d0520067b#r443848813