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

Allow using existing plans #4

Open
marius311 opened this issue Dec 19, 2022 · 2 comments
Open

Allow using existing plans #4

marius311 opened this issue Dec 19, 2022 · 2 comments

Comments

@marius311
Copy link

Great package, thanks, have been doing something similar recently. One thing which would be great to have here is to allow using existing non-Dual plans on Dual arrays. Sometimes you have a calculation with precomputed plans, then you later want to compute derivatives, e.g.

plan = plan_fft(Array{Float64}(undef, 10))
x = rand(10)
foo = A -> norm(plan * (A * x))
ForwardDiff.derivative(foo, 1) # ArgumentError: FFTW plan applied to wrong-size array

Should be possible to use the existing plan and manually loop over slices of the dual2array array (may need a copy, not sure if memory needs to be contiguous there, probably yes). This is probably less efficient than the single "batched" plan approach you have here when planning with Duals, but will allow this to work at least.

@dlfivefifty
Copy link
Member

A previous version of the code (JuliaDiff/ForwardDiff.jl#541) did something like this ... will accept a PR that brings it back

Note the code I wrote also does copies since FFTW doesn't recognise that a reshaped array is a strided

@srivatsabprasad
Copy link

Hi, could someone provide a working example of how to generate an FFTW plan with FastTransformsForwardDiff.jl that would allow me to do the example in the README or otherwise the problem in #4 (comment)? Without documentation for this package I am struggling to understand how to use it.

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