Skip to content
This repository was archived by the owner on Sep 28, 2024. It is now read-only.

Commit 0c8adfa

Browse files
committed
Refactor test
1 parent 7c3ea39 commit 0c8adfa

File tree

7 files changed

+34
-39
lines changed

7 files changed

+34
-39
lines changed

test/deeponet.jl renamed to test/DeepONet/DeepONet.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,9 @@
3333
@test_throws AssertionError DeepONet((32, 64, 70), (24, 48, 72), σ, tanh)
3434
@test_throws DimensionMismatch m(a, sensors)
3535
end
36+
37+
if CUDA.functional()
38+
include("cuda.jl")
39+
else
40+
@warn "CUDA unavailable, not testing GPU support"
41+
end

test/cuda.jl renamed to test/DeepONet/cuda.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@testset "CUDA" begin @testset "DeepONet" begin
1+
@testset "DeepONet CUDA" begin
22
batch_size = 2
33
a = [0.83541104, 0.83479851, 0.83404712, 0.83315711, 0.83212979, 0.83096755,
44
0.82967374, 0.82825263, 0.82670928, 0.82504949, 0.82327962, 0.82140651,
@@ -13,4 +13,4 @@
1313

1414
mgrad = Flux.Zygote.gradient(() -> sum(model(a, sensors)), Flux.params(model))
1515
@test length(mgrad.grads) == 9
16-
end end
16+
end
File renamed without changes.
File renamed without changes.

test/graph_kernel.jl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
@testset "GraphKernel" begin
2+
batch_size = 5
3+
channel = 32
4+
N = 10 * 10
5+
6+
κ = Dense(2 * channel, channel, relu)
7+
8+
graph = grid([10, 10])
9+
𝐱 = rand(Float32, channel, N, batch_size)
10+
l = WithGraph(FeaturedGraph(graph), GraphKernel(κ, channel))
11+
@test repr(l.layer) == "GraphKernel(Dense(64 => 32, relu), channel=32)"
12+
@test size(l(𝐱)) == (channel, N, batch_size)
13+
14+
g = Zygote.gradient(() -> sum(l(𝐱)), Flux.params(l))
15+
@test length(g.grads) == 3
16+
end

test/operator_kernel.jl

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -142,20 +142,3 @@ end
142142
@test SpectralConv(ch, modes) isa OperatorConv
143143
@test SpectralConv(ch, modes).transform isa FourierTransform
144144
end
145-
146-
@testset "GraphKernel" begin
147-
batch_size = 5
148-
channel = 32
149-
N = 10 * 10
150-
151-
κ = Dense(2 * channel, channel, relu)
152-
153-
graph = grid([10, 10])
154-
𝐱 = rand(Float32, channel, N, batch_size)
155-
l = WithGraph(FeaturedGraph(graph), GraphKernel(κ, channel))
156-
@test repr(l.layer) == "GraphKernel(Dense(64 => 32, relu), channel=32)"
157-
@test size(l(𝐱)) == (channel, N, batch_size)
158-
159-
g = Zygote.gradient(() -> sum(l(𝐱)), Flux.params(l))
160-
@test length(g.grads) == 3
161-
end

test/runtests.jl

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,19 @@ using Test
88

99
CUDA.allowscalar(false)
1010

11-
cuda_tests = [
12-
"cuda.jl",
13-
]
11+
@testset "NeuralOperators.jl" begin
12+
# kernels
13+
include("Transform/Transform.jl")
14+
include("operator_kernel.jl")
15+
include("graph_kernel.jl")
16+
include("loss.jl")
1417

15-
tests = [
16-
"Transform/Transform.jl",
17-
"operator_kernel.jl",
18-
"loss.jl",
19-
"model.jl",
20-
"deeponet.jl",
21-
"nomad.jl",
22-
]
23-
24-
if CUDA.functional()
25-
append!(tests, cuda_tests)
26-
else
27-
@warn "CUDA unavailable, not testing GPU support"
18+
# models
19+
include("FNO/FNO.jl")
20+
include("DeepONet/DeepONet.jl")
21+
include("NOMAD/NOMAD.jl")
2822
end
2923

30-
@testset "NeuralOperators.jl" begin for t in tests
31-
include(t)
32-
end end
33-
3424
#=
3525
  /l、 meow?
3626
゙(゚、 。 7

0 commit comments

Comments
 (0)