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