| 1 | // Copyright 2022 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 | // Auto-generated file. Do not edit! |
| 7 | // Microkernel: qu8-dwconv-minmax-multipass-rndnu |
| 8 | // Generator: tools/generate-dwconv-multipass-test.py |
| 9 | |
| 10 | |
| 11 | #include <algorithm> |
| 12 | #include <cstddef> |
| 13 | #include <functional> |
| 14 | #include <string> |
| 15 | #include <vector> |
| 16 | |
| 17 | #include <gtest/gtest.h> |
| 18 | #include "xnnpack/common.h" |
| 19 | #include "xnnpack/dwconv.h" |
| 20 | #include "xnnpack/isa-checks.h" |
| 21 | #include "xnnpack/microparams-init.h" |
| 22 | #include "xnnpack/requantization.h" |
| 23 | #include "dwconv-microkernel-tester.h" |
| 24 | #include "next_prime.h" |
| 25 | |
| 26 | namespace { |
| 27 | |
| 28 | std::vector<DWConvTestParams> CreateTests( |
| 29 | size_t c_block, size_t cr, size_t kr, |
| 30 | size_t first_pass_tile, size_t middle_pass_tile, size_t last_pass_tile, |
| 31 | size_t channel_subtile, size_t channel_round, |
| 32 | std::function<void(DWConvMicrokernelTester& tester)> test_func, |
| 33 | std::function<void()> isa_check = nullptr) { |
| 34 | const std::string cbs = std::to_string(c_block); |
| 35 | |
| 36 | std::vector<DWConvTestParams> tests; |
| 37 | tests.reserve(17); |
| 38 | |
| 39 | tests.push_back(DWConvTestParams( |
| 40 | "c_eq_" + cbs + "_first_pass_plus_one", |
| 41 | DWConvMicrokernelTester() |
| 42 | .first_pass_tile(first_pass_tile) |
| 43 | .middle_pass_tile(middle_pass_tile) |
| 44 | .last_pass_tile(last_pass_tile) |
| 45 | .channel_tile(cr) |
| 46 | .channel_subtile(channel_subtile) |
| 47 | .channel_round(channel_round) |
| 48 | .kernel_size(first_pass_tile + 1) |
| 49 | .channels(c_block) |
| 50 | , test_func, isa_check)); |
| 51 | |
| 52 | tests.push_back(DWConvTestParams( |
| 53 | "c_eq_" + cbs + "_first_pass_and_last_pass", |
| 54 | DWConvMicrokernelTester() |
| 55 | .first_pass_tile(first_pass_tile) |
| 56 | .middle_pass_tile(middle_pass_tile) |
| 57 | .last_pass_tile(last_pass_tile) |
| 58 | .channel_tile(cr) |
| 59 | .channel_subtile(channel_subtile) |
| 60 | .channel_round(channel_round) |
| 61 | .kernel_size(first_pass_tile + last_pass_tile) |
| 62 | .channels(c_block) |
| 63 | , test_func, isa_check)); |
| 64 | |
| 65 | tests.push_back(DWConvTestParams( |
| 66 | "c_eq_" + cbs + "_multipass", |
| 67 | DWConvMicrokernelTester() |
| 68 | .first_pass_tile(first_pass_tile) |
| 69 | .middle_pass_tile(middle_pass_tile) |
| 70 | .last_pass_tile(last_pass_tile) |
| 71 | .channel_tile(cr) |
| 72 | .channel_subtile(channel_subtile) |
| 73 | .channel_round(channel_round) |
| 74 | .channels(c_block) |
| 75 | , test_func, isa_check) |
| 76 | .loop_kernel_size( |
| 77 | first_pass_tile + middle_pass_tile + last_pass_tile, |
| 78 | first_pass_tile + middle_pass_tile * 2 + last_pass_tile)); |
| 79 | |
| 80 | if (c_block > 1) { |
| 81 | tests.push_back(DWConvTestParams( |
| 82 | "c_div_" + cbs + "_first_pass_plus_one", |
| 83 | DWConvMicrokernelTester() |
| 84 | .first_pass_tile(first_pass_tile) |
| 85 | .middle_pass_tile(middle_pass_tile) |
| 86 | .last_pass_tile(last_pass_tile) |
| 87 | .channel_tile(cr) |
| 88 | .channel_subtile(channel_subtile) |
| 89 | .channel_round(channel_round) |
| 90 | .kernel_size(first_pass_tile + 1) |
| 91 | , test_func, isa_check) |
| 92 | .loop_channels(c_block * 2, cr * 16, cr * 3)); |
| 93 | |
| 94 | tests.push_back(DWConvTestParams( |
| 95 | "c_div_" + cbs + "_first_pass_and_last_pass", |
| 96 | DWConvMicrokernelTester() |
| 97 | .first_pass_tile(first_pass_tile) |
| 98 | .middle_pass_tile(middle_pass_tile) |
| 99 | .last_pass_tile(last_pass_tile) |
| 100 | .channel_tile(cr) |
| 101 | .channel_subtile(channel_subtile) |
| 102 | .channel_round(channel_round) |
| 103 | .kernel_size(first_pass_tile + last_pass_tile) |
| 104 | , test_func, isa_check) |
| 105 | .loop_channels(c_block * 2, cr * 16, cr * 3)); |
| 106 | |
| 107 | tests.push_back(DWConvTestParams( |
| 108 | "c_div_" + cbs + "_multipass", |
| 109 | DWConvMicrokernelTester() |
| 110 | .first_pass_tile(first_pass_tile) |
| 111 | .middle_pass_tile(middle_pass_tile) |
| 112 | .last_pass_tile(last_pass_tile) |
| 113 | .channel_tile(cr) |
| 114 | .channel_subtile(channel_subtile) |
| 115 | .channel_round(channel_round) |
| 116 | , test_func, isa_check) |
| 117 | .loop_channels(c_block * 2, cr * 16, cr * 3) |
| 118 | .loop_kernel_size( |
| 119 | first_pass_tile + middle_pass_tile + last_pass_tile, |
| 120 | first_pass_tile + middle_pass_tile * 2 + last_pass_tile)); |
| 121 | |
| 122 | tests.push_back(DWConvTestParams( |
| 123 | "c_div_" + cbs + "_with_qmin", |
| 124 | DWConvMicrokernelTester() |
| 125 | .first_pass_tile(first_pass_tile) |
| 126 | .middle_pass_tile(middle_pass_tile) |
| 127 | .last_pass_tile(last_pass_tile) |
| 128 | .channel_tile(cr) |
| 129 | .channel_subtile(channel_subtile) |
| 130 | .channel_round(channel_round) |
| 131 | .kernel_size(first_pass_tile + last_pass_tile) |
| 132 | .qmin(128) |
| 133 | , test_func, isa_check) |
| 134 | .loop_channels(c_block * 2, cr * 16, cr * 3)); |
| 135 | |
| 136 | tests.push_back(DWConvTestParams( |
| 137 | "c_div_" + cbs + "_with_qmax", |
| 138 | DWConvMicrokernelTester() |
| 139 | .first_pass_tile(first_pass_tile) |
| 140 | .middle_pass_tile(middle_pass_tile) |
| 141 | .last_pass_tile(last_pass_tile) |
| 142 | .channel_tile(cr) |
| 143 | .channel_subtile(channel_subtile) |
| 144 | .channel_round(channel_round) |
| 145 | .kernel_size(first_pass_tile + last_pass_tile) |
| 146 | .qmax(128) |
| 147 | , test_func, isa_check) |
| 148 | .loop_channels(c_block * 2, cr * 16, cr * 3)); |
| 149 | } |
| 150 | |
| 151 | tests.push_back(DWConvTestParams( |
| 152 | "c_gt_" + cbs + "_first_pass_plus_one", |
| 153 | DWConvMicrokernelTester() |
| 154 | .first_pass_tile(first_pass_tile) |
| 155 | .middle_pass_tile(middle_pass_tile) |
| 156 | .last_pass_tile(last_pass_tile) |
| 157 | .channel_tile(cr) |
| 158 | .channel_subtile(channel_subtile) |
| 159 | .channel_round(channel_round) |
| 160 | .kernel_size(first_pass_tile + 1) |
| 161 | , test_func, isa_check) |
| 162 | .loop_channels(c_block + 1, c_block == 1 ? 10 : c_block * 2)); |
| 163 | |
| 164 | tests.push_back(DWConvTestParams( |
| 165 | "c_gt_" + cbs + "_first_pass_and_last_pass", |
| 166 | DWConvMicrokernelTester() |
| 167 | .first_pass_tile(first_pass_tile) |
| 168 | .middle_pass_tile(middle_pass_tile) |
| 169 | .last_pass_tile(last_pass_tile) |
| 170 | .channel_tile(cr) |
| 171 | .channel_subtile(channel_subtile) |
| 172 | .channel_round(channel_round) |
| 173 | .kernel_size(first_pass_tile + last_pass_tile) |
| 174 | , test_func, isa_check) |
| 175 | .loop_channels(c_block + 1, c_block == 1 ? 10 : c_block * 2)); |
| 176 | |
| 177 | tests.push_back(DWConvTestParams( |
| 178 | "c_gt_" + cbs + "_multipass", |
| 179 | DWConvMicrokernelTester() |
| 180 | .first_pass_tile(first_pass_tile) |
| 181 | .middle_pass_tile(middle_pass_tile) |
| 182 | .last_pass_tile(last_pass_tile) |
| 183 | .channel_tile(cr) |
| 184 | .channel_subtile(channel_subtile) |
| 185 | .channel_round(channel_round) |
| 186 | , test_func, isa_check) |
| 187 | .loop_channels(c_block + 1, c_block == 1 ? 10 : c_block * 2) |
| 188 | .loop_kernel_size( |
| 189 | first_pass_tile + middle_pass_tile + last_pass_tile, |
| 190 | first_pass_tile + middle_pass_tile * 2 + last_pass_tile)); |
| 191 | |
| 192 | tests.push_back(DWConvTestParams( |
| 193 | "c_eq_" + cbs + "_first_pass_plus_one_multipixel", |
| 194 | DWConvMicrokernelTester() |
| 195 | .first_pass_tile(first_pass_tile) |
| 196 | .middle_pass_tile(middle_pass_tile) |
| 197 | .last_pass_tile(last_pass_tile) |
| 198 | .channel_tile(cr) |
| 199 | .channel_subtile(channel_subtile) |
| 200 | .channel_round(channel_round) |
| 201 | .kernel_size(first_pass_tile + 1) |
| 202 | .width(3) |
| 203 | , test_func, isa_check) |
| 204 | .loop_channels(1, c_block * 5 + 1, std::max(size_t(1), c_block - 1))); |
| 205 | |
| 206 | tests.push_back(DWConvTestParams( |
| 207 | "c_eq_" + cbs + "_first_pass_and_last_pass_multipixel", |
| 208 | DWConvMicrokernelTester() |
| 209 | .first_pass_tile(first_pass_tile) |
| 210 | .middle_pass_tile(middle_pass_tile) |
| 211 | .last_pass_tile(last_pass_tile) |
| 212 | .channel_tile(cr) |
| 213 | .channel_subtile(channel_subtile) |
| 214 | .channel_round(channel_round) |
| 215 | .kernel_size(first_pass_tile + last_pass_tile) |
| 216 | .width(3) |
| 217 | , test_func, isa_check) |
| 218 | .loop_channels(1, c_block * 5 + 1, std::max(size_t(1), c_block - 1))); |
| 219 | |
| 220 | tests.push_back(DWConvTestParams( |
| 221 | "c_eq_" + cbs + "_multipass_multipixel", |
| 222 | DWConvMicrokernelTester() |
| 223 | .first_pass_tile(first_pass_tile) |
| 224 | .middle_pass_tile(middle_pass_tile) |
| 225 | .last_pass_tile(last_pass_tile) |
| 226 | .channel_tile(cr) |
| 227 | .channel_subtile(channel_subtile) |
| 228 | .channel_round(channel_round) |
| 229 | .width(3) |
| 230 | , test_func, isa_check) |
| 231 | .loop_channels(1, c_block * 5 + 1, std::max(size_t(1), c_block - 1)) |
| 232 | .loop_kernel_size( |
| 233 | first_pass_tile + middle_pass_tile + last_pass_tile, |
| 234 | first_pass_tile + middle_pass_tile * 2 + last_pass_tile)); |
| 235 | |
| 236 | tests.push_back(DWConvTestParams( |
| 237 | "multipixel_with_step", |
| 238 | DWConvMicrokernelTester() |
| 239 | .first_pass_tile(first_pass_tile) |
| 240 | .middle_pass_tile(middle_pass_tile) |
| 241 | .last_pass_tile(last_pass_tile) |
| 242 | .channel_tile(cr) |
| 243 | .channel_subtile(channel_subtile) |
| 244 | .channel_round(channel_round) |
| 245 | .width(3) |
| 246 | , test_func, isa_check) |
| 247 | .loop_channels(1, c_block * 5 + 1, std::max(size_t(1), c_block - 1)) |
| 248 | .loop_kernel_size( |
| 249 | first_pass_tile + middle_pass_tile + last_pass_tile, |
| 250 | first_pass_tile + middle_pass_tile * 2 + last_pass_tile) |
| 251 | .loop_step(2, kr + 1)); |
| 252 | |
| 253 | tests.push_back(DWConvTestParams( |
| 254 | "multipixel_with_output_stride", |
| 255 | DWConvMicrokernelTester() |
| 256 | .first_pass_tile(first_pass_tile) |
| 257 | .middle_pass_tile(middle_pass_tile) |
| 258 | .last_pass_tile(last_pass_tile) |
| 259 | .channel_tile(cr) |
| 260 | .channel_subtile(channel_subtile) |
| 261 | .channel_round(channel_round) |
| 262 | .width(5) |
| 263 | .output_stride(xnnpack::NextPrime(cr * 5 + 1)) |
| 264 | , test_func, isa_check) |
| 265 | .loop_channels(1, c_block * 5 + 1, std::max(size_t(1), c_block - 1)) |
| 266 | .loop_kernel_size(first_pass_tile + middle_pass_tile + last_pass_tile, |
| 267 | first_pass_tile + middle_pass_tile * 2 + last_pass_tile)); |
| 268 | |
| 269 | tests.push_back(DWConvTestParams( |
| 270 | "input_offset", |
| 271 | DWConvMicrokernelTester() |
| 272 | .first_pass_tile(first_pass_tile) |
| 273 | .middle_pass_tile(middle_pass_tile) |
| 274 | .last_pass_tile(last_pass_tile) |
| 275 | .channel_tile(cr) |
| 276 | .channel_subtile(channel_subtile) |
| 277 | .channel_round(channel_round) |
| 278 | .input_offset(xnnpack::NextPrime(cr + 1) * 16) |
| 279 | , test_func, isa_check) |
| 280 | .loop_channels(c_block * 2, cr * 16, cr * 3) |
| 281 | .loop_kernel_size(first_pass_tile + middle_pass_tile + last_pass_tile, |
| 282 | first_pass_tile + middle_pass_tile * 2 + last_pass_tile)); |
| 283 | |
| 284 | return tests; |
| 285 | } |
| 286 | |
| 287 | } // namespace |
| 288 | |
| 289 | #define XNN_DWCONV_MULTIPASS(arch_flags, ukernel, first_pass_tile, middle_pass_tile, last_pass_tile, channel_tile, channel_subtile, channel_round, datatype, weights_type, buffer_type, params_type, init_params)\ |
| 290 | INSTANTIATE_TEST_SUITE_P( \ |
| 291 | ukernel, DWConvTest, \ |
| 292 | testing::ValuesIn(CreateTests( \ |
| 293 | channel_tile, channel_tile, first_pass_tile, \ |
| 294 | first_pass_tile, middle_pass_tile, last_pass_tile, \ |
| 295 | channel_subtile, channel_round, \ |
| 296 | [](DWConvMicrokernelTester& tester) { \ |
| 297 | TEST_REQUIRES_ARCH_FLAGS(arch_flags); \ |
| 298 | tester.Test(ukernel, init_params, xnn_qu8_requantize_rndnu); \ |
| 299 | })), \ |
| 300 | [](const testing::TestParamInfo<DWConvTest::ParamType>& info) { \ |
| 301 | return info.param.test_name; \ |
| 302 | }); |
| 303 | #include "qu8-dwconv/qu8-dwconv-minmax-multipass-rndnu.h" |
| 304 | #undef XNN_UKERNEL_WITH_PARAMS |