From 0c236811f97906279595121423b00b19f387e860 Mon Sep 17 00:00:00 2001 From: Avik Pal Date: Sat, 27 Jul 2024 10:10:52 -0700 Subject: [PATCH] chore: run formatter --- Project.toml | 17 ----------------- test/Project.toml | 15 +++++++++++++++ test/basic_tests.jl | 21 ++++++++++----------- test/lux_tests.jl | 4 ++-- test/runtests.jl | 2 +- test/struct_tests.jl | 5 +++-- 6 files changed, 31 insertions(+), 33 deletions(-) create mode 100644 test/Project.toml diff --git a/Project.toml b/Project.toml index c1e4791d5..2f285a009 100644 --- a/Project.toml +++ b/Project.toml @@ -29,20 +29,3 @@ NNlib = "0.9" Preferences = "1.4" Reactant_jll = "0.0.13" julia = "1.9" - -[extras] -BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf" -Flux = "587475ba-b771-5e3f-ad9e-33799f191a9c" -Hwloc = "0e44f5e4-bd66-52a0-8798-143a42290a1d" -InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240" -Lux = "b2108857-7c20-44ae-9111-449ecde12c47" -MLUtils = "f1d291b0-491e-4a28-83b9-f70985020b54" -OneHotArrays = "0b1bfda6-eb8a-41d2-88d8-f5af5cad476f" -Optimisers = "3bd65402-5787-11e9-1adc-39752487f4e2" -Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" -ReTestItems = "817f1d60-ba6b-4fd5-9520-3cf149f6a823" -Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" -Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" - -[targets] -test = ["BenchmarkTools", "Flux", "Hwloc", "InteractiveUtils", "Lux", "MLUtils", "OneHotArrays", "Optimisers", "Random", "ReTestItems", "Statistics", "Test"] diff --git a/test/Project.toml b/test/Project.toml new file mode 100644 index 000000000..57fb2968b --- /dev/null +++ b/test/Project.toml @@ -0,0 +1,15 @@ +[deps] +BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf" +Enzyme = "7da242da-08ed-463a-9acd-ee780be4f1d9" +Flux = "587475ba-b771-5e3f-ad9e-33799f191a9c" +Hwloc = "0e44f5e4-bd66-52a0-8798-143a42290a1d" +InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240" +Lux = "b2108857-7c20-44ae-9111-449ecde12c47" +MLUtils = "f1d291b0-491e-4a28-83b9-f70985020b54" +OneHotArrays = "0b1bfda6-eb8a-41d2-88d8-f5af5cad476f" +Optimisers = "3bd65402-5787-11e9-1adc-39752487f4e2" +Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" +ReTestItems = "817f1d60-ba6b-4fd5-9520-3cf149f6a823" +Reactant_jll = "0192cb87-2b54-54ad-80e0-3be72ad8a3c0" +Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" +Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" diff --git a/test/basic_tests.jl b/test/basic_tests.jl index 9df410027..2b764868b 100644 --- a/test/basic_tests.jl +++ b/test/basic_tests.jl @@ -30,7 +30,7 @@ export fastmax, sinexp, sinexpbc, sumexp, mysoftmax, sumcos, grad_ip, resgrad_ip end -@testitem "2D sum" setup=[BasicTestSetup] begin +@testitem "2D sum" setup = [BasicTestSetup] begin r_res = sum(ones(2, 10)) a = Reactant.ConcreteRArray(ones(2, 10)) @@ -45,7 +45,7 @@ end @test f_res ≈ r_res end -@testitem "Basic reduce max" setup=[BasicTestSetup] begin +@testitem "Basic reduce max" setup = [BasicTestSetup] begin r_res = fastmax(ones(2, 10)) a = Reactant.ConcreteRArray(ones(2, 10)) @@ -60,8 +60,7 @@ end @test f_res ≈ r_res end - -@testitem "Broadcast combined" setup=[BasicTestSetup] begin +@testitem "Broadcast combined" setup = [BasicTestSetup] begin r_res = sinexpbc(ones(2, 10)) a = Reactant.ConcreteRArray(ones(2, 10)) @@ -76,7 +75,7 @@ end @test f_res ≈ r_res end -@testitem "Basic mapreduce" setup=[BasicTestSetup] begin +@testitem "Basic mapreduce" setup = [BasicTestSetup] begin x = ones(Float32, 10) a = Reactant.ConcreteRArray(x) r_res = sumexp(x) @@ -87,7 +86,7 @@ end @test f_res ≈ r_res end -@testitem "Basic softmax" setup=[BasicTestSetup] begin +@testitem "Basic softmax" setup = [BasicTestSetup] begin in = ones(2, 10) r_res = mysoftmax(in) @@ -100,7 +99,7 @@ end @test f_res ≈ r_res end -@testitem "Basic cos" setup=[BasicTestSetup] begin +@testitem "Basic cos" setup = [BasicTestSetup] begin c = Reactant.ConcreteRArray(ones(3, 2)) f = Reactant.compile(cos, (c,)) @@ -108,7 +107,7 @@ end @test r ≈ cos.(ones(3, 2)) end -@testitem "Basic grad cos" setup=[BasicTestSetup] begin +@testitem "Basic grad cos" setup = [BasicTestSetup] begin c = Reactant.ConcreteRArray(ones(3, 2)) f = Reactant.compile(grad_ip, (c,)) @@ -123,7 +122,7 @@ end @test r ≈ -sin.(ones(3, 2)) end -@testitem "Basic grad cos mul" setup=[BasicTestSetup] begin +@testitem "Basic grad cos mul" setup = [BasicTestSetup] begin c = Reactant.ConcreteRArray(ones(50, 70)) d = Reactant.ConcreteRArray(ones(70, 30)) @@ -133,12 +132,12 @@ end @test r ≈ mul(ones(50, 70), ones(70, 30)) end -@testitem "ConcreteRArray" setup=[BasicTestSetup] begin +@testitem "ConcreteRArray" setup = [BasicTestSetup] begin c = Reactant.ConcreteRArray(ones(50, 70)) similar(c) end -@testitem "Reactant.@code_hlo" setup=[BasicTestSetup] begin +@testitem "Reactant.@code_hlo" setup = [BasicTestSetup] begin W = Reactant.ConcreteRArray(randn(Float32, 10, 20)) x = Reactant.ConcreteRArray(randn(Float32, 20, 5)) res = Reactant.@code_hlo W * x diff --git a/test/lux_tests.jl b/test/lux_tests.jl index 66286b2b0..8a2036dfa 100644 --- a/test/lux_tests.jl +++ b/test/lux_tests.jl @@ -1,4 +1,4 @@ -@testitem "Lux" skip=:(VERSION < v"1.10") begin +@testitem "Lux" skip = :(VERSION < v"1.10") begin using Lux, Random, Statistics, Enzyme, Test, BenchmarkTools using MLUtils, OneHotArrays, Optimisers @@ -36,7 +36,7 @@ target = onehotbatch(truth, [true, false]) # 2×1000 OneHotMatrix ctarget = Reactant.ConcreteRArray(Array{Float32}(target)) - loader = DataLoader((noisy, target); batchsize=64, shuffle=true); + loader = DataLoader((noisy, target); batchsize=64, shuffle=true) # # 16-element DataLoader with first element: (2×64 Matrix{Float32}, 2×64 OneHotMatrix) opt = Optimisers.Adam(0.01f0) diff --git a/test/runtests.jl b/test/runtests.jl index d758862c3..9efd79042 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -45,5 +45,5 @@ const RETESTITEMS_NWORKERS = parse( ) @testset "Reactant" begin - ReTestItems.runtests(@__DIR__; nworkers=RETESTITEMS_NWORKERS, testitem_timeout=3600) + ReTestItems.runtests(Reactant; nworkers=RETESTITEMS_NWORKERS) end diff --git a/test/struct_tests.jl b/test/struct_tests.jl index edcf57f8b..17af513bd 100644 --- a/test/struct_tests.jl +++ b/test/struct_tests.jl @@ -5,7 +5,8 @@ inds::Vector{Symbol} end - MockTensor(data::A, inds) where {T,N,A<:AbstractArray{T,N}} = MockTensor{T,N,A}(data, inds) + MockTensor(data::A, inds) where {T,N,A<:AbstractArray{T,N}} = + MockTensor{T,N,A}(data, inds) Base.parent(t::MockTensor) = t.data Base.cos(x::MockTensor) = MockTensor(cos(parent(x)), x.inds) @@ -92,4 +93,4 @@ @test isapprox(y, only(y3)) end end -end \ No newline at end of file +end