Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ScaledPlan: region subfield missing (needed for AD) #182

Open
maximilian-gelbrecht opened this issue Feb 7, 2021 · 2 comments
Open

ScaledPlan: region subfield missing (needed for AD) #182

maximilian-gelbrecht opened this issue Feb 7, 2021 · 2 comments

Comments

@maximilian-gelbrecht
Copy link

The ScaledPlan like e.g. the result of plan_fft has no field region, leading to an error when attempting to AD it via Zygote. Zygote (which depends on AbstractFFT) is requiring a region subfield.

Example

begin
    using Flux
    using Zygote
    using LinearAlgebra
    using FFTW
end

N = 15
data = rand(Float64, N)

FT = plan_fft(data) # e.g. plan_dct / plan_idct would work 
iFT= plan_ifft(data)

m = Chain(x->FT*x, Dense(N,N), x->iFT*x)
loss(x,y) = sum(abs2,m(x) .- y)
loss(data,data) # precompile

grads = gradient(() -> loss(data, data), params(m))
@stevengj
Copy link
Member

stevengj commented Sep 7, 2021

Seems like this could be added (to AbstractFFTs.jl, not here).

@devmotion
Copy link
Member

This was fixed in JuliaMath/AbstractFFTs.jl#65 which is about to be released in AbstractFFTs 1.2.0 (JuliaRegistries/General#63431). There is a function fftdims now that can be used to access the transformed region. It defaults to plan.region for plans that are subtypes of Plan, and does the right thing for ScaledPlans.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants