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