1 // Copyright 2020 Google LLC
2 //
3 // This source code is licensed under the BSD-style license found in the
4 // LICENSE file in the root directory of this source tree.
5 
6 #include "depth-to-space-operator-tester.h"
7 
8 #include <gtest/gtest.h>
9 
10 
TEST(DEPTH_TO_SPACE_NCHW2NHWC_X32,one_pixel)11 TEST(DEPTH_TO_SPACE_NCHW2NHWC_X32, one_pixel) {
12   DepthToSpaceOperatorTester()
13     .input_size(1, 1)
14     .block_size(3)
15     .output_channels(17)
16     .TestNCHW2NHWCxX32();
17 }
18 
TEST(DEPTH_TO_SPACE_NCHW2NHWC_X32,one_column)19 TEST(DEPTH_TO_SPACE_NCHW2NHWC_X32, one_column) {
20   for (size_t input_height = 1; input_height <= 7; input_height++) {
21     DepthToSpaceOperatorTester()
22       .input_size(input_height, 1)
23       .block_size(3)
24       .output_channels(17)
25       .TestNCHW2NHWCxX32();
26   }
27 }
28 
TEST(DEPTH_TO_SPACE_NCHW2NHWC_X32,one_row)29 TEST(DEPTH_TO_SPACE_NCHW2NHWC_X32, one_row) {
30   for (size_t input_width = 1; input_width <= 7; input_width++) {
31     DepthToSpaceOperatorTester()
32       .input_size(1, input_width)
33       .block_size(3)
34       .output_channels(17)
35       .TestNCHW2NHWCxX32();
36   }
37 }
38 
TEST(DEPTH_TO_SPACE_NCHW2NHWC_X32,varying_input_size)39 TEST(DEPTH_TO_SPACE_NCHW2NHWC_X32, varying_input_size) {
40   for (size_t input_height = 1; input_height <= 5; input_height++) {
41     for (size_t input_width = 1; input_width <= 5; input_width++) {
42       DepthToSpaceOperatorTester()
43         .input_size(input_height, input_width)
44         .block_size(3)
45         .output_channels(17)
46         .TestNCHW2NHWCxX32();
47     }
48   }
49 }
50 
TEST(DEPTH_TO_SPACE_NCHW2NHWC_X32,varying_block_size)51 TEST(DEPTH_TO_SPACE_NCHW2NHWC_X32, varying_block_size) {
52   for (uint32_t block_size = 2; block_size <= 5; block_size++) {
53     DepthToSpaceOperatorTester()
54       .input_size(7, 5)
55       .block_size(block_size)
56       .output_channels(17)
57       .TestNCHW2NHWCxX32();
58   }
59 }
60 
TEST(DEPTH_TO_SPACE_NCHW2NHWC_X32,varying_output_channels)61 TEST(DEPTH_TO_SPACE_NCHW2NHWC_X32, varying_output_channels) {
62   for (size_t output_channels = 1; output_channels <= 15; output_channels++) {
63     DepthToSpaceOperatorTester()
64       .input_size(7, 5)
65       .block_size(3)
66       .output_channels(output_channels)
67       .TestNCHW2NHWCxX32();
68   }
69 }
70 
TEST(DEPTH_TO_SPACE_NCHW2NHWC_X32,varying_batch_size)71 TEST(DEPTH_TO_SPACE_NCHW2NHWC_X32, varying_batch_size) {
72   for (size_t batch_size = 2; batch_size <= 3; batch_size++) {
73     DepthToSpaceOperatorTester()
74       .batch_size(batch_size)
75       .input_size(7, 5)
76       .block_size(3)
77       .output_channels(17)
78       .TestNCHW2NHWCxX32();
79   }
80 }
81 
TEST(DEPTH_TO_SPACE_NCHW2NHWC_X32,input_channels_stride)82 TEST(DEPTH_TO_SPACE_NCHW2NHWC_X32, input_channels_stride) {
83   DepthToSpaceOperatorTester()
84     .batch_size(2)
85     .input_size(7, 5)
86     .block_size(3)
87     .input_channels_stride(157)
88     .output_channels(17)
89     .TestNCHW2NHWCxX32();
90 }
91 
TEST(DEPTH_TO_SPACE_NCHW2NHWC_X32,output_channels_stride)92 TEST(DEPTH_TO_SPACE_NCHW2NHWC_X32, output_channels_stride) {
93   DepthToSpaceOperatorTester()
94     .batch_size(2)
95     .input_size(7, 5)
96     .block_size(3)
97     .output_channels_stride(19)
98     .output_channels(17)
99     .TestNCHW2NHWCxX32();
100 }
101