@@ -36,11 +36,11 @@ 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:: A , w:: A ; pad = 0 , stride = 1 , dilation = 1 ) where A<: AbstractArray =
40
- ∇conv_data! (zero (x), dy, x, w; pad = pad, stride = stride, dilation = dilation)
39
+ ∇conv_data (dy:: A , x:: A , w:: A ; pad = 0 , stride = 1 , dilation = 1 , flipkernel = 0 ) where A<: AbstractArray =
40
+ ∇conv_data! (zero (x), dy, x, w; pad = pad, stride = stride, dilation = dilation, flipkernel = flipkernel )
41
41
42
- ∇conv_filter (dy:: A , x:: A , w:: A ; pad = 0 , stride = 1 , dilation = 1 ) where A<: AbstractArray =
43
- ∇conv_filter! (zero (w), dy, x, w; pad = pad, stride = stride, dilation = dilation)
42
+ ∇conv_filter (dy:: A , x:: A , w:: A ; pad = 0 , stride = 1 , dilation = 1 , flipkernel = 0 ) where A<: AbstractArray =
43
+ ∇conv_filter! (zero (w), dy, x, w; pad = pad, stride = stride, dilation = dilation, flipkernel = flipkernel )
44
44
45
45
# N-D dispatch
46
46
58
58
59
59
function ∇conv_filter! (dw:: AbstractArray{T,3} , dy:: AbstractArray{T,3} ,
60
60
x:: AbstractArray{T,3} , w:: AbstractArray{T,3} ;
61
- pad = 0 , stride = 1 , dilation = 1 ) where T
61
+ pad = 0 , stride = 1 , dilation = 1 , flipkernel = 0 ) where T
62
62
args = map (x -> reshape (x, size (x,1 ),1 ,size (x,2 ),size (x,3 )), (dw, dy, x, w))
63
- ∇conv_filter! (args... , pad = (pad... ,0 ), stride = (stride... ,1 ), dilation = (dilation... ,1 ))
63
+ ∇conv_filter! (args... , pad = (pad... ,0 ), stride = (stride... ,1 ), dilation = (dilation... ,1 ), flipkernel = flipkernel )
64
64
return dw
65
65
end
66
66
67
67
function ∇conv_data! (dx:: AbstractArray{T,3} , dy:: AbstractArray{T,3} ,
68
68
x:: AbstractArray{T,3} , w:: AbstractArray{T,3} ;
69
- pad = 0 , stride = 1 , dilation = 1 ) where T
69
+ pad = 0 , stride = 1 , dilation = 1 , flipkernel = 0 ) where T
70
70
args = map (x -> reshape (x, size (x,1 ),1 ,size (x,2 ),size (x,3 )), (dx, dy, x, w))
71
- ∇conv_data! (args... , pad = (pad... ,0 ), stride = (stride... ,1 ), dilation = (dilation... , 1 ))
71
+ ∇conv_data! (args... , pad = (pad... ,0 ), stride = (stride... ,1 ), dilation = (dilation... , 1 ), flipkernel = flipkernel )
72
72
return dx
73
73
end
74
74
@@ -77,24 +77,24 @@ conv!(y::AbstractArray{T,4}, x::AbstractArray{T,4}, w::AbstractArray{T,4};
77
77
conv2d! (y, x, w, padding = pad, stride = stride, dilation = dilation, mode= flipkernel)
78
78
79
79
∇conv_filter! (dw:: AbstractArray{T,4} , dy:: AbstractArray{T,4} , x:: AbstractArray{T,4} , w:: AbstractArray{T,4} ;
80
- pad = 0 , stride = 1 , dilation = 1 ) where T =
81
- conv2d_grad_w! (dw, x, w, dy, padding = pad, stride = stride, dilation = dilation)
80
+ pad = 0 , stride = 1 , dilation = 1 , flipkernel = 0 ) where T =
81
+ conv2d_grad_w! (dw, x, w, dy, padding = pad, stride = stride, dilation = dilation, mode = flipkernel )
82
82
83
83
∇conv_data! (dx:: AbstractArray{T,4} , dy:: AbstractArray{T,4} , x:: AbstractArray{T,4} , w:: AbstractArray{T,4} ;
84
- pad = 0 , stride = 1 , dilation = 1 ) where T =
85
- conv2d_grad_x! (dx, x, w, dy, padding = pad, stride = stride, dilation = dilation)
84
+ pad = 0 , stride = 1 , dilation = 1 , flipkernel = 0 ) where T =
85
+ conv2d_grad_x! (dx, x, w, dy, padding = pad, stride = stride, dilation = dilation, mode = flipkernel )
86
86
87
87
conv! (y:: AbstractArray{T,5} , x:: AbstractArray{T,5} , w:: AbstractArray{T,5} ;
88
88
pad = 0 , stride = 1 , dilation = 1 , flipkernel= 0 ) where T =
89
89
conv3d! (y, x, w, padding = pad, stride = stride, dilation = dilation, mode= flipkernel)
90
90
91
91
∇conv_filter! (dw:: AbstractArray{T,5} , dy:: AbstractArray{T,5} , x:: AbstractArray{T,5} , w:: AbstractArray{T,5} ;
92
- pad = 0 , stride = 1 , dilation = 1 ) where T =
93
- conv3d_grad_w! (dw, x, w, dy, padding = pad, stride = stride, dilation = dilation)
92
+ pad = 0 , stride = 1 , dilation = 1 , flipkernel = 0 ) where T =
93
+ conv3d_grad_w! (dw, x, w, dy, padding = pad, stride = stride, dilation = dilation, mode = flipkernel )
94
94
95
95
∇conv_data! (dx:: AbstractArray{T,5} , dy:: AbstractArray{T,5} , x:: AbstractArray{T,5} , w:: AbstractArray{T,5} ;
96
- pad = 0 , stride = 1 , dilation = 1 ) where T =
97
- conv3d_grad_x! (dx, x, w, dy, padding = pad, stride = stride, dilation = dilation)
96
+ pad = 0 , stride = 1 , dilation = 1 , flipkernel = 0 ) where T =
97
+ conv3d_grad_x! (dx, x, w, dy, padding = pad, stride = stride, dilation = dilation, mode = flipkernel )
98
98
99
99
# Depthwise Conv
100
100
@@ -120,19 +120,19 @@ 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:: A , w:: A ; pad = 0 , stride = 1 ) where A<: AbstractArray =
124
- ∇depthwiseconv_data! (zero (x), dy, x, w; pad = pad, stride = stride)
123
+ ∇depthwiseconv_data (dy:: A , x:: A , w:: A ; pad = 0 , stride = 1 , flipkernel = 0 ) where A<: AbstractArray =
124
+ ∇depthwiseconv_data! (zero (x), dy, x, w; pad = pad, stride = stride, flipkernel = flipkernel )
125
125
126
- ∇depthwiseconv_filter (dy:: A , x:: A , w:: A ; pad = 0 , stride = 1 ) where A<: AbstractArray =
127
- ∇depthwiseconv_filter! (zero (w), dy, x, w; pad = pad, stride = stride)
126
+ ∇depthwiseconv_filter (dy:: A , x:: A , w:: A ; pad = 0 , stride = 1 , flipkernel = 0 ) where A<: AbstractArray =
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} ;
130
- pad = 0 , stride = 1 ) where T =
131
- depthwiseconv2d_grad_w! (dw, x, w, dy, padding = pad, stride = stride)
130
+ pad = 0 , stride = 1 , flipkernel = 0 ) where T =
131
+ depthwiseconv2d_grad_w! (dw, x, w, dy, padding = pad, stride = stride, mode = flipkernel )
132
132
133
133
∇depthwiseconv_data! (dx:: AbstractArray{T,4} , dy:: AbstractArray{T,4} , x:: AbstractArray{T,4} , w:: AbstractArray{T,4} ;
134
- pad = 0 , stride = 1 ) where T =
135
- depthwiseconv2d_grad_x! (dx, x, w, dy, padding = pad, stride = stride)
134
+ pad = 0 , stride = 1 , flipkernel = 0 ) where T =
135
+ depthwiseconv2d_grad_x! (dx, x, w, dy, padding = pad, stride = stride, mode = flipkernel )
136
136
137
137
# Pooling
138
138
0 commit comments