@@ -12,7 +12,7 @@ using NNlib: input_size, kernel_size, channels_in, channels_out, channel_multipl
12
12
elseif T == DepthwiseConvDims
13
13
w = randn (1 ,2 ,4 ,3 )
14
14
end
15
-
15
+
16
16
# First, getters:
17
17
cdims = T (x, w)
18
18
@test input_size (cdims) == size (x)[1 : 2 ]
@@ -39,7 +39,7 @@ using NNlib: input_size, kernel_size, channels_in, channels_out, channel_multipl
39
39
@test padding (cdims) == (3 ,3 ,3 ,3 )
40
40
@test flipkernel (cdims) == true
41
41
@test output_size (cdims) == (6 ,4 )
42
-
42
+
43
43
# Next, tuple settings
44
44
cdims = T (x, w; stride= (1 , 2 ), dilation= (1 , 2 ), padding= (0 ,1 ))
45
45
@test stride (cdims) == (1 ,2 )
@@ -215,7 +215,7 @@ conv_answer_dict = Dict(
215
215
" dx_dil" => reshape ([
216
216
4864 , 5152 , 9696 , 4508 , 4760 , 6304 , 6592 , 12396 , 5768 , 6020 , 3648 ,
217
217
3864 , 7120 , 3220 , 3400 , 4728 , 4944 , 9100 , 4120 , 4300 , 0 , 0 , 0 , 0 , 0 , 0 ,
218
- 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 2432 , 2576 , 4544 , 1932 , 2040 ,
218
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 2432 , 2576 , 4544 , 1932 , 2040 ,
219
219
3152 , 3296 , 5804 , 2472 , 2580 , 1216 , 1288 , 1968 , 644 , 680 , 1576 , 1648 ,
220
220
2508 , 824 , 860.
221
221
], (5 ,4 ,3 )),
@@ -273,7 +273,7 @@ conv_answer_dict = Dict(
273
273
274
274
# A "drop channels and batch dimension" helper
275
275
ddims (x) = dropdims (x, dims= (rank+ 1 , rank+ 2 ))
276
-
276
+
277
277
for conv in (NNlib. conv, NNlib. conv_im2col, NNlib. conv_direct)
278
278
@testset " $(conv) " begin
279
279
# First, your basic convolution with no parameters
@@ -392,7 +392,7 @@ conv_answer_dict = Dict(
392
392
D_size in (1 , 2 , 4 , (1 ,2 ), (3 ,2 ), (4 ,2 ,3 ))
393
393
394
394
# Skip tests that are impossible due to mismatched sizes
395
- try
395
+ try
396
396
DenseConvDims (x, w;
397
397
stride= S_size, padding= P_size, dilation= D_size,
398
398
)
473
473
474
474
# A "drop channels and batch dimension" helper
475
475
ddims (x) = dropdims (x, dims= (rank+ 1 , rank+ 2 ))
476
-
476
+
477
477
for conv in (NNlib. depthwiseconv, NNlib. depthwiseconv_im2col, NNlib. depthwiseconv_direct)
478
478
@testset " $(conv) " begin
479
479
# First, your basic convolution with no parameters
592
592
D_size in (1 , 2 , 4 , (1 ,2 ), (3 ,2 ), (4 ,2 ,3 ))
593
593
594
594
# Skip tests that are impossible due to mismatched sizes
595
- try
595
+ try
596
596
DepthwiseConvDims (x, w;
597
597
stride= S_size, padding= P_size, dilation= D_size,
598
598
)
639
639
println ()
640
640
end
641
641
end
642
+
643
+ @testset " conv_wrapper" begin
644
+ x = rand (10 , 10 , 3 , 10 )
645
+ w = rand (2 , 2 , 3 , 16 )
646
+ w1 = rand (3 , 4 , 3 , 16 )
647
+ @test size (conv (x, w)) == (9 , 9 , 16 , 10 )
648
+ @test size (conv (x, w; stride = (2 , 2 ), pad = (2 , 2 ))) == (7 , 7 , 16 , 10 )
649
+ @test size (conv (x, w1; stride = (1 , 2 ), pad = (2 , 3 ))) == (12 , 7 , 16 , 10 )
650
+ @test size (conv (x, w; stride = (1 , 2 ), pad = (2 , 3 ), dilation = (2 , 2 ))) == (12 , 7 , 16 , 10 )
651
+ @test size (conv (x, w; stride = (1 , 2 ), pad = (2 , 3 ), dilation = (2 , 2 ), flipped = true )) == (12 , 7 , 16 , 10 )
652
+ end
653
+
654
+ @testset " depthwiseconv_wrapper" begin
655
+ x = rand (10 , 10 , 3 , 10 )
656
+ w = rand (2 , 2 , 3 , 3 )
657
+ w1 = rand (3 , 4 , 3 , 3 )
658
+ @test size (depthwiseconv (x, w)) == (9 , 9 , 9 , 10 )
659
+ @test size (depthwiseconv (x, w; stride = (2 , 2 ), pad = (2 , 2 ))) == (7 , 7 , 9 , 10 )
660
+ @test size (depthwiseconv (x, w1; stride = (1 , 2 ), pad = (2 , 3 ))) == (12 , 7 , 9 , 10 )
661
+ @test size (depthwiseconv (x, w1; stride = (1 , 2 ), pad = (2 , 3 ), dilation = (2 , 2 ))) == (10 , 5 , 9 , 10 )
662
+ @test size (depthwiseconv (x, w1; stride = (1 , 2 ), pad = (2 , 3 ), dilation = (2 , 2 ), flipped = true )) == (10 , 5 , 9 , 10 )
663
+ end
0 commit comments