Skip to content

Commit d5a356f

Browse files
Make basic function wrapping dispatches without ForwardDiff
1 parent 432ace4 commit d5a356f

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

src/utils.jl

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,37 @@ macro tight_loop_macros(ex)
1515
:($(esc(ex)))
1616
end
1717

18+
const oop_arglists = (Tuple{Vector{Float64}, Vector{Float64}, Float64},
19+
Tuple{Vector{Float64}, SciMLBase.NullParameters, Float64})
20+
21+
const NORECOMPILE_OOP_SUPPORTED_ARGS = (Tuple{Vector{Float64},
22+
Vector{Float64}, Float64},
23+
Tuple{Vector{Float64},
24+
SciMLBase.NullParameters, Float64})
25+
const oop_returnlists = (Vector{Float64}, Vector{Float64})
26+
27+
function wrapfun_oop(ff, inputs = ())
28+
if !isempty(inputs)
29+
IT = Tuple{map(typeof, inputs)...}
30+
if IT NORECOMPILE_OOP_SUPPORTED_ARGS
31+
throw(NoRecompileArgumentError(IT))
32+
end
33+
end
34+
FunctionWrappersWrappers.FunctionWrappersWrapper(ff, oop_arglists,
35+
oop_returnlists)
36+
end
37+
38+
function wrapfun_iip(ff, inputs)
39+
T = eltype(inputs[2])
40+
iip_arglists = (Tuple{T1, T2, T3, T4},)
41+
iip_returnlists = ntuple(x -> Nothing, 1)
42+
43+
fwt = map(iip_arglists, iip_returnlists) do A, R
44+
FunctionWrappersWrappers.FunctionWrappers.FunctionWrapper{R, A}(Void(ff))
45+
end
46+
FunctionWrappersWrappers.FunctionWrappersWrapper{typeof(fwt), false}(fwt)
47+
end
48+
1849
# TODO: would be good to have dtmin a function of dt
1950
function prob2dtmin(prob; use_end_time = true)
2051
prob2dtmin(prob.tspan, oneunit(eltype(prob.tspan)), use_end_time)

0 commit comments

Comments
 (0)