From b78712ddba74b5126f4541b313a1bcabca271797 Mon Sep 17 00:00:00 2001 From: Hossein Pourbozorg Date: Fri, 9 Aug 2024 15:30:22 +0330 Subject: [PATCH] cleaning --- Project.toml | 6 ++---- benchmark/Project.toml | 4 ++-- src/ContinuousNormalizingFlows.jl | 4 +--- src/layers/mul_layer.jl | 35 ------------------------------- test/Project.toml | 10 +++------ test/call_tests.jl | 25 +++++----------------- test/fit_tests.jl | 6 +----- test/runtests.jl | 2 -- 8 files changed, 14 insertions(+), 78 deletions(-) delete mode 100644 src/layers/mul_layer.jl diff --git a/Project.toml b/Project.toml index cd91780b..23972024 100644 --- a/Project.toml +++ b/Project.toml @@ -22,7 +22,6 @@ MLJBase = "a7f614a8-145f-11e9-1d2a-a57a1082229d" MLJModelInterface = "e80e1ace-859a-464e-9ed9-23947d8ae3ea" MLUtils = "f1d291b0-491e-4a28-83b9-f70985020b54" NNlib = "872c559c-99b0-510c-b3b7-b6c96a88d5cd" -Octavian = "6fd5a793-0b7e-452c-907f-f8bfe9c57db4" Optimisers = "3bd65402-5787-11e9-1adc-39752487f4e2" Optimization = "7f7a1694-90dd-40f0-9382-eb1efda571ba" OptimizationOptimisers = "42dfb2eb-d2b4-4451-abcd-913932933ac1" @@ -41,7 +40,7 @@ CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" ContinuousNormalizingFlowsCUDAExt = "CUDA" [compat] -ADTypes = "0.2, 1" +ADTypes = "1" AbstractDifferentiation = "0.6" CUDA = "5" ChainRulesCore = "1" @@ -49,7 +48,7 @@ ComponentArrays = "0.15" ComputationalResources = "0.3" DataFrames = "1" Dates = "1" -DifferentiationInterface = "0.1, 0.2, 0.3, 0.4, 0.5" +DifferentiationInterface = "0.5" Distributions = "0.25" DistributionsAD = "0.6" FillArrays = "1" @@ -60,7 +59,6 @@ MLJBase = "1" MLJModelInterface = "1" MLUtils = "0.4" NNlib = "0.9" -Octavian = "0.3" Optimisers = "0.3" Optimization = "3" OptimizationOptimisers = "0.2" diff --git a/benchmark/Project.toml b/benchmark/Project.toml index 05622ac9..9464f2ee 100644 --- a/benchmark/Project.toml +++ b/benchmark/Project.toml @@ -9,10 +9,10 @@ StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3" Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f" [compat] -ADTypes = "0.2, 1" +ADTypes = "1" BenchmarkTools = "1" ComponentArrays = "0.15" -DifferentiationInterface = "0.1, 0.2, 0.3, 0.4, 0.5" +DifferentiationInterface = "0.5" Lux = "0.5" PkgBenchmark = "0.2" StableRNGs = "1" diff --git a/src/ContinuousNormalizingFlows.jl b/src/ContinuousNormalizingFlows.jl index dc597f11..84e81d24 100644 --- a/src/ContinuousNormalizingFlows.jl +++ b/src/ContinuousNormalizingFlows.jl @@ -19,7 +19,6 @@ import AbstractDifferentiation, MLJModelInterface, MLUtils, NNlib, - Octavian, Optimisers, Optimization, OptimizationOptimisers, @@ -53,8 +52,7 @@ export construct, ICNFModel, CondICNFModel, CondLayer, - PlanarLayer, - MulLayer + PlanarLayer include(joinpath("layers", "cond_layer.jl")) include(joinpath("layers", "planar_layer.jl")) diff --git a/src/layers/mul_layer.jl b/src/layers/mul_layer.jl deleted file mode 100644 index 616d9fc3..00000000 --- a/src/layers/mul_layer.jl +++ /dev/null @@ -1,35 +0,0 @@ -struct MulLayer{F1, F2, NVARS <: Int} <: LuxCore.AbstractExplicitLayer - activation::F1 - nvars::NVARS - init_weight::F2 -end - -function MulLayer( - nvars::Int, - activation::Any = identity; - init_weight::Any = Lux.glorot_uniform, - allow_fast_activation::Bool = true, -) - activation = ifelse(allow_fast_activation, NNlib.fast_act(activation), activation) - MulLayer{typeof(activation), typeof(init_weight), typeof(nvars)}( - activation, - nvars, - init_weight, - ) -end - -function LuxCore.initialparameters(rng::Random.AbstractRNG, m::MulLayer) - (weight = m.init_weight(rng, m.nvars, m.nvars),) -end - -function LuxCore.parameterlength(m::MulLayer) - m.nvars * m.nvars -end - -function LuxCore.outputsize(m::MulLayer) - (m.nvars,) -end - -@inline function (m::MulLayer)(x::AbstractVecOrMat, ps::Any, st::NamedTuple) - m.activation.(Octavian.matmul(ps.weight, x)), st -end diff --git a/test/Project.toml b/test/Project.toml index 0ea7888c..e9fd29cd 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -8,14 +8,12 @@ ComputationalResources = "ed09eef8-17a6-5b46-8889-db040fac31e3" DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" DifferentiationInterface = "a0c0ee7d-e4b9-4e03-894e-1c5f64a51d63" Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f" -ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" GPUArraysCore = "46192b85-c4d5-4398-a991-12ede77f4527" JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b" Logging = "56ddb016-857b-54e1-b83d-db4d58db5568" Lux = "b2108857-7c20-44ae-9111-449ecde12c47" LuxCUDA = "d0bbae9a-e099-4d5b-a835-1c6931763bda" MLJBase = "a7f614a8-145f-11e9-1d2a-a57a1082229d" -ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267" SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462" TerminalLoggers = "5d786b92-1e48-4d6f-9151-6b4477ca9bed" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" @@ -23,22 +21,20 @@ Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f" cuDNN = "02a925ec-e4fe-4b08-9a7e-0d78e3d38ccd" [compat] -ADTypes = "0.2, 1" +ADTypes = "1" AbstractDifferentiation = "0.6" Aqua = "0.8" CUDA = "5" ComponentArrays = "0.15" ComputationalResources = "0.3" DataFrames = "1" -DifferentiationInterface = "0.1, 0.2, 0.3, 0.4, 0.5" +DifferentiationInterface = "0.5" Distributions = "0.25" -ForwardDiff = "0.10" GPUArraysCore = "0.1" -JET = "0.8, 0.9" +JET = "0.9" Lux = "0.5" LuxCUDA = "0.3" MLJBase = "1" -ReverseDiff = "1" SciMLBase = "2" TerminalLoggers = "0.1" Zygote = "0.6" diff --git a/test/call_tests.jl b/test/call_tests.jl index 9d2f9419..0d8dfc03 100644 --- a/test/call_tests.jl +++ b/test/call_tests.jl @@ -29,16 +29,9 @@ Test.@testset "Call Tests" begin nvars_ = Int[2] aug_steers = Bool[false, true] inplaces = Bool[false, true] - adb_list = AbstractDifferentiation.AbstractBackend[ - AbstractDifferentiation.ZygoteBackend(), - AbstractDifferentiation.ReverseDiffBackend(), - AbstractDifferentiation.ForwardDiffBackend(), - ] - adtypes = ADTypes.AbstractADType[ - ADTypes.AutoZygote(), - ADTypes.AutoReverseDiff(), - ADTypes.AutoForwardDiff(), - ] + adb_list = + AbstractDifferentiation.AbstractBackend[AbstractDifferentiation.ZygoteBackend()] + adtypes = ADTypes.AbstractADType[ADTypes.AutoZygote()] compute_modes = ContinuousNormalizingFlows.ComputeMode[ ContinuousNormalizingFlows.ADVecJacVectorMode( AbstractDifferentiation.ZygoteBackend(), @@ -226,11 +219,7 @@ Test.@testset "Call Tests" begin Test.@testset "x" begin Test.@test !isnothing( AbstractDifferentiation.gradient(adb, diff2_loss, r), - ) broken = - (GROUP != "All") && - adb isa AbstractDifferentiation.ReverseDiffBackend && - compute_mode isa ContinuousNormalizingFlows.MatrixMode && - VERSION >= v"1.10" + ) end end end @@ -244,11 +233,7 @@ Test.@testset "Call Tests" begin Test.@testset "x" begin Test.@test !isnothing( DifferentiationInterface.gradient(diff2_loss, adtype, r), - ) broken = - (GROUP != "All") && - adtype isa ADTypes.AutoReverseDiff && - compute_mode isa ContinuousNormalizingFlows.MatrixMode && - VERSION >= v"1.10" + ) end end end diff --git a/test/fit_tests.jl b/test/fit_tests.jl index a59b1b50..f367d391 100644 --- a/test/fit_tests.jl +++ b/test/fit_tests.jl @@ -26,11 +26,7 @@ Test.@testset "Fit Tests" begin nvars_ = Int[2] aug_steers = Bool[false, true] inplaces = Bool[false, true] - adtypes = ADTypes.AbstractADType[ - ADTypes.AutoZygote(), - ADTypes.AutoReverseDiff(), - ADTypes.AutoForwardDiff(), - ] + adtypes = ADTypes.AbstractADType[ADTypes.AutoZygote()] compute_modes = ContinuousNormalizingFlows.ComputeMode[ ContinuousNormalizingFlows.ADVecJacVectorMode( AbstractDifferentiation.ZygoteBackend(), diff --git a/test/runtests.jl b/test/runtests.jl index 29c646e4..27aacda9 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -8,14 +8,12 @@ import AbstractDifferentiation, DataFrames, DifferentiationInterface, Distributions, - ForwardDiff, GPUArraysCore, JET, Logging, Lux, LuxCUDA, MLJBase, - ReverseDiff, SciMLBase, TerminalLoggers, Test,