From a22527547b5e03408d89dbc678414f799106595e Mon Sep 17 00:00:00 2001 From: roflmaostc Date: Tue, 21 Mar 2023 14:54:31 +0100 Subject: [PATCH 1/2] Remove wrong rule to fix issue #35 --- src/convolutions.jl | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/convolutions.jl b/src/convolutions.jl index 38585b6..75d2353 100644 --- a/src/convolutions.jl +++ b/src/convolutions.jl @@ -74,18 +74,6 @@ function conv_psf(u::AbstractArray{T, N}, psf::AbstractArray{D, M}, dims=ntuple( return conv(u, ifftshift(psf, dims), dims) end - # define custom adjoint for conv - # so far only defined for the derivative regarding the first component -function ChainRulesCore.rrule(::typeof(conv), u::AbstractArray{T, N}, v::AbstractArray{D, M}, - dims=ntuple(+, min(N, M))) where {T, D, N, M} - Y = conv(u, v, dims) - function conv_pullback(barx) - z = zero(eltype(u)) - return NoTangent(), conv(barx, conj(v), dims), z, z - end - return Y, conv_pullback -end - """ From 79cd82a79e680d843fad81ec15f126dd5830b6a2 Mon Sep 17 00:00:00 2001 From: roflmaostc Date: Tue, 21 Mar 2023 16:15:02 +0100 Subject: [PATCH 2/2] Remove another wrong rule --- src/convolutions.jl | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/convolutions.jl b/src/convolutions.jl index 75d2353..1081b34 100644 --- a/src/convolutions.jl +++ b/src/convolutions.jl @@ -207,15 +207,6 @@ function p_conv_aux(P, P_inv, u, v_ft) return (P_inv.p * ((P * u) .* v_ft .* P_inv.scale)) end -function ChainRulesCore.rrule(::typeof(p_conv_aux), P, P_inv, u, v) - Y = p_conv_aux(P, P_inv, u, v) - function conv_pullback(barx) - z = zero(eltype(u)) - ∇ = p_conv_aux(P, P_inv, barx, conj(v)) - return NoTangent(), z, z, ∇, z - end - return Y, conv_pullback -end """ fft_or_rfft(T)