Skip to content

Commit

Permalink
refactor: only create SymbolCache in SciMLFunctions if symbols are given
Browse files Browse the repository at this point in the history
  • Loading branch information
AayushSabharwal committed Jan 29, 2024
1 parent 9783507 commit 102b905
Showing 1 changed file with 51 additions and 23 deletions.
74 changes: 51 additions & 23 deletions src/scimlfunctions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2477,8 +2477,9 @@ function ODEFunction{iip, specialize}(f;

_f = prepare_function(f)

sys = something(sys, SymbolCache(syms, paramsyms, indepsym))

if sys === nothing && (syms !== nothing || paramsyms !== nothing || indepsym !== nothing)
sys = SymbolCache(syms, paramsyms, indepsym)

Check warning on line 2481 in src/scimlfunctions.jl

View check run for this annotation

Codecov / codecov/patch

src/scimlfunctions.jl#L2481

Added line #L2481 was not covered by tests
end
if specialize === NoSpecialize
ODEFunction{iip, specialize,
Any, Any, Any, Any,
Expand Down Expand Up @@ -2695,7 +2696,9 @@ function SplitFunction{iip, specialize}(f1, f2;
sys = __has_sys(f1) ? f1.sys : nothing) where {iip,
specialize,
}
sys = something(sys, SymbolCache(syms, paramsyms, indepsym))
if sys === nothing && (syms !== nothing || paramsyms !== nothing || indepsym !== nothing)
sys = SymbolCache(syms, paramsyms, indepsym)

Check warning on line 2700 in src/scimlfunctions.jl

View check run for this annotation

Codecov / codecov/patch

src/scimlfunctions.jl#L2699-L2700

Added lines #L2699 - L2700 were not covered by tests
end
if specialize === NoSpecialize
SplitFunction{iip, specialize, Any, Any, Any, Any, Any, Any, Any, Any, Any,
Any, Any, Any, Any, Any,
Expand Down Expand Up @@ -2776,7 +2779,9 @@ function DynamicalODEFunction{iip, specialize}(f1, f2;
iip,
specialize,
}
sys = something(sys, SymbolCache(syms, paramsyms, indepsym))
if sys === nothing && (syms !== nothing || paramsyms !== nothing || indepsym !== nothing)
sys = SymbolCache(syms, paramsyms, indepsym)

Check warning on line 2783 in src/scimlfunctions.jl

View check run for this annotation

Codecov / codecov/patch

src/scimlfunctions.jl#L2782-L2783

Added lines #L2782 - L2783 were not covered by tests
end

if specialize === NoSpecialize
DynamicalODEFunction{iip, specialize, Any, Any, Any, Any, Any, Any, Any,
Expand Down Expand Up @@ -2824,7 +2829,9 @@ function DiscreteFunction{iip, specialize}(f;
specialize,
}
_f = prepare_function(f)
sys = something(sys, SymbolCache(syms, paramsyms, indepsym))
if sys === nothing && (syms !== nothing || paramsyms !== nothing || indepsym !== nothing)
sys = SymbolCache(syms, paramsyms, indepsym)

Check warning on line 2833 in src/scimlfunctions.jl

View check run for this annotation

Codecov / codecov/patch

src/scimlfunctions.jl#L2833

Added line #L2833 was not covered by tests
end

if specialize === NoSpecialize
DiscreteFunction{iip, specialize, Any, Any, Any, Any}(_f, analytic,
Expand Down Expand Up @@ -2872,7 +2879,9 @@ function ImplicitDiscreteFunction{iip, specialize}(f;
specialize,
}
_f = prepare_function(f)
sys = something(sys, SymbolCache(syms, paramsyms, indepsym))
if sys === nothing && (syms !== nothing || paramsyms !== nothing || indepsym !== nothing)
sys = SymbolCache(syms, paramsyms, indepsym)

Check warning on line 2883 in src/scimlfunctions.jl

View check run for this annotation

Codecov / codecov/patch

src/scimlfunctions.jl#L2882-L2883

Added lines #L2882 - L2883 were not covered by tests
end

if specialize === NoSpecialize
ImplicitDiscreteFunction{iip, specialize, Any, Any, Any, Any}(_f,
Expand Down Expand Up @@ -2968,7 +2977,9 @@ function SDEFunction{iip, specialize}(f, g;
_f = prepare_function(f)
_g = prepare_function(g)

sys = something(sys, SymbolCache(syms, paramsyms, indepsym))
if sys === nothing && (syms !== nothing || paramsyms !== nothing || indepsym !== nothing)
sys = SymbolCache(syms, paramsyms, indepsym)

Check warning on line 2981 in src/scimlfunctions.jl

View check run for this annotation

Codecov / codecov/patch

src/scimlfunctions.jl#L2980-L2981

Added lines #L2980 - L2981 were not covered by tests
end

if specialize === NoSpecialize
SDEFunction{iip, specialize, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any,
Expand Down Expand Up @@ -3098,7 +3109,9 @@ function SplitSDEFunction{iip, specialize}(f1, f2, g;
iip,
specialize,
}
sys = something(sys, SymbolCache(syms, paramsyms, indepsym))
if sys === nothing && (syms !== nothing || paramsyms !== nothing || indepsym !== nothing)
sys = SymbolCache(syms, paramsyms, indepsym)

Check warning on line 3113 in src/scimlfunctions.jl

View check run for this annotation

Codecov / codecov/patch

src/scimlfunctions.jl#L3112-L3113

Added lines #L3112 - L3113 were not covered by tests
end

if specialize === NoSpecialize
SplitSDEFunction{iip, specialize, Any, Any, Any, Any, Any, Any,
Expand Down Expand Up @@ -3181,7 +3194,9 @@ function DynamicalSDEFunction{iip, specialize}(f1, f2, g;
iip,
specialize,
}
sys = something(sys, SymbolCache(syms, paramsyms, indepsym))
if sys === nothing && (syms !== nothing || paramsyms !== nothing || indepsym !== nothing)
sys = SymbolCache(syms, paramsyms, indepsym)

Check warning on line 3198 in src/scimlfunctions.jl

View check run for this annotation

Codecov / codecov/patch

src/scimlfunctions.jl#L3197-L3198

Added lines #L3197 - L3198 were not covered by tests
end

if specialize === NoSpecialize
DynamicalSDEFunction{iip, specialize, Any, Any, Any, Any, Any, Any,
Expand Down Expand Up @@ -3277,8 +3292,9 @@ function RODEFunction{iip, specialize}(f;
=#

_f = prepare_function(f)
sys = something(sys, SymbolCache(syms, paramsyms, indepsym))

if sys === nothing && (syms !== nothing || paramsyms !== nothing || indepsym !== nothing)
sys = SymbolCache(syms, paramsyms, indepsym)

Check warning on line 3296 in src/scimlfunctions.jl

View check run for this annotation

Codecov / codecov/patch

src/scimlfunctions.jl#L3295-L3296

Added lines #L3295 - L3296 were not covered by tests
end

if specialize === NoSpecialize
RODEFunction{iip, specialize, Any, Any, Any, Any, Any,
Expand Down Expand Up @@ -3365,8 +3381,9 @@ function DAEFunction{iip, specialize}(f;
end

_f = prepare_function(f)
sys = something(sys, SymbolCache(syms, paramsyms, indepsym))

if sys === nothing && (syms !== nothing || paramsyms !== nothing || indepsym !== nothing)
sys = SymbolCache(syms, paramsyms, indepsym)

Check warning on line 3385 in src/scimlfunctions.jl

View check run for this annotation

Codecov / codecov/patch

src/scimlfunctions.jl#L3384-L3385

Added lines #L3384 - L3385 were not covered by tests
end

if specialize === NoSpecialize
DAEFunction{iip, specialize, Any, Any, Any,
Expand Down Expand Up @@ -3453,8 +3470,9 @@ function DDEFunction{iip, specialize}(f;
end

_f = prepare_function(f)
sys = something(sys, SymbolCache(syms, paramsyms, indepsym))

if sys === nothing && (syms !== nothing || paramsyms !== nothing || indepsym !== nothing)
sys = SymbolCache(syms, paramsyms, indepsym)

Check warning on line 3474 in src/scimlfunctions.jl

View check run for this annotation

Codecov / codecov/patch

src/scimlfunctions.jl#L3473-L3474

Added lines #L3473 - L3474 were not covered by tests
end

if specialize === NoSpecialize
DDEFunction{iip, specialize, Any, Any, Any, Any,
Expand Down Expand Up @@ -3543,7 +3561,9 @@ function DynamicalDDEFunction{iip, specialize}(f1, f2;
iip,
specialize,
}
sys = something(sys, SymbolCache(syms, paramsyms, indepsym))
if sys === nothing && (syms !== nothing || paramsyms !== nothing || indepsym !== nothing)
sys = SymbolCache(syms, paramsyms, indepsym)

Check warning on line 3565 in src/scimlfunctions.jl

View check run for this annotation

Codecov / codecov/patch

src/scimlfunctions.jl#L3564-L3565

Added lines #L3564 - L3565 were not covered by tests
end

if specialize === NoSpecialize
DynamicalDDEFunction{iip, specialize, Any, Any, Any, Any, Any, Any, Any, Any, Any,
Expand Down Expand Up @@ -3623,8 +3643,9 @@ function SDDEFunction{iip, specialize}(f, g;

_f = prepare_function(f)
_g = prepare_function(g)
sys = something(sys, SymbolCache(syms, paramsyms, indepsym))

if sys === nothing && (syms !== nothing || paramsyms !== nothing || indepsym !== nothing)
sys = SymbolCache(syms, paramsyms, indepsym)

Check warning on line 3647 in src/scimlfunctions.jl

View check run for this annotation

Codecov / codecov/patch

src/scimlfunctions.jl#L3646-L3647

Added lines #L3646 - L3647 were not covered by tests
end

if specialize === NoSpecialize
SDDEFunction{iip, specialize, Any, Any, Any, Any, Any,
Expand Down Expand Up @@ -3727,8 +3748,9 @@ function NonlinearFunction{iip, specialize}(f;
end

_f = prepare_function(f)
sys = something(sys, SymbolCache(syms, paramsyms))

if sys === nothing && (syms !== nothing || paramsyms !== nothing)
sys = SymbolCache(syms, paramsyms)

Check warning on line 3752 in src/scimlfunctions.jl

View check run for this annotation

Codecov / codecov/patch

src/scimlfunctions.jl#L3752

Added line #L3752 was not covered by tests
end

if specialize === NoSpecialize
NonlinearFunction{iip, specialize,
Expand Down Expand Up @@ -3782,7 +3804,9 @@ function IntervalNonlinearFunction{iip, specialize}(f;
specialize,
}
_f = prepare_function(f)
sys = something(sys, SymbolCache(syms, paramsyms))
if sys === nothing && (syms !== nothing || paramsyms !== nothing)
sys = SymbolCache(syms, paramsyms)

Check warning on line 3808 in src/scimlfunctions.jl

View check run for this annotation

Codecov / codecov/patch

src/scimlfunctions.jl#L3808

Added line #L3808 was not covered by tests
end


if specialize === NoSpecialize
Expand Down Expand Up @@ -3832,7 +3856,9 @@ function OptimizationFunction{iip}(f, adtype::AbstractADType = NoAD();
nothing,
lag_hess_colorvec = nothing) where {iip}
isinplace(f, 2; has_two_dispatches = false, isoptimization = true)
sys = something(sys, SymbolCache(syms, paramsyms))
if sys === nothing && (syms !== nothing || paramsyms !== nothing)
sys = SymbolCache(syms, paramsyms)

Check warning on line 3860 in src/scimlfunctions.jl

View check run for this annotation

Codecov / codecov/patch

src/scimlfunctions.jl#L3859-L3860

Added lines #L3859 - L3860 were not covered by tests
end
OptimizationFunction{iip, typeof(adtype), typeof(f), typeof(grad), typeof(hess),
typeof(hv),
typeof(cons), typeof(cons_j), typeof(cons_h),
Expand Down Expand Up @@ -3976,7 +4002,9 @@ function BVPFunction{iip, specialize, twopoint}(f, bc;

_f = prepare_function(f)

sys = something(sys, SymbolCache(syms, paramsyms, indepsym))
if sys === nothing && (syms !== nothing || paramsyms !== nothing || indepsym !== nothing)
sys = SymbolCache(syms, paramsyms, indepsym)

Check warning on line 4006 in src/scimlfunctions.jl

View check run for this annotation

Codecov / codecov/patch

src/scimlfunctions.jl#L4005-L4006

Added lines #L4005 - L4006 were not covered by tests
end


if specialize === NoSpecialize
Expand Down

0 comments on commit 102b905

Please sign in to comment.