@@ -161,12 +161,18 @@ end
161
161
162
162
# plans
163
163
function 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
165
168
Δy = P * Δx
166
169
return y, Δy
167
170
end
168
171
function ChainRulesCore. rrule (:: typeof (* ), P:: AbstractFFTs.Plan , x:: AbstractArray )
169
172
y = P * x
173
+ if Base. mightalias (y, x)
174
+ throw (ArgumentError (" differentiation rules are not supported for in-place plans" ))
175
+ end
170
176
project_x = ChainRulesCore. ProjectTo (x)
171
177
Pt = P'
172
178
function mul_plan_pullback (ȳ)
@@ -177,12 +183,18 @@ function ChainRulesCore.rrule(::typeof(*), P::AbstractFFTs.Plan, x::AbstractArra
177
183
end
178
184
179
185
function 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
181
190
Δy = P * Δx .+ (ΔP. scale / P. scale) .* y
182
191
return y, Δy
183
192
end
184
193
function ChainRulesCore. rrule (:: typeof (* ), P:: AbstractFFTs.ScaledPlan , x:: AbstractArray )
185
194
y = P * x
195
+ if Base. mightalias (y, x)
196
+ throw (ArgumentError (" differentiation rules are not supported for in-place plans" ))
197
+ end
186
198
Pt = P'
187
199
scale = P. scale
188
200
project_x = ChainRulesCore. ProjectTo (x)
0 commit comments