@@ -161,12 +161,18 @@ end
161161
162162# plans
163163function ChainRulesCore. frule ((_, _, Δx), :: typeof (* ), P:: AbstractFFTs.Plan , x:: AbstractArray )
164- y = P * x
164+ y = P * x
165+ if Base. mightalias (y, x)
166+ throw (ArgumentError (" differentiation rules are not supported for in-place plans" ))
167+ end
165168 Δy = P * Δx
166169 return y, Δy
167170end
168171function ChainRulesCore. rrule (:: typeof (* ), P:: AbstractFFTs.Plan , x:: AbstractArray )
169172 y = P * x
173+ if Base. mightalias (y, x)
174+ throw (ArgumentError (" differentiation rules are not supported for in-place plans" ))
175+ end
170176 project_x = ChainRulesCore. ProjectTo (x)
171177 Pt = P'
172178 function mul_plan_pullback (ȳ)
@@ -177,12 +183,18 @@ function ChainRulesCore.rrule(::typeof(*), P::AbstractFFTs.Plan, x::AbstractArra
177183end
178184
179185function ChainRulesCore. frule ((_, ΔP, Δx), :: typeof (* ), P:: AbstractFFTs.ScaledPlan , x:: AbstractArray )
180- y = P * x
186+ y = P * x
187+ if Base. mightalias (y, x)
188+ throw (ArgumentError (" differentiation rules are not supported for in-place plans" ))
189+ end
181190 Δy = P * Δx .+ (ΔP. scale / P. scale) .* y
182191 return y, Δy
183192end
184193function ChainRulesCore. rrule (:: typeof (* ), P:: AbstractFFTs.ScaledPlan , x:: AbstractArray )
185194 y = P * x
195+ if Base. mightalias (y, x)
196+ throw (ArgumentError (" differentiation rules are not supported for in-place plans" ))
197+ end
186198 Pt = P'
187199 scale = P. scale
188200 project_x = ChainRulesCore. ProjectTo (x)
0 commit comments