@@ -54,7 +54,7 @@ padtuple(x::Tuple,p::Integer) = map(_->p, head(head(x)))
54
54
padtuple (x:: Tuple ,p:: Tuple ) = p
55
55
padtuple (x:: AbstractArray ,p) = padtuple (size (x),p)
56
56
57
- function conv (x:: A , w:: A ; size= nothing , pad = 0 , stride = 1 , dilation = 1 ) where A <: AbstractArray
57
+ function conv (x:: AbstractArray , w:: AbstractArray ; size= nothing , pad = 0 , stride = 1 , dilation = 1 )
58
58
pad_, stride_ = padtuple (x, pad), padtuple (x, stride)
59
59
if size === nothing
60
60
size = cdims (Base. size (x), dilation_dims (w, dilation), pad_, stride_)
@@ -70,15 +70,15 @@ function crosscor(x::A, w::A; size=nothing, pad = 0, stride = 1, dilation = 1) w
70
70
crosscor! (similar (x, size), x, w, pad = pad_, stride = stride_, dilation = dilation)
71
71
end
72
72
73
- function ∇conv_data (dy:: A , w:: A ; size= nothing , pad = 0 , stride = 1 , dilation = 1 , flipkernel = 0 ) where A <: AbstractArray
73
+ function ∇conv_data (dy:: AbstractArray , w:: AbstractArray ; size= nothing , pad = 0 , stride = 1 , dilation = 1 , flipkernel = 0 )
74
74
pad_, stride_, dilation_ = padtuple (dy, pad), padtuple (dy, stride), padtuple (dy, dilation)
75
75
if size === nothing
76
76
size = ctdims (Base. size (dy), Base. size (w), pad_, stride_, dilation_)
77
77
end
78
78
∇conv_data! (similar (dy, size), dy, w, pad = pad_, stride = stride_, dilation = dilation_, flipkernel= flipkernel)
79
79
end
80
80
81
- function ∇conv_filter (dy:: A , x:: A ; size = nothing , pad = 0 , stride = 1 , dilation = 1 , flipkernel= 0 ) where A <: AbstractArray
81
+ function ∇conv_filter (dy:: AbstractArray , x:: AbstractArray ; size = nothing , pad = 0 , stride = 1 , dilation = 1 , flipkernel= 0 )
82
82
pad_, stride_, dilation_ = padtuple (dy, pad), padtuple (dy, stride), padtuple (dy, dilation)
83
83
if size === nothing
84
84
size = wdims (Base. size (x), Base. size (dy), pad_, stride_, dilation_)
@@ -144,7 +144,7 @@ function dcdims(x::NTuple{4,Int}, w::NTuple{4,Int}, pad, stride)
144
144
((x[1 ] + 2 * pad[1 ] - w[1 ])÷ stride[1 ] + 1 ,(x[2 ] + 2 * pad[2 ] - w[2 ])÷ stride[2 ] + 1 ,w[3 ]* w[4 ],x[4 ])
145
145
end
146
146
147
- function depthwiseconv (x:: A , w:: A ; pad = 0 , stride = 1 ) where A <: AbstractArray
147
+ function depthwiseconv (x:: AbstractArray , w:: AbstractArray ; pad = 0 , stride = 1 )
148
148
pad_, stride_ = padtuple (x, pad), padtuple (x, stride)
149
149
depthwiseconv! (similar (x, dcdims (size (x), size (w), pad_, stride_)), x, w, pad = pad_, stride = stride_)
150
150
end
@@ -162,10 +162,10 @@ depthwisecrosscor!(y::AbstractArray{T,4}, x::AbstractArray{T,4}, w::AbstractArra
162
162
pad = 0 , stride = 1 ) where T =
163
163
depthwiseconv! (y, x, w, pad = pad, stride = stride, flipkernel= 1 )
164
164
165
- ∇depthwiseconv_data (dy:: A , x:: A , w:: A ; pad = 0 , stride = 1 , flipkernel= 0 ) where A <: AbstractArray =
165
+ ∇depthwiseconv_data (dy:: AbstractArray , x:: AbstractArray , w:: AbstractArray ; pad = 0 , stride = 1 , flipkernel= 0 ) =
166
166
∇depthwiseconv_data! (zero (x), dy, x, w; pad = pad, stride = stride, flipkernel= flipkernel)
167
167
168
- ∇depthwiseconv_filter (dy:: A , x:: A , w:: A ; pad = 0 , stride = 1 , flipkernel= 0 ) where A <: AbstractArray =
168
+ ∇depthwiseconv_filter (dy:: AbstractArray , x:: AbstractArray , w:: AbstractArray ; pad = 0 , stride = 1 , flipkernel= 0 ) =
169
169
∇depthwiseconv_filter! (zero (w), dy, x, w; pad = pad, stride = stride, flipkernel= flipkernel)
170
170
171
171
∇depthwiseconv_filter! (dw:: AbstractArray{T,4} , dy:: AbstractArray{T,4} , x:: AbstractArray{T,4} , w:: AbstractArray{T,4} ;
0 commit comments