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" |
John Richardson | a36eae1 | 2017-09-26 16:55:59 +0100 | [diff] [blame] | 29 | #include "arm_compute/core/Strides.h" |
Georgios Pinitas | 3faea25 | 2017-10-30 14:13:50 +0000 | [diff] [blame] | 30 | #include "arm_compute/core/TensorInfo.h" |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 31 | #include "arm_compute/core/Types.h" |
| 32 | |
Abe Mbise | 4bd2cb8 | 2017-09-27 18:39:19 +0100 | [diff] [blame] | 33 | #include "tests/Types.h" |
| 34 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 35 | #include <ostream> |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 36 | #include <sstream> |
| 37 | #include <string> |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 38 | |
| 39 | namespace arm_compute |
| 40 | { |
| 41 | /** Formatted output of the Dimensions type. */ |
| 42 | template <typename T> |
| 43 | inline ::std::ostream &operator<<(::std::ostream &os, const Dimensions<T> &dimensions) |
| 44 | { |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 45 | if(dimensions.num_dimensions() > 0) |
| 46 | { |
| 47 | os << dimensions[0]; |
| 48 | |
| 49 | for(unsigned int d = 1; d < dimensions.num_dimensions(); ++d) |
| 50 | { |
Moritz Pflanzer | c87fbf8 | 2017-07-18 14:02:10 +0100 | [diff] [blame] | 51 | os << "x" << dimensions[d]; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 52 | } |
| 53 | } |
| 54 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 55 | return os; |
| 56 | } |
| 57 | |
Isabella Gottardi | 3b77e9d | 2017-06-22 11:05:41 +0100 | [diff] [blame] | 58 | /** Formatted output of the NonLinearFilterFunction type. */ |
| 59 | inline ::std::ostream &operator<<(::std::ostream &os, const NonLinearFilterFunction &function) |
| 60 | { |
| 61 | switch(function) |
| 62 | { |
| 63 | case NonLinearFilterFunction::MAX: |
| 64 | os << "MAX"; |
| 65 | break; |
| 66 | case NonLinearFilterFunction::MEDIAN: |
| 67 | os << "MEDIAN"; |
| 68 | break; |
| 69 | case NonLinearFilterFunction::MIN: |
| 70 | os << "MIN"; |
| 71 | break; |
| 72 | default: |
| 73 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 74 | } |
| 75 | |
| 76 | return os; |
| 77 | } |
| 78 | |
John Richardson | 6f4d49f | 2017-09-07 11:21:10 +0100 | [diff] [blame] | 79 | inline std::string to_string(const NonLinearFilterFunction &function) |
| 80 | { |
| 81 | std::stringstream str; |
| 82 | str << function; |
| 83 | return str.str(); |
| 84 | } |
| 85 | |
Isabella Gottardi | 3b77e9d | 2017-06-22 11:05:41 +0100 | [diff] [blame] | 86 | /** Formatted output of the MatrixPattern type. */ |
| 87 | inline ::std::ostream &operator<<(::std::ostream &os, const MatrixPattern &pattern) |
| 88 | { |
| 89 | switch(pattern) |
| 90 | { |
| 91 | case MatrixPattern::BOX: |
| 92 | os << "BOX"; |
| 93 | break; |
| 94 | case MatrixPattern::CROSS: |
| 95 | os << "CROSS"; |
| 96 | break; |
| 97 | case MatrixPattern::DISK: |
| 98 | os << "DISK"; |
| 99 | break; |
| 100 | case MatrixPattern::OTHER: |
| 101 | os << "OTHER"; |
| 102 | break; |
| 103 | default: |
| 104 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 105 | } |
| 106 | |
| 107 | return os; |
| 108 | } |
| 109 | |
John Richardson | 6f4d49f | 2017-09-07 11:21:10 +0100 | [diff] [blame] | 110 | inline std::string to_string(const MatrixPattern &pattern) |
| 111 | { |
| 112 | std::stringstream str; |
| 113 | str << pattern; |
| 114 | return str.str(); |
| 115 | } |
| 116 | |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 117 | /** Formatted output of the RoundingPolicy type. */ |
| 118 | inline ::std::ostream &operator<<(::std::ostream &os, const RoundingPolicy &rounding_policy) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 119 | { |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 120 | switch(rounding_policy) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 121 | { |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 122 | case RoundingPolicy::TO_ZERO: |
| 123 | os << "TO_ZERO"; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 124 | break; |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 125 | case RoundingPolicy::TO_NEAREST_UP: |
| 126 | os << "TO_NEAREST_UP"; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 127 | break; |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 128 | case RoundingPolicy::TO_NEAREST_EVEN: |
| 129 | os << "TO_NEAREST_EVEN"; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 130 | break; |
| 131 | default: |
| 132 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 133 | } |
| 134 | |
| 135 | return os; |
| 136 | } |
| 137 | |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 138 | /** Formatted output of the WeightsInfo type. */ |
| 139 | inline ::std::ostream &operator<<(::std::ostream &os, const WeightsInfo &weights_info) |
Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 140 | { |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 141 | os << weights_info.are_reshaped() << ";"; |
| 142 | os << weights_info.num_kernels() << ";" << weights_info.kernel_size().first << "," << weights_info.kernel_size().second; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 143 | |
| 144 | return os; |
| 145 | } |
| 146 | |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 147 | /** Formatted output of the ROIPoolingInfo type. */ |
| 148 | inline ::std::ostream &operator<<(::std::ostream &os, const ROIPoolingLayerInfo &pool_info) |
Sanghoon Lee | 70f8291 | 2017-08-24 14:21:24 +0100 | [diff] [blame] | 149 | { |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 150 | os << pool_info.pooled_width() << "x" << pool_info.pooled_height() << "~" << pool_info.spatial_scale(); |
Georgios Pinitas | d976958 | 2017-08-03 10:19:40 +0100 | [diff] [blame] | 151 | return os; |
| 152 | } |
| 153 | |
Chunosov | d621bca | 2017-11-03 17:33:15 +0700 | [diff] [blame] | 154 | /** Formatted output of the QuantizationInfo type. */ |
| 155 | inline ::std::ostream &operator<<(::std::ostream &os, const QuantizationInfo &quantization_info) |
| 156 | { |
| 157 | os << "Scale:" << quantization_info.scale << "~" |
| 158 | << "Offset:" << quantization_info.offset; |
| 159 | return os; |
| 160 | } |
| 161 | |
| 162 | inline std::string to_string(const QuantizationInfo &quantization_info) |
| 163 | { |
| 164 | std::stringstream str; |
| 165 | str << quantization_info; |
| 166 | return str.str(); |
| 167 | } |
| 168 | |
Abe Mbise | 4bd2cb8 | 2017-09-27 18:39:19 +0100 | [diff] [blame] | 169 | inline ::std::ostream &operator<<(::std::ostream &os, const FixedPointOp &op) |
| 170 | { |
| 171 | switch(op) |
| 172 | { |
John Richardson | 70f946b | 2017-10-02 16:52:16 +0100 | [diff] [blame] | 173 | case FixedPointOp::ADD: |
| 174 | os << "ADD"; |
| 175 | break; |
| 176 | case FixedPointOp::SUB: |
| 177 | os << "SUB"; |
| 178 | break; |
| 179 | case FixedPointOp::MUL: |
| 180 | os << "MUL"; |
| 181 | break; |
Abe Mbise | 4bd2cb8 | 2017-09-27 18:39:19 +0100 | [diff] [blame] | 182 | case FixedPointOp::EXP: |
| 183 | os << "EXP"; |
| 184 | break; |
| 185 | case FixedPointOp::LOG: |
| 186 | os << "LOG"; |
| 187 | break; |
| 188 | case FixedPointOp::INV_SQRT: |
| 189 | os << "INV_SQRT"; |
| 190 | break; |
| 191 | case FixedPointOp::RECIPROCAL: |
| 192 | os << "RECIPROCAL"; |
| 193 | break; |
| 194 | default: |
| 195 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 196 | } |
| 197 | |
| 198 | return os; |
| 199 | } |
John Richardson | 70f946b | 2017-10-02 16:52:16 +0100 | [diff] [blame] | 200 | |
Abe Mbise | 4bd2cb8 | 2017-09-27 18:39:19 +0100 | [diff] [blame] | 201 | inline std::string to_string(const FixedPointOp &op) |
| 202 | { |
| 203 | std::stringstream str; |
| 204 | str << op; |
| 205 | return str.str(); |
| 206 | } |
| 207 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 208 | /** Formatted output of the activation function type. */ |
| 209 | inline ::std::ostream &operator<<(::std::ostream &os, const ActivationLayerInfo::ActivationFunction &act_function) |
| 210 | { |
| 211 | switch(act_function) |
| 212 | { |
| 213 | case ActivationLayerInfo::ActivationFunction::ABS: |
| 214 | os << "ABS"; |
| 215 | break; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 216 | case ActivationLayerInfo::ActivationFunction::LINEAR: |
| 217 | os << "LINEAR"; |
| 218 | break; |
| 219 | case ActivationLayerInfo::ActivationFunction::LOGISTIC: |
| 220 | os << "LOGISTIC"; |
| 221 | break; |
| 222 | case ActivationLayerInfo::ActivationFunction::RELU: |
| 223 | os << "RELU"; |
| 224 | break; |
Georgios Pinitas | 579c049 | 2017-07-12 16:12:12 +0100 | [diff] [blame] | 225 | case ActivationLayerInfo::ActivationFunction::BOUNDED_RELU: |
| 226 | os << "BOUNDED_RELU"; |
| 227 | break; |
| 228 | case ActivationLayerInfo::ActivationFunction::LEAKY_RELU: |
| 229 | os << "LEAKY_RELU"; |
| 230 | break; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 231 | case ActivationLayerInfo::ActivationFunction::SOFT_RELU: |
| 232 | os << "SOFT_RELU"; |
| 233 | break; |
| 234 | case ActivationLayerInfo::ActivationFunction::SQRT: |
| 235 | os << "SQRT"; |
| 236 | break; |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 237 | case ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU: |
| 238 | os << "LU_BOUNDED_RELU"; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 239 | case ActivationLayerInfo::ActivationFunction::SQUARE: |
| 240 | os << "SQUARE"; |
| 241 | break; |
| 242 | case ActivationLayerInfo::ActivationFunction::TANH: |
| 243 | os << "TANH"; |
| 244 | break; |
| 245 | default: |
| 246 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 247 | } |
| 248 | |
| 249 | return os; |
| 250 | } |
| 251 | |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 252 | inline std::string to_string(const arm_compute::ActivationLayerInfo &info) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 253 | { |
| 254 | std::stringstream str; |
| 255 | str << info.activation(); |
| 256 | return str.str(); |
| 257 | } |
| 258 | |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 259 | inline std::string to_string(const arm_compute::ActivationLayerInfo::ActivationFunction &function) |
| 260 | { |
| 261 | std::stringstream str; |
| 262 | str << function; |
| 263 | return str.str(); |
| 264 | } |
| 265 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 266 | /** Formatted output of the NormType type. */ |
| 267 | inline ::std::ostream &operator<<(::std::ostream &os, const NormType &norm_type) |
| 268 | { |
| 269 | switch(norm_type) |
| 270 | { |
| 271 | case NormType::CROSS_MAP: |
| 272 | os << "CROSS_MAP"; |
| 273 | break; |
| 274 | case NormType::IN_MAP_1D: |
| 275 | os << "IN_MAP_1D"; |
| 276 | break; |
| 277 | case NormType::IN_MAP_2D: |
| 278 | os << "IN_MAP_2D"; |
| 279 | break; |
| 280 | default: |
| 281 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 282 | } |
| 283 | |
| 284 | return os; |
| 285 | } |
| 286 | |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 287 | inline std::string to_string(const arm_compute::NormalizationLayerInfo &info) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 288 | { |
| 289 | std::stringstream str; |
| 290 | str << info.type(); |
| 291 | return str.str(); |
| 292 | } |
| 293 | |
Georgios Pinitas | 6f669f0 | 2017-09-26 12:32:57 +0100 | [diff] [blame] | 294 | /** Formatted output of @ref NormalizationLayerInfo. */ |
| 295 | inline ::std::ostream &operator<<(::std::ostream &os, const NormalizationLayerInfo &info) |
| 296 | { |
| 297 | os << info.type(); |
| 298 | return os; |
| 299 | } |
| 300 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 301 | /** Formatted output of the PoolingType type. */ |
| 302 | inline ::std::ostream &operator<<(::std::ostream &os, const PoolingType &pool_type) |
| 303 | { |
| 304 | switch(pool_type) |
| 305 | { |
| 306 | case PoolingType::AVG: |
| 307 | os << "AVG"; |
| 308 | break; |
| 309 | case PoolingType::MAX: |
| 310 | os << "MAX"; |
| 311 | break; |
Georgios Pinitas | cdf5145 | 2017-08-31 14:21:36 +0100 | [diff] [blame] | 312 | case PoolingType::L2: |
| 313 | os << "L2"; |
| 314 | break; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 315 | default: |
| 316 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 317 | } |
| 318 | |
| 319 | return os; |
| 320 | } |
| 321 | |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 322 | /** Formatted output of @ref PoolingLayerInfo. */ |
| 323 | inline ::std::ostream &operator<<(::std::ostream &os, const PoolingLayerInfo &info) |
| 324 | { |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 325 | os << info.pool_type(); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 326 | |
| 327 | return os; |
| 328 | } |
| 329 | |
John Richardson | dd715f2 | 2017-09-18 16:10:48 +0100 | [diff] [blame] | 330 | inline std::string to_string(const RoundingPolicy &rounding_policy) |
| 331 | { |
| 332 | std::stringstream str; |
| 333 | str << rounding_policy; |
| 334 | return str.str(); |
| 335 | } |
| 336 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 337 | /** Formatted output of the DataType type. */ |
| 338 | inline ::std::ostream &operator<<(::std::ostream &os, const DataType &data_type) |
| 339 | { |
| 340 | switch(data_type) |
| 341 | { |
| 342 | case DataType::UNKNOWN: |
| 343 | os << "UNKNOWN"; |
| 344 | break; |
| 345 | case DataType::U8: |
| 346 | os << "U8"; |
| 347 | break; |
| 348 | case DataType::QS8: |
| 349 | os << "QS8"; |
| 350 | break; |
Chunosov | d621bca | 2017-11-03 17:33:15 +0700 | [diff] [blame] | 351 | case DataType::QASYMM8: |
| 352 | os << "QASYMM8"; |
| 353 | break; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 354 | case DataType::S8: |
| 355 | os << "S8"; |
| 356 | break; |
| 357 | case DataType::U16: |
| 358 | os << "U16"; |
| 359 | break; |
| 360 | case DataType::S16: |
| 361 | os << "S16"; |
| 362 | break; |
Gian Marco Iodice | bdb6b0b | 2017-06-30 12:21:00 +0100 | [diff] [blame] | 363 | case DataType::QS16: |
| 364 | os << "QS16"; |
| 365 | break; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 366 | case DataType::U32: |
| 367 | os << "U32"; |
| 368 | break; |
| 369 | case DataType::S32: |
| 370 | os << "S32"; |
| 371 | break; |
| 372 | case DataType::U64: |
| 373 | os << "U64"; |
| 374 | break; |
| 375 | case DataType::S64: |
| 376 | os << "S64"; |
| 377 | break; |
| 378 | case DataType::F16: |
| 379 | os << "F16"; |
| 380 | break; |
| 381 | case DataType::F32: |
| 382 | os << "F32"; |
| 383 | break; |
| 384 | case DataType::F64: |
| 385 | os << "F64"; |
| 386 | break; |
| 387 | case DataType::SIZET: |
| 388 | os << "SIZET"; |
| 389 | break; |
| 390 | default: |
| 391 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 392 | } |
| 393 | |
| 394 | return os; |
| 395 | } |
| 396 | |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 397 | inline std::string to_string(const arm_compute::DataType &data_type) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 398 | { |
| 399 | std::stringstream str; |
| 400 | str << data_type; |
| 401 | return str.str(); |
| 402 | } |
| 403 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 404 | /** Formatted output of the Format type. */ |
| 405 | inline ::std::ostream &operator<<(::std::ostream &os, const Format &format) |
| 406 | { |
| 407 | switch(format) |
| 408 | { |
| 409 | case Format::UNKNOWN: |
| 410 | os << "UNKNOWN"; |
| 411 | break; |
| 412 | case Format::U8: |
| 413 | os << "U8"; |
| 414 | break; |
| 415 | case Format::S16: |
| 416 | os << "S16"; |
| 417 | break; |
| 418 | case Format::U16: |
| 419 | os << "U16"; |
| 420 | break; |
| 421 | case Format::S32: |
| 422 | os << "S32"; |
| 423 | break; |
| 424 | case Format::U32: |
| 425 | os << "U32"; |
| 426 | break; |
| 427 | case Format::F16: |
| 428 | os << "F16"; |
| 429 | break; |
| 430 | case Format::F32: |
| 431 | os << "F32"; |
| 432 | break; |
| 433 | case Format::UV88: |
| 434 | os << "UV88"; |
| 435 | break; |
| 436 | case Format::RGB888: |
| 437 | os << "RGB888"; |
| 438 | break; |
| 439 | case Format::RGBA8888: |
| 440 | os << "RGBA8888"; |
| 441 | break; |
| 442 | case Format::YUV444: |
| 443 | os << "YUV444"; |
| 444 | break; |
| 445 | case Format::YUYV422: |
| 446 | os << "YUYV422"; |
| 447 | break; |
| 448 | case Format::NV12: |
| 449 | os << "NV12"; |
| 450 | break; |
| 451 | case Format::NV21: |
| 452 | os << "NV21"; |
| 453 | break; |
| 454 | case Format::IYUV: |
| 455 | os << "IYUV"; |
| 456 | break; |
| 457 | case Format::UYVY422: |
| 458 | os << "UYVY422"; |
| 459 | break; |
| 460 | default: |
| 461 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 462 | } |
| 463 | |
| 464 | return os; |
| 465 | } |
| 466 | |
Moritz Pflanzer | 7655a67 | 2017-09-23 11:57:33 +0100 | [diff] [blame] | 467 | inline std::string to_string(const Format &format) |
| 468 | { |
| 469 | std::stringstream str; |
| 470 | str << format; |
| 471 | return str.str(); |
| 472 | } |
| 473 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 474 | /** Formatted output of the Channel type. */ |
| 475 | inline ::std::ostream &operator<<(::std::ostream &os, const Channel &channel) |
| 476 | { |
| 477 | switch(channel) |
| 478 | { |
| 479 | case Channel::UNKNOWN: |
| 480 | os << "UNKNOWN"; |
| 481 | break; |
| 482 | case Channel::C0: |
| 483 | os << "C0"; |
| 484 | break; |
| 485 | case Channel::C1: |
| 486 | os << "C1"; |
| 487 | break; |
| 488 | case Channel::C2: |
| 489 | os << "C2"; |
| 490 | break; |
| 491 | case Channel::C3: |
| 492 | os << "C3"; |
| 493 | break; |
| 494 | case Channel::R: |
| 495 | os << "R"; |
| 496 | break; |
| 497 | case Channel::G: |
| 498 | os << "G"; |
| 499 | break; |
| 500 | case Channel::B: |
| 501 | os << "B"; |
| 502 | break; |
| 503 | case Channel::A: |
| 504 | os << "A"; |
| 505 | break; |
| 506 | case Channel::Y: |
| 507 | os << "Y"; |
| 508 | break; |
| 509 | case Channel::U: |
| 510 | os << "U"; |
| 511 | break; |
| 512 | case Channel::V: |
| 513 | os << "V"; |
| 514 | break; |
| 515 | default: |
| 516 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 517 | } |
| 518 | |
| 519 | return os; |
| 520 | } |
| 521 | |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 522 | /** Formatted output of the BorderMode type. */ |
| 523 | inline ::std::ostream &operator<<(::std::ostream &os, const BorderMode &mode) |
| 524 | { |
| 525 | switch(mode) |
| 526 | { |
| 527 | case BorderMode::UNDEFINED: |
| 528 | os << "UNDEFINED"; |
| 529 | break; |
| 530 | case BorderMode::CONSTANT: |
| 531 | os << "CONSTANT"; |
| 532 | break; |
| 533 | case BorderMode::REPLICATE: |
| 534 | os << "REPLICATE"; |
| 535 | break; |
| 536 | default: |
| 537 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 538 | } |
| 539 | |
| 540 | return os; |
| 541 | } |
| 542 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 543 | /** Formatted output of the BorderSize type. */ |
| 544 | inline ::std::ostream &operator<<(::std::ostream &os, const BorderSize &border) |
| 545 | { |
Moritz Pflanzer | c87fbf8 | 2017-07-18 14:02:10 +0100 | [diff] [blame] | 546 | os << border.top << "," |
| 547 | << border.right << "," |
| 548 | << border.bottom << "," |
| 549 | << border.left; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 550 | |
| 551 | return os; |
| 552 | } |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 553 | |
| 554 | /** Formatted output of the InterpolationPolicy type. */ |
| 555 | inline ::std::ostream &operator<<(::std::ostream &os, const InterpolationPolicy &policy) |
| 556 | { |
| 557 | switch(policy) |
| 558 | { |
| 559 | case InterpolationPolicy::NEAREST_NEIGHBOR: |
| 560 | os << "NEAREST_NEIGHBOR"; |
| 561 | break; |
| 562 | case InterpolationPolicy::BILINEAR: |
| 563 | os << "BILINEAR"; |
| 564 | break; |
| 565 | case InterpolationPolicy::AREA: |
| 566 | os << "AREA"; |
| 567 | break; |
| 568 | default: |
| 569 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 570 | } |
| 571 | |
| 572 | return os; |
| 573 | } |
| 574 | |
Georgios Pinitas | 3faea25 | 2017-10-30 14:13:50 +0000 | [diff] [blame] | 575 | /** Formatted output of the TensorInfo type. */ |
| 576 | inline std::string to_string(const TensorInfo &info) |
| 577 | { |
| 578 | std::stringstream str; |
| 579 | str << "{Shape=" << info.tensor_shape() << "," |
| 580 | << "Type=" << info.data_type() << "," |
| 581 | << "Channels=" << info.num_channels() << "," |
| 582 | << "FixedPointPos=" << info.fixed_point_position() << "}"; |
| 583 | return str.str(); |
| 584 | } |
| 585 | |
Abe Mbise | 925ca0f | 2017-10-02 19:16:33 +0100 | [diff] [blame] | 586 | //FIXME: Check why this doesn't work and the TensorShape and Coordinates overload are needed |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 587 | template <typename T> |
| 588 | inline std::string to_string(const Dimensions<T> &dimensions) |
| 589 | { |
| 590 | std::stringstream str; |
| 591 | str << dimensions; |
| 592 | return str.str(); |
| 593 | } |
| 594 | |
John Richardson | a36eae1 | 2017-09-26 16:55:59 +0100 | [diff] [blame] | 595 | inline std::string to_string(const Strides &stride) |
| 596 | { |
| 597 | std::stringstream str; |
| 598 | str << stride; |
| 599 | return str.str(); |
| 600 | } |
| 601 | |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 602 | /** Formatted output of the TensorShape type. */ |
| 603 | inline std::string to_string(const TensorShape &shape) |
| 604 | { |
| 605 | std::stringstream str; |
| 606 | str << shape; |
| 607 | return str.str(); |
| 608 | } |
| 609 | |
Abe Mbise | 925ca0f | 2017-10-02 19:16:33 +0100 | [diff] [blame] | 610 | /** Formatted output of the Coordinates type. */ |
| 611 | inline std::string to_string(const Coordinates &coord) |
| 612 | { |
| 613 | std::stringstream str; |
| 614 | str << coord; |
| 615 | return str.str(); |
| 616 | } |
| 617 | |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 618 | /** Formatted output of the Rectangle type. */ |
| 619 | inline ::std::ostream &operator<<(::std::ostream &os, const Rectangle &rect) |
| 620 | { |
| 621 | os << rect.width << "x" << rect.height; |
| 622 | os << "+" << rect.x << "+" << rect.y; |
| 623 | |
| 624 | return os; |
| 625 | } |
| 626 | |
| 627 | /** Formatted output of the PadStridInfo type. */ |
| 628 | inline ::std::ostream &operator<<(::std::ostream &os, const PadStrideInfo &pad_stride_info) |
| 629 | { |
| 630 | os << pad_stride_info.stride().first << "," << pad_stride_info.stride().second; |
| 631 | os << ";"; |
Jaroslaw Rzepecki | a1ed41f | 2017-10-13 11:13:58 +0100 | [diff] [blame] | 632 | os << pad_stride_info.pad_left() << "," << pad_stride_info.pad_right() << "," |
| 633 | << pad_stride_info.pad_top() << "," << pad_stride_info.pad_bottom(); |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 634 | |
| 635 | return os; |
| 636 | } |
| 637 | |
| 638 | inline std::string to_string(const PadStrideInfo &pad_stride_info) |
| 639 | { |
| 640 | std::stringstream str; |
| 641 | str << pad_stride_info; |
| 642 | return str.str(); |
| 643 | } |
| 644 | |
| 645 | inline std::string to_string(const BorderMode &mode) |
| 646 | { |
| 647 | std::stringstream str; |
| 648 | str << mode; |
| 649 | return str.str(); |
| 650 | } |
| 651 | |
John Richardson | b482ce1 | 2017-09-18 12:44:01 +0100 | [diff] [blame] | 652 | inline std::string to_string(const BorderSize &border) |
| 653 | { |
| 654 | std::stringstream str; |
| 655 | str << border; |
| 656 | return str.str(); |
| 657 | } |
| 658 | |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 659 | inline std::string to_string(const InterpolationPolicy &policy) |
| 660 | { |
| 661 | std::stringstream str; |
| 662 | str << policy; |
| 663 | return str.str(); |
| 664 | } |
| 665 | |
| 666 | /** Formatted output of the ConversionPolicy type. */ |
| 667 | inline ::std::ostream &operator<<(::std::ostream &os, const ConvertPolicy &policy) |
| 668 | { |
| 669 | switch(policy) |
| 670 | { |
| 671 | case ConvertPolicy::WRAP: |
| 672 | os << "WRAP"; |
| 673 | break; |
| 674 | case ConvertPolicy::SATURATE: |
| 675 | os << "SATURATE"; |
| 676 | break; |
| 677 | default: |
| 678 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 679 | } |
| 680 | |
| 681 | return os; |
| 682 | } |
| 683 | |
| 684 | inline std::string to_string(const ConvertPolicy &policy) |
| 685 | { |
| 686 | std::stringstream str; |
| 687 | str << policy; |
| 688 | return str.str(); |
| 689 | } |
| 690 | |
| 691 | /** Formatted output of the Reduction Operations. */ |
| 692 | inline ::std::ostream &operator<<(::std::ostream &os, const ReductionOperation &op) |
| 693 | { |
| 694 | switch(op) |
| 695 | { |
| 696 | case ReductionOperation::SUM_SQUARE: |
| 697 | os << "SUM_SQUARE"; |
| 698 | break; |
| 699 | default: |
| 700 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 701 | } |
| 702 | |
| 703 | return os; |
| 704 | } |
| 705 | |
| 706 | inline std::string to_string(const ReductionOperation &op) |
| 707 | { |
| 708 | std::stringstream str; |
| 709 | str << op; |
| 710 | return str.str(); |
| 711 | } |
| 712 | |
| 713 | inline std::string to_string(const NormType &type) |
| 714 | { |
| 715 | std::stringstream str; |
| 716 | str << type; |
| 717 | return str.str(); |
| 718 | } |
| 719 | |
| 720 | inline std::string to_string(const PoolingType &type) |
| 721 | { |
| 722 | std::stringstream str; |
| 723 | str << type; |
| 724 | return str.str(); |
| 725 | } |
| 726 | |
| 727 | inline std::string to_string(const PoolingLayerInfo &info) |
| 728 | { |
| 729 | std::stringstream str; |
Georgios Pinitas | 4c2dd54 | 2017-11-13 12:58:41 +0000 | [diff] [blame^] | 730 | str << "{Type=" << info.pool_type() << "," |
| 731 | << "IsGlobalPooling=" << info.is_global_pooling(); |
| 732 | if(!info.is_global_pooling()) |
| 733 | { |
| 734 | str << "," |
| 735 | << "PoolSize=" << info.pool_size() << "," |
| 736 | << "PadStride=" << info.pad_stride_info(); |
| 737 | } |
| 738 | str << "}"; |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 739 | return str.str(); |
| 740 | } |
| 741 | |
Moritz Pflanzer | 6c6597c | 2017-09-24 12:09:41 +0100 | [diff] [blame] | 742 | /** Formatted output of the KeyPoint type. */ |
| 743 | inline ::std::ostream &operator<<(::std::ostream &os, const KeyPoint &point) |
| 744 | { |
| 745 | os << "{x=" << point.x << "," |
| 746 | << "y=" << point.y << "," |
| 747 | << "strength=" << point.strength << "," |
| 748 | << "scale=" << point.scale << "," |
| 749 | << "orientation=" << point.orientation << "," |
| 750 | << "tracking_status=" << point.tracking_status << "," |
| 751 | << "error=" << point.error << "}"; |
| 752 | |
| 753 | return os; |
| 754 | } |
John Richardson | 63e5041 | 2017-10-13 20:51:42 +0100 | [diff] [blame] | 755 | |
| 756 | /** Formatted output of the PhaseType type. */ |
| 757 | inline ::std::ostream &operator<<(::std::ostream &os, const PhaseType &phase_type) |
| 758 | { |
| 759 | switch(phase_type) |
| 760 | { |
| 761 | case PhaseType::SIGNED: |
| 762 | os << "SIGNED"; |
| 763 | break; |
| 764 | case PhaseType::UNSIGNED: |
| 765 | os << "UNSIGNED"; |
| 766 | break; |
| 767 | default: |
| 768 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 769 | } |
| 770 | |
| 771 | return os; |
| 772 | } |
| 773 | |
| 774 | inline std::string to_string(const arm_compute::PhaseType &type) |
| 775 | { |
| 776 | std::stringstream str; |
| 777 | str << type; |
| 778 | return str.str(); |
| 779 | } |
John Richardson | 3c5f949 | 2017-10-04 15:27:37 +0100 | [diff] [blame] | 780 | |
| 781 | /** Formatted output of the MagnitudeType type. */ |
| 782 | inline ::std::ostream &operator<<(::std::ostream &os, const MagnitudeType &magnitude_type) |
| 783 | { |
| 784 | switch(magnitude_type) |
| 785 | { |
| 786 | case MagnitudeType::L1NORM: |
| 787 | os << "L1NORM"; |
| 788 | break; |
| 789 | case MagnitudeType::L2NORM: |
| 790 | os << "L2NORM"; |
| 791 | break; |
| 792 | default: |
| 793 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 794 | } |
| 795 | |
| 796 | return os; |
| 797 | } |
| 798 | |
| 799 | inline std::string to_string(const arm_compute::MagnitudeType &type) |
| 800 | { |
| 801 | std::stringstream str; |
| 802 | str << type; |
| 803 | return str.str(); |
| 804 | } |
John Richardson | 1c52992 | 2017-11-01 10:57:48 +0000 | [diff] [blame] | 805 | |
| 806 | /** Formatted output of the GradientDimension type. */ |
| 807 | inline ::std::ostream &operator<<(::std::ostream &os, const GradientDimension &dim) |
| 808 | { |
| 809 | switch(dim) |
| 810 | { |
| 811 | case GradientDimension::GRAD_X: |
| 812 | os << "GRAD_X"; |
| 813 | break; |
| 814 | case GradientDimension::GRAD_Y: |
| 815 | os << "GRAD_Y"; |
| 816 | break; |
| 817 | case GradientDimension::GRAD_XY: |
| 818 | os << "GRAD_XY"; |
| 819 | break; |
| 820 | default: |
| 821 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 822 | } |
| 823 | |
| 824 | return os; |
| 825 | } |
| 826 | |
| 827 | inline std::string to_string(const arm_compute::GradientDimension &type) |
| 828 | { |
| 829 | std::stringstream str; |
| 830 | str << type; |
| 831 | return str.str(); |
| 832 | } |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 833 | } // namespace arm_compute |
Anthony Barbier | ac69aa1 | 2017-07-03 17:39:37 +0100 | [diff] [blame] | 834 | #endif /* __ARM_COMPUTE_TEST_TYPE_PRINTER_H__ */ |