Skip to content

Commit

Permalink
chore: run formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
avik-pal committed Aug 3, 2024
1 parent 4417756 commit 0c23681
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 33 deletions.
17 changes: 0 additions & 17 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
15 changes: 15 additions & 0 deletions test/Project.toml
Original file line number Diff line number Diff line change
@@ -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"
21 changes: 10 additions & 11 deletions test/basic_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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))
Expand All @@ -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))
Expand All @@ -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)
Expand All @@ -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)

Expand All @@ -100,15 +99,15 @@ 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,))
r = f(c)
@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,))
Expand All @@ -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))

Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions test/lux_tests.jl
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 3 additions & 2 deletions test/struct_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -92,4 +93,4 @@
@test isapprox(y, only(y3))
end
end
end
end

0 comments on commit 0c23681

Please sign in to comment.