-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
This has been touched on in #24 and JuliaLabs/Cassette.jl#157, but it should probably have its own dedicated issue for clarity.
julia> using ForwardDiff2: D
[ Info: Precompiling ForwardDiff2 [994df76e-a4c1-5e1f-bd5c-23b9b5303d4f]
julia> f(x::Float64) = x + 1
f (generic function with 1 method)
julia> D(f)(1)
ERROR: MethodError: no method matching f(::ForwardDiff2.Dual{ForwardDiff2.Tag{Nothing},Int64,Int64})
Closest candidates are:
f(::Float64) at REPL[2]:1
Last I heard the plan was to support this using the above referenced Cassette PR, but that seems to not be very well received by the repo maintainers.
An alternative way to support this would be to use this IRTools Dynamo example which works already:
using IRTools: @dynamo, argument!, IR
concrete(::Type{Type{T}}) where {T} = T
function _sneaky_transform(f::Type, Types::Type{<:Tuple})
ir = IR(f, Types.parameters...)
argument!(ir, at = 2)
return ir
end
@dynamo function sneakyinvoke(f, T, args...)
Types = concrete(T)
return _sneaky_transform(f, Types)
end
julia> sneakyinvoke(f, Tuple{Float64}, 1)
2
julia> D(x -> sneakyinvoke(f, Tuple{Float64}, x))(10.0)
1.0
oxinabox
Metadata
Metadata
Assignees
Labels
No labels