Skip to content

Commit b3c0c2a

Browse files
Fix deprecations
1 parent 1ed81ee commit b3c0c2a

File tree

2 files changed

+38
-38
lines changed

2 files changed

+38
-38
lines changed

src/impl/conv.jl

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ function psize(p, x)
1010
end
1111
end
1212

13-
function im2col_2d!{T}(img::AbstractArray{T,3}, col::AbstractArray{T,2}, width::Int, height::Int, channels::Int,
13+
function im2col_2d!(img::AbstractArray{T,3}, col::AbstractArray{T,2}, width::Int, height::Int, channels::Int,
1414
kernel_w::Int, kernel_h::Int, pad_w::Int, pad_h::Int, stride_w::Int, stride_h::Int,
15-
dil_w::Int, dil_h::Int, mode::Int)
15+
dil_w::Int, dil_h::Int, mode::Int) where T
1616

1717
height_col = div(height + 2pad_h - (kernel_h - 1) * dil_h - 1, stride_h) + 1
1818
width_col = div(width + 2pad_w - (kernel_w - 1) * dil_w - 1, stride_w) + 1
@@ -42,9 +42,9 @@ function im2col_2d!{T}(img::AbstractArray{T,3}, col::AbstractArray{T,2}, width::
4242
end
4343
end
4444

45-
function col2im_2d!{T}(col::AbstractArray{T,2}, img::AbstractArray{T,3}, width::Int, height::Int,
45+
function col2im_2d!(col::AbstractArray{T,2}, img::AbstractArray{T,3}, width::Int, height::Int,
4646
channels::Int, kernel_w::Int, kernel_h::Int, pad_w::Int, pad_h::Int, stride_w::Int,
47-
stride_h::Int, dil_w::Int, dil_h::Int, mode::Int)
47+
stride_h::Int, dil_w::Int, dil_h::Int, mode::Int) where T
4848

4949
height_col = div(height + 2pad_h - (kernel_h - 1) * dil_h - 1, stride_h) + 1
5050
width_col = div(width + 2pad_w - (kernel_w - 1) * dil_w - 1, stride_w) + 1
@@ -71,9 +71,9 @@ function col2im_2d!{T}(col::AbstractArray{T,2}, img::AbstractArray{T,3}, width::
7171
end
7272
end
7373

74-
function im2col_3d!{T}(img::AbstractArray{T,4}, col::AbstractArray{T,2}, width::Int, height::Int, depth::Int,
74+
function im2col_3d!(img::AbstractArray{T,4}, col::AbstractArray{T,2}, width::Int, height::Int, depth::Int,
7575
channels::Int, kernel_w::Int, kernel_h::Int, kernel_d::Int, pad_w::Int, pad_h::Int, pad_d::Int,
76-
stride_w::Int, stride_h::Int, stride_d::Int, dil_w::Int, dil_h::Int, dil_d::Int, mode::Int)
76+
stride_w::Int, stride_h::Int, stride_d::Int, dil_w::Int, dil_h::Int, dil_d::Int, mode::Int) where T
7777

7878
height_col = div(height + 2pad_h - (kernel_h - 1) * dil_h - 1, stride_h) + 1
7979
width_col = div(width + 2pad_w - (kernel_w - 1) * dil_w - 1, stride_w) + 1
@@ -107,10 +107,10 @@ function im2col_3d!{T}(img::AbstractArray{T,4}, col::AbstractArray{T,2}, width::
107107
end
108108
end
109109

110-
function col2im_3d!{T}(col::AbstractArray{T,2}, img::AbstractArray{T,4}, width::Int, height::Int,
110+
function col2im_3d!(col::AbstractArray{T,2}, img::AbstractArray{T,4}, width::Int, height::Int,
111111
depth::Int, channels::Int, kernel_w::Int, kernel_h::Int, kernel_d::Int,
112112
pad_w::Int, pad_h::Int, pad_d::Int, stride_w::Int, stride_h::Int, stride_d::Int,
113-
dil_w::Int, dil_h::Int, dil_d::Int, mode::Int)
113+
dil_w::Int, dil_h::Int, dil_d::Int, mode::Int) where T
114114

115115
height_col = div(height + 2pad_h - (kernel_h - 1) * dil_h - 1, stride_h) + 1
116116
width_col = div(width + 2pad_w - (kernel_w - 1) * dil_w - 1, stride_w) + 1
@@ -170,8 +170,8 @@ function im2col_dims(w,y)
170170
return (r, c)
171171
end
172172

173-
function conv2d!{T}(y::AbstractArray{T,4}, x::AbstractArray{T,4}, w::AbstractArray{T,4};
174-
padding=0, stride=1, dilation=1, mode=0, alpha=T(1))
173+
function conv2d!(y::AbstractArray{T,4}, x::AbstractArray{T,4}, w::AbstractArray{T,4};
174+
padding=0, stride=1, dilation=1, mode=0, alpha=T(1)) where T
175175
if mode != 0 && mode != 1; throw(ArgumentError("conv2d only supports mode=0 or 1.")); end
176176
Wx,Hx,Cx,Nx = size(x)
177177
Ww,Hw,C1,C2 = size(w)
@@ -192,8 +192,8 @@ function conv2d!{T}(y::AbstractArray{T,4}, x::AbstractArray{T,4}, w::AbstractArr
192192
return y
193193
end
194194

195-
function conv2d_grad_w!{T}(dw::AbstractArray{T,4}, x::AbstractArray{T,4}, w::AbstractArray{T,4}, dy::AbstractArray{T,4};
196-
padding=0, stride=1, dilation=1, mode=0, alpha=1)
195+
function conv2d_grad_w!(dw::AbstractArray{T,4}, x::AbstractArray{T,4}, w::AbstractArray{T,4}, dy::AbstractArray{T,4};
196+
padding=0, stride=1, dilation=1, mode=0, alpha=1) where T
197197
# dw = x'*dy
198198
Wx,Hx,Cx,Nx = size(x)
199199
Ww,Hw,C1,C2 = size(w)
@@ -217,8 +217,8 @@ function conv2d_grad_w!{T}(dw::AbstractArray{T,4}, x::AbstractArray{T,4}, w::Abs
217217
return dw
218218
end
219219

220-
function conv2d_grad_x!{T}(dx::AbstractArray{T,4}, x::AbstractArray{T,4}, w::AbstractArray{T,4}, dy::AbstractArray{T,4};
221-
padding=0, stride=1, dilation=1, mode=0, alpha=1)
220+
function conv2d_grad_x!(dx::AbstractArray{T,4}, x::AbstractArray{T,4}, w::AbstractArray{T,4}, dy::AbstractArray{T,4};
221+
padding=0, stride=1, dilation=1, mode=0, alpha=1) where T
222222
# dx = dy*w'
223223
Wx,Hx,Cx,Nx = size(x)
224224
Ww,Hw,C1,C2 = size(w)
@@ -261,8 +261,8 @@ function col2im2d!(w::AbstractArray{T,4}, x::AbstractArray{T,4}, x2::AbstractArr
261261
return x
262262
end
263263

264-
function conv3d!{T}(y::AbstractArray{T,5}, x::AbstractArray{T,5}, w::AbstractArray{T,5};
265-
padding=0, stride=1, dilation = 1, mode=0, alpha=T(1))
264+
function conv3d!(y::AbstractArray{T,5}, x::AbstractArray{T,5}, w::AbstractArray{T,5};
265+
padding=0, stride=1, dilation = 1, mode=0, alpha=T(1)) where T
266266
if mode != 0 && mode != 1; throw(ArgumentError("conv3d only supports mode=0 or 1.")); end
267267
Wx,Hx,Dx,Cx,Nx = size(x)
268268
Ww,Hw,Dw,C1,C2 = size(w)
@@ -285,8 +285,8 @@ function conv3d!{T}(y::AbstractArray{T,5}, x::AbstractArray{T,5}, w::AbstractArr
285285
return y
286286
end
287287

288-
function conv3d_grad_w!{T}(dw::AbstractArray{T,5}, x::AbstractArray{T,5}, w::AbstractArray{T,5}, dy::AbstractArray{T,5};
289-
padding=0, stride=1, dilation = 1, mode=0, alpha=1)
288+
function conv3d_grad_w!(dw::AbstractArray{T,5}, x::AbstractArray{T,5}, w::AbstractArray{T,5}, dy::AbstractArray{T,5};
289+
padding=0, stride=1, dilation = 1, mode=0, alpha=1) where T
290290
# dw = x'*dy
291291
Wx,Hx,Dx,Cx,Nx = size(x)
292292
Ww,Hw,Dw,C1,C2 = size(w)
@@ -310,8 +310,8 @@ function conv3d_grad_w!{T}(dw::AbstractArray{T,5}, x::AbstractArray{T,5}, w::Abs
310310
return dw
311311
end
312312

313-
function conv3d_grad_x!{T}(dx::AbstractArray{T,5}, x::AbstractArray{T,5}, w::AbstractArray{T,5}, dy::AbstractArray{T,5};
314-
padding=0, stride=1, dilation = 1, mode=0, alpha=1)
313+
function conv3d_grad_x!(dx::AbstractArray{T,5}, x::AbstractArray{T,5}, w::AbstractArray{T,5}, dy::AbstractArray{T,5};
314+
padding=0, stride=1, dilation = 1, mode=0, alpha=1) where T
315315
# dx = dy*w'
316316
Wx,Hx,Dx,Cx,Nx = size(x)
317317
Ww,Hw,Dw,C1,C2 = size(w)

src/impl/pool.jl

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
function max_pooling2d_fwd!{T}(x::AbstractArray{T,4}, y::AbstractArray{T,4},
2-
width::Int, height::Int, channels::Int, num::Int, pooled_width::Int,
3-
pooled_height::Int, kernel_w::Int, kernel_h::Int, pad_w::Int, pad_h::Int,
4-
stride_w::Int, stride_h::Int)
1+
function max_pooling2d_fwd!(x::AbstractArray{T,4}, y::AbstractArray{T,4},
2+
width::Int, height::Int, channels::Int, num::Int, pooled_width::Int,
3+
pooled_height::Int, kernel_w::Int, kernel_h::Int, pad_w::Int, pad_h::Int,
4+
stride_w::Int, stride_h::Int) where T
55
for n = 1:num, c = 1:channels, ph = 1:pooled_height, pw = 1:pooled_width
66
hstart = (ph - 1)*stride_h - pad_h
77
wstart = (pw - 1)*stride_w - pad_w
@@ -27,10 +27,10 @@ function maxpool2d!(y::AbstractArray{T,4}, x::AbstractArray{T,4};
2727
return y
2828
end
2929

30-
function max_pooling2d_bwd!{T}(x::AbstractArray{T,4}, y::AbstractArray{T,4},
30+
function max_pooling2d_bwd!(x::AbstractArray{T,4}, y::AbstractArray{T,4},
3131
grad_output::AbstractArray{T,4}, grad_input::AbstractArray{T,4}, width::Int, height::Int,
3232
channels::Int, num::Int, pooled_width::Int, pooled_height::Int, kernel_w::Int,
33-
kernel_h::Int, pad_w::Int, pad_h::Int, stride_w::Int, stride_h::Int)
33+
kernel_h::Int, pad_w::Int, pad_h::Int, stride_w::Int, stride_h::Int) where T
3434

3535
grad_input[:, :, :, :] = 0
3636
#pragma omp parallel for
@@ -64,10 +64,10 @@ function maxpool2d_grad!(dx::AbstractArray{T,4}, dy::AbstractArray{T,4}, y::Abst
6464
end
6565

6666

67-
function mean_pooling2d_fwd!{T}(x::AbstractArray{T,4}, y::AbstractArray{T,4},
67+
function mean_pooling2d_fwd!(x::AbstractArray{T,4}, y::AbstractArray{T,4},
6868
width::Int, height::Int, channels::Int, num::Int, pooled_width::Int,
6969
pooled_height::Int, kernel_w::Int, kernel_h::Int,pad_w::Int, pad_h::Int,
70-
stride_w::Int, stride_h::Int)
70+
stride_w::Int, stride_h::Int) where T
7171
kernel_size = kernel_w * kernel_h
7272
for n = 1:num, c = 1:channels, ph = 1:pooled_height, pw = 1:pooled_width
7373
hstart = (ph - 1) * stride_h - pad_h
@@ -94,10 +94,10 @@ function meanpool2d!(y::AbstractArray{T,4}, x::AbstractArray{T,4};
9494
return y
9595
end
9696

97-
function mean_pooling2d_bwd!{T}(x::AbstractArray{T,4}, y::AbstractArray{T,4},
97+
function mean_pooling2d_bwd!(x::AbstractArray{T,4}, y::AbstractArray{T,4},
9898
width::Int, height::Int, channels::Int, num::Int, pooled_width::Int,
9999
pooled_height::Int, kernel_w::Int, kernel_h::Int, pad_w::Int, pad_h::Int,
100-
stride_w::Int, stride_h::Int)
100+
stride_w::Int, stride_h::Int) where T
101101

102102
x[:, :, :, :] = 0
103103
kernel_size = kernel_w * kernel_h
@@ -128,10 +128,10 @@ function meanpool2d_grad!(dx::AbstractArray{T,4}, dy::AbstractArray{T,4}, y::Abs
128128
return dx
129129
end
130130

131-
function max_pooling3d_fwd!{T}(x::AbstractArray{T,5}, y::AbstractArray{T,5},
131+
function max_pooling3d_fwd!(x::AbstractArray{T,5}, y::AbstractArray{T,5},
132132
width::Int, height::Int, depth::Int, channels::Int, num::Int, pooled_width::Int,
133133
pooled_height::Int, pooled_depth::Int, kernel_w::Int, kernel_h::Int, kernel_d::Int,
134-
pad_w::Int, pad_h::Int, pad_d::Int, stride_w::Int, stride_h::Int, stride_d::Int)
134+
pad_w::Int, pad_h::Int, pad_d::Int, stride_w::Int, stride_h::Int, stride_d::Int) where T
135135
for n = 1:num, c = 1:channels, pd = 1:pooled_depth, ph = 1:pooled_height, pw = 1:pooled_width
136136
dstart = (pd - 1)* stride_d - pad_d
137137
hstart = (ph - 1)* stride_h - pad_h
@@ -162,11 +162,11 @@ function maxpool3d!(y::AbstractArray{T,5}, x::AbstractArray{T,5};
162162
return y
163163
end
164164

165-
function max_pooling3d_bwd!{T}(x::AbstractArray{T,5}, y::AbstractArray{T,5},
165+
function max_pooling3d_bwd!(x::AbstractArray{T,5}, y::AbstractArray{T,5},
166166
grad_output::AbstractArray{T,5}, grad_input::AbstractArray{T,5}, width::Int, height::Int, depth::Int,
167167
channels::Int, num::Int, pooled_width::Int, pooled_height::Int, pooled_depth::Int,
168168
kernel_w::Int, kernel_h::Int, kernel_d::Int, pad_w::Int, pad_h::Int, pad_d::Int,
169-
stride_w::Int, stride_h::Int, stride_d::Int)
169+
stride_w::Int, stride_h::Int, stride_d::Int) where T
170170

171171
grad_input[:, :, :, :, :] = 0
172172

@@ -206,10 +206,10 @@ function maxpool3d_grad!(dx::AbstractArray{T,5}, dy::AbstractArray{T,5}, y::Abst
206206
return dx
207207
end
208208

209-
function mean_pooling3d_fwd!{T}(x::AbstractArray{T,5}, y::AbstractArray{T,5},
209+
function mean_pooling3d_fwd!(x::AbstractArray{T,5}, y::AbstractArray{T,5},
210210
width::Int, height::Int, depth::Int, channels::Int, num::Int, pooled_width::Int,
211211
pooled_height::Int, pooled_depth::Int, kernel_w::Int, kernel_h::Int, kernel_d::Int,
212-
pad_w::Int, pad_h::Int, pad_d::Int, stride_w::Int, stride_h::Int, stride_d::Int)
212+
pad_w::Int, pad_h::Int, pad_d::Int, stride_w::Int, stride_h::Int, stride_d::Int) where T
213213

214214
kernel_size = kernel_w * kernel_h * kernel_d
215215
#pragma omp parallel for
@@ -243,10 +243,10 @@ function meanpool3d!(y::AbstractArray{T,5}, x::AbstractArray{T,5};
243243
return y
244244
end
245245

246-
function mean_pooling3d_bwd!{T}(grad_input::AbstractArray{T,5}, grad_output::AbstractArray{T,5},
246+
function mean_pooling3d_bwd!(grad_input::AbstractArray{T,5}, grad_output::AbstractArray{T,5},
247247
width::Int, height::Int, depth::Int, channels::Int, num::Int, pooled_width::Int,
248248
pooled_height::Int, pooled_depth::Int, kernel_w::Int, kernel_h::Int, kernel_d::Int,
249-
pad_w::Int, pad_h::Int, pad_d::Int, stride_w::Int, stride_h::Int, stride_d::Int)
249+
pad_w::Int, pad_h::Int, pad_d::Int, stride_w::Int, stride_h::Int, stride_d::Int) where T
250250

251251
kernel_size = kernel_w * kernel_h * kernel_d
252252
fill!(grad_input, 0.0)

0 commit comments

Comments
 (0)