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/common.h>
9 #include <xnnpack/isa-checks.h>
10
11 #include <xnnpack/rmax.h>
12 #include "rmax-microkernel-tester.h"
13
14
15 #if XNN_ARCH_ARM || XNN_ARCH_ARM64
TEST(F32_RMAX__NEON,n_lt_16)16 TEST(F32_RMAX__NEON, n_lt_16) {
17 TEST_REQUIRES_ARM_NEON;
18 for (size_t n = 1; n < 16; n++) {
19 RMaxMicrokernelTester()
20 .n(n)
21 .Test(xnn_f32_rmax_ukernel__neon);
22 }
23 }
24
TEST(F32_RMAX__NEON,n_eq_16)25 TEST(F32_RMAX__NEON, n_eq_16) {
26 TEST_REQUIRES_ARM_NEON;
27 RMaxMicrokernelTester()
28 .n(16)
29 .Test(xnn_f32_rmax_ukernel__neon);
30 }
31
TEST(F32_RMAX__NEON,n_div_16)32 TEST(F32_RMAX__NEON, n_div_16) {
33 TEST_REQUIRES_ARM_NEON;
34 for (size_t n = 16; n < 128; n += 16) {
35 RMaxMicrokernelTester()
36 .n(n)
37 .Test(xnn_f32_rmax_ukernel__neon);
38 }
39 }
40
TEST(F32_RMAX__NEON,n_gt_16)41 TEST(F32_RMAX__NEON, n_gt_16) {
42 TEST_REQUIRES_ARM_NEON;
43 for (size_t n = 16; n < 32; n++) {
44 RMaxMicrokernelTester()
45 .n(n)
46 .Test(xnn_f32_rmax_ukernel__neon);
47 }
48 }
49 #endif // XNN_ARCH_ARM || XNN_ARCH_ARM64
50
51 #if XNN_ARCH_X86 || XNN_ARCH_X86_64
TEST(F32_RMAX__SSE,n_lt_16)52 TEST(F32_RMAX__SSE, n_lt_16) {
53 TEST_REQUIRES_X86_SSE2;
54 for (size_t n = 1; n < 16; n++) {
55 RMaxMicrokernelTester()
56 .n(n)
57 .Test(xnn_f32_rmax_ukernel__sse);
58 }
59 }
60
TEST(F32_RMAX__SSE,n_eq_16)61 TEST(F32_RMAX__SSE, n_eq_16) {
62 TEST_REQUIRES_X86_SSE2;
63 RMaxMicrokernelTester()
64 .n(16)
65 .Test(xnn_f32_rmax_ukernel__sse);
66 }
67
TEST(F32_RMAX__SSE,n_div_16)68 TEST(F32_RMAX__SSE, n_div_16) {
69 TEST_REQUIRES_X86_SSE2;
70 for (size_t n = 16; n < 128; n += 16) {
71 RMaxMicrokernelTester()
72 .n(n)
73 .Test(xnn_f32_rmax_ukernel__sse);
74 }
75 }
76
TEST(F32_RMAX__SSE,n_gt_16)77 TEST(F32_RMAX__SSE, n_gt_16) {
78 TEST_REQUIRES_X86_SSE2;
79 for (size_t n = 16; n < 32; n++) {
80 RMaxMicrokernelTester()
81 .n(n)
82 .Test(xnn_f32_rmax_ukernel__sse);
83 }
84 }
85 #endif // XNN_ARCH_X86 || XNN_ARCH_X86_64
86
87 #if XNN_ARCH_X86 || XNN_ARCH_X86_64
TEST(F32_RMAX__AVX,n_lt_32)88 TEST(F32_RMAX__AVX, n_lt_32) {
89 TEST_REQUIRES_X86_AVX;
90 for (size_t n = 1; n < 32; n++) {
91 RMaxMicrokernelTester()
92 .n(n)
93 .Test(xnn_f32_rmax_ukernel__avx);
94 }
95 }
96
TEST(F32_RMAX__AVX,n_eq_32)97 TEST(F32_RMAX__AVX, n_eq_32) {
98 TEST_REQUIRES_X86_AVX;
99 RMaxMicrokernelTester()
100 .n(32)
101 .Test(xnn_f32_rmax_ukernel__avx);
102 }
103
TEST(F32_RMAX__AVX,n_div_32)104 TEST(F32_RMAX__AVX, n_div_32) {
105 TEST_REQUIRES_X86_AVX;
106 for (size_t n = 32; n < 256; n += 32) {
107 RMaxMicrokernelTester()
108 .n(n)
109 .Test(xnn_f32_rmax_ukernel__avx);
110 }
111 }
112
TEST(F32_RMAX__AVX,n_gt_32)113 TEST(F32_RMAX__AVX, n_gt_32) {
114 TEST_REQUIRES_X86_AVX;
115 for (size_t n = 32; n < 64; n++) {
116 RMaxMicrokernelTester()
117 .n(n)
118 .Test(xnn_f32_rmax_ukernel__avx);
119 }
120 }
121 #endif // XNN_ARCH_X86 || XNN_ARCH_X86_64
122
123 #if XNN_ARCH_X86 || XNN_ARCH_X86_64
TEST(F32_RMAX__AVX512F,n_lt_64)124 TEST(F32_RMAX__AVX512F, n_lt_64) {
125 TEST_REQUIRES_X86_AVX512F;
126 for (size_t n = 1; n < 64; n++) {
127 RMaxMicrokernelTester()
128 .n(n)
129 .Test(xnn_f32_rmax_ukernel__avx512f);
130 }
131 }
132
TEST(F32_RMAX__AVX512F,n_eq_64)133 TEST(F32_RMAX__AVX512F, n_eq_64) {
134 TEST_REQUIRES_X86_AVX512F;
135 RMaxMicrokernelTester()
136 .n(64)
137 .Test(xnn_f32_rmax_ukernel__avx512f);
138 }
139
TEST(F32_RMAX__AVX512F,n_div_64)140 TEST(F32_RMAX__AVX512F, n_div_64) {
141 TEST_REQUIRES_X86_AVX512F;
142 for (size_t n = 64; n < 512; n += 64) {
143 RMaxMicrokernelTester()
144 .n(n)
145 .Test(xnn_f32_rmax_ukernel__avx512f);
146 }
147 }
148
TEST(F32_RMAX__AVX512F,n_gt_64)149 TEST(F32_RMAX__AVX512F, n_gt_64) {
150 TEST_REQUIRES_X86_AVX512F;
151 for (size_t n = 64; n < 128; n++) {
152 RMaxMicrokernelTester()
153 .n(n)
154 .Test(xnn_f32_rmax_ukernel__avx512f);
155 }
156 }
157 #endif // XNN_ARCH_X86 || XNN_ARCH_X86_64
158
159 #if XNN_ARCH_WASMSIMD
TEST(F32_RMAX__WASMSIMD_ARM,n_lt_16)160 TEST(F32_RMAX__WASMSIMD_ARM, n_lt_16) {
161 for (size_t n = 1; n < 16; n++) {
162 RMaxMicrokernelTester()
163 .n(n)
164 .Test(xnn_f32_rmax_ukernel__wasmsimd_arm);
165 }
166 }
167
TEST(F32_RMAX__WASMSIMD_ARM,n_eq_16)168 TEST(F32_RMAX__WASMSIMD_ARM, n_eq_16) {
169 RMaxMicrokernelTester()
170 .n(16)
171 .Test(xnn_f32_rmax_ukernel__wasmsimd_arm);
172 }
173
TEST(F32_RMAX__WASMSIMD_ARM,n_div_16)174 TEST(F32_RMAX__WASMSIMD_ARM, n_div_16) {
175 for (size_t n = 16; n < 128; n += 16) {
176 RMaxMicrokernelTester()
177 .n(n)
178 .Test(xnn_f32_rmax_ukernel__wasmsimd_arm);
179 }
180 }
181
TEST(F32_RMAX__WASMSIMD_ARM,n_gt_16)182 TEST(F32_RMAX__WASMSIMD_ARM, n_gt_16) {
183 for (size_t n = 16; n < 32; n++) {
184 RMaxMicrokernelTester()
185 .n(n)
186 .Test(xnn_f32_rmax_ukernel__wasmsimd_arm);
187 }
188 }
189 #endif // XNN_ARCH_WASMSIMD
190
191 #if XNN_ARCH_WASMSIMD
TEST(F32_RMAX__WASMSIMD_X86,n_lt_16)192 TEST(F32_RMAX__WASMSIMD_X86, n_lt_16) {
193 for (size_t n = 1; n < 16; n++) {
194 RMaxMicrokernelTester()
195 .n(n)
196 .Test(xnn_f32_rmax_ukernel__wasmsimd_x86);
197 }
198 }
199
TEST(F32_RMAX__WASMSIMD_X86,n_eq_16)200 TEST(F32_RMAX__WASMSIMD_X86, n_eq_16) {
201 RMaxMicrokernelTester()
202 .n(16)
203 .Test(xnn_f32_rmax_ukernel__wasmsimd_x86);
204 }
205
TEST(F32_RMAX__WASMSIMD_X86,n_div_16)206 TEST(F32_RMAX__WASMSIMD_X86, n_div_16) {
207 for (size_t n = 16; n < 128; n += 16) {
208 RMaxMicrokernelTester()
209 .n(n)
210 .Test(xnn_f32_rmax_ukernel__wasmsimd_x86);
211 }
212 }
213
TEST(F32_RMAX__WASMSIMD_X86,n_gt_16)214 TEST(F32_RMAX__WASMSIMD_X86, n_gt_16) {
215 for (size_t n = 16; n < 32; n++) {
216 RMaxMicrokernelTester()
217 .n(n)
218 .Test(xnn_f32_rmax_ukernel__wasmsimd_x86);
219 }
220 }
221 #endif // XNN_ARCH_WASMSIMD
222
TEST(F32_RMAX__SCALAR,n_lt_4)223 TEST(F32_RMAX__SCALAR, n_lt_4) {
224 for (size_t n = 1; n < 4; n++) {
225 RMaxMicrokernelTester()
226 .n(n)
227 .Test(xnn_f32_rmax_ukernel__scalar);
228 }
229 }
230
TEST(F32_RMAX__SCALAR,n_eq_4)231 TEST(F32_RMAX__SCALAR, n_eq_4) {
232 RMaxMicrokernelTester()
233 .n(4)
234 .Test(xnn_f32_rmax_ukernel__scalar);
235 }
236
TEST(F32_RMAX__SCALAR,n_div_4)237 TEST(F32_RMAX__SCALAR, n_div_4) {
238 for (size_t n = 4; n < 32; n += 4) {
239 RMaxMicrokernelTester()
240 .n(n)
241 .Test(xnn_f32_rmax_ukernel__scalar);
242 }
243 }
244
TEST(F32_RMAX__SCALAR,n_gt_4)245 TEST(F32_RMAX__SCALAR, n_gt_4) {
246 for (size_t n = 4; n < 8; n++) {
247 RMaxMicrokernelTester()
248 .n(n)
249 .Test(xnn_f32_rmax_ukernel__scalar);
250 }
251 }
252