Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2017 ARM Limited. |
| 3 | * |
| 4 | * SPDX-License-Identifier: MIT |
| 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | * of this software and associated documentation files (the "Software"), to |
| 8 | * deal in the Software without restriction, including without limitation the |
| 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
| 10 | * sell copies of the Software, and to permit persons to whom the Software is |
| 11 | * furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice shall be included in all |
| 14 | * copies or substantial portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 22 | * SOFTWARE. |
| 23 | */ |
| 24 | #ifndef __ARM_COMPUTE_TEST_TYPE_PRINTER_H__ |
| 25 | #define __ARM_COMPUTE_TEST_TYPE_PRINTER_H__ |
| 26 | |
| 27 | #include "arm_compute/core/Dimensions.h" |
| 28 | #include "arm_compute/core/Error.h" |
| 29 | #include "arm_compute/core/Types.h" |
| 30 | |
| 31 | #include <ostream> |
| 32 | |
| 33 | namespace arm_compute |
| 34 | { |
| 35 | /** Formatted output of the Dimensions type. */ |
| 36 | template <typename T> |
| 37 | inline ::std::ostream &operator<<(::std::ostream &os, const Dimensions<T> &dimensions) |
| 38 | { |
| 39 | os << "("; |
| 40 | |
| 41 | if(dimensions.num_dimensions() > 0) |
| 42 | { |
| 43 | os << dimensions[0]; |
| 44 | |
| 45 | for(unsigned int d = 1; d < dimensions.num_dimensions(); ++d) |
| 46 | { |
| 47 | os << ", " << dimensions[d]; |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | os << ")"; |
| 52 | |
| 53 | return os; |
| 54 | } |
| 55 | |
| 56 | /** Formatted output of the PadStridInfo type. */ |
| 57 | inline ::std::ostream &operator<<(::std::ostream &os, const PadStrideInfo &pad_stride_info) |
| 58 | { |
| 59 | os << "("; |
| 60 | os << pad_stride_info.stride().first << ", " << pad_stride_info.stride().second; |
| 61 | os << ", "; |
| 62 | os << pad_stride_info.pad().first << ", " << pad_stride_info.pad().second; |
| 63 | os << ")"; |
| 64 | |
| 65 | return os; |
| 66 | } |
| 67 | |
| 68 | /** Formatted output of the BorderMode type. */ |
| 69 | inline ::std::ostream &operator<<(::std::ostream &os, const BorderMode &mode) |
| 70 | { |
| 71 | switch(mode) |
| 72 | { |
| 73 | case BorderMode::UNDEFINED: |
| 74 | os << "UNDEFINED"; |
| 75 | break; |
| 76 | case BorderMode::CONSTANT: |
| 77 | os << "CONSTANT"; |
| 78 | break; |
| 79 | case BorderMode::REPLICATE: |
| 80 | os << "REPLICATE"; |
| 81 | break; |
| 82 | default: |
| 83 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 84 | } |
| 85 | |
| 86 | return os; |
| 87 | } |
| 88 | |
Isabella Gottardi | 3b77e9d | 2017-06-22 11:05:41 +0100 | [diff] [blame] | 89 | /** Formatted output of the NonLinearFilterFunction type. */ |
| 90 | inline ::std::ostream &operator<<(::std::ostream &os, const NonLinearFilterFunction &function) |
| 91 | { |
| 92 | switch(function) |
| 93 | { |
| 94 | case NonLinearFilterFunction::MAX: |
| 95 | os << "MAX"; |
| 96 | break; |
| 97 | case NonLinearFilterFunction::MEDIAN: |
| 98 | os << "MEDIAN"; |
| 99 | break; |
| 100 | case NonLinearFilterFunction::MIN: |
| 101 | os << "MIN"; |
| 102 | break; |
| 103 | default: |
| 104 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 105 | } |
| 106 | |
| 107 | return os; |
| 108 | } |
| 109 | |
| 110 | /** Formatted output of the MatrixPattern type. */ |
| 111 | inline ::std::ostream &operator<<(::std::ostream &os, const MatrixPattern &pattern) |
| 112 | { |
| 113 | switch(pattern) |
| 114 | { |
| 115 | case MatrixPattern::BOX: |
| 116 | os << "BOX"; |
| 117 | break; |
| 118 | case MatrixPattern::CROSS: |
| 119 | os << "CROSS"; |
| 120 | break; |
| 121 | case MatrixPattern::DISK: |
| 122 | os << "DISK"; |
| 123 | break; |
| 124 | case MatrixPattern::OTHER: |
| 125 | os << "OTHER"; |
| 126 | break; |
| 127 | default: |
| 128 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 129 | } |
| 130 | |
| 131 | return os; |
| 132 | } |
| 133 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 134 | /** Formatted output of the InterpolationPolicy type. */ |
| 135 | inline ::std::ostream &operator<<(::std::ostream &os, const InterpolationPolicy &policy) |
| 136 | { |
| 137 | switch(policy) |
| 138 | { |
| 139 | case InterpolationPolicy::NEAREST_NEIGHBOR: |
| 140 | os << "NEAREST_NEIGHBOR"; |
| 141 | break; |
| 142 | case InterpolationPolicy::BILINEAR: |
| 143 | os << "BILINEAR"; |
| 144 | break; |
| 145 | case InterpolationPolicy::AREA: |
| 146 | os << "AREA"; |
| 147 | break; |
| 148 | default: |
| 149 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 150 | } |
| 151 | |
| 152 | return os; |
| 153 | } |
| 154 | |
| 155 | /** Formatted output of the ConversionPolicy type. */ |
| 156 | inline ::std::ostream &operator<<(::std::ostream &os, const ConvertPolicy &policy) |
| 157 | { |
| 158 | switch(policy) |
| 159 | { |
| 160 | case ConvertPolicy::WRAP: |
| 161 | os << "WRAP"; |
| 162 | break; |
| 163 | case ConvertPolicy::SATURATE: |
| 164 | os << "SATURATE"; |
| 165 | break; |
| 166 | default: |
| 167 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 168 | } |
| 169 | |
| 170 | return os; |
| 171 | } |
| 172 | |
| 173 | /** Formatted output of the activation function type. */ |
| 174 | inline ::std::ostream &operator<<(::std::ostream &os, const ActivationLayerInfo::ActivationFunction &act_function) |
| 175 | { |
| 176 | switch(act_function) |
| 177 | { |
| 178 | case ActivationLayerInfo::ActivationFunction::ABS: |
| 179 | os << "ABS"; |
| 180 | break; |
| 181 | case ActivationLayerInfo::ActivationFunction::BOUNDED_RELU: |
| 182 | os << "BOUNDED_RELU"; |
| 183 | break; |
| 184 | case ActivationLayerInfo::ActivationFunction::LINEAR: |
| 185 | os << "LINEAR"; |
| 186 | break; |
| 187 | case ActivationLayerInfo::ActivationFunction::LOGISTIC: |
| 188 | os << "LOGISTIC"; |
| 189 | break; |
| 190 | case ActivationLayerInfo::ActivationFunction::RELU: |
| 191 | os << "RELU"; |
| 192 | break; |
| 193 | case ActivationLayerInfo::ActivationFunction::SOFT_RELU: |
| 194 | os << "SOFT_RELU"; |
| 195 | break; |
| 196 | case ActivationLayerInfo::ActivationFunction::SQRT: |
| 197 | os << "SQRT"; |
| 198 | break; |
| 199 | case ActivationLayerInfo::ActivationFunction::SQUARE: |
| 200 | os << "SQUARE"; |
| 201 | break; |
| 202 | case ActivationLayerInfo::ActivationFunction::TANH: |
| 203 | os << "TANH"; |
| 204 | break; |
| 205 | default: |
| 206 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 207 | } |
| 208 | |
| 209 | return os; |
| 210 | } |
| 211 | |
| 212 | /** Formatted output of the NormType type. */ |
| 213 | inline ::std::ostream &operator<<(::std::ostream &os, const NormType &norm_type) |
| 214 | { |
| 215 | switch(norm_type) |
| 216 | { |
| 217 | case NormType::CROSS_MAP: |
| 218 | os << "CROSS_MAP"; |
| 219 | break; |
| 220 | case NormType::IN_MAP_1D: |
| 221 | os << "IN_MAP_1D"; |
| 222 | break; |
| 223 | case NormType::IN_MAP_2D: |
| 224 | os << "IN_MAP_2D"; |
| 225 | break; |
| 226 | default: |
| 227 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 228 | } |
| 229 | |
| 230 | return os; |
| 231 | } |
| 232 | |
| 233 | /** Formatted output of the PoolingType type. */ |
| 234 | inline ::std::ostream &operator<<(::std::ostream &os, const PoolingType &pool_type) |
| 235 | { |
| 236 | switch(pool_type) |
| 237 | { |
| 238 | case PoolingType::AVG: |
| 239 | os << "AVG"; |
| 240 | break; |
| 241 | case PoolingType::MAX: |
| 242 | os << "MAX"; |
| 243 | break; |
| 244 | default: |
| 245 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 246 | } |
| 247 | |
| 248 | return os; |
| 249 | } |
| 250 | |
| 251 | /** Formatted output of the RoundingPolicy type. */ |
| 252 | inline ::std::ostream &operator<<(::std::ostream &os, const RoundingPolicy &rounding_policy) |
| 253 | { |
| 254 | switch(rounding_policy) |
| 255 | { |
| 256 | case RoundingPolicy::TO_ZERO: |
| 257 | os << "TO_ZERO"; |
| 258 | break; |
| 259 | case RoundingPolicy::TO_NEAREST_UP: |
| 260 | os << "TO_NEAREST_UP"; |
| 261 | break; |
| 262 | case RoundingPolicy::TO_NEAREST_EVEN: |
| 263 | os << "TO_NEAREST_EVEN"; |
| 264 | break; |
| 265 | default: |
| 266 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 267 | } |
| 268 | |
| 269 | return os; |
| 270 | } |
| 271 | |
| 272 | /** Formatted output of the DataType type. */ |
| 273 | inline ::std::ostream &operator<<(::std::ostream &os, const DataType &data_type) |
| 274 | { |
| 275 | switch(data_type) |
| 276 | { |
| 277 | case DataType::UNKNOWN: |
| 278 | os << "UNKNOWN"; |
| 279 | break; |
| 280 | case DataType::U8: |
| 281 | os << "U8"; |
| 282 | break; |
| 283 | case DataType::QS8: |
| 284 | os << "QS8"; |
| 285 | break; |
| 286 | case DataType::S8: |
| 287 | os << "S8"; |
| 288 | break; |
| 289 | case DataType::U16: |
| 290 | os << "U16"; |
| 291 | break; |
| 292 | case DataType::S16: |
| 293 | os << "S16"; |
| 294 | break; |
| 295 | case DataType::U32: |
| 296 | os << "U32"; |
| 297 | break; |
| 298 | case DataType::S32: |
| 299 | os << "S32"; |
| 300 | break; |
| 301 | case DataType::U64: |
| 302 | os << "U64"; |
| 303 | break; |
| 304 | case DataType::S64: |
| 305 | os << "S64"; |
| 306 | break; |
| 307 | case DataType::F16: |
| 308 | os << "F16"; |
| 309 | break; |
| 310 | case DataType::F32: |
| 311 | os << "F32"; |
| 312 | break; |
| 313 | case DataType::F64: |
| 314 | os << "F64"; |
| 315 | break; |
| 316 | case DataType::SIZET: |
| 317 | os << "SIZET"; |
| 318 | break; |
| 319 | default: |
| 320 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 321 | } |
| 322 | |
| 323 | return os; |
| 324 | } |
| 325 | |
| 326 | /** Formatted output of the Format type. */ |
| 327 | inline ::std::ostream &operator<<(::std::ostream &os, const Format &format) |
| 328 | { |
| 329 | switch(format) |
| 330 | { |
| 331 | case Format::UNKNOWN: |
| 332 | os << "UNKNOWN"; |
| 333 | break; |
| 334 | case Format::U8: |
| 335 | os << "U8"; |
| 336 | break; |
| 337 | case Format::S16: |
| 338 | os << "S16"; |
| 339 | break; |
| 340 | case Format::U16: |
| 341 | os << "U16"; |
| 342 | break; |
| 343 | case Format::S32: |
| 344 | os << "S32"; |
| 345 | break; |
| 346 | case Format::U32: |
| 347 | os << "U32"; |
| 348 | break; |
| 349 | case Format::F16: |
| 350 | os << "F16"; |
| 351 | break; |
| 352 | case Format::F32: |
| 353 | os << "F32"; |
| 354 | break; |
| 355 | case Format::UV88: |
| 356 | os << "UV88"; |
| 357 | break; |
| 358 | case Format::RGB888: |
| 359 | os << "RGB888"; |
| 360 | break; |
| 361 | case Format::RGBA8888: |
| 362 | os << "RGBA8888"; |
| 363 | break; |
| 364 | case Format::YUV444: |
| 365 | os << "YUV444"; |
| 366 | break; |
| 367 | case Format::YUYV422: |
| 368 | os << "YUYV422"; |
| 369 | break; |
| 370 | case Format::NV12: |
| 371 | os << "NV12"; |
| 372 | break; |
| 373 | case Format::NV21: |
| 374 | os << "NV21"; |
| 375 | break; |
| 376 | case Format::IYUV: |
| 377 | os << "IYUV"; |
| 378 | break; |
| 379 | case Format::UYVY422: |
| 380 | os << "UYVY422"; |
| 381 | break; |
| 382 | default: |
| 383 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 384 | } |
| 385 | |
| 386 | return os; |
| 387 | } |
| 388 | |
| 389 | /** Formatted output of the Channel type. */ |
| 390 | inline ::std::ostream &operator<<(::std::ostream &os, const Channel &channel) |
| 391 | { |
| 392 | switch(channel) |
| 393 | { |
| 394 | case Channel::UNKNOWN: |
| 395 | os << "UNKNOWN"; |
| 396 | break; |
| 397 | case Channel::C0: |
| 398 | os << "C0"; |
| 399 | break; |
| 400 | case Channel::C1: |
| 401 | os << "C1"; |
| 402 | break; |
| 403 | case Channel::C2: |
| 404 | os << "C2"; |
| 405 | break; |
| 406 | case Channel::C3: |
| 407 | os << "C3"; |
| 408 | break; |
| 409 | case Channel::R: |
| 410 | os << "R"; |
| 411 | break; |
| 412 | case Channel::G: |
| 413 | os << "G"; |
| 414 | break; |
| 415 | case Channel::B: |
| 416 | os << "B"; |
| 417 | break; |
| 418 | case Channel::A: |
| 419 | os << "A"; |
| 420 | break; |
| 421 | case Channel::Y: |
| 422 | os << "Y"; |
| 423 | break; |
| 424 | case Channel::U: |
| 425 | os << "U"; |
| 426 | break; |
| 427 | case Channel::V: |
| 428 | os << "V"; |
| 429 | break; |
| 430 | default: |
| 431 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 432 | } |
| 433 | |
| 434 | return os; |
| 435 | } |
| 436 | |
| 437 | /** Formatted output of the BorderSize type. */ |
| 438 | inline ::std::ostream &operator<<(::std::ostream &os, const BorderSize &border) |
| 439 | { |
| 440 | os << "{" << border.top << ", " |
| 441 | << border.right << ", " |
| 442 | << border.bottom << ", " |
| 443 | << border.left << "}"; |
| 444 | |
| 445 | return os; |
| 446 | } |
| 447 | } // namespace arm_compute |
| 448 | #endif |