diff --git a/ext/PreallocationToolsForwardDiffExt.jl b/ext/PreallocationToolsForwardDiffExt.jl index 971fc67..39102a7 100644 --- a/ext/PreallocationToolsForwardDiffExt.jl +++ b/ext/PreallocationToolsForwardDiffExt.jl @@ -1,10 +1,9 @@ module PreallocationToolsForwardDiffExt using PreallocationTools -using ForwardDiff -using ArrayInterface -using Adapt -using PrecompileTools +using ForwardDiff: ForwardDiff +using ArrayInterface: ArrayInterface +using PrecompileTools: @setup_workload, @compile_workload function PreallocationTools.dualarraycreator( u::AbstractArray{T}, siz, @@ -72,7 +71,7 @@ function replace_type_parameter(::Type{T}, ::Type{From}, ::Type{To}) where {T, F parameter isa Type ? replace_type_parameter(parameter, From, To) : parameter end - return new_parameters == parameters ? T : Core.apply_type(wrapper, new_parameters...) + return new_parameters == parameters ? T : wrapper{new_parameters...} end function diffcache_dual_tmp(dc::PreallocationTools.DiffCache, ::Type{T}) where {T <: ForwardDiff.Dual} diff --git a/test/qa/Project.toml b/test/qa/Project.toml index c1e9b2d..6f2e1d2 100644 --- a/test/qa/Project.toml +++ b/test/qa/Project.toml @@ -1,15 +1,23 @@ [deps] AllocCheck = "9b6a8646-10ed-4001-bbdc-1d2f46dfbb1a" Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" +EnzymeCore = "f151be2c-9106-41f4-ab19-57ee4f262869" +ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" PreallocationTools = "d236fae5-4411-538c-8e31-a6e3d9e00b46" +ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267" SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f" SciMLTesting = "09d9d899-5365-40a9-917a-5f67fddea283" +SparseConnectivityTracer = "9f842d2f-2579-4b1d-911e-f412cf18a3f5" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [compat] AllocCheck = "0.2" Aqua = "0.8.11" +EnzymeCore = "0.8" +ForwardDiff = "0.10.38, 1.0.1" +ReverseDiff = "1.16" SafeTestsets = "0.1, 1" SciMLTesting = "2.4" +SparseConnectivityTracer = "1" Test = "1.10" julia = "1.10" diff --git a/test/qa/qa.jl b/test/qa/qa.jl index 862e382..6947d00 100644 --- a/test/qa/qa.jl +++ b/test/qa/qa.jl @@ -1,6 +1,48 @@ using SciMLTesting, PreallocationTools, Test -run_qa(PreallocationTools) +# ExplicitImports only checks an extension module once it has been loaded, which +# requires its trigger package to be present. Loading every weakdep here puts all +# four extensions under the QA checks. +using EnzymeCore, ForwardDiff, ReverseDiff, SparseConnectivityTracer + +run_qa( + PreallocationTools; + ei_kwargs = (; + all_explicit_imports_are_public = (; + ignore = ( + # EnzymeCore neither exports nor declares `EnzymeRules` public, + # yet the submodule is the only entry point for defining Enzyme + # custom rules. + :EnzymeRules, + # SparseConnectivityTracer exports only its detectors and + # sparsity entry points. `AbstractTracer` and `Dual` are the + # types a `get_tmp` method has to dispatch on for sparsity + # detection to reach the cache, and neither has a public name. + :AbstractTracer, :Dual, + ), + ), + all_qualified_accesses_are_public = (; + ignore = ( + # `EnzymeCore.EnzymeRules` declares `forward`, + # `augmented_primal` and `reverse` as bare `function ... end` + # stubs without exporting them. Adding methods to them is the + # documented way to write a custom rule. + :forward, :augmented_primal, :reverse, + # ForwardDiff exports only `DiffResults`. `Dual` is the type + # every dual-cache method dispatches on and `pickchunksize` is + # the chunk heuristic the cache sizing mirrors. + :Dual, :pickchunksize, + # ReverseDiff likewise exports only `DiffResults`; + # `TrackedArray` is the type the LazyBufferCache method keys on. + :TrackedArray, + # `Base.typename` is the only way to recover a DataType's + # UnionAll wrapper so its type parameters can be substituted; + # Base offers no public equivalent. + :typename, + ), + ), + ) +) @testset "AllocCheck" begin include("allocation_tests.jl")