1 // Copyright 2019 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 <gtest/gtest.h>
7
8 #include <xnnpack/params.h>
9
10 #include "prelu-operator-tester.h"
11
12
TEST(PRELU_NC_F32,unit_batch)13 TEST(PRELU_NC_F32, unit_batch) {
14 for (size_t channels = 1; channels < xnn_params.f32.prelu.channel_tile * 10; channels += std::max<size_t>(1, xnn_params.f32.prelu.channel_tile - 1)) {
15 PReLUOperatorTester()
16 .batch_size(1)
17 .channels(channels)
18 .iterations(3)
19 .TestF32();
20 }
21 }
22
TEST(PRELU_NC_F32,unit_batch_with_qmin)23 TEST(PRELU_NC_F32, unit_batch_with_qmin) {
24 for (size_t channels = 1; channels < xnn_params.f32.prelu.channel_tile * 10; channels += std::max<size_t>(1, xnn_params.f32.prelu.channel_tile - 1)) {
25 PReLUOperatorTester()
26 .batch_size(1)
27 .channels(channels)
28 .qmin(128)
29 .iterations(3)
30 .TestF32();
31 }
32 }
33
TEST(PRELU_NC_F32,unit_batch_with_qmax)34 TEST(PRELU_NC_F32, unit_batch_with_qmax) {
35 for (size_t channels = 1; channels < xnn_params.f32.prelu.channel_tile * 10; channels += std::max<size_t>(1, xnn_params.f32.prelu.channel_tile - 1)) {
36 PReLUOperatorTester()
37 .batch_size(1)
38 .channels(channels)
39 .qmax(128)
40 .iterations(3)
41 .TestF32();
42 }
43 }
44
TEST(PRELU_NC_F32,small_batch)45 TEST(PRELU_NC_F32, small_batch) {
46 for (size_t channels = 1; channels < xnn_params.f32.prelu.channel_tile * 10; channels += std::max<size_t>(1, xnn_params.f32.prelu.channel_tile - 1)) {
47 PReLUOperatorTester()
48 .batch_size(xnn_params.f32.prelu.row_tile)
49 .channels(channels)
50 .iterations(3)
51 .TestF32();
52 }
53 }
54
TEST(PRELU_NC_F32,small_batch_with_x_stride)55 TEST(PRELU_NC_F32, small_batch_with_x_stride) {
56 for (size_t channels = 1; channels < xnn_params.f32.prelu.channel_tile * 10; channels += std::max<size_t>(1, xnn_params.f32.prelu.channel_tile - 1)) {
57 PReLUOperatorTester()
58 .batch_size(xnn_params.f32.prelu.row_tile)
59 .channels(channels)
60 .x_stride(123)
61 .iterations(3)
62 .TestF32();
63 }
64 }
65
TEST(PRELU_NC_F32,small_batch_with_y_stride)66 TEST(PRELU_NC_F32, small_batch_with_y_stride) {
67 for (size_t channels = 1; channels < xnn_params.f32.prelu.channel_tile * 10; channels += std::max<size_t>(1, xnn_params.f32.prelu.channel_tile - 1)) {
68 PReLUOperatorTester()
69 .batch_size(xnn_params.f32.prelu.row_tile)
70 .channels(channels)
71 .y_stride(117)
72 .iterations(3)
73 .TestF32();
74 }
75 }
76
TEST(PRELU_NC_F32,small_batch_with_x_stride_and_y_stride)77 TEST(PRELU_NC_F32, small_batch_with_x_stride_and_y_stride) {
78 for (size_t channels = 1; channels < xnn_params.f32.prelu.channel_tile * 10; channels += std::max<size_t>(1, xnn_params.f32.prelu.channel_tile - 1)) {
79 PReLUOperatorTester()
80 .batch_size(xnn_params.f32.prelu.row_tile)
81 .channels(channels)
82 .x_stride(123)
83 .y_stride(117)
84 .iterations(3)
85 .TestF32();
86 }
87 }
88
TEST(PRELU_NC_F32,small_batch_with_qmin)89 TEST(PRELU_NC_F32, small_batch_with_qmin) {
90 for (size_t channels = 1; channels < xnn_params.f32.prelu.channel_tile * 10; channels += std::max<size_t>(1, xnn_params.f32.prelu.channel_tile - 1)) {
91 PReLUOperatorTester()
92 .batch_size(xnn_params.f32.prelu.row_tile)
93 .channels(channels)
94 .qmin(128)
95 .iterations(3)
96 .TestF32();
97 }
98 }
99
TEST(PRELU_NC_F32,small_batch_with_qmax)100 TEST(PRELU_NC_F32, small_batch_with_qmax) {
101 for (size_t channels = 1; channels < xnn_params.f32.prelu.channel_tile * 10; channels += std::max<size_t>(1, xnn_params.f32.prelu.channel_tile - 1)) {
102 PReLUOperatorTester()
103 .batch_size(xnn_params.f32.prelu.row_tile)
104 .channels(channels)
105 .qmax(128)
106 .iterations(3)
107 .TestF32();
108 }
109 }
110
TEST(PRELU_NC_F32,large_batch)111 TEST(PRELU_NC_F32, large_batch) {
112 for (size_t channels = 1; channels < xnn_params.f32.prelu.channel_tile * 10; channels += std::max<size_t>(1, xnn_params.f32.prelu.channel_tile - 1)) {
113 PReLUOperatorTester()
114 .batch_size(3 * xnn_params.f32.prelu.row_tile + 1)
115 .channels(channels)
116 .iterations(1)
117 .TestF32();
118 }
119 }
120
TEST(PRELU_NC_F32,large_batch_with_x_stride)121 TEST(PRELU_NC_F32, large_batch_with_x_stride) {
122 for (size_t channels = 1; channels < xnn_params.f32.prelu.channel_tile * 10; channels += std::max<size_t>(1, xnn_params.f32.prelu.channel_tile - 1)) {
123 PReLUOperatorTester()
124 .batch_size(3 * xnn_params.f32.prelu.row_tile + 1)
125 .channels(channels)
126 .x_stride(123)
127 .iterations(1)
128 .TestF32();
129 }
130 }
131
TEST(PRELU_NC_F32,large_batch_with_y_stride)132 TEST(PRELU_NC_F32, large_batch_with_y_stride) {
133 for (size_t channels = 1; channels < xnn_params.f32.prelu.channel_tile * 10; channels += std::max<size_t>(1, xnn_params.f32.prelu.channel_tile - 1)) {
134 PReLUOperatorTester()
135 .batch_size(3 * xnn_params.f32.prelu.row_tile + 1)
136 .channels(channels)
137 .y_stride(117)
138 .iterations(1)
139 .TestF32();
140 }
141 }
142
TEST(PRELU_NC_F32,large_batch_with_x_stride_and_y_stride)143 TEST(PRELU_NC_F32, large_batch_with_x_stride_and_y_stride) {
144 for (size_t channels = 1; channels < xnn_params.f32.prelu.channel_tile * 10; channels += std::max<size_t>(1, xnn_params.f32.prelu.channel_tile - 1)) {
145 PReLUOperatorTester()
146 .batch_size(3 * xnn_params.f32.prelu.row_tile + 1)
147 .channels(channels)
148 .x_stride(123)
149 .y_stride(117)
150 .iterations(1)
151 .TestF32();
152 }
153 }
154