Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions lib/cufft/fft.jl
Original file line number Diff line number Diff line change
Expand Up @@ -455,3 +455,12 @@ function Base.:(*)(p::cCuFFTPlan{T,K,false,N}, x::DenseCuArray{T,M}) where {T,K,
unsafe_execute_trailing!(p,x, y)
y
end

## support adjoints of FFT plans

AbstractFFTs.AdjointStyle(::cCuFFTPlan) = AbstractFFTs.FFTAdjointStyle()
AbstractFFTs.AdjointStyle(::rCuFFTPlan{T, CUFFT_FORWARD}) where {T} = AbstractFFTs.RFFTAdjointStyle()
AbstractFFTs.AdjointStyle(p::rCuFFTPlan{T, CUFFT_INVERSE}) where {T} = AbstractFFTs.IRFFTAdjointStyle(p.osz[first(p.region)])

# manually resolve ambiguity in adjoint plan application
Base.:(*)(p::AbstractFFTs.AdjointPlan{T}, x::CuArray) where T = Base.invoke(*, Tuple{AbstractFFTs.AdjointPlan, AbstractArray}, p, x)
7 changes: 7 additions & 0 deletions test/libraries/cufft.jl
Original file line number Diff line number Diff line change
Expand Up @@ -342,3 +342,10 @@ end

@test Array(dy) ≈ y
end

## AbstractFFTs tests, which also test adjoint functionality of CUFFT plans.

@testset "AbstractFFTs FFT backend tests" begin
AbstractFFTs.TestUtils.test_complex_ffts(CuArray; test_wrappers=false)
AbstractFFTs.TestUtils.test_real_ffts(CuArray; copy_input=true, test_wrappers=false)
end