From aaeb3779d6269143c6c4520cf8c645560ac4c1e1 Mon Sep 17 00:00:00 2001 From: karthik katipally Date: Sat, 30 Nov 2019 08:10:39 +0530 Subject: [PATCH 1/2] removing depthwise since conv can proxy --- src/lib/nnlib.jl | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/lib/nnlib.jl b/src/lib/nnlib.jl index 3513b54f7..9d8580130 100644 --- a/src/lib/nnlib.jl +++ b/src/lib/nnlib.jl @@ -1,5 +1,5 @@ using NNlib -import NNlib: softmax, ∇softmax, logsoftmax, ∇logsoftmax, conv, depthwiseconv, ∇conv_data, ∇depthwiseconv_data, maxpool, meanpool, σ, relu +import NNlib: softmax, ∇softmax, logsoftmax, ∇logsoftmax, conv, depthwiseconv, ∇conv_data, maxpool, meanpool, σ, relu @adjoint function Base.Broadcast.broadcasted(::typeof(relu), x::Numeric) relu.(x), Δ -> (nothing, ifelse.(x .> 0, Δ, zero.(x))) @@ -15,7 +15,7 @@ end @adjoint logsoftmax(xs) = logsoftmax(xs), Δ -> (∇logsoftmax(Δ, xs),) @adjoint NNlib.DenseConvDims(args...; kwargs...) = NNlib.DenseConvDims(args...; kwargs...), _ -> nothing -@adjoint NNlib.DepthwiseConvDims(args...; kwargs...) = NNlib.DepthwiseConvDims(args...; kwargs...), _ -> nothing +# @adjoint NNlib.DepthwiseConvDims(args...; kwargs...) = NNlib.DepthwiseConvDims(args...; kwargs...), _ -> nothing @adjoint NNlib.PoolDims(args...; kwargs...) = NNlib.PoolDims(args...; kwargs...), _ -> nothing @adjoint conv(x, w, cdims; kw...) = @@ -38,25 +38,25 @@ end ) end -@adjoint depthwiseconv(x, w, cdims; kw...) = - depthwiseconv(x, w, cdims; kw...), - Δ -> begin - return ( - NNlib.∇depthwiseconv_data(Δ, w, cdims; kw...), - NNlib.∇depthwiseconv_filter(x, Δ, cdims; kw...), - nothing, - ) - end - -@adjoint ∇depthwiseconv_data(x, w, cdims; kw...) = - ∇depthwiseconv_data(x, w, cdims; kw...), - Δ -> begin - return ( - NNlib.depthwiseconv(Δ, w, cdims; kw...), - NNlib.∇depthwiseconv_filter(Δ, x, cdims; kw...), - nothing, - ) - end +# @adjoint depthwiseconv(x, w, cdims; kw...) = +# depthwiseconv(x, w, cdims; kw...), +# Δ -> begin +# return ( +# NNlib.∇depthwiseconv_data(Δ, w, cdims; kw...), +# NNlib.∇depthwiseconv_filter(x, Δ, cdims; kw...), +# nothing, +# ) +# end +# +# @adjoint ∇depthwiseconv_data(x, w, cdims; kw...) = +# ∇depthwiseconv_data(x, w, cdims; kw...), +# Δ -> begin +# return ( +# NNlib.depthwiseconv(Δ, w, cdims; kw...), +# NNlib.∇depthwiseconv_filter(Δ, x, cdims; kw...), +# nothing, +# ) +# end @adjoint function maxpool(x, pdims; kw...) y = maxpool(x, pdims; kw...) From f861c25d9e0672fd30007a30c3becda671b21966 Mon Sep 17 00:00:00 2001 From: karthik katipally Date: Sun, 8 Dec 2019 12:35:28 +0530 Subject: [PATCH 2/2] Removing DenseConvDims and Adapting ConDims for all convolutions --- src/lib/nnlib.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/nnlib.jl b/src/lib/nnlib.jl index 9d8580130..8f71c67dd 100644 --- a/src/lib/nnlib.jl +++ b/src/lib/nnlib.jl @@ -14,7 +14,7 @@ end @adjoint logsoftmax(xs) = logsoftmax(xs), Δ -> (∇logsoftmax(Δ, xs),) -@adjoint NNlib.DenseConvDims(args...; kwargs...) = NNlib.DenseConvDims(args...; kwargs...), _ -> nothing +@adjoint NNlib.ConvDims(args...; kwargs...) = NNlib.ConvDims(args...; kwargs...), _ -> nothing # @adjoint NNlib.DepthwiseConvDims(args...; kwargs...) = NNlib.DepthwiseConvDims(args...; kwargs...), _ -> nothing @adjoint NNlib.PoolDims(args...; kwargs...) = NNlib.PoolDims(args...; kwargs...), _ -> nothing