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

Commit 7aa00f8

Browse files
authored
Merge pull request #22 from foldfelis/w
permute weight dim to improve performance
2 parents e9d23d5 + 8ea158d commit 7aa00f8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/fourier.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ function SpectralConv(
5959
) where {S<:Integer, N}
6060
in_chs, out_chs = ch
6161
scale = one(T) / (in_chs * out_chs)
62-
weights = scale * init(out_chs, in_chs, prod(modes))
62+
weights = scale * init(prod(modes), in_chs, out_chs)
6363

6464
return SpectralConv{permuted}(weights, in_chs, out_chs, modes, σ)
6565
end
@@ -174,7 +174,7 @@ end
174174
c_glorot_uniform(dims...) = Flux.glorot_uniform(dims...) + Flux.glorot_uniform(dims...)*im
175175

176176
# [prod(modes), out_chs, batch] <- [prod(modes), in_chs, batch] * [out_chs, in_chs, prod(modes)]
177-
apply_spectral_pattern(𝐱₁, 𝐱₂) = @tullio 𝐲[m, o, b] := 𝐱₁[m, i, b] * 𝐱₂[o, i, m]
177+
apply_spectral_pattern(𝐱₁, 𝐱₂) = @tullio 𝐲[m, o, b] := 𝐱₁[m, i, b] * 𝐱₂[m, i, o]
178178

179179
spectral_pad(𝐱::AbstractArray, dims::NTuple) = spectral_pad!(similar(𝐱, dims), 𝐱)
180180

0 commit comments

Comments
 (0)