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 | |
Abe Mbise | 4bd2cb8 | 2017-09-27 18:39:19 +0100 | [diff] [blame] | 154 | inline ::std::ostream &operator<<(::std::ostream &os, const FixedPointOp &op) |
| 155 | { |
| 156 | switch(op) |
| 157 | { |
John Richardson | 70f946b | 2017-10-02 16:52:16 +0100 | [diff] [blame] | 158 | case FixedPointOp::ADD: |
| 159 | os << "ADD"; |
| 160 | break; |
| 161 | case FixedPointOp::SUB: |
| 162 | os << "SUB"; |
| 163 | break; |
| 164 | case FixedPointOp::MUL: |
| 165 | os << "MUL"; |
| 166 | break; |
Abe Mbise | 4bd2cb8 | 2017-09-27 18:39:19 +0100 | [diff] [blame] | 167 | case FixedPointOp::EXP: |
| 168 | os << "EXP"; |
| 169 | break; |
| 170 | case FixedPointOp::LOG: |
| 171 | os << "LOG"; |
| 172 | break; |
| 173 | case FixedPointOp::INV_SQRT: |
| 174 | os << "INV_SQRT"; |
| 175 | break; |
| 176 | case FixedPointOp::RECIPROCAL: |
| 177 | os << "RECIPROCAL"; |
| 178 | break; |
| 179 | default: |
| 180 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 181 | } |
| 182 | |
| 183 | return os; |
| 184 | } |
John Richardson | 70f946b | 2017-10-02 16:52:16 +0100 | [diff] [blame] | 185 | |
Abe Mbise | 4bd2cb8 | 2017-09-27 18:39:19 +0100 | [diff] [blame] | 186 | inline std::string to_string(const FixedPointOp &op) |
| 187 | { |
| 188 | std::stringstream str; |
| 189 | str << op; |
| 190 | return str.str(); |
| 191 | } |
| 192 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 193 | /** Formatted output of the activation function type. */ |
| 194 | inline ::std::ostream &operator<<(::std::ostream &os, const ActivationLayerInfo::ActivationFunction &act_function) |
| 195 | { |
| 196 | switch(act_function) |
| 197 | { |
| 198 | case ActivationLayerInfo::ActivationFunction::ABS: |
| 199 | os << "ABS"; |
| 200 | break; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 201 | case ActivationLayerInfo::ActivationFunction::LINEAR: |
| 202 | os << "LINEAR"; |
| 203 | break; |
| 204 | case ActivationLayerInfo::ActivationFunction::LOGISTIC: |
| 205 | os << "LOGISTIC"; |
| 206 | break; |
| 207 | case ActivationLayerInfo::ActivationFunction::RELU: |
| 208 | os << "RELU"; |
| 209 | break; |
Georgios Pinitas | 579c049 | 2017-07-12 16:12:12 +0100 | [diff] [blame] | 210 | case ActivationLayerInfo::ActivationFunction::BOUNDED_RELU: |
| 211 | os << "BOUNDED_RELU"; |
| 212 | break; |
| 213 | case ActivationLayerInfo::ActivationFunction::LEAKY_RELU: |
| 214 | os << "LEAKY_RELU"; |
| 215 | break; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 216 | case ActivationLayerInfo::ActivationFunction::SOFT_RELU: |
| 217 | os << "SOFT_RELU"; |
| 218 | break; |
| 219 | case ActivationLayerInfo::ActivationFunction::SQRT: |
| 220 | os << "SQRT"; |
| 221 | break; |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 222 | case ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU: |
| 223 | os << "LU_BOUNDED_RELU"; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 224 | case ActivationLayerInfo::ActivationFunction::SQUARE: |
| 225 | os << "SQUARE"; |
| 226 | break; |
| 227 | case ActivationLayerInfo::ActivationFunction::TANH: |
| 228 | os << "TANH"; |
| 229 | break; |
| 230 | default: |
| 231 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 232 | } |
| 233 | |
| 234 | return os; |
| 235 | } |
| 236 | |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 237 | inline std::string to_string(const arm_compute::ActivationLayerInfo &info) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 238 | { |
| 239 | std::stringstream str; |
| 240 | str << info.activation(); |
| 241 | return str.str(); |
| 242 | } |
| 243 | |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 244 | inline std::string to_string(const arm_compute::ActivationLayerInfo::ActivationFunction &function) |
| 245 | { |
| 246 | std::stringstream str; |
| 247 | str << function; |
| 248 | return str.str(); |
| 249 | } |
| 250 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 251 | /** Formatted output of the NormType type. */ |
| 252 | inline ::std::ostream &operator<<(::std::ostream &os, const NormType &norm_type) |
| 253 | { |
| 254 | switch(norm_type) |
| 255 | { |
| 256 | case NormType::CROSS_MAP: |
| 257 | os << "CROSS_MAP"; |
| 258 | break; |
| 259 | case NormType::IN_MAP_1D: |
| 260 | os << "IN_MAP_1D"; |
| 261 | break; |
| 262 | case NormType::IN_MAP_2D: |
| 263 | os << "IN_MAP_2D"; |
| 264 | break; |
| 265 | default: |
| 266 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 267 | } |
| 268 | |
| 269 | return os; |
| 270 | } |
| 271 | |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 272 | inline std::string to_string(const arm_compute::NormalizationLayerInfo &info) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 273 | { |
| 274 | std::stringstream str; |
| 275 | str << info.type(); |
| 276 | return str.str(); |
| 277 | } |
| 278 | |
Georgios Pinitas | 6f669f0 | 2017-09-26 12:32:57 +0100 | [diff] [blame] | 279 | /** Formatted output of @ref NormalizationLayerInfo. */ |
| 280 | inline ::std::ostream &operator<<(::std::ostream &os, const NormalizationLayerInfo &info) |
| 281 | { |
| 282 | os << info.type(); |
| 283 | return os; |
| 284 | } |
| 285 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 286 | /** Formatted output of the PoolingType type. */ |
| 287 | inline ::std::ostream &operator<<(::std::ostream &os, const PoolingType &pool_type) |
| 288 | { |
| 289 | switch(pool_type) |
| 290 | { |
| 291 | case PoolingType::AVG: |
| 292 | os << "AVG"; |
| 293 | break; |
| 294 | case PoolingType::MAX: |
| 295 | os << "MAX"; |
| 296 | break; |
Georgios Pinitas | cdf5145 | 2017-08-31 14:21:36 +0100 | [diff] [blame] | 297 | case PoolingType::L2: |
| 298 | os << "L2"; |
| 299 | break; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 300 | default: |
| 301 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 302 | } |
| 303 | |
| 304 | return os; |
| 305 | } |
| 306 | |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 307 | /** Formatted output of @ref PoolingLayerInfo. */ |
| 308 | inline ::std::ostream &operator<<(::std::ostream &os, const PoolingLayerInfo &info) |
| 309 | { |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 310 | os << info.pool_type(); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 311 | |
| 312 | return os; |
| 313 | } |
| 314 | |
John Richardson | dd715f2 | 2017-09-18 16:10:48 +0100 | [diff] [blame] | 315 | inline std::string to_string(const RoundingPolicy &rounding_policy) |
| 316 | { |
| 317 | std::stringstream str; |
| 318 | str << rounding_policy; |
| 319 | return str.str(); |
| 320 | } |
| 321 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 322 | /** Formatted output of the DataType type. */ |
| 323 | inline ::std::ostream &operator<<(::std::ostream &os, const DataType &data_type) |
| 324 | { |
| 325 | switch(data_type) |
| 326 | { |
| 327 | case DataType::UNKNOWN: |
| 328 | os << "UNKNOWN"; |
| 329 | break; |
| 330 | case DataType::U8: |
| 331 | os << "U8"; |
| 332 | break; |
| 333 | case DataType::QS8: |
| 334 | os << "QS8"; |
| 335 | break; |
| 336 | case DataType::S8: |
| 337 | os << "S8"; |
| 338 | break; |
| 339 | case DataType::U16: |
| 340 | os << "U16"; |
| 341 | break; |
| 342 | case DataType::S16: |
| 343 | os << "S16"; |
| 344 | break; |
Gian Marco Iodice | bdb6b0b | 2017-06-30 12:21:00 +0100 | [diff] [blame] | 345 | case DataType::QS16: |
| 346 | os << "QS16"; |
| 347 | break; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 348 | case DataType::U32: |
| 349 | os << "U32"; |
| 350 | break; |
| 351 | case DataType::S32: |
| 352 | os << "S32"; |
| 353 | break; |
| 354 | case DataType::U64: |
| 355 | os << "U64"; |
| 356 | break; |
| 357 | case DataType::S64: |
| 358 | os << "S64"; |
| 359 | break; |
| 360 | case DataType::F16: |
| 361 | os << "F16"; |
| 362 | break; |
| 363 | case DataType::F32: |
| 364 | os << "F32"; |
| 365 | break; |
| 366 | case DataType::F64: |
| 367 | os << "F64"; |
| 368 | break; |
| 369 | case DataType::SIZET: |
| 370 | os << "SIZET"; |
| 371 | break; |
| 372 | default: |
| 373 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 374 | } |
| 375 | |
| 376 | return os; |
| 377 | } |
| 378 | |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 379 | inline std::string to_string(const arm_compute::DataType &data_type) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 380 | { |
| 381 | std::stringstream str; |
| 382 | str << data_type; |
| 383 | return str.str(); |
| 384 | } |
| 385 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 386 | /** Formatted output of the Format type. */ |
| 387 | inline ::std::ostream &operator<<(::std::ostream &os, const Format &format) |
| 388 | { |
| 389 | switch(format) |
| 390 | { |
| 391 | case Format::UNKNOWN: |
| 392 | os << "UNKNOWN"; |
| 393 | break; |
| 394 | case Format::U8: |
| 395 | os << "U8"; |
| 396 | break; |
| 397 | case Format::S16: |
| 398 | os << "S16"; |
| 399 | break; |
| 400 | case Format::U16: |
| 401 | os << "U16"; |
| 402 | break; |
| 403 | case Format::S32: |
| 404 | os << "S32"; |
| 405 | break; |
| 406 | case Format::U32: |
| 407 | os << "U32"; |
| 408 | break; |
| 409 | case Format::F16: |
| 410 | os << "F16"; |
| 411 | break; |
| 412 | case Format::F32: |
| 413 | os << "F32"; |
| 414 | break; |
| 415 | case Format::UV88: |
| 416 | os << "UV88"; |
| 417 | break; |
| 418 | case Format::RGB888: |
| 419 | os << "RGB888"; |
| 420 | break; |
| 421 | case Format::RGBA8888: |
| 422 | os << "RGBA8888"; |
| 423 | break; |
| 424 | case Format::YUV444: |
| 425 | os << "YUV444"; |
| 426 | break; |
| 427 | case Format::YUYV422: |
| 428 | os << "YUYV422"; |
| 429 | break; |
| 430 | case Format::NV12: |
| 431 | os << "NV12"; |
| 432 | break; |
| 433 | case Format::NV21: |
| 434 | os << "NV21"; |
| 435 | break; |
| 436 | case Format::IYUV: |
| 437 | os << "IYUV"; |
| 438 | break; |
| 439 | case Format::UYVY422: |
| 440 | os << "UYVY422"; |
| 441 | break; |
| 442 | default: |
| 443 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 444 | } |
| 445 | |
| 446 | return os; |
| 447 | } |
| 448 | |
Moritz Pflanzer | 7655a67 | 2017-09-23 11:57:33 +0100 | [diff] [blame] | 449 | inline std::string to_string(const Format &format) |
| 450 | { |
| 451 | std::stringstream str; |
| 452 | str << format; |
| 453 | return str.str(); |
| 454 | } |
| 455 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 456 | /** Formatted output of the Channel type. */ |
| 457 | inline ::std::ostream &operator<<(::std::ostream &os, const Channel &channel) |
| 458 | { |
| 459 | switch(channel) |
| 460 | { |
| 461 | case Channel::UNKNOWN: |
| 462 | os << "UNKNOWN"; |
| 463 | break; |
| 464 | case Channel::C0: |
| 465 | os << "C0"; |
| 466 | break; |
| 467 | case Channel::C1: |
| 468 | os << "C1"; |
| 469 | break; |
| 470 | case Channel::C2: |
| 471 | os << "C2"; |
| 472 | break; |
| 473 | case Channel::C3: |
| 474 | os << "C3"; |
| 475 | break; |
| 476 | case Channel::R: |
| 477 | os << "R"; |
| 478 | break; |
| 479 | case Channel::G: |
| 480 | os << "G"; |
| 481 | break; |
| 482 | case Channel::B: |
| 483 | os << "B"; |
| 484 | break; |
| 485 | case Channel::A: |
| 486 | os << "A"; |
| 487 | break; |
| 488 | case Channel::Y: |
| 489 | os << "Y"; |
| 490 | break; |
| 491 | case Channel::U: |
| 492 | os << "U"; |
| 493 | break; |
| 494 | case Channel::V: |
| 495 | os << "V"; |
| 496 | break; |
| 497 | default: |
| 498 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 499 | } |
| 500 | |
| 501 | return os; |
| 502 | } |
| 503 | |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 504 | /** Formatted output of the BorderMode type. */ |
| 505 | inline ::std::ostream &operator<<(::std::ostream &os, const BorderMode &mode) |
| 506 | { |
| 507 | switch(mode) |
| 508 | { |
| 509 | case BorderMode::UNDEFINED: |
| 510 | os << "UNDEFINED"; |
| 511 | break; |
| 512 | case BorderMode::CONSTANT: |
| 513 | os << "CONSTANT"; |
| 514 | break; |
| 515 | case BorderMode::REPLICATE: |
| 516 | os << "REPLICATE"; |
| 517 | break; |
| 518 | default: |
| 519 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 520 | } |
| 521 | |
| 522 | return os; |
| 523 | } |
| 524 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 525 | /** Formatted output of the BorderSize type. */ |
| 526 | inline ::std::ostream &operator<<(::std::ostream &os, const BorderSize &border) |
| 527 | { |
Moritz Pflanzer | c87fbf8 | 2017-07-18 14:02:10 +0100 | [diff] [blame] | 528 | os << border.top << "," |
| 529 | << border.right << "," |
| 530 | << border.bottom << "," |
| 531 | << border.left; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 532 | |
| 533 | return os; |
| 534 | } |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 535 | |
| 536 | /** Formatted output of the InterpolationPolicy type. */ |
| 537 | inline ::std::ostream &operator<<(::std::ostream &os, const InterpolationPolicy &policy) |
| 538 | { |
| 539 | switch(policy) |
| 540 | { |
| 541 | case InterpolationPolicy::NEAREST_NEIGHBOR: |
| 542 | os << "NEAREST_NEIGHBOR"; |
| 543 | break; |
| 544 | case InterpolationPolicy::BILINEAR: |
| 545 | os << "BILINEAR"; |
| 546 | break; |
| 547 | case InterpolationPolicy::AREA: |
| 548 | os << "AREA"; |
| 549 | break; |
| 550 | default: |
| 551 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 552 | } |
| 553 | |
| 554 | return os; |
| 555 | } |
| 556 | |
Georgios Pinitas | 3faea25 | 2017-10-30 14:13:50 +0000 | [diff] [blame^] | 557 | /** Formatted output of the TensorInfo type. */ |
| 558 | inline std::string to_string(const TensorInfo &info) |
| 559 | { |
| 560 | std::stringstream str; |
| 561 | str << "{Shape=" << info.tensor_shape() << "," |
| 562 | << "Type=" << info.data_type() << "," |
| 563 | << "Channels=" << info.num_channels() << "," |
| 564 | << "FixedPointPos=" << info.fixed_point_position() << "}"; |
| 565 | return str.str(); |
| 566 | } |
| 567 | |
Abe Mbise | 925ca0f | 2017-10-02 19:16:33 +0100 | [diff] [blame] | 568 | //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] | 569 | template <typename T> |
| 570 | inline std::string to_string(const Dimensions<T> &dimensions) |
| 571 | { |
| 572 | std::stringstream str; |
| 573 | str << dimensions; |
| 574 | return str.str(); |
| 575 | } |
| 576 | |
John Richardson | a36eae1 | 2017-09-26 16:55:59 +0100 | [diff] [blame] | 577 | inline std::string to_string(const Strides &stride) |
| 578 | { |
| 579 | std::stringstream str; |
| 580 | str << stride; |
| 581 | return str.str(); |
| 582 | } |
| 583 | |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 584 | /** Formatted output of the TensorShape type. */ |
| 585 | inline std::string to_string(const TensorShape &shape) |
| 586 | { |
| 587 | std::stringstream str; |
| 588 | str << shape; |
| 589 | return str.str(); |
| 590 | } |
| 591 | |
Abe Mbise | 925ca0f | 2017-10-02 19:16:33 +0100 | [diff] [blame] | 592 | /** Formatted output of the Coordinates type. */ |
| 593 | inline std::string to_string(const Coordinates &coord) |
| 594 | { |
| 595 | std::stringstream str; |
| 596 | str << coord; |
| 597 | return str.str(); |
| 598 | } |
| 599 | |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 600 | /** Formatted output of the Rectangle type. */ |
| 601 | inline ::std::ostream &operator<<(::std::ostream &os, const Rectangle &rect) |
| 602 | { |
| 603 | os << rect.width << "x" << rect.height; |
| 604 | os << "+" << rect.x << "+" << rect.y; |
| 605 | |
| 606 | return os; |
| 607 | } |
| 608 | |
| 609 | /** Formatted output of the PadStridInfo type. */ |
| 610 | inline ::std::ostream &operator<<(::std::ostream &os, const PadStrideInfo &pad_stride_info) |
| 611 | { |
| 612 | os << pad_stride_info.stride().first << "," << pad_stride_info.stride().second; |
| 613 | os << ";"; |
Jaroslaw Rzepecki | a1ed41f | 2017-10-13 11:13:58 +0100 | [diff] [blame] | 614 | os << pad_stride_info.pad_left() << "," << pad_stride_info.pad_right() << "," |
| 615 | << pad_stride_info.pad_top() << "," << pad_stride_info.pad_bottom(); |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 616 | |
| 617 | return os; |
| 618 | } |
| 619 | |
| 620 | inline std::string to_string(const PadStrideInfo &pad_stride_info) |
| 621 | { |
| 622 | std::stringstream str; |
| 623 | str << pad_stride_info; |
| 624 | return str.str(); |
| 625 | } |
| 626 | |
| 627 | inline std::string to_string(const BorderMode &mode) |
| 628 | { |
| 629 | std::stringstream str; |
| 630 | str << mode; |
| 631 | return str.str(); |
| 632 | } |
| 633 | |
John Richardson | b482ce1 | 2017-09-18 12:44:01 +0100 | [diff] [blame] | 634 | inline std::string to_string(const BorderSize &border) |
| 635 | { |
| 636 | std::stringstream str; |
| 637 | str << border; |
| 638 | return str.str(); |
| 639 | } |
| 640 | |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 641 | inline std::string to_string(const InterpolationPolicy &policy) |
| 642 | { |
| 643 | std::stringstream str; |
| 644 | str << policy; |
| 645 | return str.str(); |
| 646 | } |
| 647 | |
| 648 | /** Formatted output of the ConversionPolicy type. */ |
| 649 | inline ::std::ostream &operator<<(::std::ostream &os, const ConvertPolicy &policy) |
| 650 | { |
| 651 | switch(policy) |
| 652 | { |
| 653 | case ConvertPolicy::WRAP: |
| 654 | os << "WRAP"; |
| 655 | break; |
| 656 | case ConvertPolicy::SATURATE: |
| 657 | os << "SATURATE"; |
| 658 | break; |
| 659 | default: |
| 660 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 661 | } |
| 662 | |
| 663 | return os; |
| 664 | } |
| 665 | |
| 666 | inline std::string to_string(const ConvertPolicy &policy) |
| 667 | { |
| 668 | std::stringstream str; |
| 669 | str << policy; |
| 670 | return str.str(); |
| 671 | } |
| 672 | |
| 673 | /** Formatted output of the Reduction Operations. */ |
| 674 | inline ::std::ostream &operator<<(::std::ostream &os, const ReductionOperation &op) |
| 675 | { |
| 676 | switch(op) |
| 677 | { |
| 678 | case ReductionOperation::SUM_SQUARE: |
| 679 | os << "SUM_SQUARE"; |
| 680 | break; |
| 681 | default: |
| 682 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 683 | } |
| 684 | |
| 685 | return os; |
| 686 | } |
| 687 | |
| 688 | inline std::string to_string(const ReductionOperation &op) |
| 689 | { |
| 690 | std::stringstream str; |
| 691 | str << op; |
| 692 | return str.str(); |
| 693 | } |
| 694 | |
| 695 | inline std::string to_string(const NormType &type) |
| 696 | { |
| 697 | std::stringstream str; |
| 698 | str << type; |
| 699 | return str.str(); |
| 700 | } |
| 701 | |
| 702 | inline std::string to_string(const PoolingType &type) |
| 703 | { |
| 704 | std::stringstream str; |
| 705 | str << type; |
| 706 | return str.str(); |
| 707 | } |
| 708 | |
| 709 | inline std::string to_string(const PoolingLayerInfo &info) |
| 710 | { |
| 711 | std::stringstream str; |
| 712 | str << info.pool_type(); |
| 713 | return str.str(); |
| 714 | } |
| 715 | |
Moritz Pflanzer | 6c6597c | 2017-09-24 12:09:41 +0100 | [diff] [blame] | 716 | /** Formatted output of the KeyPoint type. */ |
| 717 | inline ::std::ostream &operator<<(::std::ostream &os, const KeyPoint &point) |
| 718 | { |
| 719 | os << "{x=" << point.x << "," |
| 720 | << "y=" << point.y << "," |
| 721 | << "strength=" << point.strength << "," |
| 722 | << "scale=" << point.scale << "," |
| 723 | << "orientation=" << point.orientation << "," |
| 724 | << "tracking_status=" << point.tracking_status << "," |
| 725 | << "error=" << point.error << "}"; |
| 726 | |
| 727 | return os; |
| 728 | } |
John Richardson | 63e5041 | 2017-10-13 20:51:42 +0100 | [diff] [blame] | 729 | |
| 730 | /** Formatted output of the PhaseType type. */ |
| 731 | inline ::std::ostream &operator<<(::std::ostream &os, const PhaseType &phase_type) |
| 732 | { |
| 733 | switch(phase_type) |
| 734 | { |
| 735 | case PhaseType::SIGNED: |
| 736 | os << "SIGNED"; |
| 737 | break; |
| 738 | case PhaseType::UNSIGNED: |
| 739 | os << "UNSIGNED"; |
| 740 | break; |
| 741 | default: |
| 742 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 743 | } |
| 744 | |
| 745 | return os; |
| 746 | } |
| 747 | |
| 748 | inline std::string to_string(const arm_compute::PhaseType &type) |
| 749 | { |
| 750 | std::stringstream str; |
| 751 | str << type; |
| 752 | return str.str(); |
| 753 | } |
John Richardson | 3c5f949 | 2017-10-04 15:27:37 +0100 | [diff] [blame] | 754 | |
| 755 | /** Formatted output of the MagnitudeType type. */ |
| 756 | inline ::std::ostream &operator<<(::std::ostream &os, const MagnitudeType &magnitude_type) |
| 757 | { |
| 758 | switch(magnitude_type) |
| 759 | { |
| 760 | case MagnitudeType::L1NORM: |
| 761 | os << "L1NORM"; |
| 762 | break; |
| 763 | case MagnitudeType::L2NORM: |
| 764 | os << "L2NORM"; |
| 765 | break; |
| 766 | default: |
| 767 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 768 | } |
| 769 | |
| 770 | return os; |
| 771 | } |
| 772 | |
| 773 | inline std::string to_string(const arm_compute::MagnitudeType &type) |
| 774 | { |
| 775 | std::stringstream str; |
| 776 | str << type; |
| 777 | return str.str(); |
| 778 | } |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 779 | } // namespace arm_compute |
Anthony Barbier | ac69aa1 | 2017-07-03 17:39:37 +0100 | [diff] [blame] | 780 | #endif /* __ARM_COMPUTE_TEST_TYPE_PRINTER_H__ */ |