diff --git a/src/CoolPDLP.jl b/src/CoolPDLP.jl index c675f15..a99257e 100644 --- a/src/CoolPDLP.jl +++ b/src/CoolPDLP.jl @@ -20,7 +20,7 @@ using SparseArrays: SparseArrays, SparseMatrixCSC, AbstractSparseMatrix, findnz, include("public.jl") -@stable begin +@stable default_mode = "warn" begin include("utils/device.jl") include("utils/mat_coo.jl") include("utils/mat_csr.jl") diff --git a/src/utils/test.jl b/src/utils/test.jl index f5cdb8b..c0a014d 100644 --- a/src/utils/test.jl +++ b/src/utils/test.jl @@ -48,3 +48,12 @@ function random_milp_and_sol(m::Int, n::Int, p::Float64) y = proj_multiplier.(randn(m), lc, uc) return MILP(; c, lv, uv, A, lc, uc, int_var), PrimalDualSolution(x, y) end + +# to test DispatchDoctor preference activation +function _unstable_relu(x) + if x > 0 + return x + else + return 0.0 + end +end diff --git a/test/Project.toml b/test/Project.toml index 4083803..d794261 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -2,6 +2,7 @@ Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" CoolPDLP = "9e90bdc5-3073-4e0f-a275-e19f28ac1b53" +DispatchDoctor = "8d63f2c5-f18a-4cf2-ba9d-b3f60fc568c8" ExplicitImports = "7d51a73a-1435-4ff3-83d9-f097790105c7" GPUArraysCore = "46192b85-c4d5-4398-a991-12ede77f4527" HiGHS = "87dc4568-4c63-4d18-b0c0-bb2238e4078b" @@ -13,15 +14,18 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" MathOptBenchmarkInstances = "f7f8d0a1-fd34-491e-a7ac-a4cf52f91fe5" MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee" Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" -Preferences = "21216c6a-2e73-6563-6e65-726566657250" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" SCS = "c946c3f1-0d1f-5ce8-9dea-7daa1f7e2d13" SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [sources] -CoolPDLP = {path = ".."} +CoolPDLP = { path = ".." } [compat] Aqua = "0.8.14" Test = "1" + +[preferences.CoolPDLP] +dispatch_doctor_default_codegen_level = "min" +dispatch_doctor_mode = "error" diff --git a/test/runtests.jl b/test/runtests.jl index c95e6f3..e8a0fa1 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,8 +1,5 @@ using Pkg using Test -using Preferences: set_preferences! -# see https://github.com/MilesCranmer/DispatchDoctor.jl?tab=readme-ov-file#-usage-in-packages -set_preferences!("CoolPDLP", "default_codegen_level" => "min") GROUP = get(ENV, "COOLPDLP_TEST_GROUP", nothing) diff --git a/test/utils/test.jl b/test/utils/test.jl new file mode 100644 index 0000000..3c5f998 --- /dev/null +++ b/test/utils/test.jl @@ -0,0 +1,6 @@ +using CoolPDLP +using DispatchDoctor +using Test + +@test CoolPDLP._unstable_relu(1.0) == 1.0 +@test_throws DispatchDoctor.TypeInstabilityError CoolPDLP._unstable_relu(0)