@@ -24,7 +24,7 @@ padtuple(x::Tuple,p::Integer) = map(_->p, head(head(x)))
24
24
padtuple (x:: Tuple ,p:: Tuple ) = p
25
25
padtuple (x:: AbstractArray ,p) = padtuple (size (x),p)
26
26
27
- function conv (x:: A , w:: B ; pad = 0 , stride = 1 , dilation = 1 ) where {A <: AbstractArray , B <: AbstractArray }
27
+ function conv (x:: AbstractArray , w:: AbstractArray ; pad = 0 , stride = 1 , dilation = 1 )
28
28
pad_, stride_ = padtuple (x, pad), padtuple (x, stride)
29
29
conv! (similar (x, cdims (size (x), dilation_dims (w, dilation), pad_, stride_)),
30
30
x, w, pad = pad_, stride = stride_, dilation = dilation)
@@ -36,10 +36,10 @@ function crosscor(x::A, w::A; pad = 0, stride = 1, dilation = 1) where A<:Abstra
36
36
x, w, pad = pad_, stride = stride_, dilation = dilation)
37
37
end
38
38
39
- ∇conv_data (dy:: A , x:: B , w:: C ; pad = 0 , stride = 1 , dilation = 1 , flipkernel = 0 ) where {A <: AbstractArray , B <: AbstractArray , C <: AbstractArray } =
39
+ ∇conv_data (dy:: AbstractArray , x:: AbstractArray , w:: AbstractArray ; pad = 0 , stride = 1 , dilation = 1 , flipkernel = 0 ) =
40
40
∇conv_data! (zero (x), dy, x, w; pad = pad, stride = stride, dilation = dilation, flipkernel= flipkernel)
41
41
42
- ∇conv_filter (dy:: A , x:: B , w:: C ; pad = 0 , stride = 1 , dilation = 1 , flipkernel= 0 ) where {A <: AbstractArray , B <: AbstractArray , C <: AbstractArray } =
42
+ ∇conv_filter (dy:: AbstractArray , x:: AbstractArray , w:: AbstractArray ; pad = 0 , stride = 1 , dilation = 1 , flipkernel= 0 ) =
43
43
∇conv_filter! (zero (w), dy, x, w; pad = pad, stride = stride, dilation = dilation, flipkernel= flipkernel)
44
44
45
45
# N-D dispatch
@@ -102,7 +102,7 @@ function dcdims(x::NTuple{4,Int}, w::NTuple{4,Int}, pad, stride)
102
102
((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 ])
103
103
end
104
104
105
- function depthwiseconv (x:: A , w:: B ; pad = 0 , stride = 1 ) where {A <: AbstractArray , B <: AbstractArray }
105
+ function depthwiseconv (x:: AbstractArray , w:: AbstractArray ; pad = 0 , stride = 1 )
106
106
pad_, stride_ = padtuple (x, pad), padtuple (x, stride)
107
107
depthwiseconv! (similar (x, dcdims (size (x), size (w), pad_, stride_)), x, w, pad = pad_, stride = stride_)
108
108
end
@@ -120,10 +120,10 @@ depthwisecrosscor!(y::AbstractArray{T,4}, x::AbstractArray{T,4}, w::AbstractArra
120
120
pad = 0 , stride = 1 ) where T =
121
121
depthwiseconv! (y, x, w, pad = pad, stride = stride, flipkernel= 1 )
122
122
123
- ∇depthwiseconv_data (dy:: A , x:: B , w:: C ; pad = 0 , stride = 1 , flipkernel= 0 ) where {A <: AbstractArray , B <: AbstractArray , C <: AbstractArray } =
123
+ ∇depthwiseconv_data (dy:: AbstractArray , x:: AbstractArray , w:: AbstractArray ; pad = 0 , stride = 1 , flipkernel= 0 ) =
124
124
∇depthwiseconv_data! (zero (x), dy, x, w; pad = pad, stride = stride, flipkernel= flipkernel)
125
125
126
- ∇depthwiseconv_filter (dy:: A , x:: B , w:: C ; pad = 0 , stride = 1 , flipkernel= 0 ) where {A <: AbstractArray , B <: AbstractArray , C <: AbstractArray } =
126
+ ∇depthwiseconv_filter (dy:: AbstractArray , x:: AbstractArray , w:: AbstractArray ; pad = 0 , stride = 1 , flipkernel= 0 ) =
127
127
∇depthwiseconv_filter! (zero (w), dy, x, w; pad = pad, stride = stride, flipkernel= flipkernel)
128
128
129
129
∇depthwiseconv_filter! (dw:: AbstractArray{T,4} , dy:: AbstractArray{T,4} , x:: AbstractArray{T,4} , w:: AbstractArray{T,4} ;
0 commit comments