Marat Dukhan | b1a0fc3 | 2019-12-02 19:32:02 -0800 | [diff] [blame] | 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 "binary-elementwise-operator-tester.h" |
| 9 | |
Marat Dukhan | ab4af57 | 2019-12-03 11:11:18 -0800 | [diff] [blame] | 10 | constexpr size_t kDim1 = 2; |
| 11 | constexpr size_t kDim2 = 3; |
| 12 | constexpr size_t kDim3 = 4; |
| 13 | constexpr size_t kDim4 = 5; |
Marat Dukhan | fc2b96e | 2019-12-03 12:04:04 -0800 | [diff] [blame] | 14 | constexpr size_t kDim5 = 6; |
| 15 | constexpr size_t kDim6 = 7; |
Marat Dukhan | b1a0fc3 | 2019-12-02 19:32:02 -0800 | [diff] [blame] | 16 | |
Marat Dukhan | ab4af57 | 2019-12-03 11:11:18 -0800 | [diff] [blame] | 17 | |
Frank Barchard | 01898c0 | 2020-06-23 21:49:50 -0700 | [diff] [blame] | 18 | TEST(ADD_ND_F16, 0d_x_0d) { |
| 19 | BinaryElementwiseOperatorTester() |
| 20 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 21 | .TestF16(); |
| 22 | } |
| 23 | |
| 24 | TEST(ADD_ND_F16, 1d_x_0d) { |
| 25 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 1); bm1++) { |
| 26 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 27 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 28 | BinaryElementwiseOperatorTester() |
| 29 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 30 | .input1_shape({input1_dim1}) |
| 31 | .TestF16(); |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | TEST(ADD_ND_F16, 0d_x_1d) { |
| 36 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 1); bm2++) { |
| 37 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 38 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 39 | BinaryElementwiseOperatorTester() |
| 40 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 41 | .input2_shape({input2_dim1}) |
| 42 | .TestF16(); |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | TEST(ADD_ND_F16, 1d_x_1d) { |
| 47 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 1); bm1++) { |
| 48 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 1); bm2++) { |
| 49 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 50 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 51 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 52 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 53 | BinaryElementwiseOperatorTester() |
| 54 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 55 | .input1_shape({input1_dim1}) |
| 56 | .input2_shape({input2_dim1}) |
| 57 | .TestF16(); |
| 58 | } |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | TEST(ADD_ND_F16, 0d_x_2d) { |
| 63 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 2); bm2++) { |
| 64 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 65 | const bool input2_broadcast_dim2 = bm2 & (uint32_t(1) << 1); |
| 66 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 67 | const size_t input2_dim2 = input2_broadcast_dim2 ? 1 : kDim2; |
| 68 | BinaryElementwiseOperatorTester() |
| 69 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 70 | .input2_shape({input2_dim2, input2_dim1}) |
| 71 | .TestF16(); |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | TEST(ADD_ND_F16, 1d_x_2d) { |
| 76 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 1); bm1++) { |
| 77 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 2); bm2++) { |
| 78 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 79 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 80 | const bool input2_broadcast_dim2 = bm2 & (uint32_t(1) << 1); |
| 81 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 82 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 83 | const size_t input2_dim2 = input2_broadcast_dim2 ? 1 : kDim2; |
| 84 | BinaryElementwiseOperatorTester() |
| 85 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 86 | .input1_shape({input1_dim1}) |
| 87 | .input2_shape({input2_dim2, input2_dim1}) |
| 88 | .TestF16(); |
| 89 | } |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | TEST(ADD_ND_F16, 2d_x_0d) { |
| 94 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 2); bm1++) { |
| 95 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 96 | const bool input1_broadcast_dim2 = bm1 & (uint32_t(1) << 1); |
| 97 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 98 | const size_t input1_dim2 = input1_broadcast_dim2 ? 1 : kDim2; |
| 99 | BinaryElementwiseOperatorTester() |
| 100 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 101 | .input1_shape({input1_dim2, input1_dim1}) |
| 102 | .TestF16(); |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | TEST(ADD_ND_F16, 2d_x_1d) { |
| 107 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 2); bm1++) { |
| 108 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 1); bm2++) { |
| 109 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 110 | const bool input1_broadcast_dim2 = bm1 & (uint32_t(1) << 1); |
| 111 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 112 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 113 | const size_t input1_dim2 = input1_broadcast_dim2 ? 1 : kDim2; |
| 114 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 115 | BinaryElementwiseOperatorTester() |
| 116 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 117 | .input1_shape({input1_dim2, input1_dim1}) |
| 118 | .input2_shape({input2_dim1}) |
| 119 | .TestF16(); |
| 120 | } |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | TEST(ADD_ND_F16, 2d_x_2d) { |
| 125 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 2); bm1++) { |
| 126 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 2); bm2++) { |
| 127 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 128 | const bool input1_broadcast_dim2 = bm1 & (uint32_t(1) << 1); |
| 129 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 130 | const bool input2_broadcast_dim2 = bm2 & (uint32_t(1) << 1); |
| 131 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 132 | const size_t input1_dim2 = input1_broadcast_dim2 ? 1 : kDim2; |
| 133 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 134 | const size_t input2_dim2 = input2_broadcast_dim2 ? 1 : kDim2; |
| 135 | BinaryElementwiseOperatorTester() |
| 136 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 137 | .input1_shape({input1_dim2, input1_dim1}) |
| 138 | .input2_shape({input2_dim2, input2_dim1}) |
| 139 | .TestF16(); |
| 140 | } |
| 141 | } |
| 142 | } |
| 143 | |
| 144 | TEST(ADD_ND_F16, 0d_x_3d) { |
| 145 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 3); bm2++) { |
| 146 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 147 | const bool input2_broadcast_dim2 = bm2 & (uint32_t(1) << 1); |
| 148 | const bool input2_broadcast_dim3 = bm2 & (uint32_t(1) << 2); |
| 149 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 150 | const size_t input2_dim2 = input2_broadcast_dim2 ? 1 : kDim2; |
| 151 | const size_t input2_dim3 = input2_broadcast_dim3 ? 1 : kDim3; |
| 152 | BinaryElementwiseOperatorTester() |
| 153 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 154 | .input2_shape({input2_dim3, input2_dim2, input2_dim1}) |
| 155 | .TestF16(); |
| 156 | } |
| 157 | } |
| 158 | |
| 159 | TEST(ADD_ND_F16, 1d_x_3d) { |
| 160 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 1); bm1++) { |
| 161 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 3); bm2++) { |
| 162 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 163 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 164 | const bool input2_broadcast_dim2 = bm2 & (uint32_t(1) << 1); |
| 165 | const bool input2_broadcast_dim3 = bm2 & (uint32_t(1) << 2); |
| 166 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 167 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 168 | const size_t input2_dim2 = input2_broadcast_dim2 ? 1 : kDim2; |
| 169 | const size_t input2_dim3 = input2_broadcast_dim3 ? 1 : kDim3; |
| 170 | BinaryElementwiseOperatorTester() |
| 171 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 172 | .input1_shape({input1_dim1}) |
| 173 | .input2_shape({input2_dim3, input2_dim2, input2_dim1}) |
| 174 | .TestF16(); |
| 175 | } |
| 176 | } |
| 177 | } |
| 178 | |
| 179 | TEST(ADD_ND_F16, 2d_x_3d) { |
| 180 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 2); bm1++) { |
| 181 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 3); bm2++) { |
| 182 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 183 | const bool input1_broadcast_dim2 = bm1 & (uint32_t(1) << 1); |
| 184 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 185 | const bool input2_broadcast_dim2 = bm2 & (uint32_t(1) << 1); |
| 186 | const bool input2_broadcast_dim3 = bm2 & (uint32_t(1) << 2); |
| 187 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 188 | const size_t input1_dim2 = input1_broadcast_dim2 ? 1 : kDim2; |
| 189 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 190 | const size_t input2_dim2 = input2_broadcast_dim2 ? 1 : kDim2; |
| 191 | const size_t input2_dim3 = input2_broadcast_dim3 ? 1 : kDim3; |
| 192 | BinaryElementwiseOperatorTester() |
| 193 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 194 | .input1_shape({input1_dim2, input1_dim1}) |
| 195 | .input2_shape({input2_dim3, input2_dim2, input2_dim1}) |
| 196 | .TestF16(); |
| 197 | } |
| 198 | } |
| 199 | } |
| 200 | |
| 201 | TEST(ADD_ND_F16, 3d_x_0d) { |
| 202 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 3); bm1++) { |
| 203 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 204 | const bool input1_broadcast_dim2 = bm1 & (uint32_t(1) << 1); |
| 205 | const bool input1_broadcast_dim3 = bm1 & (uint32_t(1) << 2); |
| 206 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 207 | const size_t input1_dim2 = input1_broadcast_dim2 ? 1 : kDim2; |
| 208 | const size_t input1_dim3 = input1_broadcast_dim3 ? 1 : kDim3; |
| 209 | BinaryElementwiseOperatorTester() |
| 210 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 211 | .input1_shape({input1_dim3, input1_dim2, input1_dim1}) |
| 212 | .TestF16(); |
| 213 | } |
| 214 | } |
| 215 | |
| 216 | TEST(ADD_ND_F16, 3d_x_1d) { |
| 217 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 3); bm1++) { |
| 218 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 1); bm2++) { |
| 219 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 220 | const bool input1_broadcast_dim2 = bm1 & (uint32_t(1) << 1); |
| 221 | const bool input1_broadcast_dim3 = bm1 & (uint32_t(1) << 2); |
| 222 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 223 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 224 | const size_t input1_dim2 = input1_broadcast_dim2 ? 1 : kDim2; |
| 225 | const size_t input1_dim3 = input1_broadcast_dim3 ? 1 : kDim3; |
| 226 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 227 | BinaryElementwiseOperatorTester() |
| 228 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 229 | .input1_shape({input1_dim3, input1_dim2, input1_dim1}) |
| 230 | .input2_shape({input2_dim1}) |
| 231 | .TestF16(); |
| 232 | } |
| 233 | } |
| 234 | } |
| 235 | |
| 236 | TEST(ADD_ND_F16, 3d_x_2d) { |
| 237 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 3); bm1++) { |
| 238 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 2); bm2++) { |
| 239 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 240 | const bool input1_broadcast_dim2 = bm1 & (uint32_t(1) << 1); |
| 241 | const bool input1_broadcast_dim3 = bm1 & (uint32_t(1) << 2); |
| 242 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 243 | const bool input2_broadcast_dim2 = bm2 & (uint32_t(1) << 1); |
| 244 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 245 | const size_t input1_dim2 = input1_broadcast_dim2 ? 1 : kDim2; |
| 246 | const size_t input1_dim3 = input1_broadcast_dim3 ? 1 : kDim3; |
| 247 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 248 | const size_t input2_dim2 = input2_broadcast_dim2 ? 1 : kDim2; |
| 249 | BinaryElementwiseOperatorTester() |
| 250 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 251 | .input1_shape({input1_dim3, input1_dim2, input1_dim1}) |
| 252 | .input2_shape({input2_dim2, input2_dim1}) |
| 253 | .TestF16(); |
| 254 | } |
| 255 | } |
| 256 | } |
| 257 | |
| 258 | TEST(ADD_ND_F16, 3d_x_3d) { |
| 259 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 3); bm1++) { |
| 260 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 3); bm2++) { |
| 261 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 262 | const bool input1_broadcast_dim2 = bm1 & (uint32_t(1) << 1); |
| 263 | const bool input1_broadcast_dim3 = bm1 & (uint32_t(1) << 2); |
| 264 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 265 | const bool input2_broadcast_dim2 = bm2 & (uint32_t(1) << 1); |
| 266 | const bool input2_broadcast_dim3 = bm2 & (uint32_t(1) << 2); |
| 267 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 268 | const size_t input1_dim2 = input1_broadcast_dim2 ? 1 : kDim2; |
| 269 | const size_t input1_dim3 = input1_broadcast_dim3 ? 1 : kDim3; |
| 270 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 271 | const size_t input2_dim2 = input2_broadcast_dim2 ? 1 : kDim2; |
| 272 | const size_t input2_dim3 = input2_broadcast_dim3 ? 1 : kDim3; |
| 273 | BinaryElementwiseOperatorTester() |
| 274 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 275 | .input1_shape({input1_dim3, input1_dim2, input1_dim1}) |
| 276 | .input2_shape({input2_dim3, input2_dim2, input2_dim1}) |
| 277 | .TestF16(); |
| 278 | } |
| 279 | } |
| 280 | } |
| 281 | |
| 282 | TEST(ADD_ND_F16, 0d_x_4d) { |
| 283 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 4); bm2++) { |
| 284 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 285 | const bool input2_broadcast_dim2 = bm2 & (uint32_t(1) << 1); |
| 286 | const bool input2_broadcast_dim3 = bm2 & (uint32_t(1) << 2); |
| 287 | const bool input2_broadcast_dim4 = bm2 & (uint32_t(1) << 3); |
| 288 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 289 | const size_t input2_dim2 = input2_broadcast_dim2 ? 1 : kDim2; |
| 290 | const size_t input2_dim3 = input2_broadcast_dim3 ? 1 : kDim3; |
| 291 | const size_t input2_dim4 = input2_broadcast_dim4 ? 1 : kDim4; |
| 292 | BinaryElementwiseOperatorTester() |
| 293 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 294 | .input2_shape({input2_dim4, input2_dim3, input2_dim2, input2_dim1}) |
| 295 | .TestF16(); |
| 296 | } |
| 297 | } |
| 298 | |
| 299 | TEST(ADD_ND_F16, 1d_x_4d) { |
| 300 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 1); bm1++) { |
| 301 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 4); bm2++) { |
| 302 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 303 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 304 | const bool input2_broadcast_dim2 = bm2 & (uint32_t(1) << 1); |
| 305 | const bool input2_broadcast_dim3 = bm2 & (uint32_t(1) << 2); |
| 306 | const bool input2_broadcast_dim4 = bm2 & (uint32_t(1) << 3); |
| 307 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 308 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 309 | const size_t input2_dim2 = input2_broadcast_dim2 ? 1 : kDim2; |
| 310 | const size_t input2_dim3 = input2_broadcast_dim3 ? 1 : kDim3; |
| 311 | const size_t input2_dim4 = input2_broadcast_dim4 ? 1 : kDim4; |
| 312 | BinaryElementwiseOperatorTester() |
| 313 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 314 | .input1_shape({input1_dim1}) |
| 315 | .input2_shape({input2_dim4, input2_dim3, input2_dim2, input2_dim1}) |
| 316 | .TestF16(); |
| 317 | } |
| 318 | } |
| 319 | } |
| 320 | |
| 321 | TEST(ADD_ND_F16, 2d_x_4d) { |
| 322 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 2); bm1++) { |
| 323 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 4); bm2++) { |
| 324 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 325 | const bool input1_broadcast_dim2 = bm1 & (uint32_t(1) << 1); |
| 326 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 327 | const bool input2_broadcast_dim2 = bm2 & (uint32_t(1) << 1); |
| 328 | const bool input2_broadcast_dim3 = bm2 & (uint32_t(1) << 2); |
| 329 | const bool input2_broadcast_dim4 = bm2 & (uint32_t(1) << 3); |
| 330 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 331 | const size_t input1_dim2 = input1_broadcast_dim2 ? 1 : kDim2; |
| 332 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 333 | const size_t input2_dim2 = input2_broadcast_dim2 ? 1 : kDim2; |
| 334 | const size_t input2_dim3 = input2_broadcast_dim3 ? 1 : kDim3; |
| 335 | const size_t input2_dim4 = input2_broadcast_dim4 ? 1 : kDim4; |
| 336 | BinaryElementwiseOperatorTester() |
| 337 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 338 | .input1_shape({input1_dim2, input1_dim1}) |
| 339 | .input2_shape({input2_dim4, input2_dim3, input2_dim2, input2_dim1}) |
| 340 | .TestF16(); |
| 341 | } |
| 342 | } |
| 343 | } |
| 344 | |
| 345 | TEST(ADD_ND_F16, 3d_x_4d) { |
| 346 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 3); bm1++) { |
| 347 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 4); bm2++) { |
| 348 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 349 | const bool input1_broadcast_dim2 = bm1 & (uint32_t(1) << 1); |
| 350 | const bool input1_broadcast_dim3 = bm1 & (uint32_t(1) << 2); |
| 351 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 352 | const bool input2_broadcast_dim2 = bm2 & (uint32_t(1) << 1); |
| 353 | const bool input2_broadcast_dim3 = bm2 & (uint32_t(1) << 2); |
| 354 | const bool input2_broadcast_dim4 = bm2 & (uint32_t(1) << 3); |
| 355 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 356 | const size_t input1_dim2 = input1_broadcast_dim2 ? 1 : kDim2; |
| 357 | const size_t input1_dim3 = input1_broadcast_dim3 ? 1 : kDim3; |
| 358 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 359 | const size_t input2_dim2 = input2_broadcast_dim2 ? 1 : kDim2; |
| 360 | const size_t input2_dim3 = input2_broadcast_dim3 ? 1 : kDim3; |
| 361 | const size_t input2_dim4 = input2_broadcast_dim4 ? 1 : kDim4; |
| 362 | BinaryElementwiseOperatorTester() |
| 363 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 364 | .input1_shape({input1_dim3, input1_dim2, input1_dim1}) |
| 365 | .input2_shape({input2_dim4, input2_dim3, input2_dim2, input2_dim1}) |
| 366 | .TestF16(); |
| 367 | } |
| 368 | } |
| 369 | } |
| 370 | |
| 371 | TEST(ADD_ND_F16, 4d_x_0d) { |
| 372 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 4); bm1++) { |
| 373 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 374 | const bool input1_broadcast_dim2 = bm1 & (uint32_t(1) << 1); |
| 375 | const bool input1_broadcast_dim3 = bm1 & (uint32_t(1) << 2); |
| 376 | const bool input1_broadcast_dim4 = bm1 & (uint32_t(1) << 3); |
| 377 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 378 | const size_t input1_dim2 = input1_broadcast_dim2 ? 1 : kDim2; |
| 379 | const size_t input1_dim3 = input1_broadcast_dim3 ? 1 : kDim3; |
| 380 | const size_t input1_dim4 = input1_broadcast_dim4 ? 1 : kDim4; |
| 381 | BinaryElementwiseOperatorTester() |
| 382 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 383 | .input1_shape({input1_dim4, input1_dim3, input1_dim2, input1_dim1}) |
| 384 | .TestF16(); |
| 385 | } |
| 386 | } |
| 387 | |
| 388 | TEST(ADD_ND_F16, 4d_x_1d) { |
| 389 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 4); bm1++) { |
| 390 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 1); bm2++) { |
| 391 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 392 | const bool input1_broadcast_dim2 = bm1 & (uint32_t(1) << 1); |
| 393 | const bool input1_broadcast_dim3 = bm1 & (uint32_t(1) << 2); |
| 394 | const bool input1_broadcast_dim4 = bm1 & (uint32_t(1) << 3); |
| 395 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 396 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 397 | const size_t input1_dim2 = input1_broadcast_dim2 ? 1 : kDim2; |
| 398 | const size_t input1_dim3 = input1_broadcast_dim3 ? 1 : kDim3; |
| 399 | const size_t input1_dim4 = input1_broadcast_dim4 ? 1 : kDim4; |
| 400 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 401 | BinaryElementwiseOperatorTester() |
| 402 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 403 | .input1_shape({input1_dim4, input1_dim3, input1_dim2, input1_dim1}) |
| 404 | .input2_shape({input2_dim1}) |
| 405 | .TestF16(); |
| 406 | } |
| 407 | } |
| 408 | } |
| 409 | |
| 410 | TEST(ADD_ND_F16, 4d_x_2d) { |
| 411 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 4); bm1++) { |
| 412 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 2); bm2++) { |
| 413 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 414 | const bool input1_broadcast_dim2 = bm1 & (uint32_t(1) << 1); |
| 415 | const bool input1_broadcast_dim3 = bm1 & (uint32_t(1) << 2); |
| 416 | const bool input1_broadcast_dim4 = bm1 & (uint32_t(1) << 3); |
| 417 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 418 | const bool input2_broadcast_dim2 = bm2 & (uint32_t(1) << 1); |
| 419 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 420 | const size_t input1_dim2 = input1_broadcast_dim2 ? 1 : kDim2; |
| 421 | const size_t input1_dim3 = input1_broadcast_dim3 ? 1 : kDim3; |
| 422 | const size_t input1_dim4 = input1_broadcast_dim4 ? 1 : kDim4; |
| 423 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 424 | const size_t input2_dim2 = input2_broadcast_dim2 ? 1 : kDim2; |
| 425 | BinaryElementwiseOperatorTester() |
| 426 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 427 | .input1_shape({input1_dim4, input1_dim3, input1_dim2, input1_dim1}) |
| 428 | .input2_shape({input2_dim2, input2_dim1}) |
| 429 | .TestF16(); |
| 430 | } |
| 431 | } |
| 432 | } |
| 433 | |
| 434 | TEST(ADD_ND_F16, 4d_x_3d) { |
| 435 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 4); bm1++) { |
| 436 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 3); bm2++) { |
| 437 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 438 | const bool input1_broadcast_dim2 = bm1 & (uint32_t(1) << 1); |
| 439 | const bool input1_broadcast_dim3 = bm1 & (uint32_t(1) << 2); |
| 440 | const bool input1_broadcast_dim4 = bm1 & (uint32_t(1) << 3); |
| 441 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 442 | const bool input2_broadcast_dim2 = bm2 & (uint32_t(1) << 1); |
| 443 | const bool input2_broadcast_dim3 = bm2 & (uint32_t(1) << 2); |
| 444 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 445 | const size_t input1_dim2 = input1_broadcast_dim2 ? 1 : kDim2; |
| 446 | const size_t input1_dim3 = input1_broadcast_dim3 ? 1 : kDim3; |
| 447 | const size_t input1_dim4 = input1_broadcast_dim4 ? 1 : kDim4; |
| 448 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 449 | const size_t input2_dim2 = input2_broadcast_dim2 ? 1 : kDim2; |
| 450 | const size_t input2_dim3 = input2_broadcast_dim3 ? 1 : kDim3; |
| 451 | BinaryElementwiseOperatorTester() |
| 452 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 453 | .input1_shape({input1_dim4, input1_dim3, input1_dim2, input1_dim1}) |
| 454 | .input2_shape({input2_dim3, input2_dim2, input2_dim1}) |
| 455 | .TestF16(); |
| 456 | } |
| 457 | } |
| 458 | } |
| 459 | |
| 460 | TEST(ADD_ND_F16, 4d_x_4d) { |
| 461 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 4); bm1++) { |
| 462 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 4); bm2++) { |
| 463 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 464 | const bool input1_broadcast_dim2 = bm1 & (uint32_t(1) << 1); |
| 465 | const bool input1_broadcast_dim3 = bm1 & (uint32_t(1) << 2); |
| 466 | const bool input1_broadcast_dim4 = bm1 & (uint32_t(1) << 3); |
| 467 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 468 | const bool input2_broadcast_dim2 = bm2 & (uint32_t(1) << 1); |
| 469 | const bool input2_broadcast_dim3 = bm2 & (uint32_t(1) << 2); |
| 470 | const bool input2_broadcast_dim4 = bm2 & (uint32_t(1) << 3); |
| 471 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 472 | const size_t input1_dim2 = input1_broadcast_dim2 ? 1 : kDim2; |
| 473 | const size_t input1_dim3 = input1_broadcast_dim3 ? 1 : kDim3; |
| 474 | const size_t input1_dim4 = input1_broadcast_dim4 ? 1 : kDim4; |
| 475 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 476 | const size_t input2_dim2 = input2_broadcast_dim2 ? 1 : kDim2; |
| 477 | const size_t input2_dim3 = input2_broadcast_dim3 ? 1 : kDim3; |
| 478 | const size_t input2_dim4 = input2_broadcast_dim4 ? 1 : kDim4; |
| 479 | BinaryElementwiseOperatorTester() |
| 480 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 481 | .input1_shape({input1_dim4, input1_dim3, input1_dim2, input1_dim1}) |
| 482 | .input2_shape({input2_dim4, input2_dim3, input2_dim2, input2_dim1}) |
| 483 | .TestF16(); |
| 484 | } |
| 485 | } |
| 486 | } |
| 487 | |
| 488 | TEST(ADD_ND_F16, 0d_x_5d) { |
| 489 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 5); bm2++) { |
| 490 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 491 | const bool input2_broadcast_dim2 = bm2 & (uint32_t(1) << 1); |
| 492 | const bool input2_broadcast_dim3 = bm2 & (uint32_t(1) << 2); |
| 493 | const bool input2_broadcast_dim4 = bm2 & (uint32_t(1) << 3); |
| 494 | const bool input2_broadcast_dim5 = bm2 & (uint32_t(1) << 4); |
| 495 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 496 | const size_t input2_dim2 = input2_broadcast_dim2 ? 1 : kDim2; |
| 497 | const size_t input2_dim3 = input2_broadcast_dim3 ? 1 : kDim3; |
| 498 | const size_t input2_dim4 = input2_broadcast_dim4 ? 1 : kDim4; |
| 499 | const size_t input2_dim5 = input2_broadcast_dim5 ? 1 : kDim5; |
| 500 | BinaryElementwiseOperatorTester() |
| 501 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 502 | .input2_shape({input2_dim5, input2_dim4, input2_dim3, input2_dim2, input2_dim1}) |
| 503 | .TestF16(); |
| 504 | } |
| 505 | } |
| 506 | |
| 507 | TEST(ADD_ND_F16, 1d_x_5d) { |
| 508 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 1); bm1++) { |
| 509 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 5); bm2++) { |
| 510 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 511 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 512 | const bool input2_broadcast_dim2 = bm2 & (uint32_t(1) << 1); |
| 513 | const bool input2_broadcast_dim3 = bm2 & (uint32_t(1) << 2); |
| 514 | const bool input2_broadcast_dim4 = bm2 & (uint32_t(1) << 3); |
| 515 | const bool input2_broadcast_dim5 = bm2 & (uint32_t(1) << 4); |
| 516 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 517 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 518 | const size_t input2_dim2 = input2_broadcast_dim2 ? 1 : kDim2; |
| 519 | const size_t input2_dim3 = input2_broadcast_dim3 ? 1 : kDim3; |
| 520 | const size_t input2_dim4 = input2_broadcast_dim4 ? 1 : kDim4; |
| 521 | const size_t input2_dim5 = input2_broadcast_dim5 ? 1 : kDim5; |
| 522 | BinaryElementwiseOperatorTester() |
| 523 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 524 | .input1_shape({input1_dim1}) |
| 525 | .input2_shape({input2_dim5, input2_dim4, input2_dim3, input2_dim2, input2_dim1}) |
| 526 | .TestF16(); |
| 527 | } |
| 528 | } |
| 529 | } |
| 530 | |
| 531 | TEST(ADD_ND_F16, 2d_x_5d) { |
| 532 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 2); bm1++) { |
| 533 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 5); bm2++) { |
| 534 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 535 | const bool input1_broadcast_dim2 = bm1 & (uint32_t(1) << 1); |
| 536 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 537 | const bool input2_broadcast_dim2 = bm2 & (uint32_t(1) << 1); |
| 538 | const bool input2_broadcast_dim3 = bm2 & (uint32_t(1) << 2); |
| 539 | const bool input2_broadcast_dim4 = bm2 & (uint32_t(1) << 3); |
| 540 | const bool input2_broadcast_dim5 = bm2 & (uint32_t(1) << 4); |
| 541 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 542 | const size_t input1_dim2 = input1_broadcast_dim2 ? 1 : kDim2; |
| 543 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 544 | const size_t input2_dim2 = input2_broadcast_dim2 ? 1 : kDim2; |
| 545 | const size_t input2_dim3 = input2_broadcast_dim3 ? 1 : kDim3; |
| 546 | const size_t input2_dim4 = input2_broadcast_dim4 ? 1 : kDim4; |
| 547 | const size_t input2_dim5 = input2_broadcast_dim5 ? 1 : kDim5; |
| 548 | BinaryElementwiseOperatorTester() |
| 549 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 550 | .input1_shape({input1_dim2, input1_dim1}) |
| 551 | .input2_shape({input2_dim5, input2_dim4, input2_dim3, input2_dim2, input2_dim1}) |
| 552 | .TestF16(); |
| 553 | } |
| 554 | } |
| 555 | } |
| 556 | |
| 557 | TEST(ADD_ND_F16, 3d_x_5d) { |
| 558 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 3); bm1++) { |
| 559 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 5); bm2++) { |
| 560 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 561 | const bool input1_broadcast_dim2 = bm1 & (uint32_t(1) << 1); |
| 562 | const bool input1_broadcast_dim3 = bm1 & (uint32_t(1) << 2); |
| 563 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 564 | const bool input2_broadcast_dim2 = bm2 & (uint32_t(1) << 1); |
| 565 | const bool input2_broadcast_dim3 = bm2 & (uint32_t(1) << 2); |
| 566 | const bool input2_broadcast_dim4 = bm2 & (uint32_t(1) << 3); |
| 567 | const bool input2_broadcast_dim5 = bm2 & (uint32_t(1) << 4); |
| 568 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 569 | const size_t input1_dim2 = input1_broadcast_dim2 ? 1 : kDim2; |
| 570 | const size_t input1_dim3 = input1_broadcast_dim3 ? 1 : kDim3; |
| 571 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 572 | const size_t input2_dim2 = input2_broadcast_dim2 ? 1 : kDim2; |
| 573 | const size_t input2_dim3 = input2_broadcast_dim3 ? 1 : kDim3; |
| 574 | const size_t input2_dim4 = input2_broadcast_dim4 ? 1 : kDim4; |
| 575 | const size_t input2_dim5 = input2_broadcast_dim5 ? 1 : kDim5; |
| 576 | BinaryElementwiseOperatorTester() |
| 577 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 578 | .input1_shape({input1_dim3, input1_dim2, input1_dim1}) |
| 579 | .input2_shape({input2_dim5, input2_dim4, input2_dim3, input2_dim2, input2_dim1}) |
| 580 | .TestF16(); |
| 581 | } |
| 582 | } |
| 583 | } |
| 584 | |
| 585 | TEST(ADD_ND_F16, 4d_x_5d) { |
| 586 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 4); bm1++) { |
| 587 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 5); bm2++) { |
| 588 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 589 | const bool input1_broadcast_dim2 = bm1 & (uint32_t(1) << 1); |
| 590 | const bool input1_broadcast_dim3 = bm1 & (uint32_t(1) << 2); |
| 591 | const bool input1_broadcast_dim4 = bm1 & (uint32_t(1) << 3); |
| 592 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 593 | const bool input2_broadcast_dim2 = bm2 & (uint32_t(1) << 1); |
| 594 | const bool input2_broadcast_dim3 = bm2 & (uint32_t(1) << 2); |
| 595 | const bool input2_broadcast_dim4 = bm2 & (uint32_t(1) << 3); |
| 596 | const bool input2_broadcast_dim5 = bm2 & (uint32_t(1) << 4); |
| 597 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 598 | const size_t input1_dim2 = input1_broadcast_dim2 ? 1 : kDim2; |
| 599 | const size_t input1_dim3 = input1_broadcast_dim3 ? 1 : kDim3; |
| 600 | const size_t input1_dim4 = input1_broadcast_dim4 ? 1 : kDim4; |
| 601 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 602 | const size_t input2_dim2 = input2_broadcast_dim2 ? 1 : kDim2; |
| 603 | const size_t input2_dim3 = input2_broadcast_dim3 ? 1 : kDim3; |
| 604 | const size_t input2_dim4 = input2_broadcast_dim4 ? 1 : kDim4; |
| 605 | const size_t input2_dim5 = input2_broadcast_dim5 ? 1 : kDim5; |
| 606 | BinaryElementwiseOperatorTester() |
| 607 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 608 | .input1_shape({input1_dim4, input1_dim3, input1_dim2, input1_dim1}) |
| 609 | .input2_shape({input2_dim5, input2_dim4, input2_dim3, input2_dim2, input2_dim1}) |
| 610 | .TestF16(); |
| 611 | } |
| 612 | } |
| 613 | } |
| 614 | |
| 615 | TEST(ADD_ND_F16, 5d_x_0d) { |
| 616 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 5); bm1++) { |
| 617 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 618 | const bool input1_broadcast_dim2 = bm1 & (uint32_t(1) << 1); |
| 619 | const bool input1_broadcast_dim3 = bm1 & (uint32_t(1) << 2); |
| 620 | const bool input1_broadcast_dim4 = bm1 & (uint32_t(1) << 3); |
| 621 | const bool input1_broadcast_dim5 = bm1 & (uint32_t(1) << 4); |
| 622 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 623 | const size_t input1_dim2 = input1_broadcast_dim2 ? 1 : kDim2; |
| 624 | const size_t input1_dim3 = input1_broadcast_dim3 ? 1 : kDim3; |
| 625 | const size_t input1_dim4 = input1_broadcast_dim4 ? 1 : kDim4; |
| 626 | const size_t input1_dim5 = input1_broadcast_dim5 ? 1 : kDim5; |
| 627 | BinaryElementwiseOperatorTester() |
| 628 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 629 | .input1_shape({input1_dim5, input1_dim4, input1_dim3, input1_dim2, input1_dim1}) |
| 630 | .TestF16(); |
| 631 | } |
| 632 | } |
| 633 | |
| 634 | TEST(ADD_ND_F16, 5d_x_1d) { |
| 635 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 5); bm1++) { |
| 636 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 1); bm2++) { |
| 637 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 638 | const bool input1_broadcast_dim2 = bm1 & (uint32_t(1) << 1); |
| 639 | const bool input1_broadcast_dim3 = bm1 & (uint32_t(1) << 2); |
| 640 | const bool input1_broadcast_dim4 = bm1 & (uint32_t(1) << 3); |
| 641 | const bool input1_broadcast_dim5 = bm1 & (uint32_t(1) << 4); |
| 642 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 643 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 644 | const size_t input1_dim2 = input1_broadcast_dim2 ? 1 : kDim2; |
| 645 | const size_t input1_dim3 = input1_broadcast_dim3 ? 1 : kDim3; |
| 646 | const size_t input1_dim4 = input1_broadcast_dim4 ? 1 : kDim4; |
| 647 | const size_t input1_dim5 = input1_broadcast_dim5 ? 1 : kDim5; |
| 648 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 649 | BinaryElementwiseOperatorTester() |
| 650 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 651 | .input1_shape({input1_dim5, input1_dim4, input1_dim3, input1_dim2, input1_dim1}) |
| 652 | .input2_shape({input2_dim1}) |
| 653 | .TestF16(); |
| 654 | } |
| 655 | } |
| 656 | } |
| 657 | |
| 658 | TEST(ADD_ND_F16, 5d_x_2d) { |
| 659 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 5); bm1++) { |
| 660 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 2); bm2++) { |
| 661 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 662 | const bool input1_broadcast_dim2 = bm1 & (uint32_t(1) << 1); |
| 663 | const bool input1_broadcast_dim3 = bm1 & (uint32_t(1) << 2); |
| 664 | const bool input1_broadcast_dim4 = bm1 & (uint32_t(1) << 3); |
| 665 | const bool input1_broadcast_dim5 = bm1 & (uint32_t(1) << 4); |
| 666 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 667 | const bool input2_broadcast_dim2 = bm2 & (uint32_t(1) << 1); |
| 668 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 669 | const size_t input1_dim2 = input1_broadcast_dim2 ? 1 : kDim2; |
| 670 | const size_t input1_dim3 = input1_broadcast_dim3 ? 1 : kDim3; |
| 671 | const size_t input1_dim4 = input1_broadcast_dim4 ? 1 : kDim4; |
| 672 | const size_t input1_dim5 = input1_broadcast_dim5 ? 1 : kDim5; |
| 673 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 674 | const size_t input2_dim2 = input2_broadcast_dim2 ? 1 : kDim2; |
| 675 | BinaryElementwiseOperatorTester() |
| 676 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 677 | .input1_shape({input1_dim5, input1_dim4, input1_dim3, input1_dim2, input1_dim1}) |
| 678 | .input2_shape({input2_dim2, input2_dim1}) |
| 679 | .TestF16(); |
| 680 | } |
| 681 | } |
| 682 | } |
| 683 | |
| 684 | TEST(ADD_ND_F16, 5d_x_3d) { |
| 685 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 5); bm1++) { |
| 686 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 3); bm2++) { |
| 687 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 688 | const bool input1_broadcast_dim2 = bm1 & (uint32_t(1) << 1); |
| 689 | const bool input1_broadcast_dim3 = bm1 & (uint32_t(1) << 2); |
| 690 | const bool input1_broadcast_dim4 = bm1 & (uint32_t(1) << 3); |
| 691 | const bool input1_broadcast_dim5 = bm1 & (uint32_t(1) << 4); |
| 692 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 693 | const bool input2_broadcast_dim2 = bm2 & (uint32_t(1) << 1); |
| 694 | const bool input2_broadcast_dim3 = bm2 & (uint32_t(1) << 2); |
| 695 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 696 | const size_t input1_dim2 = input1_broadcast_dim2 ? 1 : kDim2; |
| 697 | const size_t input1_dim3 = input1_broadcast_dim3 ? 1 : kDim3; |
| 698 | const size_t input1_dim4 = input1_broadcast_dim4 ? 1 : kDim4; |
| 699 | const size_t input1_dim5 = input1_broadcast_dim5 ? 1 : kDim5; |
| 700 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 701 | const size_t input2_dim2 = input2_broadcast_dim2 ? 1 : kDim2; |
| 702 | const size_t input2_dim3 = input2_broadcast_dim3 ? 1 : kDim3; |
| 703 | BinaryElementwiseOperatorTester() |
| 704 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 705 | .input1_shape({input1_dim5, input1_dim4, input1_dim3, input1_dim2, input1_dim1}) |
| 706 | .input2_shape({input2_dim3, input2_dim2, input2_dim1}) |
| 707 | .TestF16(); |
| 708 | } |
| 709 | } |
| 710 | } |
| 711 | |
| 712 | TEST(ADD_ND_F16, 5d_x_4d) { |
| 713 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 5); bm1++) { |
| 714 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 4); bm2++) { |
| 715 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 716 | const bool input1_broadcast_dim2 = bm1 & (uint32_t(1) << 1); |
| 717 | const bool input1_broadcast_dim3 = bm1 & (uint32_t(1) << 2); |
| 718 | const bool input1_broadcast_dim4 = bm1 & (uint32_t(1) << 3); |
| 719 | const bool input1_broadcast_dim5 = bm1 & (uint32_t(1) << 4); |
| 720 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 721 | const bool input2_broadcast_dim2 = bm2 & (uint32_t(1) << 1); |
| 722 | const bool input2_broadcast_dim3 = bm2 & (uint32_t(1) << 2); |
| 723 | const bool input2_broadcast_dim4 = bm2 & (uint32_t(1) << 3); |
| 724 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 725 | const size_t input1_dim2 = input1_broadcast_dim2 ? 1 : kDim2; |
| 726 | const size_t input1_dim3 = input1_broadcast_dim3 ? 1 : kDim3; |
| 727 | const size_t input1_dim4 = input1_broadcast_dim4 ? 1 : kDim4; |
| 728 | const size_t input1_dim5 = input1_broadcast_dim5 ? 1 : kDim5; |
| 729 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 730 | const size_t input2_dim2 = input2_broadcast_dim2 ? 1 : kDim2; |
| 731 | const size_t input2_dim3 = input2_broadcast_dim3 ? 1 : kDim3; |
| 732 | const size_t input2_dim4 = input2_broadcast_dim4 ? 1 : kDim4; |
| 733 | BinaryElementwiseOperatorTester() |
| 734 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 735 | .input1_shape({input1_dim5, input1_dim4, input1_dim3, input1_dim2, input1_dim1}) |
| 736 | .input2_shape({input2_dim4, input2_dim3, input2_dim2, input2_dim1}) |
| 737 | .TestF16(); |
| 738 | } |
| 739 | } |
| 740 | } |
| 741 | |
| 742 | TEST(ADD_ND_F16, 5d_x_5d) { |
| 743 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 5); bm1++) { |
| 744 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 5); bm2++) { |
| 745 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 746 | const bool input1_broadcast_dim2 = bm1 & (uint32_t(1) << 1); |
| 747 | const bool input1_broadcast_dim3 = bm1 & (uint32_t(1) << 2); |
| 748 | const bool input1_broadcast_dim4 = bm1 & (uint32_t(1) << 3); |
| 749 | const bool input1_broadcast_dim5 = bm1 & (uint32_t(1) << 4); |
| 750 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 751 | const bool input2_broadcast_dim2 = bm2 & (uint32_t(1) << 1); |
| 752 | const bool input2_broadcast_dim3 = bm2 & (uint32_t(1) << 2); |
| 753 | const bool input2_broadcast_dim4 = bm2 & (uint32_t(1) << 3); |
| 754 | const bool input2_broadcast_dim5 = bm2 & (uint32_t(1) << 4); |
| 755 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 756 | const size_t input1_dim2 = input1_broadcast_dim2 ? 1 : kDim2; |
| 757 | const size_t input1_dim3 = input1_broadcast_dim3 ? 1 : kDim3; |
| 758 | const size_t input1_dim4 = input1_broadcast_dim4 ? 1 : kDim4; |
| 759 | const size_t input1_dim5 = input1_broadcast_dim5 ? 1 : kDim5; |
| 760 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 761 | const size_t input2_dim2 = input2_broadcast_dim2 ? 1 : kDim2; |
| 762 | const size_t input2_dim3 = input2_broadcast_dim3 ? 1 : kDim3; |
| 763 | const size_t input2_dim4 = input2_broadcast_dim4 ? 1 : kDim4; |
| 764 | const size_t input2_dim5 = input2_broadcast_dim5 ? 1 : kDim5; |
| 765 | BinaryElementwiseOperatorTester() |
| 766 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 767 | .input1_shape({input1_dim5, input1_dim4, input1_dim3, input1_dim2, input1_dim1}) |
| 768 | .input2_shape({input2_dim5, input2_dim4, input2_dim3, input2_dim2, input2_dim1}) |
| 769 | .iterations(1) |
| 770 | .TestF16(); |
| 771 | } |
| 772 | } |
| 773 | } |
| 774 | |
| 775 | TEST(ADD_ND_F16, 0d_x_6d) { |
| 776 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 6); bm2++) { |
| 777 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 778 | const bool input2_broadcast_dim2 = bm2 & (uint32_t(1) << 1); |
| 779 | const bool input2_broadcast_dim3 = bm2 & (uint32_t(1) << 2); |
| 780 | const bool input2_broadcast_dim4 = bm2 & (uint32_t(1) << 3); |
| 781 | const bool input2_broadcast_dim5 = bm2 & (uint32_t(1) << 4); |
| 782 | const bool input2_broadcast_dim6 = bm2 & (uint32_t(1) << 5); |
| 783 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 784 | const size_t input2_dim2 = input2_broadcast_dim2 ? 1 : kDim2; |
| 785 | const size_t input2_dim3 = input2_broadcast_dim3 ? 1 : kDim3; |
| 786 | const size_t input2_dim4 = input2_broadcast_dim4 ? 1 : kDim4; |
| 787 | const size_t input2_dim5 = input2_broadcast_dim5 ? 1 : kDim5; |
| 788 | const size_t input2_dim6 = input2_broadcast_dim6 ? 1 : kDim6; |
| 789 | BinaryElementwiseOperatorTester() |
| 790 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 791 | .input2_shape({input2_dim6, input2_dim5, input2_dim4, input2_dim3, input2_dim2, input2_dim1}) |
| 792 | .TestF16(); |
| 793 | } |
| 794 | } |
| 795 | |
| 796 | TEST(ADD_ND_F16, 1d_x_6d) { |
| 797 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 1); bm1++) { |
| 798 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 6); bm2++) { |
| 799 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 800 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 801 | const bool input2_broadcast_dim2 = bm2 & (uint32_t(1) << 1); |
| 802 | const bool input2_broadcast_dim3 = bm2 & (uint32_t(1) << 2); |
| 803 | const bool input2_broadcast_dim4 = bm2 & (uint32_t(1) << 3); |
| 804 | const bool input2_broadcast_dim5 = bm2 & (uint32_t(1) << 4); |
| 805 | const bool input2_broadcast_dim6 = bm2 & (uint32_t(1) << 5); |
| 806 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 807 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 808 | const size_t input2_dim2 = input2_broadcast_dim2 ? 1 : kDim2; |
| 809 | const size_t input2_dim3 = input2_broadcast_dim3 ? 1 : kDim3; |
| 810 | const size_t input2_dim4 = input2_broadcast_dim4 ? 1 : kDim4; |
| 811 | const size_t input2_dim5 = input2_broadcast_dim5 ? 1 : kDim5; |
| 812 | const size_t input2_dim6 = input2_broadcast_dim6 ? 1 : kDim6; |
| 813 | BinaryElementwiseOperatorTester() |
| 814 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 815 | .input1_shape({input1_dim1}) |
| 816 | .input2_shape({input2_dim6, input2_dim5, input2_dim4, input2_dim3, input2_dim2, input2_dim1}) |
| 817 | .TestF16(); |
| 818 | } |
| 819 | } |
| 820 | } |
| 821 | |
| 822 | TEST(ADD_ND_F16, 2d_x_6d) { |
| 823 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 2); bm1++) { |
| 824 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 6); bm2++) { |
| 825 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 826 | const bool input1_broadcast_dim2 = bm1 & (uint32_t(1) << 1); |
| 827 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 828 | const bool input2_broadcast_dim2 = bm2 & (uint32_t(1) << 1); |
| 829 | const bool input2_broadcast_dim3 = bm2 & (uint32_t(1) << 2); |
| 830 | const bool input2_broadcast_dim4 = bm2 & (uint32_t(1) << 3); |
| 831 | const bool input2_broadcast_dim5 = bm2 & (uint32_t(1) << 4); |
| 832 | const bool input2_broadcast_dim6 = bm2 & (uint32_t(1) << 5); |
| 833 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 834 | const size_t input1_dim2 = input1_broadcast_dim2 ? 1 : kDim2; |
| 835 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 836 | const size_t input2_dim2 = input2_broadcast_dim2 ? 1 : kDim2; |
| 837 | const size_t input2_dim3 = input2_broadcast_dim3 ? 1 : kDim3; |
| 838 | const size_t input2_dim4 = input2_broadcast_dim4 ? 1 : kDim4; |
| 839 | const size_t input2_dim5 = input2_broadcast_dim5 ? 1 : kDim5; |
| 840 | const size_t input2_dim6 = input2_broadcast_dim6 ? 1 : kDim6; |
| 841 | BinaryElementwiseOperatorTester() |
| 842 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 843 | .input1_shape({input1_dim2, input1_dim1}) |
| 844 | .input2_shape({input2_dim6, input2_dim5, input2_dim4, input2_dim3, input2_dim2, input2_dim1}) |
| 845 | .TestF16(); |
| 846 | } |
| 847 | } |
| 848 | } |
| 849 | |
| 850 | TEST(ADD_ND_F16, 3d_x_6d) { |
| 851 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 3); bm1++) { |
| 852 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 6); bm2++) { |
| 853 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 854 | const bool input1_broadcast_dim2 = bm1 & (uint32_t(1) << 1); |
| 855 | const bool input1_broadcast_dim3 = bm1 & (uint32_t(1) << 2); |
| 856 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 857 | const bool input2_broadcast_dim2 = bm2 & (uint32_t(1) << 1); |
| 858 | const bool input2_broadcast_dim3 = bm2 & (uint32_t(1) << 2); |
| 859 | const bool input2_broadcast_dim4 = bm2 & (uint32_t(1) << 3); |
| 860 | const bool input2_broadcast_dim5 = bm2 & (uint32_t(1) << 4); |
| 861 | const bool input2_broadcast_dim6 = bm2 & (uint32_t(1) << 5); |
| 862 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 863 | const size_t input1_dim2 = input1_broadcast_dim2 ? 1 : kDim2; |
| 864 | const size_t input1_dim3 = input1_broadcast_dim3 ? 1 : kDim3; |
| 865 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 866 | const size_t input2_dim2 = input2_broadcast_dim2 ? 1 : kDim2; |
| 867 | const size_t input2_dim3 = input2_broadcast_dim3 ? 1 : kDim3; |
| 868 | const size_t input2_dim4 = input2_broadcast_dim4 ? 1 : kDim4; |
| 869 | const size_t input2_dim5 = input2_broadcast_dim5 ? 1 : kDim5; |
| 870 | const size_t input2_dim6 = input2_broadcast_dim6 ? 1 : kDim6; |
| 871 | BinaryElementwiseOperatorTester() |
| 872 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 873 | .input1_shape({input1_dim3, input1_dim2, input1_dim1}) |
| 874 | .input2_shape({input2_dim6, input2_dim5, input2_dim4, input2_dim3, input2_dim2, input2_dim1}) |
| 875 | .TestF16(); |
| 876 | } |
| 877 | } |
| 878 | } |
| 879 | |
| 880 | TEST(ADD_ND_F16, 4d_x_6d) { |
| 881 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 4); bm1++) { |
| 882 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 6); bm2++) { |
| 883 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 884 | const bool input1_broadcast_dim2 = bm1 & (uint32_t(1) << 1); |
| 885 | const bool input1_broadcast_dim3 = bm1 & (uint32_t(1) << 2); |
| 886 | const bool input1_broadcast_dim4 = bm1 & (uint32_t(1) << 3); |
| 887 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 888 | const bool input2_broadcast_dim2 = bm2 & (uint32_t(1) << 1); |
| 889 | const bool input2_broadcast_dim3 = bm2 & (uint32_t(1) << 2); |
| 890 | const bool input2_broadcast_dim4 = bm2 & (uint32_t(1) << 3); |
| 891 | const bool input2_broadcast_dim5 = bm2 & (uint32_t(1) << 4); |
| 892 | const bool input2_broadcast_dim6 = bm2 & (uint32_t(1) << 5); |
| 893 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 894 | const size_t input1_dim2 = input1_broadcast_dim2 ? 1 : kDim2; |
| 895 | const size_t input1_dim3 = input1_broadcast_dim3 ? 1 : kDim3; |
| 896 | const size_t input1_dim4 = input1_broadcast_dim4 ? 1 : kDim4; |
| 897 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 898 | const size_t input2_dim2 = input2_broadcast_dim2 ? 1 : kDim2; |
| 899 | const size_t input2_dim3 = input2_broadcast_dim3 ? 1 : kDim3; |
| 900 | const size_t input2_dim4 = input2_broadcast_dim4 ? 1 : kDim4; |
| 901 | const size_t input2_dim5 = input2_broadcast_dim5 ? 1 : kDim5; |
| 902 | const size_t input2_dim6 = input2_broadcast_dim6 ? 1 : kDim6; |
| 903 | BinaryElementwiseOperatorTester() |
| 904 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 905 | .input1_shape({input1_dim4, input1_dim3, input1_dim2, input1_dim1}) |
| 906 | .input2_shape({input2_dim6, input2_dim5, input2_dim4, input2_dim3, input2_dim2, input2_dim1}) |
| 907 | .TestF16(); |
| 908 | } |
| 909 | } |
| 910 | } |
| 911 | |
| 912 | TEST(ADD_ND_F16, 5d_x_6d) { |
| 913 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 5); bm1++) { |
| 914 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 6); bm2++) { |
| 915 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 916 | const bool input1_broadcast_dim2 = bm1 & (uint32_t(1) << 1); |
| 917 | const bool input1_broadcast_dim3 = bm1 & (uint32_t(1) << 2); |
| 918 | const bool input1_broadcast_dim4 = bm1 & (uint32_t(1) << 3); |
| 919 | const bool input1_broadcast_dim5 = bm1 & (uint32_t(1) << 4); |
| 920 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 921 | const bool input2_broadcast_dim2 = bm2 & (uint32_t(1) << 1); |
| 922 | const bool input2_broadcast_dim3 = bm2 & (uint32_t(1) << 2); |
| 923 | const bool input2_broadcast_dim4 = bm2 & (uint32_t(1) << 3); |
| 924 | const bool input2_broadcast_dim5 = bm2 & (uint32_t(1) << 4); |
| 925 | const bool input2_broadcast_dim6 = bm2 & (uint32_t(1) << 5); |
| 926 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 927 | const size_t input1_dim2 = input1_broadcast_dim2 ? 1 : kDim2; |
| 928 | const size_t input1_dim3 = input1_broadcast_dim3 ? 1 : kDim3; |
| 929 | const size_t input1_dim4 = input1_broadcast_dim4 ? 1 : kDim4; |
| 930 | const size_t input1_dim5 = input1_broadcast_dim5 ? 1 : kDim5; |
| 931 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 932 | const size_t input2_dim2 = input2_broadcast_dim2 ? 1 : kDim2; |
| 933 | const size_t input2_dim3 = input2_broadcast_dim3 ? 1 : kDim3; |
| 934 | const size_t input2_dim4 = input2_broadcast_dim4 ? 1 : kDim4; |
| 935 | const size_t input2_dim5 = input2_broadcast_dim5 ? 1 : kDim5; |
| 936 | const size_t input2_dim6 = input2_broadcast_dim6 ? 1 : kDim6; |
| 937 | BinaryElementwiseOperatorTester() |
| 938 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 939 | .input1_shape({input1_dim5, input1_dim4, input1_dim3, input1_dim2, input1_dim1}) |
| 940 | .input2_shape({input2_dim6, input2_dim5, input2_dim4, input2_dim3, input2_dim2, input2_dim1}) |
| 941 | .iterations(1) |
| 942 | .TestF16(); |
| 943 | } |
| 944 | } |
| 945 | } |
| 946 | |
| 947 | TEST(ADD_ND_F16, 6d_x_0d) { |
| 948 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 6); bm1++) { |
| 949 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 950 | const bool input1_broadcast_dim2 = bm1 & (uint32_t(1) << 1); |
| 951 | const bool input1_broadcast_dim3 = bm1 & (uint32_t(1) << 2); |
| 952 | const bool input1_broadcast_dim4 = bm1 & (uint32_t(1) << 3); |
| 953 | const bool input1_broadcast_dim5 = bm1 & (uint32_t(1) << 4); |
| 954 | const bool input1_broadcast_dim6 = bm1 & (uint32_t(1) << 5); |
| 955 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 956 | const size_t input1_dim2 = input1_broadcast_dim2 ? 1 : kDim2; |
| 957 | const size_t input1_dim3 = input1_broadcast_dim3 ? 1 : kDim3; |
| 958 | const size_t input1_dim4 = input1_broadcast_dim4 ? 1 : kDim4; |
| 959 | const size_t input1_dim5 = input1_broadcast_dim5 ? 1 : kDim5; |
| 960 | const size_t input1_dim6 = input1_broadcast_dim6 ? 1 : kDim6; |
| 961 | BinaryElementwiseOperatorTester() |
| 962 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 963 | .input1_shape({input1_dim6, input1_dim5, input1_dim4, input1_dim3, input1_dim2, input1_dim1}) |
| 964 | .TestF16(); |
| 965 | } |
| 966 | } |
| 967 | |
| 968 | TEST(ADD_ND_F16, 6d_x_1d) { |
| 969 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 6); bm1++) { |
| 970 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 1); bm2++) { |
| 971 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 972 | const bool input1_broadcast_dim2 = bm1 & (uint32_t(1) << 1); |
| 973 | const bool input1_broadcast_dim3 = bm1 & (uint32_t(1) << 2); |
| 974 | const bool input1_broadcast_dim4 = bm1 & (uint32_t(1) << 3); |
| 975 | const bool input1_broadcast_dim5 = bm1 & (uint32_t(1) << 4); |
| 976 | const bool input1_broadcast_dim6 = bm1 & (uint32_t(1) << 5); |
| 977 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 978 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 979 | const size_t input1_dim2 = input1_broadcast_dim2 ? 1 : kDim2; |
| 980 | const size_t input1_dim3 = input1_broadcast_dim3 ? 1 : kDim3; |
| 981 | const size_t input1_dim4 = input1_broadcast_dim4 ? 1 : kDim4; |
| 982 | const size_t input1_dim5 = input1_broadcast_dim5 ? 1 : kDim5; |
| 983 | const size_t input1_dim6 = input1_broadcast_dim6 ? 1 : kDim6; |
| 984 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 985 | BinaryElementwiseOperatorTester() |
| 986 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 987 | .input1_shape({input1_dim6, input1_dim5, input1_dim4, input1_dim3, input1_dim2, input1_dim1}) |
| 988 | .input2_shape({input2_dim1}) |
| 989 | .TestF16(); |
| 990 | } |
| 991 | } |
| 992 | } |
| 993 | |
| 994 | TEST(ADD_ND_F16, 6d_x_2d) { |
| 995 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 6); bm1++) { |
| 996 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 2); bm2++) { |
| 997 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 998 | const bool input1_broadcast_dim2 = bm1 & (uint32_t(1) << 1); |
| 999 | const bool input1_broadcast_dim3 = bm1 & (uint32_t(1) << 2); |
| 1000 | const bool input1_broadcast_dim4 = bm1 & (uint32_t(1) << 3); |
| 1001 | const bool input1_broadcast_dim5 = bm1 & (uint32_t(1) << 4); |
| 1002 | const bool input1_broadcast_dim6 = bm1 & (uint32_t(1) << 5); |
| 1003 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 1004 | const bool input2_broadcast_dim2 = bm2 & (uint32_t(1) << 1); |
| 1005 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 1006 | const size_t input1_dim2 = input1_broadcast_dim2 ? 1 : kDim2; |
| 1007 | const size_t input1_dim3 = input1_broadcast_dim3 ? 1 : kDim3; |
| 1008 | const size_t input1_dim4 = input1_broadcast_dim4 ? 1 : kDim4; |
| 1009 | const size_t input1_dim5 = input1_broadcast_dim5 ? 1 : kDim5; |
| 1010 | const size_t input1_dim6 = input1_broadcast_dim6 ? 1 : kDim6; |
| 1011 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 1012 | const size_t input2_dim2 = input2_broadcast_dim2 ? 1 : kDim2; |
| 1013 | BinaryElementwiseOperatorTester() |
| 1014 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 1015 | .input1_shape({input1_dim6, input1_dim5, input1_dim4, input1_dim3, input1_dim2, input1_dim1}) |
| 1016 | .input2_shape({input2_dim2, input2_dim1}) |
| 1017 | .TestF16(); |
| 1018 | } |
| 1019 | } |
| 1020 | } |
| 1021 | |
| 1022 | TEST(ADD_ND_F16, 6d_x_3d) { |
| 1023 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 6); bm1++) { |
| 1024 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 3); bm2++) { |
| 1025 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 1026 | const bool input1_broadcast_dim2 = bm1 & (uint32_t(1) << 1); |
| 1027 | const bool input1_broadcast_dim3 = bm1 & (uint32_t(1) << 2); |
| 1028 | const bool input1_broadcast_dim4 = bm1 & (uint32_t(1) << 3); |
| 1029 | const bool input1_broadcast_dim5 = bm1 & (uint32_t(1) << 4); |
| 1030 | const bool input1_broadcast_dim6 = bm1 & (uint32_t(1) << 5); |
| 1031 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 1032 | const bool input2_broadcast_dim2 = bm2 & (uint32_t(1) << 1); |
| 1033 | const bool input2_broadcast_dim3 = bm2 & (uint32_t(1) << 2); |
| 1034 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 1035 | const size_t input1_dim2 = input1_broadcast_dim2 ? 1 : kDim2; |
| 1036 | const size_t input1_dim3 = input1_broadcast_dim3 ? 1 : kDim3; |
| 1037 | const size_t input1_dim4 = input1_broadcast_dim4 ? 1 : kDim4; |
| 1038 | const size_t input1_dim5 = input1_broadcast_dim5 ? 1 : kDim5; |
| 1039 | const size_t input1_dim6 = input1_broadcast_dim6 ? 1 : kDim6; |
| 1040 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 1041 | const size_t input2_dim2 = input2_broadcast_dim2 ? 1 : kDim2; |
| 1042 | const size_t input2_dim3 = input2_broadcast_dim3 ? 1 : kDim3; |
| 1043 | BinaryElementwiseOperatorTester() |
| 1044 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 1045 | .input1_shape({input1_dim6, input1_dim5, input1_dim4, input1_dim3, input1_dim2, input1_dim1}) |
| 1046 | .input2_shape({input2_dim3, input2_dim2, input2_dim1}) |
| 1047 | .TestF16(); |
| 1048 | } |
| 1049 | } |
| 1050 | } |
| 1051 | |
| 1052 | TEST(ADD_ND_F16, 6d_x_4d) { |
| 1053 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 6); bm1++) { |
| 1054 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 4); bm2++) { |
| 1055 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 1056 | const bool input1_broadcast_dim2 = bm1 & (uint32_t(1) << 1); |
| 1057 | const bool input1_broadcast_dim3 = bm1 & (uint32_t(1) << 2); |
| 1058 | const bool input1_broadcast_dim4 = bm1 & (uint32_t(1) << 3); |
| 1059 | const bool input1_broadcast_dim5 = bm1 & (uint32_t(1) << 4); |
| 1060 | const bool input1_broadcast_dim6 = bm1 & (uint32_t(1) << 5); |
| 1061 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 1062 | const bool input2_broadcast_dim2 = bm2 & (uint32_t(1) << 1); |
| 1063 | const bool input2_broadcast_dim3 = bm2 & (uint32_t(1) << 2); |
| 1064 | const bool input2_broadcast_dim4 = bm2 & (uint32_t(1) << 3); |
| 1065 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 1066 | const size_t input1_dim2 = input1_broadcast_dim2 ? 1 : kDim2; |
| 1067 | const size_t input1_dim3 = input1_broadcast_dim3 ? 1 : kDim3; |
| 1068 | const size_t input1_dim4 = input1_broadcast_dim4 ? 1 : kDim4; |
| 1069 | const size_t input1_dim5 = input1_broadcast_dim5 ? 1 : kDim5; |
| 1070 | const size_t input1_dim6 = input1_broadcast_dim6 ? 1 : kDim6; |
| 1071 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 1072 | const size_t input2_dim2 = input2_broadcast_dim2 ? 1 : kDim2; |
| 1073 | const size_t input2_dim3 = input2_broadcast_dim3 ? 1 : kDim3; |
| 1074 | const size_t input2_dim4 = input2_broadcast_dim4 ? 1 : kDim4; |
| 1075 | BinaryElementwiseOperatorTester() |
| 1076 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 1077 | .input1_shape({input1_dim6, input1_dim5, input1_dim4, input1_dim3, input1_dim2, input1_dim1}) |
| 1078 | .input2_shape({input2_dim4, input2_dim3, input2_dim2, input2_dim1}) |
| 1079 | .TestF16(); |
| 1080 | } |
| 1081 | } |
| 1082 | } |
| 1083 | |
| 1084 | TEST(ADD_ND_F16, 6d_x_5d) { |
| 1085 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 6); bm1++) { |
| 1086 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 5); bm2++) { |
| 1087 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 1088 | const bool input1_broadcast_dim2 = bm1 & (uint32_t(1) << 1); |
| 1089 | const bool input1_broadcast_dim3 = bm1 & (uint32_t(1) << 2); |
| 1090 | const bool input1_broadcast_dim4 = bm1 & (uint32_t(1) << 3); |
| 1091 | const bool input1_broadcast_dim5 = bm1 & (uint32_t(1) << 4); |
| 1092 | const bool input1_broadcast_dim6 = bm1 & (uint32_t(1) << 5); |
| 1093 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 1094 | const bool input2_broadcast_dim2 = bm2 & (uint32_t(1) << 1); |
| 1095 | const bool input2_broadcast_dim3 = bm2 & (uint32_t(1) << 2); |
| 1096 | const bool input2_broadcast_dim4 = bm2 & (uint32_t(1) << 3); |
| 1097 | const bool input2_broadcast_dim5 = bm2 & (uint32_t(1) << 4); |
| 1098 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 1099 | const size_t input1_dim2 = input1_broadcast_dim2 ? 1 : kDim2; |
| 1100 | const size_t input1_dim3 = input1_broadcast_dim3 ? 1 : kDim3; |
| 1101 | const size_t input1_dim4 = input1_broadcast_dim4 ? 1 : kDim4; |
| 1102 | const size_t input1_dim5 = input1_broadcast_dim5 ? 1 : kDim5; |
| 1103 | const size_t input1_dim6 = input1_broadcast_dim6 ? 1 : kDim6; |
| 1104 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 1105 | const size_t input2_dim2 = input2_broadcast_dim2 ? 1 : kDim2; |
| 1106 | const size_t input2_dim3 = input2_broadcast_dim3 ? 1 : kDim3; |
| 1107 | const size_t input2_dim4 = input2_broadcast_dim4 ? 1 : kDim4; |
| 1108 | const size_t input2_dim5 = input2_broadcast_dim5 ? 1 : kDim5; |
| 1109 | BinaryElementwiseOperatorTester() |
| 1110 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 1111 | .input1_shape({input1_dim6, input1_dim5, input1_dim4, input1_dim3, input1_dim2, input1_dim1}) |
| 1112 | .input2_shape({input2_dim5, input2_dim4, input2_dim3, input2_dim2, input2_dim1}) |
| 1113 | .iterations(1) |
| 1114 | .TestF16(); |
| 1115 | } |
| 1116 | } |
| 1117 | } |
| 1118 | |
| 1119 | TEST(ADD_ND_F16, 6d_x_6d) { |
| 1120 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 6); bm1++) { |
| 1121 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 6); bm2++) { |
| 1122 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 1123 | const bool input1_broadcast_dim2 = bm1 & (uint32_t(1) << 1); |
| 1124 | const bool input1_broadcast_dim3 = bm1 & (uint32_t(1) << 2); |
| 1125 | const bool input1_broadcast_dim4 = bm1 & (uint32_t(1) << 3); |
| 1126 | const bool input1_broadcast_dim5 = bm1 & (uint32_t(1) << 4); |
| 1127 | const bool input1_broadcast_dim6 = bm1 & (uint32_t(1) << 5); |
| 1128 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 1129 | const bool input2_broadcast_dim2 = bm2 & (uint32_t(1) << 1); |
| 1130 | const bool input2_broadcast_dim3 = bm2 & (uint32_t(1) << 2); |
| 1131 | const bool input2_broadcast_dim4 = bm2 & (uint32_t(1) << 3); |
| 1132 | const bool input2_broadcast_dim5 = bm2 & (uint32_t(1) << 4); |
| 1133 | const bool input2_broadcast_dim6 = bm2 & (uint32_t(1) << 5); |
| 1134 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 1135 | const size_t input1_dim2 = input1_broadcast_dim2 ? 1 : kDim2; |
| 1136 | const size_t input1_dim3 = input1_broadcast_dim3 ? 1 : kDim3; |
| 1137 | const size_t input1_dim4 = input1_broadcast_dim4 ? 1 : kDim4; |
| 1138 | const size_t input1_dim5 = input1_broadcast_dim5 ? 1 : kDim5; |
| 1139 | const size_t input1_dim6 = input1_broadcast_dim6 ? 1 : kDim6; |
| 1140 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 1141 | const size_t input2_dim2 = input2_broadcast_dim2 ? 1 : kDim2; |
| 1142 | const size_t input2_dim3 = input2_broadcast_dim3 ? 1 : kDim3; |
| 1143 | const size_t input2_dim4 = input2_broadcast_dim4 ? 1 : kDim4; |
| 1144 | const size_t input2_dim5 = input2_broadcast_dim5 ? 1 : kDim5; |
| 1145 | const size_t input2_dim6 = input2_broadcast_dim6 ? 1 : kDim6; |
| 1146 | BinaryElementwiseOperatorTester() |
| 1147 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 1148 | .input1_shape({input1_dim6, input1_dim5, input1_dim4, input1_dim3, input1_dim2, input1_dim1}) |
| 1149 | .input2_shape({input2_dim6, input2_dim5, input2_dim4, input2_dim3, input2_dim2, input2_dim1}) |
| 1150 | .iterations(1) |
| 1151 | .TestF16(); |
| 1152 | } |
| 1153 | } |
| 1154 | } |
| 1155 | |
Marat Dukhan | ab4af57 | 2019-12-03 11:11:18 -0800 | [diff] [blame] | 1156 | TEST(ADD_ND_F32, 0d_x_0d) { |
Marat Dukhan | b1a0fc3 | 2019-12-02 19:32:02 -0800 | [diff] [blame] | 1157 | BinaryElementwiseOperatorTester() |
| 1158 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
Marat Dukhan | b1a0fc3 | 2019-12-02 19:32:02 -0800 | [diff] [blame] | 1159 | .TestF32(); |
| 1160 | } |
| 1161 | |
Marat Dukhan | ab4af57 | 2019-12-03 11:11:18 -0800 | [diff] [blame] | 1162 | TEST(ADD_ND_F32, 1d_x_0d) { |
| 1163 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 1); bm1++) { |
| 1164 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 1165 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 1166 | BinaryElementwiseOperatorTester() |
| 1167 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 1168 | .input1_shape({input1_dim1}) |
| 1169 | .TestF32(); |
| 1170 | } |
Marat Dukhan | b1a0fc3 | 2019-12-02 19:32:02 -0800 | [diff] [blame] | 1171 | } |
| 1172 | |
Marat Dukhan | ab4af57 | 2019-12-03 11:11:18 -0800 | [diff] [blame] | 1173 | TEST(ADD_ND_F32, 0d_x_1d) { |
| 1174 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 1); bm2++) { |
| 1175 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 1176 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 1177 | BinaryElementwiseOperatorTester() |
| 1178 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 1179 | .input2_shape({input2_dim1}) |
| 1180 | .TestF32(); |
| 1181 | } |
Marat Dukhan | b1a0fc3 | 2019-12-02 19:32:02 -0800 | [diff] [blame] | 1182 | } |
| 1183 | |
Marat Dukhan | ab4af57 | 2019-12-03 11:11:18 -0800 | [diff] [blame] | 1184 | TEST(ADD_ND_F32, 1d_x_1d) { |
| 1185 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 1); bm1++) { |
| 1186 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 1); bm2++) { |
| 1187 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 1188 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 1189 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 1190 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 1191 | BinaryElementwiseOperatorTester() |
| 1192 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 1193 | .input1_shape({input1_dim1}) |
| 1194 | .input2_shape({input2_dim1}) |
| 1195 | .TestF32(); |
| 1196 | } |
| 1197 | } |
Marat Dukhan | b1a0fc3 | 2019-12-02 19:32:02 -0800 | [diff] [blame] | 1198 | } |
| 1199 | |
Marat Dukhan | ab4af57 | 2019-12-03 11:11:18 -0800 | [diff] [blame] | 1200 | TEST(ADD_ND_F32, 0d_x_2d) { |
| 1201 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 2); bm2++) { |
| 1202 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 1203 | const bool input2_broadcast_dim2 = bm2 & (uint32_t(1) << 1); |
| 1204 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 1205 | const size_t input2_dim2 = input2_broadcast_dim2 ? 1 : kDim2; |
| 1206 | BinaryElementwiseOperatorTester() |
| 1207 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 1208 | .input2_shape({input2_dim2, input2_dim1}) |
| 1209 | .TestF32(); |
| 1210 | } |
Marat Dukhan | b1a0fc3 | 2019-12-02 19:32:02 -0800 | [diff] [blame] | 1211 | } |
| 1212 | |
Marat Dukhan | ab4af57 | 2019-12-03 11:11:18 -0800 | [diff] [blame] | 1213 | TEST(ADD_ND_F32, 1d_x_2d) { |
| 1214 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 1); bm1++) { |
| 1215 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 2); bm2++) { |
| 1216 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 1217 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 1218 | const bool input2_broadcast_dim2 = bm2 & (uint32_t(1) << 1); |
| 1219 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 1220 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 1221 | const size_t input2_dim2 = input2_broadcast_dim2 ? 1 : kDim2; |
| 1222 | BinaryElementwiseOperatorTester() |
| 1223 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 1224 | .input1_shape({input1_dim1}) |
| 1225 | .input2_shape({input2_dim2, input2_dim1}) |
| 1226 | .TestF32(); |
| 1227 | } |
| 1228 | } |
Marat Dukhan | b1a0fc3 | 2019-12-02 19:32:02 -0800 | [diff] [blame] | 1229 | } |
| 1230 | |
Marat Dukhan | ab4af57 | 2019-12-03 11:11:18 -0800 | [diff] [blame] | 1231 | TEST(ADD_ND_F32, 2d_x_0d) { |
| 1232 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 2); bm1++) { |
| 1233 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 1234 | const bool input1_broadcast_dim2 = bm1 & (uint32_t(1) << 1); |
| 1235 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 1236 | const size_t input1_dim2 = input1_broadcast_dim2 ? 1 : kDim2; |
| 1237 | BinaryElementwiseOperatorTester() |
| 1238 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 1239 | .input1_shape({input1_dim2, input1_dim1}) |
| 1240 | .TestF32(); |
| 1241 | } |
Marat Dukhan | b1a0fc3 | 2019-12-02 19:32:02 -0800 | [diff] [blame] | 1242 | } |
| 1243 | |
Marat Dukhan | ab4af57 | 2019-12-03 11:11:18 -0800 | [diff] [blame] | 1244 | TEST(ADD_ND_F32, 2d_x_1d) { |
| 1245 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 2); bm1++) { |
| 1246 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 1); bm2++) { |
| 1247 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 1248 | const bool input1_broadcast_dim2 = bm1 & (uint32_t(1) << 1); |
| 1249 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 1250 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 1251 | const size_t input1_dim2 = input1_broadcast_dim2 ? 1 : kDim2; |
| 1252 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 1253 | BinaryElementwiseOperatorTester() |
| 1254 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 1255 | .input1_shape({input1_dim2, input1_dim1}) |
| 1256 | .input2_shape({input2_dim1}) |
| 1257 | .TestF32(); |
| 1258 | } |
| 1259 | } |
Marat Dukhan | b1a0fc3 | 2019-12-02 19:32:02 -0800 | [diff] [blame] | 1260 | } |
| 1261 | |
Marat Dukhan | ab4af57 | 2019-12-03 11:11:18 -0800 | [diff] [blame] | 1262 | TEST(ADD_ND_F32, 2d_x_2d) { |
| 1263 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 2); bm1++) { |
| 1264 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 2); bm2++) { |
| 1265 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 1266 | const bool input1_broadcast_dim2 = bm1 & (uint32_t(1) << 1); |
| 1267 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 1268 | const bool input2_broadcast_dim2 = bm2 & (uint32_t(1) << 1); |
| 1269 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 1270 | const size_t input1_dim2 = input1_broadcast_dim2 ? 1 : kDim2; |
| 1271 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 1272 | const size_t input2_dim2 = input2_broadcast_dim2 ? 1 : kDim2; |
| 1273 | BinaryElementwiseOperatorTester() |
| 1274 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 1275 | .input1_shape({input1_dim2, input1_dim1}) |
| 1276 | .input2_shape({input2_dim2, input2_dim1}) |
| 1277 | .TestF32(); |
| 1278 | } |
| 1279 | } |
Marat Dukhan | b1a0fc3 | 2019-12-02 19:32:02 -0800 | [diff] [blame] | 1280 | } |
| 1281 | |
Marat Dukhan | ab4af57 | 2019-12-03 11:11:18 -0800 | [diff] [blame] | 1282 | TEST(ADD_ND_F32, 0d_x_3d) { |
| 1283 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 3); bm2++) { |
| 1284 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 1285 | const bool input2_broadcast_dim2 = bm2 & (uint32_t(1) << 1); |
| 1286 | const bool input2_broadcast_dim3 = bm2 & (uint32_t(1) << 2); |
| 1287 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 1288 | const size_t input2_dim2 = input2_broadcast_dim2 ? 1 : kDim2; |
| 1289 | const size_t input2_dim3 = input2_broadcast_dim3 ? 1 : kDim3; |
| 1290 | BinaryElementwiseOperatorTester() |
| 1291 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 1292 | .input2_shape({input2_dim3, input2_dim2, input2_dim1}) |
| 1293 | .TestF32(); |
| 1294 | } |
| 1295 | } |
| 1296 | |
| 1297 | TEST(ADD_ND_F32, 1d_x_3d) { |
| 1298 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 1); bm1++) { |
| 1299 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 3); bm2++) { |
| 1300 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 1301 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 1302 | const bool input2_broadcast_dim2 = bm2 & (uint32_t(1) << 1); |
| 1303 | const bool input2_broadcast_dim3 = bm2 & (uint32_t(1) << 2); |
| 1304 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 1305 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 1306 | const size_t input2_dim2 = input2_broadcast_dim2 ? 1 : kDim2; |
| 1307 | const size_t input2_dim3 = input2_broadcast_dim3 ? 1 : kDim3; |
| 1308 | BinaryElementwiseOperatorTester() |
| 1309 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 1310 | .input1_shape({input1_dim1}) |
| 1311 | .input2_shape({input2_dim3, input2_dim2, input2_dim1}) |
| 1312 | .TestF32(); |
| 1313 | } |
| 1314 | } |
| 1315 | } |
| 1316 | |
| 1317 | TEST(ADD_ND_F32, 2d_x_3d) { |
| 1318 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 2); bm1++) { |
| 1319 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 3); bm2++) { |
| 1320 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 1321 | const bool input1_broadcast_dim2 = bm1 & (uint32_t(1) << 1); |
| 1322 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 1323 | const bool input2_broadcast_dim2 = bm2 & (uint32_t(1) << 1); |
| 1324 | const bool input2_broadcast_dim3 = bm2 & (uint32_t(1) << 2); |
| 1325 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 1326 | const size_t input1_dim2 = input1_broadcast_dim2 ? 1 : kDim2; |
| 1327 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 1328 | const size_t input2_dim2 = input2_broadcast_dim2 ? 1 : kDim2; |
| 1329 | const size_t input2_dim3 = input2_broadcast_dim3 ? 1 : kDim3; |
| 1330 | BinaryElementwiseOperatorTester() |
| 1331 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 1332 | .input1_shape({input1_dim2, input1_dim1}) |
| 1333 | .input2_shape({input2_dim3, input2_dim2, input2_dim1}) |
| 1334 | .TestF32(); |
| 1335 | } |
| 1336 | } |
| 1337 | } |
| 1338 | |
| 1339 | TEST(ADD_ND_F32, 3d_x_0d) { |
| 1340 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 3); bm1++) { |
| 1341 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 1342 | const bool input1_broadcast_dim2 = bm1 & (uint32_t(1) << 1); |
| 1343 | const bool input1_broadcast_dim3 = bm1 & (uint32_t(1) << 2); |
| 1344 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 1345 | const size_t input1_dim2 = input1_broadcast_dim2 ? 1 : kDim2; |
| 1346 | const size_t input1_dim3 = input1_broadcast_dim3 ? 1 : kDim3; |
| 1347 | BinaryElementwiseOperatorTester() |
| 1348 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 1349 | .input1_shape({input1_dim3, input1_dim2, input1_dim1}) |
| 1350 | .TestF32(); |
| 1351 | } |
| 1352 | } |
| 1353 | |
| 1354 | TEST(ADD_ND_F32, 3d_x_1d) { |
| 1355 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 3); bm1++) { |
| 1356 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 1); bm2++) { |
| 1357 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 1358 | const bool input1_broadcast_dim2 = bm1 & (uint32_t(1) << 1); |
| 1359 | const bool input1_broadcast_dim3 = bm1 & (uint32_t(1) << 2); |
| 1360 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 1361 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 1362 | const size_t input1_dim2 = input1_broadcast_dim2 ? 1 : kDim2; |
| 1363 | const size_t input1_dim3 = input1_broadcast_dim3 ? 1 : kDim3; |
| 1364 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 1365 | BinaryElementwiseOperatorTester() |
| 1366 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 1367 | .input1_shape({input1_dim3, input1_dim2, input1_dim1}) |
| 1368 | .input2_shape({input2_dim1}) |
| 1369 | .TestF32(); |
| 1370 | } |
| 1371 | } |
| 1372 | } |
| 1373 | |
| 1374 | TEST(ADD_ND_F32, 3d_x_2d) { |
| 1375 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 3); bm1++) { |
| 1376 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 2); bm2++) { |
| 1377 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 1378 | const bool input1_broadcast_dim2 = bm1 & (uint32_t(1) << 1); |
| 1379 | const bool input1_broadcast_dim3 = bm1 & (uint32_t(1) << 2); |
| 1380 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 1381 | const bool input2_broadcast_dim2 = bm2 & (uint32_t(1) << 1); |
| 1382 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 1383 | const size_t input1_dim2 = input1_broadcast_dim2 ? 1 : kDim2; |
| 1384 | const size_t input1_dim3 = input1_broadcast_dim3 ? 1 : kDim3; |
| 1385 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 1386 | const size_t input2_dim2 = input2_broadcast_dim2 ? 1 : kDim2; |
| 1387 | BinaryElementwiseOperatorTester() |
| 1388 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 1389 | .input1_shape({input1_dim3, input1_dim2, input1_dim1}) |
| 1390 | .input2_shape({input2_dim2, input2_dim1}) |
| 1391 | .TestF32(); |
| 1392 | } |
| 1393 | } |
| 1394 | } |
| 1395 | |
| 1396 | TEST(ADD_ND_F32, 3d_x_3d) { |
| 1397 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 3); bm1++) { |
| 1398 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 3); bm2++) { |
| 1399 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 1400 | const bool input1_broadcast_dim2 = bm1 & (uint32_t(1) << 1); |
| 1401 | const bool input1_broadcast_dim3 = bm1 & (uint32_t(1) << 2); |
| 1402 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 1403 | const bool input2_broadcast_dim2 = bm2 & (uint32_t(1) << 1); |
| 1404 | const bool input2_broadcast_dim3 = bm2 & (uint32_t(1) << 2); |
| 1405 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 1406 | const size_t input1_dim2 = input1_broadcast_dim2 ? 1 : kDim2; |
| 1407 | const size_t input1_dim3 = input1_broadcast_dim3 ? 1 : kDim3; |
| 1408 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 1409 | const size_t input2_dim2 = input2_broadcast_dim2 ? 1 : kDim2; |
| 1410 | const size_t input2_dim3 = input2_broadcast_dim3 ? 1 : kDim3; |
| 1411 | BinaryElementwiseOperatorTester() |
| 1412 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 1413 | .input1_shape({input1_dim3, input1_dim2, input1_dim1}) |
| 1414 | .input2_shape({input2_dim3, input2_dim2, input2_dim1}) |
| 1415 | .TestF32(); |
| 1416 | } |
| 1417 | } |
| 1418 | } |
| 1419 | |
| 1420 | TEST(ADD_ND_F32, 0d_x_4d) { |
| 1421 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 4); bm2++) { |
| 1422 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 1423 | const bool input2_broadcast_dim2 = bm2 & (uint32_t(1) << 1); |
| 1424 | const bool input2_broadcast_dim3 = bm2 & (uint32_t(1) << 2); |
| 1425 | const bool input2_broadcast_dim4 = bm2 & (uint32_t(1) << 3); |
| 1426 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 1427 | const size_t input2_dim2 = input2_broadcast_dim2 ? 1 : kDim2; |
| 1428 | const size_t input2_dim3 = input2_broadcast_dim3 ? 1 : kDim3; |
| 1429 | const size_t input2_dim4 = input2_broadcast_dim4 ? 1 : kDim4; |
| 1430 | BinaryElementwiseOperatorTester() |
| 1431 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 1432 | .input2_shape({input2_dim4, input2_dim3, input2_dim2, input2_dim1}) |
| 1433 | .TestF32(); |
| 1434 | } |
| 1435 | } |
| 1436 | |
| 1437 | TEST(ADD_ND_F32, 1d_x_4d) { |
| 1438 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 1); bm1++) { |
| 1439 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 4); bm2++) { |
| 1440 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 1441 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 1442 | const bool input2_broadcast_dim2 = bm2 & (uint32_t(1) << 1); |
| 1443 | const bool input2_broadcast_dim3 = bm2 & (uint32_t(1) << 2); |
| 1444 | const bool input2_broadcast_dim4 = bm2 & (uint32_t(1) << 3); |
| 1445 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 1446 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 1447 | const size_t input2_dim2 = input2_broadcast_dim2 ? 1 : kDim2; |
| 1448 | const size_t input2_dim3 = input2_broadcast_dim3 ? 1 : kDim3; |
| 1449 | const size_t input2_dim4 = input2_broadcast_dim4 ? 1 : kDim4; |
| 1450 | BinaryElementwiseOperatorTester() |
| 1451 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 1452 | .input1_shape({input1_dim1}) |
| 1453 | .input2_shape({input2_dim4, input2_dim3, input2_dim2, input2_dim1}) |
| 1454 | .TestF32(); |
| 1455 | } |
| 1456 | } |
| 1457 | } |
| 1458 | |
| 1459 | TEST(ADD_ND_F32, 2d_x_4d) { |
| 1460 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 2); bm1++) { |
| 1461 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 4); bm2++) { |
| 1462 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 1463 | const bool input1_broadcast_dim2 = bm1 & (uint32_t(1) << 1); |
| 1464 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 1465 | const bool input2_broadcast_dim2 = bm2 & (uint32_t(1) << 1); |
| 1466 | const bool input2_broadcast_dim3 = bm2 & (uint32_t(1) << 2); |
| 1467 | const bool input2_broadcast_dim4 = bm2 & (uint32_t(1) << 3); |
| 1468 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 1469 | const size_t input1_dim2 = input1_broadcast_dim2 ? 1 : kDim2; |
| 1470 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 1471 | const size_t input2_dim2 = input2_broadcast_dim2 ? 1 : kDim2; |
| 1472 | const size_t input2_dim3 = input2_broadcast_dim3 ? 1 : kDim3; |
| 1473 | const size_t input2_dim4 = input2_broadcast_dim4 ? 1 : kDim4; |
| 1474 | BinaryElementwiseOperatorTester() |
| 1475 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 1476 | .input1_shape({input1_dim2, input1_dim1}) |
| 1477 | .input2_shape({input2_dim4, input2_dim3, input2_dim2, input2_dim1}) |
| 1478 | .TestF32(); |
| 1479 | } |
| 1480 | } |
| 1481 | } |
| 1482 | |
| 1483 | TEST(ADD_ND_F32, 3d_x_4d) { |
| 1484 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 3); bm1++) { |
| 1485 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 4); bm2++) { |
| 1486 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 1487 | const bool input1_broadcast_dim2 = bm1 & (uint32_t(1) << 1); |
| 1488 | const bool input1_broadcast_dim3 = bm1 & (uint32_t(1) << 2); |
| 1489 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 1490 | const bool input2_broadcast_dim2 = bm2 & (uint32_t(1) << 1); |
| 1491 | const bool input2_broadcast_dim3 = bm2 & (uint32_t(1) << 2); |
| 1492 | const bool input2_broadcast_dim4 = bm2 & (uint32_t(1) << 3); |
| 1493 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 1494 | const size_t input1_dim2 = input1_broadcast_dim2 ? 1 : kDim2; |
| 1495 | const size_t input1_dim3 = input1_broadcast_dim3 ? 1 : kDim3; |
| 1496 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 1497 | const size_t input2_dim2 = input2_broadcast_dim2 ? 1 : kDim2; |
| 1498 | const size_t input2_dim3 = input2_broadcast_dim3 ? 1 : kDim3; |
| 1499 | const size_t input2_dim4 = input2_broadcast_dim4 ? 1 : kDim4; |
| 1500 | BinaryElementwiseOperatorTester() |
| 1501 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 1502 | .input1_shape({input1_dim3, input1_dim2, input1_dim1}) |
| 1503 | .input2_shape({input2_dim4, input2_dim3, input2_dim2, input2_dim1}) |
| 1504 | .TestF32(); |
| 1505 | } |
| 1506 | } |
| 1507 | } |
| 1508 | |
| 1509 | TEST(ADD_ND_F32, 4d_x_0d) { |
| 1510 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 4); bm1++) { |
| 1511 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 1512 | const bool input1_broadcast_dim2 = bm1 & (uint32_t(1) << 1); |
| 1513 | const bool input1_broadcast_dim3 = bm1 & (uint32_t(1) << 2); |
| 1514 | const bool input1_broadcast_dim4 = bm1 & (uint32_t(1) << 3); |
| 1515 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 1516 | const size_t input1_dim2 = input1_broadcast_dim2 ? 1 : kDim2; |
| 1517 | const size_t input1_dim3 = input1_broadcast_dim3 ? 1 : kDim3; |
| 1518 | const size_t input1_dim4 = input1_broadcast_dim4 ? 1 : kDim4; |
| 1519 | BinaryElementwiseOperatorTester() |
| 1520 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 1521 | .input1_shape({input1_dim4, input1_dim3, input1_dim2, input1_dim1}) |
| 1522 | .TestF32(); |
| 1523 | } |
| 1524 | } |
| 1525 | |
| 1526 | TEST(ADD_ND_F32, 4d_x_1d) { |
| 1527 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 4); bm1++) { |
| 1528 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 1); bm2++) { |
| 1529 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 1530 | const bool input1_broadcast_dim2 = bm1 & (uint32_t(1) << 1); |
| 1531 | const bool input1_broadcast_dim3 = bm1 & (uint32_t(1) << 2); |
| 1532 | const bool input1_broadcast_dim4 = bm1 & (uint32_t(1) << 3); |
| 1533 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 1534 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 1535 | const size_t input1_dim2 = input1_broadcast_dim2 ? 1 : kDim2; |
| 1536 | const size_t input1_dim3 = input1_broadcast_dim3 ? 1 : kDim3; |
| 1537 | const size_t input1_dim4 = input1_broadcast_dim4 ? 1 : kDim4; |
| 1538 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 1539 | BinaryElementwiseOperatorTester() |
| 1540 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 1541 | .input1_shape({input1_dim4, input1_dim3, input1_dim2, input1_dim1}) |
| 1542 | .input2_shape({input2_dim1}) |
| 1543 | .TestF32(); |
| 1544 | } |
| 1545 | } |
| 1546 | } |
| 1547 | |
| 1548 | TEST(ADD_ND_F32, 4d_x_2d) { |
| 1549 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 4); bm1++) { |
| 1550 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 2); bm2++) { |
| 1551 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 1552 | const bool input1_broadcast_dim2 = bm1 & (uint32_t(1) << 1); |
| 1553 | const bool input1_broadcast_dim3 = bm1 & (uint32_t(1) << 2); |
| 1554 | const bool input1_broadcast_dim4 = bm1 & (uint32_t(1) << 3); |
| 1555 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 1556 | const bool input2_broadcast_dim2 = bm2 & (uint32_t(1) << 1); |
| 1557 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 1558 | const size_t input1_dim2 = input1_broadcast_dim2 ? 1 : kDim2; |
| 1559 | const size_t input1_dim3 = input1_broadcast_dim3 ? 1 : kDim3; |
| 1560 | const size_t input1_dim4 = input1_broadcast_dim4 ? 1 : kDim4; |
| 1561 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 1562 | const size_t input2_dim2 = input2_broadcast_dim2 ? 1 : kDim2; |
| 1563 | BinaryElementwiseOperatorTester() |
| 1564 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 1565 | .input1_shape({input1_dim4, input1_dim3, input1_dim2, input1_dim1}) |
| 1566 | .input2_shape({input2_dim2, input2_dim1}) |
| 1567 | .TestF32(); |
| 1568 | } |
| 1569 | } |
| 1570 | } |
| 1571 | |
| 1572 | TEST(ADD_ND_F32, 4d_x_3d) { |
| 1573 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 4); bm1++) { |
| 1574 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 3); bm2++) { |
| 1575 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 1576 | const bool input1_broadcast_dim2 = bm1 & (uint32_t(1) << 1); |
| 1577 | const bool input1_broadcast_dim3 = bm1 & (uint32_t(1) << 2); |
| 1578 | const bool input1_broadcast_dim4 = bm1 & (uint32_t(1) << 3); |
| 1579 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 1580 | const bool input2_broadcast_dim2 = bm2 & (uint32_t(1) << 1); |
| 1581 | const bool input2_broadcast_dim3 = bm2 & (uint32_t(1) << 2); |
| 1582 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 1583 | const size_t input1_dim2 = input1_broadcast_dim2 ? 1 : kDim2; |
| 1584 | const size_t input1_dim3 = input1_broadcast_dim3 ? 1 : kDim3; |
| 1585 | const size_t input1_dim4 = input1_broadcast_dim4 ? 1 : kDim4; |
| 1586 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 1587 | const size_t input2_dim2 = input2_broadcast_dim2 ? 1 : kDim2; |
| 1588 | const size_t input2_dim3 = input2_broadcast_dim3 ? 1 : kDim3; |
| 1589 | BinaryElementwiseOperatorTester() |
| 1590 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 1591 | .input1_shape({input1_dim4, input1_dim3, input1_dim2, input1_dim1}) |
| 1592 | .input2_shape({input2_dim3, input2_dim2, input2_dim1}) |
| 1593 | .TestF32(); |
| 1594 | } |
| 1595 | } |
| 1596 | } |
| 1597 | |
| 1598 | TEST(ADD_ND_F32, 4d_x_4d) { |
| 1599 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 4); bm1++) { |
| 1600 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 4); bm2++) { |
| 1601 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 1602 | const bool input1_broadcast_dim2 = bm1 & (uint32_t(1) << 1); |
| 1603 | const bool input1_broadcast_dim3 = bm1 & (uint32_t(1) << 2); |
| 1604 | const bool input1_broadcast_dim4 = bm1 & (uint32_t(1) << 3); |
| 1605 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 1606 | const bool input2_broadcast_dim2 = bm2 & (uint32_t(1) << 1); |
| 1607 | const bool input2_broadcast_dim3 = bm2 & (uint32_t(1) << 2); |
| 1608 | const bool input2_broadcast_dim4 = bm2 & (uint32_t(1) << 3); |
| 1609 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 1610 | const size_t input1_dim2 = input1_broadcast_dim2 ? 1 : kDim2; |
| 1611 | const size_t input1_dim3 = input1_broadcast_dim3 ? 1 : kDim3; |
| 1612 | const size_t input1_dim4 = input1_broadcast_dim4 ? 1 : kDim4; |
| 1613 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 1614 | const size_t input2_dim2 = input2_broadcast_dim2 ? 1 : kDim2; |
| 1615 | const size_t input2_dim3 = input2_broadcast_dim3 ? 1 : kDim3; |
| 1616 | const size_t input2_dim4 = input2_broadcast_dim4 ? 1 : kDim4; |
| 1617 | BinaryElementwiseOperatorTester() |
| 1618 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 1619 | .input1_shape({input1_dim4, input1_dim3, input1_dim2, input1_dim1}) |
| 1620 | .input2_shape({input2_dim4, input2_dim3, input2_dim2, input2_dim1}) |
| 1621 | .TestF32(); |
| 1622 | } |
| 1623 | } |
Marat Dukhan | b1a0fc3 | 2019-12-02 19:32:02 -0800 | [diff] [blame] | 1624 | } |
Marat Dukhan | fc2b96e | 2019-12-03 12:04:04 -0800 | [diff] [blame] | 1625 | |
| 1626 | TEST(ADD_ND_F32, 0d_x_5d) { |
| 1627 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 5); bm2++) { |
| 1628 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 1629 | const bool input2_broadcast_dim2 = bm2 & (uint32_t(1) << 1); |
| 1630 | const bool input2_broadcast_dim3 = bm2 & (uint32_t(1) << 2); |
| 1631 | const bool input2_broadcast_dim4 = bm2 & (uint32_t(1) << 3); |
| 1632 | const bool input2_broadcast_dim5 = bm2 & (uint32_t(1) << 4); |
| 1633 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 1634 | const size_t input2_dim2 = input2_broadcast_dim2 ? 1 : kDim2; |
| 1635 | const size_t input2_dim3 = input2_broadcast_dim3 ? 1 : kDim3; |
| 1636 | const size_t input2_dim4 = input2_broadcast_dim4 ? 1 : kDim4; |
| 1637 | const size_t input2_dim5 = input2_broadcast_dim5 ? 1 : kDim5; |
| 1638 | BinaryElementwiseOperatorTester() |
| 1639 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 1640 | .input2_shape({input2_dim5, input2_dim4, input2_dim3, input2_dim2, input2_dim1}) |
| 1641 | .TestF32(); |
| 1642 | } |
| 1643 | } |
| 1644 | |
| 1645 | TEST(ADD_ND_F32, 1d_x_5d) { |
| 1646 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 1); bm1++) { |
| 1647 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 5); bm2++) { |
| 1648 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 1649 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 1650 | const bool input2_broadcast_dim2 = bm2 & (uint32_t(1) << 1); |
| 1651 | const bool input2_broadcast_dim3 = bm2 & (uint32_t(1) << 2); |
| 1652 | const bool input2_broadcast_dim4 = bm2 & (uint32_t(1) << 3); |
| 1653 | const bool input2_broadcast_dim5 = bm2 & (uint32_t(1) << 4); |
| 1654 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 1655 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 1656 | const size_t input2_dim2 = input2_broadcast_dim2 ? 1 : kDim2; |
| 1657 | const size_t input2_dim3 = input2_broadcast_dim3 ? 1 : kDim3; |
| 1658 | const size_t input2_dim4 = input2_broadcast_dim4 ? 1 : kDim4; |
| 1659 | const size_t input2_dim5 = input2_broadcast_dim5 ? 1 : kDim5; |
| 1660 | BinaryElementwiseOperatorTester() |
| 1661 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 1662 | .input1_shape({input1_dim1}) |
| 1663 | .input2_shape({input2_dim5, input2_dim4, input2_dim3, input2_dim2, input2_dim1}) |
| 1664 | .TestF32(); |
| 1665 | } |
| 1666 | } |
| 1667 | } |
| 1668 | |
| 1669 | TEST(ADD_ND_F32, 2d_x_5d) { |
| 1670 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 2); bm1++) { |
| 1671 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 5); bm2++) { |
| 1672 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 1673 | const bool input1_broadcast_dim2 = bm1 & (uint32_t(1) << 1); |
| 1674 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 1675 | const bool input2_broadcast_dim2 = bm2 & (uint32_t(1) << 1); |
| 1676 | const bool input2_broadcast_dim3 = bm2 & (uint32_t(1) << 2); |
| 1677 | const bool input2_broadcast_dim4 = bm2 & (uint32_t(1) << 3); |
| 1678 | const bool input2_broadcast_dim5 = bm2 & (uint32_t(1) << 4); |
| 1679 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 1680 | const size_t input1_dim2 = input1_broadcast_dim2 ? 1 : kDim2; |
| 1681 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 1682 | const size_t input2_dim2 = input2_broadcast_dim2 ? 1 : kDim2; |
| 1683 | const size_t input2_dim3 = input2_broadcast_dim3 ? 1 : kDim3; |
| 1684 | const size_t input2_dim4 = input2_broadcast_dim4 ? 1 : kDim4; |
| 1685 | const size_t input2_dim5 = input2_broadcast_dim5 ? 1 : kDim5; |
| 1686 | BinaryElementwiseOperatorTester() |
| 1687 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 1688 | .input1_shape({input1_dim2, input1_dim1}) |
| 1689 | .input2_shape({input2_dim5, input2_dim4, input2_dim3, input2_dim2, input2_dim1}) |
| 1690 | .TestF32(); |
| 1691 | } |
| 1692 | } |
| 1693 | } |
| 1694 | |
| 1695 | TEST(ADD_ND_F32, 3d_x_5d) { |
| 1696 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 3); bm1++) { |
| 1697 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 5); bm2++) { |
| 1698 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 1699 | const bool input1_broadcast_dim2 = bm1 & (uint32_t(1) << 1); |
| 1700 | const bool input1_broadcast_dim3 = bm1 & (uint32_t(1) << 2); |
| 1701 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 1702 | const bool input2_broadcast_dim2 = bm2 & (uint32_t(1) << 1); |
| 1703 | const bool input2_broadcast_dim3 = bm2 & (uint32_t(1) << 2); |
| 1704 | const bool input2_broadcast_dim4 = bm2 & (uint32_t(1) << 3); |
| 1705 | const bool input2_broadcast_dim5 = bm2 & (uint32_t(1) << 4); |
| 1706 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 1707 | const size_t input1_dim2 = input1_broadcast_dim2 ? 1 : kDim2; |
| 1708 | const size_t input1_dim3 = input1_broadcast_dim3 ? 1 : kDim3; |
| 1709 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 1710 | const size_t input2_dim2 = input2_broadcast_dim2 ? 1 : kDim2; |
| 1711 | const size_t input2_dim3 = input2_broadcast_dim3 ? 1 : kDim3; |
| 1712 | const size_t input2_dim4 = input2_broadcast_dim4 ? 1 : kDim4; |
| 1713 | const size_t input2_dim5 = input2_broadcast_dim5 ? 1 : kDim5; |
| 1714 | BinaryElementwiseOperatorTester() |
| 1715 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 1716 | .input1_shape({input1_dim3, input1_dim2, input1_dim1}) |
| 1717 | .input2_shape({input2_dim5, input2_dim4, input2_dim3, input2_dim2, input2_dim1}) |
| 1718 | .TestF32(); |
| 1719 | } |
| 1720 | } |
| 1721 | } |
| 1722 | |
| 1723 | TEST(ADD_ND_F32, 4d_x_5d) { |
| 1724 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 4); bm1++) { |
| 1725 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 5); bm2++) { |
| 1726 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 1727 | const bool input1_broadcast_dim2 = bm1 & (uint32_t(1) << 1); |
| 1728 | const bool input1_broadcast_dim3 = bm1 & (uint32_t(1) << 2); |
| 1729 | const bool input1_broadcast_dim4 = bm1 & (uint32_t(1) << 3); |
| 1730 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 1731 | const bool input2_broadcast_dim2 = bm2 & (uint32_t(1) << 1); |
| 1732 | const bool input2_broadcast_dim3 = bm2 & (uint32_t(1) << 2); |
| 1733 | const bool input2_broadcast_dim4 = bm2 & (uint32_t(1) << 3); |
| 1734 | const bool input2_broadcast_dim5 = bm2 & (uint32_t(1) << 4); |
| 1735 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 1736 | const size_t input1_dim2 = input1_broadcast_dim2 ? 1 : kDim2; |
| 1737 | const size_t input1_dim3 = input1_broadcast_dim3 ? 1 : kDim3; |
| 1738 | const size_t input1_dim4 = input1_broadcast_dim4 ? 1 : kDim4; |
| 1739 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 1740 | const size_t input2_dim2 = input2_broadcast_dim2 ? 1 : kDim2; |
| 1741 | const size_t input2_dim3 = input2_broadcast_dim3 ? 1 : kDim3; |
| 1742 | const size_t input2_dim4 = input2_broadcast_dim4 ? 1 : kDim4; |
| 1743 | const size_t input2_dim5 = input2_broadcast_dim5 ? 1 : kDim5; |
| 1744 | BinaryElementwiseOperatorTester() |
| 1745 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 1746 | .input1_shape({input1_dim4, input1_dim3, input1_dim2, input1_dim1}) |
| 1747 | .input2_shape({input2_dim5, input2_dim4, input2_dim3, input2_dim2, input2_dim1}) |
| 1748 | .TestF32(); |
| 1749 | } |
| 1750 | } |
| 1751 | } |
| 1752 | |
| 1753 | TEST(ADD_ND_F32, 5d_x_0d) { |
| 1754 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 5); bm1++) { |
| 1755 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 1756 | const bool input1_broadcast_dim2 = bm1 & (uint32_t(1) << 1); |
| 1757 | const bool input1_broadcast_dim3 = bm1 & (uint32_t(1) << 2); |
| 1758 | const bool input1_broadcast_dim4 = bm1 & (uint32_t(1) << 3); |
| 1759 | const bool input1_broadcast_dim5 = bm1 & (uint32_t(1) << 4); |
| 1760 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 1761 | const size_t input1_dim2 = input1_broadcast_dim2 ? 1 : kDim2; |
| 1762 | const size_t input1_dim3 = input1_broadcast_dim3 ? 1 : kDim3; |
| 1763 | const size_t input1_dim4 = input1_broadcast_dim4 ? 1 : kDim4; |
| 1764 | const size_t input1_dim5 = input1_broadcast_dim5 ? 1 : kDim5; |
| 1765 | BinaryElementwiseOperatorTester() |
| 1766 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 1767 | .input1_shape({input1_dim5, input1_dim4, input1_dim3, input1_dim2, input1_dim1}) |
| 1768 | .TestF32(); |
| 1769 | } |
| 1770 | } |
| 1771 | |
| 1772 | TEST(ADD_ND_F32, 5d_x_1d) { |
| 1773 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 5); bm1++) { |
| 1774 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 1); bm2++) { |
| 1775 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 1776 | const bool input1_broadcast_dim2 = bm1 & (uint32_t(1) << 1); |
| 1777 | const bool input1_broadcast_dim3 = bm1 & (uint32_t(1) << 2); |
| 1778 | const bool input1_broadcast_dim4 = bm1 & (uint32_t(1) << 3); |
| 1779 | const bool input1_broadcast_dim5 = bm1 & (uint32_t(1) << 4); |
| 1780 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 1781 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 1782 | const size_t input1_dim2 = input1_broadcast_dim2 ? 1 : kDim2; |
| 1783 | const size_t input1_dim3 = input1_broadcast_dim3 ? 1 : kDim3; |
| 1784 | const size_t input1_dim4 = input1_broadcast_dim4 ? 1 : kDim4; |
| 1785 | const size_t input1_dim5 = input1_broadcast_dim5 ? 1 : kDim5; |
| 1786 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 1787 | BinaryElementwiseOperatorTester() |
| 1788 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 1789 | .input1_shape({input1_dim5, input1_dim4, input1_dim3, input1_dim2, input1_dim1}) |
| 1790 | .input2_shape({input2_dim1}) |
| 1791 | .TestF32(); |
| 1792 | } |
| 1793 | } |
| 1794 | } |
| 1795 | |
| 1796 | TEST(ADD_ND_F32, 5d_x_2d) { |
| 1797 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 5); bm1++) { |
| 1798 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 2); bm2++) { |
| 1799 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 1800 | const bool input1_broadcast_dim2 = bm1 & (uint32_t(1) << 1); |
| 1801 | const bool input1_broadcast_dim3 = bm1 & (uint32_t(1) << 2); |
| 1802 | const bool input1_broadcast_dim4 = bm1 & (uint32_t(1) << 3); |
| 1803 | const bool input1_broadcast_dim5 = bm1 & (uint32_t(1) << 4); |
| 1804 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 1805 | const bool input2_broadcast_dim2 = bm2 & (uint32_t(1) << 1); |
| 1806 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 1807 | const size_t input1_dim2 = input1_broadcast_dim2 ? 1 : kDim2; |
| 1808 | const size_t input1_dim3 = input1_broadcast_dim3 ? 1 : kDim3; |
| 1809 | const size_t input1_dim4 = input1_broadcast_dim4 ? 1 : kDim4; |
| 1810 | const size_t input1_dim5 = input1_broadcast_dim5 ? 1 : kDim5; |
| 1811 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 1812 | const size_t input2_dim2 = input2_broadcast_dim2 ? 1 : kDim2; |
| 1813 | BinaryElementwiseOperatorTester() |
| 1814 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 1815 | .input1_shape({input1_dim5, input1_dim4, input1_dim3, input1_dim2, input1_dim1}) |
| 1816 | .input2_shape({input2_dim2, input2_dim1}) |
| 1817 | .TestF32(); |
| 1818 | } |
| 1819 | } |
| 1820 | } |
| 1821 | |
| 1822 | TEST(ADD_ND_F32, 5d_x_3d) { |
| 1823 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 5); bm1++) { |
| 1824 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 3); bm2++) { |
| 1825 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 1826 | const bool input1_broadcast_dim2 = bm1 & (uint32_t(1) << 1); |
| 1827 | const bool input1_broadcast_dim3 = bm1 & (uint32_t(1) << 2); |
| 1828 | const bool input1_broadcast_dim4 = bm1 & (uint32_t(1) << 3); |
| 1829 | const bool input1_broadcast_dim5 = bm1 & (uint32_t(1) << 4); |
| 1830 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 1831 | const bool input2_broadcast_dim2 = bm2 & (uint32_t(1) << 1); |
| 1832 | const bool input2_broadcast_dim3 = bm2 & (uint32_t(1) << 2); |
| 1833 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 1834 | const size_t input1_dim2 = input1_broadcast_dim2 ? 1 : kDim2; |
| 1835 | const size_t input1_dim3 = input1_broadcast_dim3 ? 1 : kDim3; |
| 1836 | const size_t input1_dim4 = input1_broadcast_dim4 ? 1 : kDim4; |
| 1837 | const size_t input1_dim5 = input1_broadcast_dim5 ? 1 : kDim5; |
| 1838 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 1839 | const size_t input2_dim2 = input2_broadcast_dim2 ? 1 : kDim2; |
| 1840 | const size_t input2_dim3 = input2_broadcast_dim3 ? 1 : kDim3; |
| 1841 | BinaryElementwiseOperatorTester() |
| 1842 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 1843 | .input1_shape({input1_dim5, input1_dim4, input1_dim3, input1_dim2, input1_dim1}) |
| 1844 | .input2_shape({input2_dim3, input2_dim2, input2_dim1}) |
| 1845 | .TestF32(); |
| 1846 | } |
| 1847 | } |
| 1848 | } |
| 1849 | |
| 1850 | TEST(ADD_ND_F32, 5d_x_4d) { |
| 1851 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 5); bm1++) { |
| 1852 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 4); bm2++) { |
| 1853 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 1854 | const bool input1_broadcast_dim2 = bm1 & (uint32_t(1) << 1); |
| 1855 | const bool input1_broadcast_dim3 = bm1 & (uint32_t(1) << 2); |
| 1856 | const bool input1_broadcast_dim4 = bm1 & (uint32_t(1) << 3); |
| 1857 | const bool input1_broadcast_dim5 = bm1 & (uint32_t(1) << 4); |
| 1858 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 1859 | const bool input2_broadcast_dim2 = bm2 & (uint32_t(1) << 1); |
| 1860 | const bool input2_broadcast_dim3 = bm2 & (uint32_t(1) << 2); |
| 1861 | const bool input2_broadcast_dim4 = bm2 & (uint32_t(1) << 3); |
| 1862 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 1863 | const size_t input1_dim2 = input1_broadcast_dim2 ? 1 : kDim2; |
| 1864 | const size_t input1_dim3 = input1_broadcast_dim3 ? 1 : kDim3; |
| 1865 | const size_t input1_dim4 = input1_broadcast_dim4 ? 1 : kDim4; |
| 1866 | const size_t input1_dim5 = input1_broadcast_dim5 ? 1 : kDim5; |
| 1867 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 1868 | const size_t input2_dim2 = input2_broadcast_dim2 ? 1 : kDim2; |
| 1869 | const size_t input2_dim3 = input2_broadcast_dim3 ? 1 : kDim3; |
| 1870 | const size_t input2_dim4 = input2_broadcast_dim4 ? 1 : kDim4; |
| 1871 | BinaryElementwiseOperatorTester() |
| 1872 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 1873 | .input1_shape({input1_dim5, input1_dim4, input1_dim3, input1_dim2, input1_dim1}) |
| 1874 | .input2_shape({input2_dim4, input2_dim3, input2_dim2, input2_dim1}) |
| 1875 | .TestF32(); |
| 1876 | } |
| 1877 | } |
| 1878 | } |
| 1879 | |
| 1880 | TEST(ADD_ND_F32, 5d_x_5d) { |
| 1881 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 5); bm1++) { |
| 1882 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 5); bm2++) { |
| 1883 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 1884 | const bool input1_broadcast_dim2 = bm1 & (uint32_t(1) << 1); |
| 1885 | const bool input1_broadcast_dim3 = bm1 & (uint32_t(1) << 2); |
| 1886 | const bool input1_broadcast_dim4 = bm1 & (uint32_t(1) << 3); |
| 1887 | const bool input1_broadcast_dim5 = bm1 & (uint32_t(1) << 4); |
| 1888 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 1889 | const bool input2_broadcast_dim2 = bm2 & (uint32_t(1) << 1); |
| 1890 | const bool input2_broadcast_dim3 = bm2 & (uint32_t(1) << 2); |
| 1891 | const bool input2_broadcast_dim4 = bm2 & (uint32_t(1) << 3); |
| 1892 | const bool input2_broadcast_dim5 = bm2 & (uint32_t(1) << 4); |
| 1893 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 1894 | const size_t input1_dim2 = input1_broadcast_dim2 ? 1 : kDim2; |
| 1895 | const size_t input1_dim3 = input1_broadcast_dim3 ? 1 : kDim3; |
| 1896 | const size_t input1_dim4 = input1_broadcast_dim4 ? 1 : kDim4; |
| 1897 | const size_t input1_dim5 = input1_broadcast_dim5 ? 1 : kDim5; |
| 1898 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 1899 | const size_t input2_dim2 = input2_broadcast_dim2 ? 1 : kDim2; |
| 1900 | const size_t input2_dim3 = input2_broadcast_dim3 ? 1 : kDim3; |
| 1901 | const size_t input2_dim4 = input2_broadcast_dim4 ? 1 : kDim4; |
| 1902 | const size_t input2_dim5 = input2_broadcast_dim5 ? 1 : kDim5; |
| 1903 | BinaryElementwiseOperatorTester() |
| 1904 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 1905 | .input1_shape({input1_dim5, input1_dim4, input1_dim3, input1_dim2, input1_dim1}) |
| 1906 | .input2_shape({input2_dim5, input2_dim4, input2_dim3, input2_dim2, input2_dim1}) |
| 1907 | .iterations(1) |
| 1908 | .TestF32(); |
| 1909 | } |
| 1910 | } |
| 1911 | } |
| 1912 | |
| 1913 | TEST(ADD_ND_F32, 0d_x_6d) { |
| 1914 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 6); bm2++) { |
| 1915 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 1916 | const bool input2_broadcast_dim2 = bm2 & (uint32_t(1) << 1); |
| 1917 | const bool input2_broadcast_dim3 = bm2 & (uint32_t(1) << 2); |
| 1918 | const bool input2_broadcast_dim4 = bm2 & (uint32_t(1) << 3); |
| 1919 | const bool input2_broadcast_dim5 = bm2 & (uint32_t(1) << 4); |
| 1920 | const bool input2_broadcast_dim6 = bm2 & (uint32_t(1) << 5); |
| 1921 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 1922 | const size_t input2_dim2 = input2_broadcast_dim2 ? 1 : kDim2; |
| 1923 | const size_t input2_dim3 = input2_broadcast_dim3 ? 1 : kDim3; |
| 1924 | const size_t input2_dim4 = input2_broadcast_dim4 ? 1 : kDim4; |
| 1925 | const size_t input2_dim5 = input2_broadcast_dim5 ? 1 : kDim5; |
| 1926 | const size_t input2_dim6 = input2_broadcast_dim6 ? 1 : kDim6; |
| 1927 | BinaryElementwiseOperatorTester() |
| 1928 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 1929 | .input2_shape({input2_dim6, input2_dim5, input2_dim4, input2_dim3, input2_dim2, input2_dim1}) |
| 1930 | .TestF32(); |
| 1931 | } |
| 1932 | } |
| 1933 | |
| 1934 | TEST(ADD_ND_F32, 1d_x_6d) { |
| 1935 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 1); bm1++) { |
| 1936 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 6); bm2++) { |
| 1937 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 1938 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 1939 | const bool input2_broadcast_dim2 = bm2 & (uint32_t(1) << 1); |
| 1940 | const bool input2_broadcast_dim3 = bm2 & (uint32_t(1) << 2); |
| 1941 | const bool input2_broadcast_dim4 = bm2 & (uint32_t(1) << 3); |
| 1942 | const bool input2_broadcast_dim5 = bm2 & (uint32_t(1) << 4); |
| 1943 | const bool input2_broadcast_dim6 = bm2 & (uint32_t(1) << 5); |
| 1944 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 1945 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 1946 | const size_t input2_dim2 = input2_broadcast_dim2 ? 1 : kDim2; |
| 1947 | const size_t input2_dim3 = input2_broadcast_dim3 ? 1 : kDim3; |
| 1948 | const size_t input2_dim4 = input2_broadcast_dim4 ? 1 : kDim4; |
| 1949 | const size_t input2_dim5 = input2_broadcast_dim5 ? 1 : kDim5; |
| 1950 | const size_t input2_dim6 = input2_broadcast_dim6 ? 1 : kDim6; |
| 1951 | BinaryElementwiseOperatorTester() |
| 1952 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 1953 | .input1_shape({input1_dim1}) |
| 1954 | .input2_shape({input2_dim6, input2_dim5, input2_dim4, input2_dim3, input2_dim2, input2_dim1}) |
| 1955 | .TestF32(); |
| 1956 | } |
| 1957 | } |
| 1958 | } |
| 1959 | |
| 1960 | TEST(ADD_ND_F32, 2d_x_6d) { |
| 1961 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 2); bm1++) { |
| 1962 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 6); bm2++) { |
| 1963 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 1964 | const bool input1_broadcast_dim2 = bm1 & (uint32_t(1) << 1); |
| 1965 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 1966 | const bool input2_broadcast_dim2 = bm2 & (uint32_t(1) << 1); |
| 1967 | const bool input2_broadcast_dim3 = bm2 & (uint32_t(1) << 2); |
| 1968 | const bool input2_broadcast_dim4 = bm2 & (uint32_t(1) << 3); |
| 1969 | const bool input2_broadcast_dim5 = bm2 & (uint32_t(1) << 4); |
| 1970 | const bool input2_broadcast_dim6 = bm2 & (uint32_t(1) << 5); |
| 1971 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 1972 | const size_t input1_dim2 = input1_broadcast_dim2 ? 1 : kDim2; |
| 1973 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 1974 | const size_t input2_dim2 = input2_broadcast_dim2 ? 1 : kDim2; |
| 1975 | const size_t input2_dim3 = input2_broadcast_dim3 ? 1 : kDim3; |
| 1976 | const size_t input2_dim4 = input2_broadcast_dim4 ? 1 : kDim4; |
| 1977 | const size_t input2_dim5 = input2_broadcast_dim5 ? 1 : kDim5; |
| 1978 | const size_t input2_dim6 = input2_broadcast_dim6 ? 1 : kDim6; |
| 1979 | BinaryElementwiseOperatorTester() |
| 1980 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 1981 | .input1_shape({input1_dim2, input1_dim1}) |
| 1982 | .input2_shape({input2_dim6, input2_dim5, input2_dim4, input2_dim3, input2_dim2, input2_dim1}) |
| 1983 | .TestF32(); |
| 1984 | } |
| 1985 | } |
| 1986 | } |
| 1987 | |
| 1988 | TEST(ADD_ND_F32, 3d_x_6d) { |
| 1989 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 3); bm1++) { |
| 1990 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 6); bm2++) { |
| 1991 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 1992 | const bool input1_broadcast_dim2 = bm1 & (uint32_t(1) << 1); |
| 1993 | const bool input1_broadcast_dim3 = bm1 & (uint32_t(1) << 2); |
| 1994 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 1995 | const bool input2_broadcast_dim2 = bm2 & (uint32_t(1) << 1); |
| 1996 | const bool input2_broadcast_dim3 = bm2 & (uint32_t(1) << 2); |
| 1997 | const bool input2_broadcast_dim4 = bm2 & (uint32_t(1) << 3); |
| 1998 | const bool input2_broadcast_dim5 = bm2 & (uint32_t(1) << 4); |
| 1999 | const bool input2_broadcast_dim6 = bm2 & (uint32_t(1) << 5); |
| 2000 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 2001 | const size_t input1_dim2 = input1_broadcast_dim2 ? 1 : kDim2; |
| 2002 | const size_t input1_dim3 = input1_broadcast_dim3 ? 1 : kDim3; |
| 2003 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 2004 | const size_t input2_dim2 = input2_broadcast_dim2 ? 1 : kDim2; |
| 2005 | const size_t input2_dim3 = input2_broadcast_dim3 ? 1 : kDim3; |
| 2006 | const size_t input2_dim4 = input2_broadcast_dim4 ? 1 : kDim4; |
| 2007 | const size_t input2_dim5 = input2_broadcast_dim5 ? 1 : kDim5; |
| 2008 | const size_t input2_dim6 = input2_broadcast_dim6 ? 1 : kDim6; |
| 2009 | BinaryElementwiseOperatorTester() |
| 2010 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 2011 | .input1_shape({input1_dim3, input1_dim2, input1_dim1}) |
| 2012 | .input2_shape({input2_dim6, input2_dim5, input2_dim4, input2_dim3, input2_dim2, input2_dim1}) |
| 2013 | .TestF32(); |
| 2014 | } |
| 2015 | } |
| 2016 | } |
| 2017 | |
| 2018 | TEST(ADD_ND_F32, 4d_x_6d) { |
| 2019 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 4); bm1++) { |
| 2020 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 6); bm2++) { |
| 2021 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 2022 | const bool input1_broadcast_dim2 = bm1 & (uint32_t(1) << 1); |
| 2023 | const bool input1_broadcast_dim3 = bm1 & (uint32_t(1) << 2); |
| 2024 | const bool input1_broadcast_dim4 = bm1 & (uint32_t(1) << 3); |
| 2025 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 2026 | const bool input2_broadcast_dim2 = bm2 & (uint32_t(1) << 1); |
| 2027 | const bool input2_broadcast_dim3 = bm2 & (uint32_t(1) << 2); |
| 2028 | const bool input2_broadcast_dim4 = bm2 & (uint32_t(1) << 3); |
| 2029 | const bool input2_broadcast_dim5 = bm2 & (uint32_t(1) << 4); |
| 2030 | const bool input2_broadcast_dim6 = bm2 & (uint32_t(1) << 5); |
| 2031 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 2032 | const size_t input1_dim2 = input1_broadcast_dim2 ? 1 : kDim2; |
| 2033 | const size_t input1_dim3 = input1_broadcast_dim3 ? 1 : kDim3; |
| 2034 | const size_t input1_dim4 = input1_broadcast_dim4 ? 1 : kDim4; |
| 2035 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 2036 | const size_t input2_dim2 = input2_broadcast_dim2 ? 1 : kDim2; |
| 2037 | const size_t input2_dim3 = input2_broadcast_dim3 ? 1 : kDim3; |
| 2038 | const size_t input2_dim4 = input2_broadcast_dim4 ? 1 : kDim4; |
| 2039 | const size_t input2_dim5 = input2_broadcast_dim5 ? 1 : kDim5; |
| 2040 | const size_t input2_dim6 = input2_broadcast_dim6 ? 1 : kDim6; |
| 2041 | BinaryElementwiseOperatorTester() |
| 2042 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 2043 | .input1_shape({input1_dim4, input1_dim3, input1_dim2, input1_dim1}) |
| 2044 | .input2_shape({input2_dim6, input2_dim5, input2_dim4, input2_dim3, input2_dim2, input2_dim1}) |
| 2045 | .TestF32(); |
| 2046 | } |
| 2047 | } |
| 2048 | } |
| 2049 | |
| 2050 | TEST(ADD_ND_F32, 5d_x_6d) { |
| 2051 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 5); bm1++) { |
| 2052 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 6); bm2++) { |
| 2053 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 2054 | const bool input1_broadcast_dim2 = bm1 & (uint32_t(1) << 1); |
| 2055 | const bool input1_broadcast_dim3 = bm1 & (uint32_t(1) << 2); |
| 2056 | const bool input1_broadcast_dim4 = bm1 & (uint32_t(1) << 3); |
| 2057 | const bool input1_broadcast_dim5 = bm1 & (uint32_t(1) << 4); |
| 2058 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 2059 | const bool input2_broadcast_dim2 = bm2 & (uint32_t(1) << 1); |
| 2060 | const bool input2_broadcast_dim3 = bm2 & (uint32_t(1) << 2); |
| 2061 | const bool input2_broadcast_dim4 = bm2 & (uint32_t(1) << 3); |
| 2062 | const bool input2_broadcast_dim5 = bm2 & (uint32_t(1) << 4); |
| 2063 | const bool input2_broadcast_dim6 = bm2 & (uint32_t(1) << 5); |
| 2064 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 2065 | const size_t input1_dim2 = input1_broadcast_dim2 ? 1 : kDim2; |
| 2066 | const size_t input1_dim3 = input1_broadcast_dim3 ? 1 : kDim3; |
| 2067 | const size_t input1_dim4 = input1_broadcast_dim4 ? 1 : kDim4; |
| 2068 | const size_t input1_dim5 = input1_broadcast_dim5 ? 1 : kDim5; |
| 2069 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 2070 | const size_t input2_dim2 = input2_broadcast_dim2 ? 1 : kDim2; |
| 2071 | const size_t input2_dim3 = input2_broadcast_dim3 ? 1 : kDim3; |
| 2072 | const size_t input2_dim4 = input2_broadcast_dim4 ? 1 : kDim4; |
| 2073 | const size_t input2_dim5 = input2_broadcast_dim5 ? 1 : kDim5; |
| 2074 | const size_t input2_dim6 = input2_broadcast_dim6 ? 1 : kDim6; |
| 2075 | BinaryElementwiseOperatorTester() |
| 2076 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 2077 | .input1_shape({input1_dim5, input1_dim4, input1_dim3, input1_dim2, input1_dim1}) |
| 2078 | .input2_shape({input2_dim6, input2_dim5, input2_dim4, input2_dim3, input2_dim2, input2_dim1}) |
| 2079 | .iterations(1) |
| 2080 | .TestF32(); |
| 2081 | } |
| 2082 | } |
| 2083 | } |
| 2084 | |
| 2085 | TEST(ADD_ND_F32, 6d_x_0d) { |
| 2086 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 6); bm1++) { |
| 2087 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 2088 | const bool input1_broadcast_dim2 = bm1 & (uint32_t(1) << 1); |
| 2089 | const bool input1_broadcast_dim3 = bm1 & (uint32_t(1) << 2); |
| 2090 | const bool input1_broadcast_dim4 = bm1 & (uint32_t(1) << 3); |
| 2091 | const bool input1_broadcast_dim5 = bm1 & (uint32_t(1) << 4); |
| 2092 | const bool input1_broadcast_dim6 = bm1 & (uint32_t(1) << 5); |
| 2093 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 2094 | const size_t input1_dim2 = input1_broadcast_dim2 ? 1 : kDim2; |
| 2095 | const size_t input1_dim3 = input1_broadcast_dim3 ? 1 : kDim3; |
| 2096 | const size_t input1_dim4 = input1_broadcast_dim4 ? 1 : kDim4; |
| 2097 | const size_t input1_dim5 = input1_broadcast_dim5 ? 1 : kDim5; |
| 2098 | const size_t input1_dim6 = input1_broadcast_dim6 ? 1 : kDim6; |
| 2099 | BinaryElementwiseOperatorTester() |
| 2100 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 2101 | .input1_shape({input1_dim6, input1_dim5, input1_dim4, input1_dim3, input1_dim2, input1_dim1}) |
| 2102 | .TestF32(); |
| 2103 | } |
| 2104 | } |
| 2105 | |
| 2106 | TEST(ADD_ND_F32, 6d_x_1d) { |
| 2107 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 6); bm1++) { |
| 2108 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 1); bm2++) { |
| 2109 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 2110 | const bool input1_broadcast_dim2 = bm1 & (uint32_t(1) << 1); |
| 2111 | const bool input1_broadcast_dim3 = bm1 & (uint32_t(1) << 2); |
| 2112 | const bool input1_broadcast_dim4 = bm1 & (uint32_t(1) << 3); |
| 2113 | const bool input1_broadcast_dim5 = bm1 & (uint32_t(1) << 4); |
| 2114 | const bool input1_broadcast_dim6 = bm1 & (uint32_t(1) << 5); |
| 2115 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 2116 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 2117 | const size_t input1_dim2 = input1_broadcast_dim2 ? 1 : kDim2; |
| 2118 | const size_t input1_dim3 = input1_broadcast_dim3 ? 1 : kDim3; |
| 2119 | const size_t input1_dim4 = input1_broadcast_dim4 ? 1 : kDim4; |
| 2120 | const size_t input1_dim5 = input1_broadcast_dim5 ? 1 : kDim5; |
| 2121 | const size_t input1_dim6 = input1_broadcast_dim6 ? 1 : kDim6; |
| 2122 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 2123 | BinaryElementwiseOperatorTester() |
| 2124 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 2125 | .input1_shape({input1_dim6, input1_dim5, input1_dim4, input1_dim3, input1_dim2, input1_dim1}) |
| 2126 | .input2_shape({input2_dim1}) |
| 2127 | .TestF32(); |
| 2128 | } |
| 2129 | } |
| 2130 | } |
| 2131 | |
| 2132 | TEST(ADD_ND_F32, 6d_x_2d) { |
| 2133 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 6); bm1++) { |
| 2134 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 2); bm2++) { |
| 2135 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 2136 | const bool input1_broadcast_dim2 = bm1 & (uint32_t(1) << 1); |
| 2137 | const bool input1_broadcast_dim3 = bm1 & (uint32_t(1) << 2); |
| 2138 | const bool input1_broadcast_dim4 = bm1 & (uint32_t(1) << 3); |
| 2139 | const bool input1_broadcast_dim5 = bm1 & (uint32_t(1) << 4); |
| 2140 | const bool input1_broadcast_dim6 = bm1 & (uint32_t(1) << 5); |
| 2141 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 2142 | const bool input2_broadcast_dim2 = bm2 & (uint32_t(1) << 1); |
| 2143 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 2144 | const size_t input1_dim2 = input1_broadcast_dim2 ? 1 : kDim2; |
| 2145 | const size_t input1_dim3 = input1_broadcast_dim3 ? 1 : kDim3; |
| 2146 | const size_t input1_dim4 = input1_broadcast_dim4 ? 1 : kDim4; |
| 2147 | const size_t input1_dim5 = input1_broadcast_dim5 ? 1 : kDim5; |
| 2148 | const size_t input1_dim6 = input1_broadcast_dim6 ? 1 : kDim6; |
| 2149 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 2150 | const size_t input2_dim2 = input2_broadcast_dim2 ? 1 : kDim2; |
| 2151 | BinaryElementwiseOperatorTester() |
| 2152 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 2153 | .input1_shape({input1_dim6, input1_dim5, input1_dim4, input1_dim3, input1_dim2, input1_dim1}) |
| 2154 | .input2_shape({input2_dim2, input2_dim1}) |
| 2155 | .TestF32(); |
| 2156 | } |
| 2157 | } |
| 2158 | } |
| 2159 | |
| 2160 | TEST(ADD_ND_F32, 6d_x_3d) { |
| 2161 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 6); bm1++) { |
| 2162 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 3); bm2++) { |
| 2163 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 2164 | const bool input1_broadcast_dim2 = bm1 & (uint32_t(1) << 1); |
| 2165 | const bool input1_broadcast_dim3 = bm1 & (uint32_t(1) << 2); |
| 2166 | const bool input1_broadcast_dim4 = bm1 & (uint32_t(1) << 3); |
| 2167 | const bool input1_broadcast_dim5 = bm1 & (uint32_t(1) << 4); |
| 2168 | const bool input1_broadcast_dim6 = bm1 & (uint32_t(1) << 5); |
| 2169 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 2170 | const bool input2_broadcast_dim2 = bm2 & (uint32_t(1) << 1); |
| 2171 | const bool input2_broadcast_dim3 = bm2 & (uint32_t(1) << 2); |
| 2172 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 2173 | const size_t input1_dim2 = input1_broadcast_dim2 ? 1 : kDim2; |
| 2174 | const size_t input1_dim3 = input1_broadcast_dim3 ? 1 : kDim3; |
| 2175 | const size_t input1_dim4 = input1_broadcast_dim4 ? 1 : kDim4; |
| 2176 | const size_t input1_dim5 = input1_broadcast_dim5 ? 1 : kDim5; |
| 2177 | const size_t input1_dim6 = input1_broadcast_dim6 ? 1 : kDim6; |
| 2178 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 2179 | const size_t input2_dim2 = input2_broadcast_dim2 ? 1 : kDim2; |
| 2180 | const size_t input2_dim3 = input2_broadcast_dim3 ? 1 : kDim3; |
| 2181 | BinaryElementwiseOperatorTester() |
| 2182 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 2183 | .input1_shape({input1_dim6, input1_dim5, input1_dim4, input1_dim3, input1_dim2, input1_dim1}) |
| 2184 | .input2_shape({input2_dim3, input2_dim2, input2_dim1}) |
| 2185 | .TestF32(); |
| 2186 | } |
| 2187 | } |
| 2188 | } |
| 2189 | |
| 2190 | TEST(ADD_ND_F32, 6d_x_4d) { |
| 2191 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 6); bm1++) { |
| 2192 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 4); bm2++) { |
| 2193 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 2194 | const bool input1_broadcast_dim2 = bm1 & (uint32_t(1) << 1); |
| 2195 | const bool input1_broadcast_dim3 = bm1 & (uint32_t(1) << 2); |
| 2196 | const bool input1_broadcast_dim4 = bm1 & (uint32_t(1) << 3); |
| 2197 | const bool input1_broadcast_dim5 = bm1 & (uint32_t(1) << 4); |
| 2198 | const bool input1_broadcast_dim6 = bm1 & (uint32_t(1) << 5); |
| 2199 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 2200 | const bool input2_broadcast_dim2 = bm2 & (uint32_t(1) << 1); |
| 2201 | const bool input2_broadcast_dim3 = bm2 & (uint32_t(1) << 2); |
| 2202 | const bool input2_broadcast_dim4 = bm2 & (uint32_t(1) << 3); |
| 2203 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 2204 | const size_t input1_dim2 = input1_broadcast_dim2 ? 1 : kDim2; |
| 2205 | const size_t input1_dim3 = input1_broadcast_dim3 ? 1 : kDim3; |
| 2206 | const size_t input1_dim4 = input1_broadcast_dim4 ? 1 : kDim4; |
| 2207 | const size_t input1_dim5 = input1_broadcast_dim5 ? 1 : kDim5; |
| 2208 | const size_t input1_dim6 = input1_broadcast_dim6 ? 1 : kDim6; |
| 2209 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 2210 | const size_t input2_dim2 = input2_broadcast_dim2 ? 1 : kDim2; |
| 2211 | const size_t input2_dim3 = input2_broadcast_dim3 ? 1 : kDim3; |
| 2212 | const size_t input2_dim4 = input2_broadcast_dim4 ? 1 : kDim4; |
| 2213 | BinaryElementwiseOperatorTester() |
| 2214 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 2215 | .input1_shape({input1_dim6, input1_dim5, input1_dim4, input1_dim3, input1_dim2, input1_dim1}) |
| 2216 | .input2_shape({input2_dim4, input2_dim3, input2_dim2, input2_dim1}) |
| 2217 | .TestF32(); |
| 2218 | } |
| 2219 | } |
| 2220 | } |
| 2221 | |
| 2222 | TEST(ADD_ND_F32, 6d_x_5d) { |
| 2223 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 6); bm1++) { |
| 2224 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 5); bm2++) { |
| 2225 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 2226 | const bool input1_broadcast_dim2 = bm1 & (uint32_t(1) << 1); |
| 2227 | const bool input1_broadcast_dim3 = bm1 & (uint32_t(1) << 2); |
| 2228 | const bool input1_broadcast_dim4 = bm1 & (uint32_t(1) << 3); |
| 2229 | const bool input1_broadcast_dim5 = bm1 & (uint32_t(1) << 4); |
| 2230 | const bool input1_broadcast_dim6 = bm1 & (uint32_t(1) << 5); |
| 2231 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 2232 | const bool input2_broadcast_dim2 = bm2 & (uint32_t(1) << 1); |
| 2233 | const bool input2_broadcast_dim3 = bm2 & (uint32_t(1) << 2); |
| 2234 | const bool input2_broadcast_dim4 = bm2 & (uint32_t(1) << 3); |
| 2235 | const bool input2_broadcast_dim5 = bm2 & (uint32_t(1) << 4); |
| 2236 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 2237 | const size_t input1_dim2 = input1_broadcast_dim2 ? 1 : kDim2; |
| 2238 | const size_t input1_dim3 = input1_broadcast_dim3 ? 1 : kDim3; |
| 2239 | const size_t input1_dim4 = input1_broadcast_dim4 ? 1 : kDim4; |
| 2240 | const size_t input1_dim5 = input1_broadcast_dim5 ? 1 : kDim5; |
| 2241 | const size_t input1_dim6 = input1_broadcast_dim6 ? 1 : kDim6; |
| 2242 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 2243 | const size_t input2_dim2 = input2_broadcast_dim2 ? 1 : kDim2; |
| 2244 | const size_t input2_dim3 = input2_broadcast_dim3 ? 1 : kDim3; |
| 2245 | const size_t input2_dim4 = input2_broadcast_dim4 ? 1 : kDim4; |
| 2246 | const size_t input2_dim5 = input2_broadcast_dim5 ? 1 : kDim5; |
| 2247 | BinaryElementwiseOperatorTester() |
| 2248 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 2249 | .input1_shape({input1_dim6, input1_dim5, input1_dim4, input1_dim3, input1_dim2, input1_dim1}) |
| 2250 | .input2_shape({input2_dim5, input2_dim4, input2_dim3, input2_dim2, input2_dim1}) |
| 2251 | .iterations(1) |
| 2252 | .TestF32(); |
| 2253 | } |
| 2254 | } |
| 2255 | } |
| 2256 | |
| 2257 | TEST(ADD_ND_F32, 6d_x_6d) { |
| 2258 | for (uint32_t bm1 = 0; bm1 < (uint32_t(1) << 6); bm1++) { |
| 2259 | for (uint32_t bm2 = 0; bm2 < (uint32_t(1) << 6); bm2++) { |
| 2260 | const bool input1_broadcast_dim1 = bm1 & (uint32_t(1) << 0); |
| 2261 | const bool input1_broadcast_dim2 = bm1 & (uint32_t(1) << 1); |
| 2262 | const bool input1_broadcast_dim3 = bm1 & (uint32_t(1) << 2); |
| 2263 | const bool input1_broadcast_dim4 = bm1 & (uint32_t(1) << 3); |
| 2264 | const bool input1_broadcast_dim5 = bm1 & (uint32_t(1) << 4); |
| 2265 | const bool input1_broadcast_dim6 = bm1 & (uint32_t(1) << 5); |
| 2266 | const bool input2_broadcast_dim1 = bm2 & (uint32_t(1) << 0); |
| 2267 | const bool input2_broadcast_dim2 = bm2 & (uint32_t(1) << 1); |
| 2268 | const bool input2_broadcast_dim3 = bm2 & (uint32_t(1) << 2); |
| 2269 | const bool input2_broadcast_dim4 = bm2 & (uint32_t(1) << 3); |
| 2270 | const bool input2_broadcast_dim5 = bm2 & (uint32_t(1) << 4); |
| 2271 | const bool input2_broadcast_dim6 = bm2 & (uint32_t(1) << 5); |
| 2272 | const size_t input1_dim1 = input1_broadcast_dim1 ? 1 : kDim1; |
| 2273 | const size_t input1_dim2 = input1_broadcast_dim2 ? 1 : kDim2; |
| 2274 | const size_t input1_dim3 = input1_broadcast_dim3 ? 1 : kDim3; |
| 2275 | const size_t input1_dim4 = input1_broadcast_dim4 ? 1 : kDim4; |
| 2276 | const size_t input1_dim5 = input1_broadcast_dim5 ? 1 : kDim5; |
| 2277 | const size_t input1_dim6 = input1_broadcast_dim6 ? 1 : kDim6; |
| 2278 | const size_t input2_dim1 = input2_broadcast_dim1 ? 1 : kDim1; |
| 2279 | const size_t input2_dim2 = input2_broadcast_dim2 ? 1 : kDim2; |
| 2280 | const size_t input2_dim3 = input2_broadcast_dim3 ? 1 : kDim3; |
| 2281 | const size_t input2_dim4 = input2_broadcast_dim4 ? 1 : kDim4; |
| 2282 | const size_t input2_dim5 = input2_broadcast_dim5 ? 1 : kDim5; |
| 2283 | const size_t input2_dim6 = input2_broadcast_dim6 ? 1 : kDim6; |
| 2284 | BinaryElementwiseOperatorTester() |
| 2285 | .operation_type(BinaryElementwiseOperatorTester::OperationType::Add) |
| 2286 | .input1_shape({input1_dim6, input1_dim5, input1_dim4, input1_dim3, input1_dim2, input1_dim1}) |
| 2287 | .input2_shape({input2_dim6, input2_dim5, input2_dim4, input2_dim3, input2_dim2, input2_dim1}) |
| 2288 | .iterations(1) |
| 2289 | .TestF32(); |
| 2290 | } |
| 2291 | } |
| 2292 | } |