Skip to content

Adjoint of AbstractFFTs.Plan is too general #899

@MikaelSlevinsky

Description

@MikaelSlevinsky

These two invocations of the adjoint macro seem a little too general given it's not true for the (unitary) DCT plan FFTW.DCTPlan{Float64,5,false} <: AbstractFFTs.Plan{Float64}

Zygote.jl/src/lib/array.jl

Lines 729 to 741 in 956cbcf

@adjoint function *(P::AbstractFFTs.Plan, xs)
return P * xs, function(Δ)
N = prod(size(xs)[[P.region...]])
return (nothing, N * (P \ Δ))
end
end
@adjoint function \(P::AbstractFFTs.Plan, xs)
return P \ xs, function(Δ)
N = prod(size(Δ)[[P.region...]])
return (nothing, (P * Δ)/N)
end
end

julia> using FFTW, LinearAlgebra

julia> Id = Matrix{Float64}(I, 10, 10);

julia> p = plan_dct(Id, 1)
FFTW DCT (DCT-II) plan for 10×10 array of Float64

julia> P = p*Id;

julia> N = prod(size(Id)[[p.region...]])
10

julia> P'  N*inv(P)
false

It's probably false for some of the real-to-real plans as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions