Skip to content

Commit 0d27d79

Browse files
committed
test for crosscor, increased coverage
1 parent c4ac366 commit 0d27d79

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

test/conv.jl

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
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
22

33
@testset "conv2d" begin
44
x = reshape(Float64[1:20;], 5, 4, 1, 1)
@@ -10,6 +10,12 @@ using NNlib: conv, ∇conv_filter, ∇conv_data, ∇maxpool, maxpool, depthwisec
1010
49 99 149;
1111
59 109 159.]
1212

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+
1319
@test dropdims(conv(Float32.(x), Float32.(w)), dims=(3,4)) == Float32.([
1420
29 79 129;
1521
39 89 139;
@@ -59,8 +65,8 @@ using NNlib: conv, ∇conv_filter, ∇conv_data, ∇maxpool, maxpool, depthwisec
5965
# correctness of gradients is cross-checked with CUDNN.jl
6066
# (it's assumed convolution code won't change often)
6167

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)
6470

6571
# Test that stride/pad work backward as well
6672
y = conv(x, w; stride=2, pad=1, dilation=2)

0 commit comments

Comments
 (0)