1
- using NNlib: conv, ∇conv_filter, ∇conv_data, ∇maxpool, maxpool, depthwiseconv, ∇depthwiseconv_filter, ∇depthwiseconv_data
1
+ using NNlib: conv, crosscor, ∇conv_filter, ∇conv_data, ∇maxpool, maxpool, depthwiseconv, ∇depthwiseconv_filter, ∇depthwiseconv_data
2
2
3
3
@testset " conv2d" begin
4
4
x = reshape (Float64[1 : 20 ;], 5 , 4 , 1 , 1 )
@@ -10,6 +10,12 @@ using NNlib: conv, ∇conv_filter, ∇conv_data, ∇maxpool, maxpool, depthwisec
10
10
49 99 149 ;
11
11
59 109 159. ]
12
12
13
+ @test dropdims (crosscor (x, w), dims = (3 ,4 )) == [
14
+ 51 101 151 ;
15
+ 61 111 161 ;
16
+ 71 121 171 ;
17
+ 81 131 181. ]
18
+
13
19
@test dropdims (conv (Float32 .(x), Float32 .(w)), dims= (3 ,4 )) == Float32 .([
14
20
29 79 129 ;
15
21
39 89 139 ;
@@ -59,8 +65,8 @@ using NNlib: conv, ∇conv_filter, ∇conv_data, ∇maxpool, maxpool, depthwisec
59
65
# correctness of gradients is cross-checked with CUDNN.jl
60
66
# (it's assumed convolution code won't change often)
61
67
62
- @test size (∇conv_filter (reshape (rand (4 ,3 ), 4 , 3 , 1 , 1 ), x; size = size (w) )) == size (w)
63
- @test size (∇conv_data (reshape (rand (4 ,3 ), 4 , 3 , 1 , 1 ), w; size = size (x) )) == size (x)
68
+ @test size (∇conv_filter (reshape (rand (4 ,3 ), 4 , 3 , 1 , 1 ), x)) == size (w)
69
+ @test size (∇conv_data (reshape (rand (4 ,3 ), 4 , 3 , 1 , 1 ), w)) == size (x)
64
70
65
71
# Test that stride/pad work backward as well
66
72
y = conv (x, w; stride= 2 , pad= 1 , dilation= 2 )
0 commit comments