blob: 2f126dfe4645bdfaf6a6dc633d3b2ed64475a840 [file] [log] [blame]
XNNPACK Teamb455b122019-09-27 18:10:33 -07001// Copyright (c) Facebook, Inc. and its affiliates.
2// All rights reserved.
3//
4// Copyright 2019 Google LLC
5//
6// This source code is licensed under the BSD-style license found in the
7// LICENSE file in the root directory of this source tree.
8
XNNPACK Teamb455b122019-09-27 18:10:33 -07009#include <gtest/gtest.h>
10
Marat Dukhan1dadbf72019-10-01 10:46:20 -070011#include <xnnpack/common.h>
XNNPACK Teamb455b122019-09-27 18:10:33 -070012#include <xnnpack/isa-checks.h>
XNNPACK Teamb455b122019-09-27 18:10:33 -070013
Marat Dukhan1dadbf72019-10-01 10:46:20 -070014#include <xnnpack/vadd.h>
XNNPACK Teamb455b122019-09-27 18:10:33 -070015#include "vadd-microkernel-tester.h"
16
17
Marat Dukhan1dadbf72019-10-01 10:46:20 -070018#if XNN_ARCH_X86 || XNN_ARCH_X86_64
Marat Dukhan08b7a972020-07-14 18:17:29 -070019 TEST(QU8_VADD_MINMAX__SSE2, n_eq_8) {
XNNPACK Teamb455b122019-09-27 18:10:33 -070020 TEST_REQUIRES_X86_SSE2;
21 VAddMicrokernelTester()
Marat Dukhand9f3ad42020-08-10 12:30:58 -070022 .batch_size(8)
Marat Dukhan08b7a972020-07-14 18:17:29 -070023 .Test(xnn_qu8_vadd_minmax_ukernel__sse2);
XNNPACK Teamb455b122019-09-27 18:10:33 -070024 }
25
Marat Dukhan08b7a972020-07-14 18:17:29 -070026 TEST(QU8_VADD_MINMAX__SSE2, n_div_8) {
XNNPACK Teamb455b122019-09-27 18:10:33 -070027 TEST_REQUIRES_X86_SSE2;
Marat Dukhand9f3ad42020-08-10 12:30:58 -070028 for (size_t batch_size = 8; batch_size < 128; batch_size += 24) {
XNNPACK Teamb455b122019-09-27 18:10:33 -070029 VAddMicrokernelTester()
Marat Dukhand9f3ad42020-08-10 12:30:58 -070030 .batch_size(batch_size)
Marat Dukhan08b7a972020-07-14 18:17:29 -070031 .Test(xnn_qu8_vadd_minmax_ukernel__sse2);
XNNPACK Teamb455b122019-09-27 18:10:33 -070032 }
33 }
34
Marat Dukhan08b7a972020-07-14 18:17:29 -070035 TEST(QU8_VADD_MINMAX__SSE2, n_gt_8) {
XNNPACK Teamb455b122019-09-27 18:10:33 -070036 TEST_REQUIRES_X86_SSE2;
Marat Dukhand9f3ad42020-08-10 12:30:58 -070037 for (size_t batch_size = 9; batch_size < 16; batch_size++) {
XNNPACK Teamb455b122019-09-27 18:10:33 -070038 VAddMicrokernelTester()
Marat Dukhand9f3ad42020-08-10 12:30:58 -070039 .batch_size(batch_size)
Marat Dukhan08b7a972020-07-14 18:17:29 -070040 .Test(xnn_qu8_vadd_minmax_ukernel__sse2);
XNNPACK Teamb455b122019-09-27 18:10:33 -070041 }
42 }
43
Marat Dukhan08b7a972020-07-14 18:17:29 -070044 TEST(QU8_VADD_MINMAX__SSE2, n_lt_8) {
XNNPACK Teamb455b122019-09-27 18:10:33 -070045 TEST_REQUIRES_X86_SSE2;
Marat Dukhand9f3ad42020-08-10 12:30:58 -070046 for (size_t batch_size = 1; batch_size < 8; batch_size++) {
XNNPACK Teamb455b122019-09-27 18:10:33 -070047 VAddMicrokernelTester()
Marat Dukhand9f3ad42020-08-10 12:30:58 -070048 .batch_size(batch_size)
Marat Dukhan08b7a972020-07-14 18:17:29 -070049 .Test(xnn_qu8_vadd_minmax_ukernel__sse2);
XNNPACK Teamb455b122019-09-27 18:10:33 -070050 }
51 }
52
Marat Dukhan08b7a972020-07-14 18:17:29 -070053 TEST(QU8_VADD_MINMAX__SSE2, inplace_a) {
XNNPACK Teamb455b122019-09-27 18:10:33 -070054 TEST_REQUIRES_X86_SSE2;
Marat Dukhand9f3ad42020-08-10 12:30:58 -070055 for (size_t batch_size = 1; batch_size < 128; batch_size += 11) {
XNNPACK Teamb455b122019-09-27 18:10:33 -070056 VAddMicrokernelTester()
57 .iterations(1)
Marat Dukhand9f3ad42020-08-10 12:30:58 -070058 .batch_size(batch_size)
XNNPACK Teamb455b122019-09-27 18:10:33 -070059 .inplace_a(true)
Marat Dukhan08b7a972020-07-14 18:17:29 -070060 .Test(xnn_qu8_vadd_minmax_ukernel__sse2);
XNNPACK Teamb455b122019-09-27 18:10:33 -070061 }
62 }
63
Marat Dukhan08b7a972020-07-14 18:17:29 -070064 TEST(QU8_VADD_MINMAX__SSE2, inplace_b) {
XNNPACK Teamb455b122019-09-27 18:10:33 -070065 TEST_REQUIRES_X86_SSE2;
Marat Dukhand9f3ad42020-08-10 12:30:58 -070066 for (size_t batch_size = 1; batch_size < 128; batch_size += 11) {
XNNPACK Teamb455b122019-09-27 18:10:33 -070067 VAddMicrokernelTester()
68 .iterations(1)
Marat Dukhand9f3ad42020-08-10 12:30:58 -070069 .batch_size(batch_size)
XNNPACK Teamb455b122019-09-27 18:10:33 -070070 .inplace_b(true)
Marat Dukhan08b7a972020-07-14 18:17:29 -070071 .Test(xnn_qu8_vadd_minmax_ukernel__sse2);
XNNPACK Teamb455b122019-09-27 18:10:33 -070072 }
73 }
74
Marat Dukhan08b7a972020-07-14 18:17:29 -070075 TEST(QU8_VADD_MINMAX__SSE2, inplace_a_and_b) {
XNNPACK Teamb455b122019-09-27 18:10:33 -070076 TEST_REQUIRES_X86_SSE2;
Marat Dukhand9f3ad42020-08-10 12:30:58 -070077 for (size_t batch_size = 1; batch_size < 128; batch_size += 11) {
XNNPACK Teamb455b122019-09-27 18:10:33 -070078 VAddMicrokernelTester()
79 .iterations(1)
Marat Dukhand9f3ad42020-08-10 12:30:58 -070080 .batch_size(batch_size)
XNNPACK Teamb455b122019-09-27 18:10:33 -070081 .inplace_a(true)
82 .inplace_b(true)
Marat Dukhan08b7a972020-07-14 18:17:29 -070083 .Test(xnn_qu8_vadd_minmax_ukernel__sse2);
XNNPACK Teamb455b122019-09-27 18:10:33 -070084 }
85 }
86
Marat Dukhan08b7a972020-07-14 18:17:29 -070087 TEST(QU8_VADD_MINMAX__SSE2, a_scale) {
XNNPACK Teamb455b122019-09-27 18:10:33 -070088 TEST_REQUIRES_X86_SSE2;
Marat Dukhand9f3ad42020-08-10 12:30:58 -070089 for (size_t batch_size = 1; batch_size < 128; batch_size += 11) {
XNNPACK Teamb455b122019-09-27 18:10:33 -070090 for (float a_scale = 1.0e-2; a_scale < 1.0e+2; a_scale *= 1.7f) {
91 VAddMicrokernelTester()
92 .iterations(1)
Marat Dukhand9f3ad42020-08-10 12:30:58 -070093 .batch_size(batch_size)
XNNPACK Teamb455b122019-09-27 18:10:33 -070094 .a_scale(a_scale)
Marat Dukhan08b7a972020-07-14 18:17:29 -070095 .Test(xnn_qu8_vadd_minmax_ukernel__sse2);
XNNPACK Teamb455b122019-09-27 18:10:33 -070096 }
97 }
98 }
99
Marat Dukhan08b7a972020-07-14 18:17:29 -0700100 TEST(QU8_VADD_MINMAX__SSE2, b_scale) {
XNNPACK Teamb455b122019-09-27 18:10:33 -0700101 TEST_REQUIRES_X86_SSE2;
Marat Dukhand9f3ad42020-08-10 12:30:58 -0700102 for (size_t batch_size = 1; batch_size < 128; batch_size += 11) {
XNNPACK Teamb455b122019-09-27 18:10:33 -0700103 for (float b_scale = 1.0e-2; b_scale < 1.0e+2; b_scale *= 1.7f) {
104 VAddMicrokernelTester()
105 .iterations(1)
Marat Dukhand9f3ad42020-08-10 12:30:58 -0700106 .batch_size(batch_size)
XNNPACK Teamb455b122019-09-27 18:10:33 -0700107 .b_scale(b_scale)
Marat Dukhan08b7a972020-07-14 18:17:29 -0700108 .Test(xnn_qu8_vadd_minmax_ukernel__sse2);
XNNPACK Teamb455b122019-09-27 18:10:33 -0700109 }
110 }
111 }
112
Marat Dukhan08b7a972020-07-14 18:17:29 -0700113 TEST(QU8_VADD_MINMAX__SSE2, y_scale) {
XNNPACK Teamb455b122019-09-27 18:10:33 -0700114 TEST_REQUIRES_X86_SSE2;
Marat Dukhand9f3ad42020-08-10 12:30:58 -0700115 for (size_t batch_size = 1; batch_size < 128; batch_size += 11) {
XNNPACK Teamb455b122019-09-27 18:10:33 -0700116 for (float y_scale = 1.0e-2; y_scale < 1.0e+2; y_scale *= 1.7f) {
117 VAddMicrokernelTester()
118 .iterations(1)
Marat Dukhand9f3ad42020-08-10 12:30:58 -0700119 .batch_size(batch_size)
XNNPACK Teamb455b122019-09-27 18:10:33 -0700120 .y_scale(y_scale)
Marat Dukhan08b7a972020-07-14 18:17:29 -0700121 .Test(xnn_qu8_vadd_minmax_ukernel__sse2);
XNNPACK Teamb455b122019-09-27 18:10:33 -0700122 }
123 }
124 }
125
Marat Dukhan08b7a972020-07-14 18:17:29 -0700126 TEST(QU8_VADD_MINMAX__SSE2, a_zero_point) {
XNNPACK Teamb455b122019-09-27 18:10:33 -0700127 TEST_REQUIRES_X86_SSE2;
Marat Dukhand9f3ad42020-08-10 12:30:58 -0700128 for (size_t batch_size = 1; batch_size < 128; batch_size += 11) {
XNNPACK Teamb455b122019-09-27 18:10:33 -0700129 for (int32_t a_zero_point = 0; a_zero_point <= 255; a_zero_point += 51) {
130 VAddMicrokernelTester()
131 .iterations(1)
Marat Dukhand9f3ad42020-08-10 12:30:58 -0700132 .batch_size(batch_size)
XNNPACK Teamb455b122019-09-27 18:10:33 -0700133 .a_zero_point(uint8_t(a_zero_point))
Marat Dukhan08b7a972020-07-14 18:17:29 -0700134 .Test(xnn_qu8_vadd_minmax_ukernel__sse2);
XNNPACK Teamb455b122019-09-27 18:10:33 -0700135 }
136 }
137 }
138
Marat Dukhan08b7a972020-07-14 18:17:29 -0700139 TEST(QU8_VADD_MINMAX__SSE2, b_zero_point) {
XNNPACK Teamb455b122019-09-27 18:10:33 -0700140 TEST_REQUIRES_X86_SSE2;
Marat Dukhand9f3ad42020-08-10 12:30:58 -0700141 for (size_t batch_size = 1; batch_size < 128; batch_size += 11) {
XNNPACK Teamb455b122019-09-27 18:10:33 -0700142 for (int32_t b_zero_point = 0; b_zero_point <= 255; b_zero_point += 51) {
143 VAddMicrokernelTester()
144 .iterations(1)
Marat Dukhand9f3ad42020-08-10 12:30:58 -0700145 .batch_size(batch_size)
XNNPACK Teamb455b122019-09-27 18:10:33 -0700146 .b_zero_point(uint8_t(b_zero_point))
Marat Dukhan08b7a972020-07-14 18:17:29 -0700147 .Test(xnn_qu8_vadd_minmax_ukernel__sse2);
XNNPACK Teamb455b122019-09-27 18:10:33 -0700148 }
149 }
150 }
151
Marat Dukhan08b7a972020-07-14 18:17:29 -0700152 TEST(QU8_VADD_MINMAX__SSE2, y_zero_point) {
XNNPACK Teamb455b122019-09-27 18:10:33 -0700153 TEST_REQUIRES_X86_SSE2;
Marat Dukhand9f3ad42020-08-10 12:30:58 -0700154 for (size_t batch_size = 1; batch_size < 128; batch_size += 11) {
XNNPACK Teamb455b122019-09-27 18:10:33 -0700155 for (int32_t y_zero_point = 0; y_zero_point <= 255; y_zero_point += 51) {
156 VAddMicrokernelTester()
157 .iterations(1)
Marat Dukhand9f3ad42020-08-10 12:30:58 -0700158 .batch_size(batch_size)
XNNPACK Teamb455b122019-09-27 18:10:33 -0700159 .y_zero_point(uint8_t(y_zero_point))
Marat Dukhan08b7a972020-07-14 18:17:29 -0700160 .Test(xnn_qu8_vadd_minmax_ukernel__sse2);
XNNPACK Teamb455b122019-09-27 18:10:33 -0700161 }
162 }
163 }
164
Marat Dukhan08b7a972020-07-14 18:17:29 -0700165 TEST(QU8_VADD_MINMAX__SSE2, qmin) {
XNNPACK Teamb455b122019-09-27 18:10:33 -0700166 TEST_REQUIRES_X86_SSE2;
Marat Dukhand9f3ad42020-08-10 12:30:58 -0700167 for (size_t batch_size = 1; batch_size < 128; batch_size += 11) {
XNNPACK Teamb455b122019-09-27 18:10:33 -0700168 VAddMicrokernelTester()
169 .iterations(1)
Marat Dukhand9f3ad42020-08-10 12:30:58 -0700170 .batch_size(batch_size)
XNNPACK Teamb455b122019-09-27 18:10:33 -0700171 .qmin(128)
Marat Dukhan08b7a972020-07-14 18:17:29 -0700172 .Test(xnn_qu8_vadd_minmax_ukernel__sse2);
XNNPACK Teamb455b122019-09-27 18:10:33 -0700173 }
174 }
175
Marat Dukhan08b7a972020-07-14 18:17:29 -0700176 TEST(QU8_VADD_MINMAX__SSE2, qmax) {
XNNPACK Teamb455b122019-09-27 18:10:33 -0700177 TEST_REQUIRES_X86_SSE2;
Marat Dukhand9f3ad42020-08-10 12:30:58 -0700178 for (size_t batch_size = 1; batch_size < 128; batch_size += 11) {
XNNPACK Teamb455b122019-09-27 18:10:33 -0700179 VAddMicrokernelTester()
180 .iterations(1)
Marat Dukhand9f3ad42020-08-10 12:30:58 -0700181 .batch_size(batch_size)
XNNPACK Teamb455b122019-09-27 18:10:33 -0700182 .qmax(128)
Marat Dukhan08b7a972020-07-14 18:17:29 -0700183 .Test(xnn_qu8_vadd_minmax_ukernel__sse2);
XNNPACK Teamb455b122019-09-27 18:10:33 -0700184 }
185 }
Marat Dukhan1dadbf72019-10-01 10:46:20 -0700186#endif // XNN_ARCH_X86 || XNN_ARCH_X86_64
XNNPACK Teamb455b122019-09-27 18:10:33 -0700187
Marat Dukhan1dadbf72019-10-01 10:46:20 -0700188#if XNN_ARCH_ARM || XNN_ARCH_ARM64
Marat Dukhan08b7a972020-07-14 18:17:29 -0700189 TEST(QU8_VADD_MINMAX__NEON, n_eq_8) {
XNNPACK Teamb455b122019-09-27 18:10:33 -0700190 TEST_REQUIRES_ARM_NEON;
191 VAddMicrokernelTester()
Marat Dukhand9f3ad42020-08-10 12:30:58 -0700192 .batch_size(8)
Marat Dukhan08b7a972020-07-14 18:17:29 -0700193 .Test(xnn_qu8_vadd_minmax_ukernel__neon);
XNNPACK Teamb455b122019-09-27 18:10:33 -0700194 }
195
Marat Dukhan08b7a972020-07-14 18:17:29 -0700196 TEST(QU8_VADD_MINMAX__NEON, n_div_8) {
XNNPACK Teamb455b122019-09-27 18:10:33 -0700197 TEST_REQUIRES_ARM_NEON;
Marat Dukhand9f3ad42020-08-10 12:30:58 -0700198 for (size_t batch_size = 8; batch_size < 128; batch_size += 24) {
XNNPACK Teamb455b122019-09-27 18:10:33 -0700199 VAddMicrokernelTester()
Marat Dukhand9f3ad42020-08-10 12:30:58 -0700200 .batch_size(batch_size)
Marat Dukhan08b7a972020-07-14 18:17:29 -0700201 .Test(xnn_qu8_vadd_minmax_ukernel__neon);
XNNPACK Teamb455b122019-09-27 18:10:33 -0700202 }
203 }
204
Marat Dukhan08b7a972020-07-14 18:17:29 -0700205 TEST(QU8_VADD_MINMAX__NEON, n_gt_8) {
XNNPACK Teamb455b122019-09-27 18:10:33 -0700206 TEST_REQUIRES_ARM_NEON;
Marat Dukhand9f3ad42020-08-10 12:30:58 -0700207 for (size_t batch_size = 9; batch_size < 16; batch_size++) {
XNNPACK Teamb455b122019-09-27 18:10:33 -0700208 VAddMicrokernelTester()
Marat Dukhand9f3ad42020-08-10 12:30:58 -0700209 .batch_size(batch_size)
Marat Dukhan08b7a972020-07-14 18:17:29 -0700210 .Test(xnn_qu8_vadd_minmax_ukernel__neon);
XNNPACK Teamb455b122019-09-27 18:10:33 -0700211 }
212 }
213
Marat Dukhan08b7a972020-07-14 18:17:29 -0700214 TEST(QU8_VADD_MINMAX__NEON, n_lt_8) {
XNNPACK Teamb455b122019-09-27 18:10:33 -0700215 TEST_REQUIRES_ARM_NEON;
Marat Dukhand9f3ad42020-08-10 12:30:58 -0700216 for (size_t batch_size = 1; batch_size < 8; batch_size++) {
XNNPACK Teamb455b122019-09-27 18:10:33 -0700217 VAddMicrokernelTester()
Marat Dukhand9f3ad42020-08-10 12:30:58 -0700218 .batch_size(batch_size)
Marat Dukhan08b7a972020-07-14 18:17:29 -0700219 .Test(xnn_qu8_vadd_minmax_ukernel__neon);
XNNPACK Teamb455b122019-09-27 18:10:33 -0700220 }
221 }
222
Marat Dukhan08b7a972020-07-14 18:17:29 -0700223 TEST(QU8_VADD_MINMAX__NEON, inplace_a) {
XNNPACK Teamb455b122019-09-27 18:10:33 -0700224 TEST_REQUIRES_ARM_NEON;
Marat Dukhand9f3ad42020-08-10 12:30:58 -0700225 for (size_t batch_size = 1; batch_size < 128; batch_size += 11) {
XNNPACK Teamb455b122019-09-27 18:10:33 -0700226 VAddMicrokernelTester()
227 .iterations(1)
Marat Dukhand9f3ad42020-08-10 12:30:58 -0700228 .batch_size(batch_size)
XNNPACK Teamb455b122019-09-27 18:10:33 -0700229 .inplace_a(true)
Marat Dukhan08b7a972020-07-14 18:17:29 -0700230 .Test(xnn_qu8_vadd_minmax_ukernel__neon);
XNNPACK Teamb455b122019-09-27 18:10:33 -0700231 }
232 }
233
Marat Dukhan08b7a972020-07-14 18:17:29 -0700234 TEST(QU8_VADD_MINMAX__NEON, inplace_b) {
XNNPACK Teamb455b122019-09-27 18:10:33 -0700235 TEST_REQUIRES_ARM_NEON;
Marat Dukhand9f3ad42020-08-10 12:30:58 -0700236 for (size_t batch_size = 1; batch_size < 128; batch_size += 11) {
XNNPACK Teamb455b122019-09-27 18:10:33 -0700237 VAddMicrokernelTester()
238 .iterations(1)
Marat Dukhand9f3ad42020-08-10 12:30:58 -0700239 .batch_size(batch_size)
XNNPACK Teamb455b122019-09-27 18:10:33 -0700240 .inplace_b(true)
Marat Dukhan08b7a972020-07-14 18:17:29 -0700241 .Test(xnn_qu8_vadd_minmax_ukernel__neon);
XNNPACK Teamb455b122019-09-27 18:10:33 -0700242 }
243 }
244
Marat Dukhan08b7a972020-07-14 18:17:29 -0700245 TEST(QU8_VADD_MINMAX__NEON, inplace_a_and_b) {
XNNPACK Teamb455b122019-09-27 18:10:33 -0700246 TEST_REQUIRES_ARM_NEON;
Marat Dukhand9f3ad42020-08-10 12:30:58 -0700247 for (size_t batch_size = 1; batch_size < 128; batch_size += 11) {
XNNPACK Teamb455b122019-09-27 18:10:33 -0700248 VAddMicrokernelTester()
249 .iterations(1)
Marat Dukhand9f3ad42020-08-10 12:30:58 -0700250 .batch_size(batch_size)
XNNPACK Teamb455b122019-09-27 18:10:33 -0700251 .inplace_a(true)
252 .inplace_b(true)
Marat Dukhan08b7a972020-07-14 18:17:29 -0700253 .Test(xnn_qu8_vadd_minmax_ukernel__neon);
XNNPACK Teamb455b122019-09-27 18:10:33 -0700254 }
255 }
256
Marat Dukhan08b7a972020-07-14 18:17:29 -0700257 TEST(QU8_VADD_MINMAX__NEON, a_scale) {
XNNPACK Teamb455b122019-09-27 18:10:33 -0700258 TEST_REQUIRES_ARM_NEON;
Marat Dukhand9f3ad42020-08-10 12:30:58 -0700259 for (size_t batch_size = 1; batch_size < 128; batch_size += 11) {
XNNPACK Teamb455b122019-09-27 18:10:33 -0700260 for (float a_scale = 1.0e-2; a_scale < 1.0e+2; a_scale *= 1.7f) {
261 VAddMicrokernelTester()
262 .iterations(1)
Marat Dukhand9f3ad42020-08-10 12:30:58 -0700263 .batch_size(batch_size)
XNNPACK Teamb455b122019-09-27 18:10:33 -0700264 .a_scale(a_scale)
Marat Dukhan08b7a972020-07-14 18:17:29 -0700265 .Test(xnn_qu8_vadd_minmax_ukernel__neon);
XNNPACK Teamb455b122019-09-27 18:10:33 -0700266 }
267 }
268 }
269
Marat Dukhan08b7a972020-07-14 18:17:29 -0700270 TEST(QU8_VADD_MINMAX__NEON, b_scale) {
XNNPACK Teamb455b122019-09-27 18:10:33 -0700271 TEST_REQUIRES_ARM_NEON;
Marat Dukhand9f3ad42020-08-10 12:30:58 -0700272 for (size_t batch_size = 1; batch_size < 128; batch_size += 11) {
XNNPACK Teamb455b122019-09-27 18:10:33 -0700273 for (float b_scale = 1.0e-2; b_scale < 1.0e+2; b_scale *= 1.7f) {
274 VAddMicrokernelTester()
275 .iterations(1)
Marat Dukhand9f3ad42020-08-10 12:30:58 -0700276 .batch_size(batch_size)
XNNPACK Teamb455b122019-09-27 18:10:33 -0700277 .b_scale(b_scale)
Marat Dukhan08b7a972020-07-14 18:17:29 -0700278 .Test(xnn_qu8_vadd_minmax_ukernel__neon);
XNNPACK Teamb455b122019-09-27 18:10:33 -0700279 }
280 }
281 }
282
Marat Dukhan08b7a972020-07-14 18:17:29 -0700283 TEST(QU8_VADD_MINMAX__NEON, y_scale) {
XNNPACK Teamb455b122019-09-27 18:10:33 -0700284 TEST_REQUIRES_ARM_NEON;
Marat Dukhand9f3ad42020-08-10 12:30:58 -0700285 for (size_t batch_size = 1; batch_size < 128; batch_size += 11) {
XNNPACK Teamb455b122019-09-27 18:10:33 -0700286 for (float y_scale = 1.0e-2; y_scale < 1.0e+2; y_scale *= 1.7f) {
287 VAddMicrokernelTester()
288 .iterations(1)
Marat Dukhand9f3ad42020-08-10 12:30:58 -0700289 .batch_size(batch_size)
XNNPACK Teamb455b122019-09-27 18:10:33 -0700290 .y_scale(y_scale)
Marat Dukhan08b7a972020-07-14 18:17:29 -0700291 .Test(xnn_qu8_vadd_minmax_ukernel__neon);
XNNPACK Teamb455b122019-09-27 18:10:33 -0700292 }
293 }
294 }
295
Marat Dukhan08b7a972020-07-14 18:17:29 -0700296 TEST(QU8_VADD_MINMAX__NEON, a_zero_point) {
XNNPACK Teamb455b122019-09-27 18:10:33 -0700297 TEST_REQUIRES_ARM_NEON;
Marat Dukhand9f3ad42020-08-10 12:30:58 -0700298 for (size_t batch_size = 1; batch_size < 128; batch_size += 11) {
XNNPACK Teamb455b122019-09-27 18:10:33 -0700299 for (int32_t a_zero_point = 0; a_zero_point <= 255; a_zero_point += 51) {
300 VAddMicrokernelTester()
301 .iterations(1)
Marat Dukhand9f3ad42020-08-10 12:30:58 -0700302 .batch_size(batch_size)
XNNPACK Teamb455b122019-09-27 18:10:33 -0700303 .a_zero_point(uint8_t(a_zero_point))
Marat Dukhan08b7a972020-07-14 18:17:29 -0700304 .Test(xnn_qu8_vadd_minmax_ukernel__neon);
XNNPACK Teamb455b122019-09-27 18:10:33 -0700305 }
306 }
307 }
308
Marat Dukhan08b7a972020-07-14 18:17:29 -0700309 TEST(QU8_VADD_MINMAX__NEON, b_zero_point) {
XNNPACK Teamb455b122019-09-27 18:10:33 -0700310 TEST_REQUIRES_ARM_NEON;
Marat Dukhand9f3ad42020-08-10 12:30:58 -0700311 for (size_t batch_size = 1; batch_size < 128; batch_size += 11) {
XNNPACK Teamb455b122019-09-27 18:10:33 -0700312 for (int32_t b_zero_point = 0; b_zero_point <= 255; b_zero_point += 51) {
313 VAddMicrokernelTester()
314 .iterations(1)
Marat Dukhand9f3ad42020-08-10 12:30:58 -0700315 .batch_size(batch_size)
XNNPACK Teamb455b122019-09-27 18:10:33 -0700316 .b_zero_point(uint8_t(b_zero_point))
Marat Dukhan08b7a972020-07-14 18:17:29 -0700317 .Test(xnn_qu8_vadd_minmax_ukernel__neon);
XNNPACK Teamb455b122019-09-27 18:10:33 -0700318 }
319 }
320 }
321
Marat Dukhan08b7a972020-07-14 18:17:29 -0700322 TEST(QU8_VADD_MINMAX__NEON, y_zero_point) {
XNNPACK Teamb455b122019-09-27 18:10:33 -0700323 TEST_REQUIRES_ARM_NEON;
Marat Dukhand9f3ad42020-08-10 12:30:58 -0700324 for (size_t batch_size = 1; batch_size < 128; batch_size += 11) {
XNNPACK Teamb455b122019-09-27 18:10:33 -0700325 for (int32_t y_zero_point = 0; y_zero_point <= 255; y_zero_point += 51) {
326 VAddMicrokernelTester()
327 .iterations(1)
Marat Dukhand9f3ad42020-08-10 12:30:58 -0700328 .batch_size(batch_size)
XNNPACK Teamb455b122019-09-27 18:10:33 -0700329 .y_zero_point(uint8_t(y_zero_point))
Marat Dukhan08b7a972020-07-14 18:17:29 -0700330 .Test(xnn_qu8_vadd_minmax_ukernel__neon);
XNNPACK Teamb455b122019-09-27 18:10:33 -0700331 }
332 }
333 }
334
Marat Dukhan08b7a972020-07-14 18:17:29 -0700335 TEST(QU8_VADD_MINMAX__NEON, qmin) {
XNNPACK Teamb455b122019-09-27 18:10:33 -0700336 TEST_REQUIRES_ARM_NEON;
Marat Dukhand9f3ad42020-08-10 12:30:58 -0700337 for (size_t batch_size = 1; batch_size < 128; batch_size += 11) {
XNNPACK Teamb455b122019-09-27 18:10:33 -0700338 VAddMicrokernelTester()
339 .iterations(1)
Marat Dukhand9f3ad42020-08-10 12:30:58 -0700340 .batch_size(batch_size)
XNNPACK Teamb455b122019-09-27 18:10:33 -0700341 .qmin(128)
Marat Dukhan08b7a972020-07-14 18:17:29 -0700342 .Test(xnn_qu8_vadd_minmax_ukernel__neon);
XNNPACK Teamb455b122019-09-27 18:10:33 -0700343 }
344 }
345
Marat Dukhan08b7a972020-07-14 18:17:29 -0700346 TEST(QU8_VADD_MINMAX__NEON, qmax) {
XNNPACK Teamb455b122019-09-27 18:10:33 -0700347 TEST_REQUIRES_ARM_NEON;
Marat Dukhand9f3ad42020-08-10 12:30:58 -0700348 for (size_t batch_size = 1; batch_size < 128; batch_size += 11) {
XNNPACK Teamb455b122019-09-27 18:10:33 -0700349 VAddMicrokernelTester()
350 .iterations(1)
Marat Dukhand9f3ad42020-08-10 12:30:58 -0700351 .batch_size(batch_size)
XNNPACK Teamb455b122019-09-27 18:10:33 -0700352 .qmax(128)
Marat Dukhan08b7a972020-07-14 18:17:29 -0700353 .Test(xnn_qu8_vadd_minmax_ukernel__neon);
XNNPACK Teamb455b122019-09-27 18:10:33 -0700354 }
355 }
Marat Dukhan1dadbf72019-10-01 10:46:20 -0700356#endif // XNN_ARCH_ARM || XNN_ARCH_ARM64
XNNPACK Teamb455b122019-09-27 18:10:33 -0700357
Marat Dukhan08b7a972020-07-14 18:17:29 -0700358TEST(QU8_VADD_MINMAX__SCALAR, n_eq_1) {
XNNPACK Teamb455b122019-09-27 18:10:33 -0700359 VAddMicrokernelTester()
Marat Dukhand9f3ad42020-08-10 12:30:58 -0700360 .batch_size(1)
Marat Dukhan08b7a972020-07-14 18:17:29 -0700361 .Test(xnn_qu8_vadd_minmax_ukernel__scalar, VAddMicrokernelTester::Variant::Scalar);
XNNPACK Teamb455b122019-09-27 18:10:33 -0700362}
363
Marat Dukhan08b7a972020-07-14 18:17:29 -0700364TEST(QU8_VADD_MINMAX__SCALAR, n_gt_1) {
Marat Dukhand9f3ad42020-08-10 12:30:58 -0700365 for (size_t batch_size = 2; batch_size < 8; batch_size++) {
XNNPACK Teamb455b122019-09-27 18:10:33 -0700366 VAddMicrokernelTester()
Marat Dukhand9f3ad42020-08-10 12:30:58 -0700367 .batch_size(batch_size)
Marat Dukhan08b7a972020-07-14 18:17:29 -0700368 .Test(xnn_qu8_vadd_minmax_ukernel__scalar, VAddMicrokernelTester::Variant::Scalar);
XNNPACK Teamb455b122019-09-27 18:10:33 -0700369 }
370}
371
Marat Dukhan08b7a972020-07-14 18:17:29 -0700372TEST(QU8_VADD_MINMAX__SCALAR, inplace_a) {
Marat Dukhand9f3ad42020-08-10 12:30:58 -0700373 for (size_t batch_size = 1; batch_size < 16; batch_size += 3) {
XNNPACK Teamb455b122019-09-27 18:10:33 -0700374 VAddMicrokernelTester()
375 .iterations(1)
Marat Dukhand9f3ad42020-08-10 12:30:58 -0700376 .batch_size(batch_size)
XNNPACK Teamb455b122019-09-27 18:10:33 -0700377 .inplace_a(true)
Marat Dukhan08b7a972020-07-14 18:17:29 -0700378 .Test(xnn_qu8_vadd_minmax_ukernel__scalar, VAddMicrokernelTester::Variant::Scalar);
XNNPACK Teamb455b122019-09-27 18:10:33 -0700379 }
380}
381
Marat Dukhan08b7a972020-07-14 18:17:29 -0700382TEST(QU8_VADD_MINMAX__SCALAR, inplace_b) {
Marat Dukhand9f3ad42020-08-10 12:30:58 -0700383 for (size_t batch_size = 1; batch_size < 16; batch_size += 3) {
XNNPACK Teamb455b122019-09-27 18:10:33 -0700384 VAddMicrokernelTester()
385 .iterations(1)
Marat Dukhand9f3ad42020-08-10 12:30:58 -0700386 .batch_size(batch_size)
XNNPACK Teamb455b122019-09-27 18:10:33 -0700387 .inplace_b(true)
Marat Dukhan08b7a972020-07-14 18:17:29 -0700388 .Test(xnn_qu8_vadd_minmax_ukernel__scalar, VAddMicrokernelTester::Variant::Scalar);
XNNPACK Teamb455b122019-09-27 18:10:33 -0700389 }
390}
391
Marat Dukhan08b7a972020-07-14 18:17:29 -0700392TEST(QU8_VADD_MINMAX__SCALAR, inplace_a_and_b) {
Marat Dukhand9f3ad42020-08-10 12:30:58 -0700393 for (size_t batch_size = 1; batch_size < 16; batch_size += 3) {
XNNPACK Teamb455b122019-09-27 18:10:33 -0700394 VAddMicrokernelTester()
395 .iterations(1)
Marat Dukhand9f3ad42020-08-10 12:30:58 -0700396 .batch_size(batch_size)
XNNPACK Teamb455b122019-09-27 18:10:33 -0700397 .inplace_a(true)
398 .inplace_b(true)
Marat Dukhan08b7a972020-07-14 18:17:29 -0700399 .Test(xnn_qu8_vadd_minmax_ukernel__scalar, VAddMicrokernelTester::Variant::Scalar);
XNNPACK Teamb455b122019-09-27 18:10:33 -0700400 }
401}
402
Marat Dukhan08b7a972020-07-14 18:17:29 -0700403TEST(QU8_VADD_MINMAX__SCALAR, a_scale) {
Marat Dukhand9f3ad42020-08-10 12:30:58 -0700404 for (size_t batch_size = 1; batch_size < 16; batch_size += 3) {
XNNPACK Teamb455b122019-09-27 18:10:33 -0700405 for (float a_scale = 1.0e-2; a_scale < 1.0e+2; a_scale *= 1.7f) {
406 VAddMicrokernelTester()
407 .iterations(1)
Marat Dukhand9f3ad42020-08-10 12:30:58 -0700408 .batch_size(batch_size)
XNNPACK Teamb455b122019-09-27 18:10:33 -0700409 .a_scale(a_scale)
Marat Dukhan08b7a972020-07-14 18:17:29 -0700410 .Test(xnn_qu8_vadd_minmax_ukernel__scalar, VAddMicrokernelTester::Variant::Scalar);
XNNPACK Teamb455b122019-09-27 18:10:33 -0700411 }
412 }
413}
414
Marat Dukhan08b7a972020-07-14 18:17:29 -0700415TEST(QU8_VADD_MINMAX__SCALAR, b_scale) {
Marat Dukhand9f3ad42020-08-10 12:30:58 -0700416 for (size_t batch_size = 1; batch_size < 16; batch_size += 3) {
XNNPACK Teamb455b122019-09-27 18:10:33 -0700417 for (float b_scale = 1.0e-2; b_scale < 1.0e+2; b_scale *= 1.7f) {
418 VAddMicrokernelTester()
419 .iterations(1)
Marat Dukhand9f3ad42020-08-10 12:30:58 -0700420 .batch_size(batch_size)
XNNPACK Teamb455b122019-09-27 18:10:33 -0700421 .b_scale(b_scale)
Marat Dukhan08b7a972020-07-14 18:17:29 -0700422 .Test(xnn_qu8_vadd_minmax_ukernel__scalar, VAddMicrokernelTester::Variant::Scalar);
XNNPACK Teamb455b122019-09-27 18:10:33 -0700423 }
424 }
425}
426
Marat Dukhan08b7a972020-07-14 18:17:29 -0700427TEST(QU8_VADD_MINMAX__SCALAR, y_scale) {
Marat Dukhand9f3ad42020-08-10 12:30:58 -0700428 for (size_t batch_size = 1; batch_size < 16; batch_size += 3) {
XNNPACK Teamb455b122019-09-27 18:10:33 -0700429 for (float y_scale = 1.0e-2; y_scale < 1.0e+2; y_scale *= 1.7f) {
430 VAddMicrokernelTester()
431 .iterations(1)
Marat Dukhand9f3ad42020-08-10 12:30:58 -0700432 .batch_size(batch_size)
XNNPACK Teamb455b122019-09-27 18:10:33 -0700433 .y_scale(y_scale)
Marat Dukhan08b7a972020-07-14 18:17:29 -0700434 .Test(xnn_qu8_vadd_minmax_ukernel__scalar, VAddMicrokernelTester::Variant::Scalar);
XNNPACK Teamb455b122019-09-27 18:10:33 -0700435 }
436 }
437}
438
Marat Dukhan08b7a972020-07-14 18:17:29 -0700439TEST(QU8_VADD_MINMAX__SCALAR, a_zero_point) {
Marat Dukhand9f3ad42020-08-10 12:30:58 -0700440 for (size_t batch_size = 1; batch_size < 16; batch_size += 3) {
XNNPACK Teamb455b122019-09-27 18:10:33 -0700441 for (int32_t a_zero_point = 0; a_zero_point <= 255; a_zero_point += 51) {
442 VAddMicrokernelTester()
443 .iterations(1)
Marat Dukhand9f3ad42020-08-10 12:30:58 -0700444 .batch_size(batch_size)
XNNPACK Teamb455b122019-09-27 18:10:33 -0700445 .a_zero_point(uint8_t(a_zero_point))
Marat Dukhan08b7a972020-07-14 18:17:29 -0700446 .Test(xnn_qu8_vadd_minmax_ukernel__scalar, VAddMicrokernelTester::Variant::Scalar);
XNNPACK Teamb455b122019-09-27 18:10:33 -0700447 }
448 }
449}
450
Marat Dukhan08b7a972020-07-14 18:17:29 -0700451TEST(QU8_VADD_MINMAX__SCALAR, b_zero_point) {
Marat Dukhand9f3ad42020-08-10 12:30:58 -0700452 for (size_t batch_size = 1; batch_size < 16; batch_size += 3) {
XNNPACK Teamb455b122019-09-27 18:10:33 -0700453 for (int32_t b_zero_point = 0; b_zero_point <= 255; b_zero_point += 51) {
454 VAddMicrokernelTester()
455 .iterations(1)
Marat Dukhand9f3ad42020-08-10 12:30:58 -0700456 .batch_size(batch_size)
XNNPACK Teamb455b122019-09-27 18:10:33 -0700457 .b_zero_point(uint8_t(b_zero_point))
Marat Dukhan08b7a972020-07-14 18:17:29 -0700458 .Test(xnn_qu8_vadd_minmax_ukernel__scalar, VAddMicrokernelTester::Variant::Scalar);
XNNPACK Teamb455b122019-09-27 18:10:33 -0700459 }
460 }
461}
462
Marat Dukhan08b7a972020-07-14 18:17:29 -0700463TEST(QU8_VADD_MINMAX__SCALAR, y_zero_point) {
Marat Dukhand9f3ad42020-08-10 12:30:58 -0700464 for (size_t batch_size = 1; batch_size < 16; batch_size += 3) {
XNNPACK Teamb455b122019-09-27 18:10:33 -0700465 for (int32_t y_zero_point = 0; y_zero_point <= 255; y_zero_point += 51) {
466 VAddMicrokernelTester()
467 .iterations(1)
Marat Dukhand9f3ad42020-08-10 12:30:58 -0700468 .batch_size(batch_size)
XNNPACK Teamb455b122019-09-27 18:10:33 -0700469 .y_zero_point(uint8_t(y_zero_point))
Marat Dukhan08b7a972020-07-14 18:17:29 -0700470 .Test(xnn_qu8_vadd_minmax_ukernel__scalar, VAddMicrokernelTester::Variant::Scalar);
XNNPACK Teamb455b122019-09-27 18:10:33 -0700471 }
472 }
473}
474
Marat Dukhan08b7a972020-07-14 18:17:29 -0700475TEST(QU8_VADD_MINMAX__SCALAR, qmin) {
Marat Dukhand9f3ad42020-08-10 12:30:58 -0700476 for (size_t batch_size = 1; batch_size < 16; batch_size += 3) {
XNNPACK Teamb455b122019-09-27 18:10:33 -0700477 VAddMicrokernelTester()
478 .iterations(1)
Marat Dukhand9f3ad42020-08-10 12:30:58 -0700479 .batch_size(batch_size)
XNNPACK Teamb455b122019-09-27 18:10:33 -0700480 .qmin(128)
Marat Dukhan08b7a972020-07-14 18:17:29 -0700481 .Test(xnn_qu8_vadd_minmax_ukernel__scalar, VAddMicrokernelTester::Variant::Scalar);
XNNPACK Teamb455b122019-09-27 18:10:33 -0700482 }
483}
484
Marat Dukhan08b7a972020-07-14 18:17:29 -0700485TEST(QU8_VADD_MINMAX__SCALAR, qmax) {
Marat Dukhand9f3ad42020-08-10 12:30:58 -0700486 for (size_t batch_size = 1; batch_size < 16; batch_size += 3) {
XNNPACK Teamb455b122019-09-27 18:10:33 -0700487 VAddMicrokernelTester()
488 .iterations(1)
Marat Dukhand9f3ad42020-08-10 12:30:58 -0700489 .batch_size(batch_size)
XNNPACK Teamb455b122019-09-27 18:10:33 -0700490 .qmax(128)
Marat Dukhan08b7a972020-07-14 18:17:29 -0700491 .Test(xnn_qu8_vadd_minmax_ukernel__scalar, VAddMicrokernelTester::Variant::Scalar);
XNNPACK Teamb455b122019-09-27 18:10:33 -0700492 }
493}