Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 1 | /* |
Michalis Spyrou | d466c2d | 2018-01-30 10:54:39 +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 | |
Isabella Gottardi | f07d28d | 2018-02-06 14:52:43 +0000 | [diff] [blame] | 27 | #include "arm_compute/core/CL/CLTypes.h" |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 28 | #include "arm_compute/core/Dimensions.h" |
| 29 | #include "arm_compute/core/Error.h" |
Michele Di Giorgio | b8fc60f | 2018-04-25 11:58:07 +0100 | [diff] [blame] | 30 | #include "arm_compute/core/GPUTarget.h" |
John Richardson | 25f2368 | 2017-11-27 14:35:09 +0000 | [diff] [blame] | 31 | #include "arm_compute/core/HOGInfo.h" |
| 32 | #include "arm_compute/core/Size2D.h" |
John Richardson | a36eae1 | 2017-09-26 16:55:59 +0100 | [diff] [blame] | 33 | #include "arm_compute/core/Strides.h" |
Georgios Pinitas | 3faea25 | 2017-10-30 14:13:50 +0000 | [diff] [blame] | 34 | #include "arm_compute/core/TensorInfo.h" |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 35 | #include "arm_compute/core/Types.h" |
| 36 | |
Abe Mbise | 4bd2cb8 | 2017-09-27 18:39:19 +0100 | [diff] [blame] | 37 | #include "tests/Types.h" |
| 38 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 39 | #include <ostream> |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 40 | #include <sstream> |
| 41 | #include <string> |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 42 | |
| 43 | namespace arm_compute |
| 44 | { |
Anthony Barbier | b940fd6 | 2018-06-04 14:14:32 +0100 | [diff] [blame] | 45 | /** Formatted output if arg is not null |
| 46 | * |
| 47 | * @param[in] arg Object to print |
| 48 | * |
| 49 | * @return String representing arg. |
| 50 | */ |
| 51 | template <typename T> |
| 52 | std::string to_string_if_not_null(T *arg) |
| 53 | { |
| 54 | if(arg == nullptr) |
| 55 | { |
| 56 | return "nullptr"; |
| 57 | } |
| 58 | else |
| 59 | { |
| 60 | return to_string(*arg); |
| 61 | } |
| 62 | } |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 63 | /** Formatted output of the Dimensions type. |
| 64 | * |
| 65 | * @param[out] os Output stream. |
| 66 | * @param[in] dimensions Type to output. |
| 67 | * |
| 68 | * @return Modified output stream. |
| 69 | */ |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 70 | template <typename T> |
| 71 | inline ::std::ostream &operator<<(::std::ostream &os, const Dimensions<T> &dimensions) |
| 72 | { |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 73 | if(dimensions.num_dimensions() > 0) |
| 74 | { |
| 75 | os << dimensions[0]; |
| 76 | |
| 77 | for(unsigned int d = 1; d < dimensions.num_dimensions(); ++d) |
| 78 | { |
Moritz Pflanzer | c87fbf8 | 2017-07-18 14:02:10 +0100 | [diff] [blame] | 79 | os << "x" << dimensions[d]; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 80 | } |
| 81 | } |
| 82 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 83 | return os; |
| 84 | } |
| 85 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 86 | /** Formatted output of the NonLinearFilterFunction type. |
| 87 | * |
| 88 | * @param[out] os Output stream. |
| 89 | * @param[in] function Type to output. |
| 90 | * |
| 91 | * @return Modified output stream. |
| 92 | */ |
Isabella Gottardi | 3b77e9d | 2017-06-22 11:05:41 +0100 | [diff] [blame] | 93 | inline ::std::ostream &operator<<(::std::ostream &os, const NonLinearFilterFunction &function) |
| 94 | { |
| 95 | switch(function) |
| 96 | { |
| 97 | case NonLinearFilterFunction::MAX: |
| 98 | os << "MAX"; |
| 99 | break; |
| 100 | case NonLinearFilterFunction::MEDIAN: |
| 101 | os << "MEDIAN"; |
| 102 | break; |
| 103 | case NonLinearFilterFunction::MIN: |
| 104 | os << "MIN"; |
| 105 | break; |
| 106 | default: |
| 107 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 108 | } |
| 109 | |
| 110 | return os; |
| 111 | } |
| 112 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 113 | /** Formatted output of the NonLinearFilterFunction type. |
| 114 | * |
| 115 | * @param[in] function Type to output. |
| 116 | * |
| 117 | * @return Formatted string. |
| 118 | */ |
John Richardson | 6f4d49f | 2017-09-07 11:21:10 +0100 | [diff] [blame] | 119 | inline std::string to_string(const NonLinearFilterFunction &function) |
| 120 | { |
| 121 | std::stringstream str; |
| 122 | str << function; |
| 123 | return str.str(); |
| 124 | } |
| 125 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 126 | /** Formatted output of the MatrixPattern type. |
| 127 | * |
| 128 | * @param[out] os Output stream. |
| 129 | * @param[in] pattern Type to output. |
| 130 | * |
| 131 | * @return Modified output stream. |
| 132 | */ |
Isabella Gottardi | 3b77e9d | 2017-06-22 11:05:41 +0100 | [diff] [blame] | 133 | inline ::std::ostream &operator<<(::std::ostream &os, const MatrixPattern &pattern) |
| 134 | { |
| 135 | switch(pattern) |
| 136 | { |
| 137 | case MatrixPattern::BOX: |
| 138 | os << "BOX"; |
| 139 | break; |
| 140 | case MatrixPattern::CROSS: |
| 141 | os << "CROSS"; |
| 142 | break; |
| 143 | case MatrixPattern::DISK: |
| 144 | os << "DISK"; |
| 145 | break; |
| 146 | case MatrixPattern::OTHER: |
| 147 | os << "OTHER"; |
| 148 | break; |
| 149 | default: |
| 150 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 151 | } |
| 152 | |
| 153 | return os; |
| 154 | } |
| 155 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 156 | /** Formatted output of the MatrixPattern type. |
| 157 | * |
| 158 | * @param[in] pattern Type to output. |
| 159 | * |
| 160 | * @return Formatted string. |
| 161 | */ |
John Richardson | 6f4d49f | 2017-09-07 11:21:10 +0100 | [diff] [blame] | 162 | inline std::string to_string(const MatrixPattern &pattern) |
| 163 | { |
| 164 | std::stringstream str; |
| 165 | str << pattern; |
| 166 | return str.str(); |
| 167 | } |
| 168 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 169 | /** Formatted output of the RoundingPolicy type. |
| 170 | * |
| 171 | * @param[out] os Output stream. |
| 172 | * @param[in] rounding_policy Type to output. |
| 173 | * |
| 174 | * @return Modified output stream. |
| 175 | */ |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 176 | inline ::std::ostream &operator<<(::std::ostream &os, const RoundingPolicy &rounding_policy) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 177 | { |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 178 | switch(rounding_policy) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 179 | { |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 180 | case RoundingPolicy::TO_ZERO: |
| 181 | os << "TO_ZERO"; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 182 | break; |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 183 | case RoundingPolicy::TO_NEAREST_UP: |
| 184 | os << "TO_NEAREST_UP"; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 185 | break; |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 186 | case RoundingPolicy::TO_NEAREST_EVEN: |
| 187 | os << "TO_NEAREST_EVEN"; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 188 | break; |
| 189 | default: |
| 190 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 191 | } |
| 192 | |
| 193 | return os; |
| 194 | } |
| 195 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 196 | /** Formatted output of the WeightsInfo type. |
| 197 | * |
| 198 | * @param[out] os Output stream. |
| 199 | * @param[in] weights_info Type to output. |
| 200 | * |
| 201 | * @return Modified output stream. |
| 202 | */ |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 203 | inline ::std::ostream &operator<<(::std::ostream &os, const WeightsInfo &weights_info) |
Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 204 | { |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 205 | os << weights_info.are_reshaped() << ";"; |
| 206 | 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] | 207 | |
| 208 | return os; |
| 209 | } |
| 210 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 211 | /** Formatted output of the ROIPoolingInfo type. |
| 212 | * |
| 213 | * @param[out] os Output stream. |
| 214 | * @param[in] pool_info Type to output. |
| 215 | * |
| 216 | * @return Modified output stream. |
| 217 | */ |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 218 | inline ::std::ostream &operator<<(::std::ostream &os, const ROIPoolingLayerInfo &pool_info) |
Sanghoon Lee | 70f8291 | 2017-08-24 14:21:24 +0100 | [diff] [blame] | 219 | { |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 220 | 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] | 221 | return os; |
| 222 | } |
| 223 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 224 | /** Formatted output of the QuantizationInfo type. |
| 225 | * |
| 226 | * @param[out] os Output stream. |
| 227 | * @param[in] quantization_info Type to output. |
| 228 | * |
| 229 | * @return Modified output stream. |
| 230 | */ |
Chunosov | d621bca | 2017-11-03 17:33:15 +0700 | [diff] [blame] | 231 | inline ::std::ostream &operator<<(::std::ostream &os, const QuantizationInfo &quantization_info) |
| 232 | { |
| 233 | os << "Scale:" << quantization_info.scale << "~" |
| 234 | << "Offset:" << quantization_info.offset; |
| 235 | return os; |
| 236 | } |
| 237 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 238 | /** Formatted output of the QuantizationInfo type. |
| 239 | * |
| 240 | * @param[in] quantization_info Type to output. |
| 241 | * |
| 242 | * @return Formatted string. |
| 243 | */ |
Chunosov | d621bca | 2017-11-03 17:33:15 +0700 | [diff] [blame] | 244 | inline std::string to_string(const QuantizationInfo &quantization_info) |
| 245 | { |
| 246 | std::stringstream str; |
| 247 | str << quantization_info; |
| 248 | return str.str(); |
| 249 | } |
| 250 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 251 | /** Formatted output of the activation function type. |
| 252 | * |
| 253 | * @param[out] os Output stream. |
| 254 | * @param[in] act_function Type to output. |
| 255 | * |
| 256 | * @return Modified output stream. |
| 257 | */ |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 258 | inline ::std::ostream &operator<<(::std::ostream &os, const ActivationLayerInfo::ActivationFunction &act_function) |
| 259 | { |
| 260 | switch(act_function) |
| 261 | { |
| 262 | case ActivationLayerInfo::ActivationFunction::ABS: |
| 263 | os << "ABS"; |
| 264 | break; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 265 | case ActivationLayerInfo::ActivationFunction::LINEAR: |
| 266 | os << "LINEAR"; |
| 267 | break; |
| 268 | case ActivationLayerInfo::ActivationFunction::LOGISTIC: |
| 269 | os << "LOGISTIC"; |
| 270 | break; |
| 271 | case ActivationLayerInfo::ActivationFunction::RELU: |
| 272 | os << "RELU"; |
| 273 | break; |
Georgios Pinitas | 579c049 | 2017-07-12 16:12:12 +0100 | [diff] [blame] | 274 | case ActivationLayerInfo::ActivationFunction::BOUNDED_RELU: |
| 275 | os << "BOUNDED_RELU"; |
| 276 | break; |
| 277 | case ActivationLayerInfo::ActivationFunction::LEAKY_RELU: |
| 278 | os << "LEAKY_RELU"; |
| 279 | break; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 280 | case ActivationLayerInfo::ActivationFunction::SOFT_RELU: |
| 281 | os << "SOFT_RELU"; |
| 282 | break; |
| 283 | case ActivationLayerInfo::ActivationFunction::SQRT: |
| 284 | os << "SQRT"; |
| 285 | break; |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 286 | case ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU: |
| 287 | os << "LU_BOUNDED_RELU"; |
Kevin Petit | d9f8071 | 2017-12-06 12:18:48 +0000 | [diff] [blame] | 288 | break; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 289 | case ActivationLayerInfo::ActivationFunction::SQUARE: |
| 290 | os << "SQUARE"; |
| 291 | break; |
| 292 | case ActivationLayerInfo::ActivationFunction::TANH: |
| 293 | os << "TANH"; |
| 294 | break; |
| 295 | default: |
| 296 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 297 | } |
| 298 | |
| 299 | return os; |
| 300 | } |
| 301 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 302 | /** Formatted output of the activation function info type. |
| 303 | * |
| 304 | * @param[in] info Type to output. |
| 305 | * |
| 306 | * @return Formatted string. |
| 307 | */ |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 308 | inline std::string to_string(const arm_compute::ActivationLayerInfo &info) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 309 | { |
| 310 | std::stringstream str; |
Isabella Gottardi | 3f217ec | 2018-02-12 14:59:19 +0000 | [diff] [blame] | 311 | if(info.enabled()) |
| 312 | { |
| 313 | str << info.activation(); |
| 314 | } |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 315 | return str.str(); |
| 316 | } |
| 317 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 318 | /** Formatted output of the activation function type. |
| 319 | * |
| 320 | * @param[in] function Type to output. |
| 321 | * |
| 322 | * @return Formatted string. |
| 323 | */ |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 324 | inline std::string to_string(const arm_compute::ActivationLayerInfo::ActivationFunction &function) |
| 325 | { |
| 326 | std::stringstream str; |
| 327 | str << function; |
| 328 | return str.str(); |
| 329 | } |
| 330 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 331 | /** Formatted output of the NormType type. |
| 332 | * |
| 333 | * @param[out] os Output stream. |
| 334 | * @param[in] norm_type Type to output. |
| 335 | * |
| 336 | * @return Modified output stream. |
| 337 | */ |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 338 | inline ::std::ostream &operator<<(::std::ostream &os, const NormType &norm_type) |
| 339 | { |
| 340 | switch(norm_type) |
| 341 | { |
| 342 | case NormType::CROSS_MAP: |
| 343 | os << "CROSS_MAP"; |
| 344 | break; |
| 345 | case NormType::IN_MAP_1D: |
| 346 | os << "IN_MAP_1D"; |
| 347 | break; |
| 348 | case NormType::IN_MAP_2D: |
| 349 | os << "IN_MAP_2D"; |
| 350 | break; |
| 351 | default: |
| 352 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 353 | } |
| 354 | |
| 355 | return os; |
| 356 | } |
| 357 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 358 | /** Formatted output of @ref NormalizationLayerInfo. |
| 359 | * |
| 360 | * @param[in] info Type to output. |
| 361 | * |
| 362 | * @return Formatted string. |
| 363 | */ |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 364 | inline std::string to_string(const arm_compute::NormalizationLayerInfo &info) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 365 | { |
| 366 | std::stringstream str; |
Michalis Spyrou | d466c2d | 2018-01-30 10:54:39 +0000 | [diff] [blame] | 367 | str << info.type() << ":NormSize=" << info.norm_size(); |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 368 | return str.str(); |
| 369 | } |
| 370 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 371 | /** Formatted output of @ref NormalizationLayerInfo. |
| 372 | * |
| 373 | * @param[out] os Output stream. |
| 374 | * @param[in] info Type to output. |
| 375 | * |
| 376 | * @return Modified output stream. |
| 377 | */ |
Georgios Pinitas | 6f669f0 | 2017-09-26 12:32:57 +0100 | [diff] [blame] | 378 | inline ::std::ostream &operator<<(::std::ostream &os, const NormalizationLayerInfo &info) |
| 379 | { |
Michalis Spyrou | d466c2d | 2018-01-30 10:54:39 +0000 | [diff] [blame] | 380 | os << info.type() << ":NormSize=" << info.norm_size(); |
Georgios Pinitas | 6f669f0 | 2017-09-26 12:32:57 +0100 | [diff] [blame] | 381 | return os; |
| 382 | } |
| 383 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 384 | /** Formatted output of the PoolingType type. |
| 385 | * |
| 386 | * @param[out] os Output stream. |
| 387 | * @param[in] pool_type Type to output. |
| 388 | * |
| 389 | * @return Modified output stream. |
| 390 | */ |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 391 | inline ::std::ostream &operator<<(::std::ostream &os, const PoolingType &pool_type) |
| 392 | { |
| 393 | switch(pool_type) |
| 394 | { |
| 395 | case PoolingType::AVG: |
| 396 | os << "AVG"; |
| 397 | break; |
| 398 | case PoolingType::MAX: |
| 399 | os << "MAX"; |
| 400 | break; |
Georgios Pinitas | cdf5145 | 2017-08-31 14:21:36 +0100 | [diff] [blame] | 401 | case PoolingType::L2: |
| 402 | os << "L2"; |
| 403 | break; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 404 | default: |
| 405 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 406 | } |
| 407 | |
| 408 | return os; |
| 409 | } |
| 410 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 411 | /** Formatted output of @ref PoolingLayerInfo. |
| 412 | * |
| 413 | * @param[out] os Output stream. |
| 414 | * @param[in] info Type to output. |
| 415 | * |
| 416 | * @return Modified output stream. |
| 417 | */ |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 418 | inline ::std::ostream &operator<<(::std::ostream &os, const PoolingLayerInfo &info) |
| 419 | { |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 420 | os << info.pool_type(); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 421 | |
| 422 | return os; |
| 423 | } |
| 424 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 425 | /** Formatted output of @ref RoundingPolicy. |
| 426 | * |
| 427 | * @param[in] rounding_policy Type to output. |
| 428 | * |
| 429 | * @return Formatted string. |
| 430 | */ |
John Richardson | dd715f2 | 2017-09-18 16:10:48 +0100 | [diff] [blame] | 431 | inline std::string to_string(const RoundingPolicy &rounding_policy) |
| 432 | { |
| 433 | std::stringstream str; |
| 434 | str << rounding_policy; |
| 435 | return str.str(); |
| 436 | } |
| 437 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 438 | /** Formatted output of the DataLayout type. |
| 439 | * |
| 440 | * @param[out] os Output stream. |
| 441 | * @param[in] data_layout Type to output. |
| 442 | * |
| 443 | * @return Modified output stream. |
| 444 | */ |
Michele Di Giorgio | 4a65b98 | 2018-03-02 11:21:38 +0000 | [diff] [blame] | 445 | inline ::std::ostream &operator<<(::std::ostream &os, const DataLayout &data_layout) |
| 446 | { |
| 447 | switch(data_layout) |
| 448 | { |
| 449 | case DataLayout::UNKNOWN: |
| 450 | os << "UNKNOWN"; |
| 451 | break; |
| 452 | case DataLayout::NHWC: |
| 453 | os << "NHWC"; |
| 454 | break; |
| 455 | case DataLayout::NCHW: |
| 456 | os << "NCHW"; |
| 457 | break; |
| 458 | default: |
| 459 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 460 | } |
| 461 | |
| 462 | return os; |
| 463 | } |
| 464 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 465 | /** Formatted output of the DataLayout type. |
| 466 | * |
| 467 | * @param[in] data_layout Type to output. |
| 468 | * |
| 469 | * @return Formatted string. |
| 470 | */ |
Michele Di Giorgio | 4a65b98 | 2018-03-02 11:21:38 +0000 | [diff] [blame] | 471 | inline std::string to_string(const arm_compute::DataLayout &data_layout) |
| 472 | { |
| 473 | std::stringstream str; |
| 474 | str << data_layout; |
| 475 | return str.str(); |
| 476 | } |
| 477 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 478 | /** Formatted output of the DataType type. |
| 479 | * |
| 480 | * @param[out] os Output stream. |
| 481 | * @param[in] data_type Type to output. |
| 482 | * |
| 483 | * @return Modified output stream. |
| 484 | */ |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 485 | inline ::std::ostream &operator<<(::std::ostream &os, const DataType &data_type) |
| 486 | { |
| 487 | switch(data_type) |
| 488 | { |
| 489 | case DataType::UNKNOWN: |
| 490 | os << "UNKNOWN"; |
| 491 | break; |
| 492 | case DataType::U8: |
| 493 | os << "U8"; |
| 494 | break; |
Chunosov | d621bca | 2017-11-03 17:33:15 +0700 | [diff] [blame] | 495 | case DataType::QASYMM8: |
| 496 | os << "QASYMM8"; |
| 497 | break; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 498 | case DataType::S8: |
| 499 | os << "S8"; |
| 500 | break; |
| 501 | case DataType::U16: |
| 502 | os << "U16"; |
| 503 | break; |
| 504 | case DataType::S16: |
| 505 | os << "S16"; |
| 506 | break; |
| 507 | case DataType::U32: |
| 508 | os << "U32"; |
| 509 | break; |
| 510 | case DataType::S32: |
| 511 | os << "S32"; |
| 512 | break; |
| 513 | case DataType::U64: |
| 514 | os << "U64"; |
| 515 | break; |
| 516 | case DataType::S64: |
| 517 | os << "S64"; |
| 518 | break; |
| 519 | case DataType::F16: |
| 520 | os << "F16"; |
| 521 | break; |
| 522 | case DataType::F32: |
| 523 | os << "F32"; |
| 524 | break; |
| 525 | case DataType::F64: |
| 526 | os << "F64"; |
| 527 | break; |
| 528 | case DataType::SIZET: |
| 529 | os << "SIZET"; |
| 530 | break; |
| 531 | default: |
| 532 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 533 | } |
| 534 | |
| 535 | return os; |
| 536 | } |
| 537 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 538 | /** Formatted output of the DataType type. |
| 539 | * |
| 540 | * @param[in] data_type Type to output. |
| 541 | * |
| 542 | * @return Formatted string. |
| 543 | */ |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 544 | inline std::string to_string(const arm_compute::DataType &data_type) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 545 | { |
| 546 | std::stringstream str; |
| 547 | str << data_type; |
| 548 | return str.str(); |
| 549 | } |
| 550 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 551 | /** Formatted output of the Format type. |
| 552 | * |
| 553 | * @param[out] os Output stream. |
| 554 | * @param[in] format Type to output. |
| 555 | * |
| 556 | * @return Modified output stream. |
| 557 | */ |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 558 | inline ::std::ostream &operator<<(::std::ostream &os, const Format &format) |
| 559 | { |
| 560 | switch(format) |
| 561 | { |
| 562 | case Format::UNKNOWN: |
| 563 | os << "UNKNOWN"; |
| 564 | break; |
| 565 | case Format::U8: |
| 566 | os << "U8"; |
| 567 | break; |
| 568 | case Format::S16: |
| 569 | os << "S16"; |
| 570 | break; |
| 571 | case Format::U16: |
| 572 | os << "U16"; |
| 573 | break; |
| 574 | case Format::S32: |
| 575 | os << "S32"; |
| 576 | break; |
| 577 | case Format::U32: |
| 578 | os << "U32"; |
| 579 | break; |
| 580 | case Format::F16: |
| 581 | os << "F16"; |
| 582 | break; |
| 583 | case Format::F32: |
| 584 | os << "F32"; |
| 585 | break; |
| 586 | case Format::UV88: |
| 587 | os << "UV88"; |
| 588 | break; |
| 589 | case Format::RGB888: |
| 590 | os << "RGB888"; |
| 591 | break; |
| 592 | case Format::RGBA8888: |
| 593 | os << "RGBA8888"; |
| 594 | break; |
| 595 | case Format::YUV444: |
| 596 | os << "YUV444"; |
| 597 | break; |
| 598 | case Format::YUYV422: |
| 599 | os << "YUYV422"; |
| 600 | break; |
| 601 | case Format::NV12: |
| 602 | os << "NV12"; |
| 603 | break; |
| 604 | case Format::NV21: |
| 605 | os << "NV21"; |
| 606 | break; |
| 607 | case Format::IYUV: |
| 608 | os << "IYUV"; |
| 609 | break; |
| 610 | case Format::UYVY422: |
| 611 | os << "UYVY422"; |
| 612 | break; |
| 613 | default: |
| 614 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 615 | } |
| 616 | |
| 617 | return os; |
| 618 | } |
| 619 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 620 | /** Formatted output of the Format type. |
| 621 | * |
| 622 | * @param[in] format Type to output. |
| 623 | * |
| 624 | * @return Formatted string. |
| 625 | */ |
Moritz Pflanzer | 7655a67 | 2017-09-23 11:57:33 +0100 | [diff] [blame] | 626 | inline std::string to_string(const Format &format) |
| 627 | { |
| 628 | std::stringstream str; |
| 629 | str << format; |
| 630 | return str.str(); |
| 631 | } |
| 632 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 633 | /** Formatted output of the Channel type. |
| 634 | * |
| 635 | * @param[out] os Output stream. |
| 636 | * @param[in] channel Type to output. |
| 637 | * |
| 638 | * @return Modified output stream. |
| 639 | */ |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 640 | inline ::std::ostream &operator<<(::std::ostream &os, const Channel &channel) |
| 641 | { |
| 642 | switch(channel) |
| 643 | { |
| 644 | case Channel::UNKNOWN: |
| 645 | os << "UNKNOWN"; |
| 646 | break; |
| 647 | case Channel::C0: |
| 648 | os << "C0"; |
| 649 | break; |
| 650 | case Channel::C1: |
| 651 | os << "C1"; |
| 652 | break; |
| 653 | case Channel::C2: |
| 654 | os << "C2"; |
| 655 | break; |
| 656 | case Channel::C3: |
| 657 | os << "C3"; |
| 658 | break; |
| 659 | case Channel::R: |
| 660 | os << "R"; |
| 661 | break; |
| 662 | case Channel::G: |
| 663 | os << "G"; |
| 664 | break; |
| 665 | case Channel::B: |
| 666 | os << "B"; |
| 667 | break; |
| 668 | case Channel::A: |
| 669 | os << "A"; |
| 670 | break; |
| 671 | case Channel::Y: |
| 672 | os << "Y"; |
| 673 | break; |
| 674 | case Channel::U: |
| 675 | os << "U"; |
| 676 | break; |
| 677 | case Channel::V: |
| 678 | os << "V"; |
| 679 | break; |
| 680 | default: |
| 681 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 682 | } |
| 683 | |
| 684 | return os; |
| 685 | } |
| 686 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 687 | /** Formatted output of the Channel type. |
| 688 | * |
| 689 | * @param[in] channel Type to output. |
| 690 | * |
| 691 | * @return Formatted string. |
| 692 | */ |
Ioan-Cristian Szabo | 9414f64 | 2017-10-27 17:35:40 +0100 | [diff] [blame] | 693 | inline std::string to_string(const Channel &channel) |
| 694 | { |
| 695 | std::stringstream str; |
| 696 | str << channel; |
| 697 | return str.str(); |
| 698 | } |
| 699 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 700 | /** Formatted output of the BorderMode type. |
| 701 | * |
| 702 | * @param[out] os Output stream. |
| 703 | * @param[in] mode Type to output. |
| 704 | * |
| 705 | * @return Modified output stream. |
| 706 | */ |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 707 | inline ::std::ostream &operator<<(::std::ostream &os, const BorderMode &mode) |
| 708 | { |
| 709 | switch(mode) |
| 710 | { |
| 711 | case BorderMode::UNDEFINED: |
| 712 | os << "UNDEFINED"; |
| 713 | break; |
| 714 | case BorderMode::CONSTANT: |
| 715 | os << "CONSTANT"; |
| 716 | break; |
| 717 | case BorderMode::REPLICATE: |
| 718 | os << "REPLICATE"; |
| 719 | break; |
| 720 | default: |
| 721 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 722 | } |
| 723 | |
| 724 | return os; |
| 725 | } |
| 726 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 727 | /** Formatted output of the BorderSize type. |
| 728 | * |
| 729 | * @param[out] os Output stream. |
| 730 | * @param[in] border Type to output. |
| 731 | * |
| 732 | * @return Modified output stream. |
| 733 | */ |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 734 | inline ::std::ostream &operator<<(::std::ostream &os, const BorderSize &border) |
| 735 | { |
Moritz Pflanzer | c87fbf8 | 2017-07-18 14:02:10 +0100 | [diff] [blame] | 736 | os << border.top << "," |
| 737 | << border.right << "," |
| 738 | << border.bottom << "," |
| 739 | << border.left; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 740 | |
| 741 | return os; |
| 742 | } |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 743 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 744 | /** Formatted output of the InterpolationPolicy type. |
| 745 | * |
| 746 | * @param[out] os Output stream. |
| 747 | * @param[in] policy Type to output. |
| 748 | * |
| 749 | * @return Modified output stream. |
| 750 | */ |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 751 | inline ::std::ostream &operator<<(::std::ostream &os, const InterpolationPolicy &policy) |
| 752 | { |
| 753 | switch(policy) |
| 754 | { |
| 755 | case InterpolationPolicy::NEAREST_NEIGHBOR: |
| 756 | os << "NEAREST_NEIGHBOR"; |
| 757 | break; |
| 758 | case InterpolationPolicy::BILINEAR: |
| 759 | os << "BILINEAR"; |
| 760 | break; |
| 761 | case InterpolationPolicy::AREA: |
| 762 | os << "AREA"; |
| 763 | break; |
| 764 | default: |
| 765 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 766 | } |
| 767 | |
| 768 | return os; |
| 769 | } |
| 770 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 771 | /** Formatted output of the SamplingPolicy type. |
| 772 | * |
| 773 | * @param[out] os Output stream. |
| 774 | * @param[in] policy Type to output. |
| 775 | * |
| 776 | * @return Modified output stream. |
| 777 | */ |
Daniil Efremov | 02bf80d | 2017-11-22 00:26:51 +0700 | [diff] [blame] | 778 | inline ::std::ostream &operator<<(::std::ostream &os, const SamplingPolicy &policy) |
| 779 | { |
| 780 | switch(policy) |
| 781 | { |
| 782 | case SamplingPolicy::CENTER: |
| 783 | os << "CENTER"; |
| 784 | break; |
| 785 | case SamplingPolicy::TOP_LEFT: |
| 786 | os << "TOP_LEFT"; |
| 787 | break; |
| 788 | default: |
| 789 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 790 | } |
| 791 | |
| 792 | return os; |
| 793 | } |
| 794 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 795 | /** Formatted output of the TensorInfo type. |
| 796 | * |
| 797 | * @param[in] info Type to output. |
| 798 | * |
| 799 | * @return Formatted string. |
| 800 | */ |
Georgios Pinitas | 3faea25 | 2017-10-30 14:13:50 +0000 | [diff] [blame] | 801 | inline std::string to_string(const TensorInfo &info) |
| 802 | { |
| 803 | std::stringstream str; |
| 804 | str << "{Shape=" << info.tensor_shape() << "," |
| 805 | << "Type=" << info.data_type() << "," |
Vidhya Sudhan Loganathan | 7485d5a | 2018-07-04 09:34:00 +0100 | [diff] [blame] | 806 | << "Channels=" << info.num_channels() << "}"; |
Georgios Pinitas | 3faea25 | 2017-10-30 14:13:50 +0000 | [diff] [blame] | 807 | return str.str(); |
| 808 | } |
| 809 | |
Abe Mbise | 925ca0f | 2017-10-02 19:16:33 +0100 | [diff] [blame] | 810 | //FIXME: Check why this doesn't work and the TensorShape and Coordinates overload are needed |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 811 | /** Formatted output of the Dimensions type. |
| 812 | * |
| 813 | * @param[in] dimensions Type to output. |
| 814 | * |
| 815 | * @return Formatted string. |
| 816 | */ |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 817 | template <typename T> |
| 818 | inline std::string to_string(const Dimensions<T> &dimensions) |
| 819 | { |
| 820 | std::stringstream str; |
| 821 | str << dimensions; |
| 822 | return str.str(); |
| 823 | } |
| 824 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 825 | /** Formatted output of the Strides type. |
| 826 | * |
| 827 | * @param[in] stride Type to output. |
| 828 | * |
| 829 | * @return Formatted string. |
| 830 | */ |
John Richardson | a36eae1 | 2017-09-26 16:55:59 +0100 | [diff] [blame] | 831 | inline std::string to_string(const Strides &stride) |
| 832 | { |
| 833 | std::stringstream str; |
| 834 | str << stride; |
| 835 | return str.str(); |
| 836 | } |
| 837 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 838 | /** Formatted output of the TensorShape type. |
| 839 | * |
| 840 | * @param[in] shape Type to output. |
| 841 | * |
| 842 | * @return Formatted string. |
| 843 | */ |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 844 | inline std::string to_string(const TensorShape &shape) |
| 845 | { |
| 846 | std::stringstream str; |
| 847 | str << shape; |
| 848 | return str.str(); |
| 849 | } |
| 850 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 851 | /** Formatted output of the Coordinates type. |
| 852 | * |
| 853 | * @param[in] coord Type to output. |
| 854 | * |
| 855 | * @return Formatted string. |
| 856 | */ |
Abe Mbise | 925ca0f | 2017-10-02 19:16:33 +0100 | [diff] [blame] | 857 | inline std::string to_string(const Coordinates &coord) |
| 858 | { |
| 859 | std::stringstream str; |
| 860 | str << coord; |
| 861 | return str.str(); |
| 862 | } |
| 863 | |
Anthony Barbier | b940fd6 | 2018-06-04 14:14:32 +0100 | [diff] [blame] | 864 | /** Formatted output of the GEMMReshapeInfo type. |
| 865 | * |
| 866 | * @param[out] os Output stream. |
| 867 | * @param[in] info Type to output. |
| 868 | * |
| 869 | * @return Modified output stream. |
| 870 | */ |
| 871 | inline ::std::ostream &operator<<(::std::ostream &os, const GEMMReshapeInfo &info) |
| 872 | { |
| 873 | os << "{m=" << info.m() << ","; |
| 874 | os << "n=" << info.n() << ","; |
| 875 | os << "k=" << info.k() << ","; |
| 876 | os << "mult_transpose1xW_width=" << info.mult_transpose1xW_width() << ","; |
| 877 | os << "mult_interleave4x4_height=" << info.mult_interleave4x4_height(); |
| 878 | os << "}"; |
| 879 | |
| 880 | return os; |
| 881 | } |
| 882 | |
| 883 | /** Formatted output of the GEMMInfo type. |
| 884 | * |
| 885 | * @param[out] os Output stream. |
| 886 | * @param[in] info Type to output. |
| 887 | * |
| 888 | * @return Modified output stream. |
| 889 | */ |
| 890 | inline ::std::ostream &operator<<(::std::ostream &os, const GEMMInfo &info) |
| 891 | { |
| 892 | os << "{is_a_reshaped=" << info.is_a_reshaped() << ","; |
| 893 | os << "is_b_reshaped=" << info.is_b_reshaped() << ","; |
| 894 | os << "reshape_b_only_on_first_run=" << info.reshape_b_only_on_first_run() << ","; |
Anthony Barbier | b940fd6 | 2018-06-04 14:14:32 +0100 | [diff] [blame] | 895 | os << "}"; |
| 896 | |
| 897 | return os; |
| 898 | } |
| 899 | |
| 900 | /** Formatted output of the Window::Dimension type. |
| 901 | * |
| 902 | * @param[out] os Output stream. |
| 903 | * @param[in] dim Type to output. |
| 904 | * |
| 905 | * @return Modified output stream. |
| 906 | */ |
| 907 | inline ::std::ostream &operator<<(::std::ostream &os, const Window::Dimension &dim) |
| 908 | { |
| 909 | os << "{start=" << dim.start() << ", end=" << dim.end() << ", step=" << dim.step() << "}"; |
| 910 | |
| 911 | return os; |
| 912 | } |
| 913 | /** Formatted output of the Window type. |
| 914 | * |
| 915 | * @param[out] os Output stream. |
| 916 | * @param[in] win Type to output. |
| 917 | * |
| 918 | * @return Modified output stream. |
| 919 | */ |
| 920 | inline ::std::ostream &operator<<(::std::ostream &os, const Window &win) |
| 921 | { |
| 922 | os << "{"; |
| 923 | for(unsigned int i = 0; i < Coordinates::num_max_dimensions; i++) |
| 924 | { |
| 925 | if(i > 0) |
| 926 | { |
| 927 | os << ", "; |
| 928 | } |
| 929 | os << win[i]; |
| 930 | } |
| 931 | os << "}"; |
| 932 | |
| 933 | return os; |
| 934 | } |
| 935 | |
| 936 | /** Formatted output of the WeightsInfo type. |
| 937 | * |
| 938 | * @param[in] info Type to output. |
| 939 | * |
| 940 | * @return Formatted string. |
| 941 | */ |
| 942 | inline std::string to_string(const WeightsInfo &info) |
| 943 | { |
| 944 | std::stringstream str; |
| 945 | str << info; |
| 946 | return str.str(); |
| 947 | } |
| 948 | |
| 949 | /** Formatted output of the GEMMReshapeInfo type. |
| 950 | * |
| 951 | * @param[in] info Type to output. |
| 952 | * |
| 953 | * @return Formatted string. |
| 954 | */ |
| 955 | inline std::string to_string(const GEMMReshapeInfo &info) |
| 956 | { |
| 957 | std::stringstream str; |
| 958 | str << info; |
| 959 | return str.str(); |
| 960 | } |
| 961 | |
| 962 | /** Formatted output of the GEMMInfo type. |
| 963 | * |
| 964 | * @param[in] info Type to output. |
| 965 | * |
| 966 | * @return Formatted string. |
| 967 | */ |
| 968 | inline std::string to_string(const GEMMInfo &info) |
| 969 | { |
| 970 | std::stringstream str; |
| 971 | str << info; |
| 972 | return str.str(); |
| 973 | } |
| 974 | |
| 975 | /** Formatted output of the Window::Dimension type. |
| 976 | * |
| 977 | * @param[in] dim Type to output. |
| 978 | * |
| 979 | * @return Formatted string. |
| 980 | */ |
| 981 | inline std::string to_string(const Window::Dimension &dim) |
| 982 | { |
| 983 | std::stringstream str; |
| 984 | str << dim; |
| 985 | return str.str(); |
| 986 | } |
| 987 | /** Formatted output of the Window type. |
| 988 | * |
| 989 | * @param[in] win Type to output. |
| 990 | * |
| 991 | * @return Formatted string. |
| 992 | */ |
| 993 | inline std::string to_string(const Window &win) |
| 994 | { |
| 995 | std::stringstream str; |
| 996 | str << win; |
| 997 | return str.str(); |
| 998 | } |
| 999 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 1000 | /** Formatted output of the Rectangle type. |
| 1001 | * |
| 1002 | * @param[out] os Output stream. |
| 1003 | * @param[in] rect Type to output. |
| 1004 | * |
| 1005 | * @return Modified output stream. |
| 1006 | */ |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 1007 | inline ::std::ostream &operator<<(::std::ostream &os, const Rectangle &rect) |
| 1008 | { |
| 1009 | os << rect.width << "x" << rect.height; |
| 1010 | os << "+" << rect.x << "+" << rect.y; |
| 1011 | |
| 1012 | return os; |
| 1013 | } |
| 1014 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 1015 | /** Formatted output of the PadStrideInfo type. |
| 1016 | * |
| 1017 | * @param[out] os Output stream. |
| 1018 | * @param[in] pad_stride_info Type to output. |
| 1019 | * |
| 1020 | * @return Modified output stream. |
| 1021 | */ |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 1022 | inline ::std::ostream &operator<<(::std::ostream &os, const PadStrideInfo &pad_stride_info) |
| 1023 | { |
| 1024 | os << pad_stride_info.stride().first << "," << pad_stride_info.stride().second; |
| 1025 | os << ";"; |
Jaroslaw Rzepecki | a1ed41f | 2017-10-13 11:13:58 +0100 | [diff] [blame] | 1026 | os << pad_stride_info.pad_left() << "," << pad_stride_info.pad_right() << "," |
| 1027 | << pad_stride_info.pad_top() << "," << pad_stride_info.pad_bottom(); |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 1028 | |
| 1029 | return os; |
| 1030 | } |
| 1031 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 1032 | /** Formatted output of the PadStrideInfo type. |
| 1033 | * |
| 1034 | * @param[in] pad_stride_info Type to output. |
| 1035 | * |
| 1036 | * @return Formatted string. |
| 1037 | */ |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 1038 | inline std::string to_string(const PadStrideInfo &pad_stride_info) |
| 1039 | { |
| 1040 | std::stringstream str; |
| 1041 | str << pad_stride_info; |
| 1042 | return str.str(); |
| 1043 | } |
| 1044 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 1045 | /** Formatted output of the BorderMode type. |
| 1046 | * |
| 1047 | * @param[in] mode Type to output. |
| 1048 | * |
| 1049 | * @return Formatted string. |
| 1050 | */ |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 1051 | inline std::string to_string(const BorderMode &mode) |
| 1052 | { |
| 1053 | std::stringstream str; |
| 1054 | str << mode; |
| 1055 | return str.str(); |
| 1056 | } |
| 1057 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 1058 | /** Formatted output of the BorderSize type. |
| 1059 | * |
| 1060 | * @param[in] border Type to output. |
| 1061 | * |
| 1062 | * @return Formatted string. |
| 1063 | */ |
John Richardson | b482ce1 | 2017-09-18 12:44:01 +0100 | [diff] [blame] | 1064 | inline std::string to_string(const BorderSize &border) |
| 1065 | { |
| 1066 | std::stringstream str; |
| 1067 | str << border; |
| 1068 | return str.str(); |
| 1069 | } |
| 1070 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 1071 | /** Formatted output of the InterpolationPolicy type. |
| 1072 | * |
| 1073 | * @param[in] policy Type to output. |
| 1074 | * |
| 1075 | * @return Formatted string. |
| 1076 | */ |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 1077 | inline std::string to_string(const InterpolationPolicy &policy) |
| 1078 | { |
| 1079 | std::stringstream str; |
| 1080 | str << policy; |
| 1081 | return str.str(); |
| 1082 | } |
| 1083 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 1084 | /** Formatted output of the SamplingPolicy type. |
| 1085 | * |
| 1086 | * @param[in] policy Type to output. |
| 1087 | * |
| 1088 | * @return Formatted string. |
| 1089 | */ |
Daniil Efremov | 02bf80d | 2017-11-22 00:26:51 +0700 | [diff] [blame] | 1090 | inline std::string to_string(const SamplingPolicy &policy) |
| 1091 | { |
| 1092 | std::stringstream str; |
| 1093 | str << policy; |
| 1094 | return str.str(); |
| 1095 | } |
| 1096 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 1097 | /** Formatted output of the ConvertPolicy type. |
| 1098 | * |
| 1099 | * @param[out] os Output stream. |
| 1100 | * @param[in] policy Type to output. |
| 1101 | * |
| 1102 | * @return Modified output stream. |
| 1103 | */ |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 1104 | inline ::std::ostream &operator<<(::std::ostream &os, const ConvertPolicy &policy) |
| 1105 | { |
| 1106 | switch(policy) |
| 1107 | { |
| 1108 | case ConvertPolicy::WRAP: |
| 1109 | os << "WRAP"; |
| 1110 | break; |
| 1111 | case ConvertPolicy::SATURATE: |
| 1112 | os << "SATURATE"; |
| 1113 | break; |
| 1114 | default: |
| 1115 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 1116 | } |
| 1117 | |
| 1118 | return os; |
| 1119 | } |
| 1120 | |
| 1121 | inline std::string to_string(const ConvertPolicy &policy) |
| 1122 | { |
| 1123 | std::stringstream str; |
| 1124 | str << policy; |
| 1125 | return str.str(); |
| 1126 | } |
| 1127 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 1128 | /** Formatted output of the Reduction Operations. |
| 1129 | * |
| 1130 | * @param[out] os Output stream. |
| 1131 | * @param[in] op Type to output. |
| 1132 | * |
| 1133 | * @return Modified output stream. |
| 1134 | */ |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 1135 | inline ::std::ostream &operator<<(::std::ostream &os, const ReductionOperation &op) |
| 1136 | { |
| 1137 | switch(op) |
| 1138 | { |
| 1139 | case ReductionOperation::SUM_SQUARE: |
| 1140 | os << "SUM_SQUARE"; |
| 1141 | break; |
| 1142 | default: |
| 1143 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 1144 | } |
| 1145 | |
| 1146 | return os; |
| 1147 | } |
| 1148 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 1149 | /** Formatted output of the Reduction Operations. |
| 1150 | * |
| 1151 | * @param[in] op Type to output. |
| 1152 | * |
| 1153 | * @return Formatted string. |
| 1154 | */ |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 1155 | inline std::string to_string(const ReductionOperation &op) |
| 1156 | { |
| 1157 | std::stringstream str; |
| 1158 | str << op; |
| 1159 | return str.str(); |
| 1160 | } |
| 1161 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 1162 | /** Formatted output of the Norm Type. |
| 1163 | * |
| 1164 | * @param[in] type Type to output. |
| 1165 | * |
| 1166 | * @return Formatted string. |
| 1167 | */ |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 1168 | inline std::string to_string(const NormType &type) |
| 1169 | { |
| 1170 | std::stringstream str; |
| 1171 | str << type; |
| 1172 | return str.str(); |
| 1173 | } |
| 1174 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 1175 | /** Formatted output of the Pooling Type. |
| 1176 | * |
| 1177 | * @param[in] type Type to output. |
| 1178 | * |
| 1179 | * @return Formatted string. |
| 1180 | */ |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 1181 | inline std::string to_string(const PoolingType &type) |
| 1182 | { |
| 1183 | std::stringstream str; |
| 1184 | str << type; |
| 1185 | return str.str(); |
| 1186 | } |
| 1187 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 1188 | /** Formatted output of the Pooling Layer Info. |
| 1189 | * |
| 1190 | * @param[in] info Type to output. |
| 1191 | * |
| 1192 | * @return Formatted string. |
| 1193 | */ |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 1194 | inline std::string to_string(const PoolingLayerInfo &info) |
| 1195 | { |
| 1196 | std::stringstream str; |
Georgios Pinitas | 4c2dd54 | 2017-11-13 12:58:41 +0000 | [diff] [blame] | 1197 | str << "{Type=" << info.pool_type() << "," |
| 1198 | << "IsGlobalPooling=" << info.is_global_pooling(); |
| 1199 | if(!info.is_global_pooling()) |
| 1200 | { |
| 1201 | str << "," |
Isabella Gottardi | 6e464c3 | 2018-01-26 12:32:45 +0000 | [diff] [blame] | 1202 | << "PoolSize=" << info.pool_size().width << "," << info.pool_size().height << "," |
Georgios Pinitas | 4c2dd54 | 2017-11-13 12:58:41 +0000 | [diff] [blame] | 1203 | << "PadStride=" << info.pad_stride_info(); |
| 1204 | } |
| 1205 | str << "}"; |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 1206 | return str.str(); |
| 1207 | } |
| 1208 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 1209 | /** Formatted output of the KeyPoint type. |
| 1210 | * |
| 1211 | * @param[out] os Output stream |
| 1212 | * @param[in] point Type to output. |
| 1213 | * |
| 1214 | * @return Modified output stream. |
| 1215 | */ |
Moritz Pflanzer | 6c6597c | 2017-09-24 12:09:41 +0100 | [diff] [blame] | 1216 | inline ::std::ostream &operator<<(::std::ostream &os, const KeyPoint &point) |
| 1217 | { |
| 1218 | os << "{x=" << point.x << "," |
| 1219 | << "y=" << point.y << "," |
| 1220 | << "strength=" << point.strength << "," |
| 1221 | << "scale=" << point.scale << "," |
| 1222 | << "orientation=" << point.orientation << "," |
| 1223 | << "tracking_status=" << point.tracking_status << "," |
| 1224 | << "error=" << point.error << "}"; |
| 1225 | |
| 1226 | return os; |
| 1227 | } |
John Richardson | 63e5041 | 2017-10-13 20:51:42 +0100 | [diff] [blame] | 1228 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 1229 | /** Formatted output of the PhaseType type. |
| 1230 | * |
| 1231 | * @param[out] os Output stream |
| 1232 | * @param[in] phase_type Type to output. |
| 1233 | * |
| 1234 | * @return Modified output stream. |
| 1235 | */ |
John Richardson | 63e5041 | 2017-10-13 20:51:42 +0100 | [diff] [blame] | 1236 | inline ::std::ostream &operator<<(::std::ostream &os, const PhaseType &phase_type) |
| 1237 | { |
| 1238 | switch(phase_type) |
| 1239 | { |
| 1240 | case PhaseType::SIGNED: |
| 1241 | os << "SIGNED"; |
| 1242 | break; |
| 1243 | case PhaseType::UNSIGNED: |
| 1244 | os << "UNSIGNED"; |
| 1245 | break; |
| 1246 | default: |
| 1247 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 1248 | } |
| 1249 | |
| 1250 | return os; |
| 1251 | } |
| 1252 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 1253 | /** Formatted output of the PhaseType type. |
| 1254 | * |
| 1255 | * @param[in] type Type to output. |
| 1256 | * |
| 1257 | * @return Formatted string. |
| 1258 | */ |
John Richardson | 63e5041 | 2017-10-13 20:51:42 +0100 | [diff] [blame] | 1259 | inline std::string to_string(const arm_compute::PhaseType &type) |
| 1260 | { |
| 1261 | std::stringstream str; |
| 1262 | str << type; |
| 1263 | return str.str(); |
| 1264 | } |
John Richardson | 3c5f949 | 2017-10-04 15:27:37 +0100 | [diff] [blame] | 1265 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 1266 | /** Formatted output of the MagnitudeType type. |
| 1267 | * |
| 1268 | * @param[out] os Output stream |
| 1269 | * @param[in] magnitude_type Type to output. |
| 1270 | * |
| 1271 | * @return Modified output stream. |
| 1272 | */ |
John Richardson | 3c5f949 | 2017-10-04 15:27:37 +0100 | [diff] [blame] | 1273 | inline ::std::ostream &operator<<(::std::ostream &os, const MagnitudeType &magnitude_type) |
| 1274 | { |
| 1275 | switch(magnitude_type) |
| 1276 | { |
| 1277 | case MagnitudeType::L1NORM: |
| 1278 | os << "L1NORM"; |
| 1279 | break; |
| 1280 | case MagnitudeType::L2NORM: |
| 1281 | os << "L2NORM"; |
| 1282 | break; |
| 1283 | default: |
| 1284 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 1285 | } |
| 1286 | |
| 1287 | return os; |
| 1288 | } |
| 1289 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 1290 | /** Formatted output of the MagnitudeType type. |
| 1291 | * |
| 1292 | * @param[in] type Type to output. |
| 1293 | * |
| 1294 | * @return Formatted string. |
| 1295 | */ |
John Richardson | 3c5f949 | 2017-10-04 15:27:37 +0100 | [diff] [blame] | 1296 | inline std::string to_string(const arm_compute::MagnitudeType &type) |
| 1297 | { |
| 1298 | std::stringstream str; |
| 1299 | str << type; |
| 1300 | return str.str(); |
| 1301 | } |
John Richardson | 1c52992 | 2017-11-01 10:57:48 +0000 | [diff] [blame] | 1302 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 1303 | /** Formatted output of the GradientDimension type. |
| 1304 | * |
| 1305 | * @param[out] os Output stream |
| 1306 | * @param[in] dim Type to output |
| 1307 | * |
| 1308 | * @return Modified output stream. |
| 1309 | */ |
John Richardson | 1c52992 | 2017-11-01 10:57:48 +0000 | [diff] [blame] | 1310 | inline ::std::ostream &operator<<(::std::ostream &os, const GradientDimension &dim) |
| 1311 | { |
| 1312 | switch(dim) |
| 1313 | { |
| 1314 | case GradientDimension::GRAD_X: |
| 1315 | os << "GRAD_X"; |
| 1316 | break; |
| 1317 | case GradientDimension::GRAD_Y: |
| 1318 | os << "GRAD_Y"; |
| 1319 | break; |
| 1320 | case GradientDimension::GRAD_XY: |
| 1321 | os << "GRAD_XY"; |
| 1322 | break; |
| 1323 | default: |
| 1324 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 1325 | } |
| 1326 | |
| 1327 | return os; |
| 1328 | } |
| 1329 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 1330 | /** Formatted output of the GradientDimension type. |
| 1331 | * |
| 1332 | * @param[in] type Type to output |
| 1333 | * |
| 1334 | * @return Formatted string. |
| 1335 | */ |
John Richardson | 1c52992 | 2017-11-01 10:57:48 +0000 | [diff] [blame] | 1336 | inline std::string to_string(const arm_compute::GradientDimension &type) |
| 1337 | { |
| 1338 | std::stringstream str; |
| 1339 | str << type; |
| 1340 | return str.str(); |
| 1341 | } |
John Richardson | 25f2368 | 2017-11-27 14:35:09 +0000 | [diff] [blame] | 1342 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 1343 | /** Formatted output of the HOGNormType type. |
| 1344 | * |
| 1345 | * @param[out] os Output stream |
| 1346 | * @param[in] norm_type Type to output |
| 1347 | * |
| 1348 | * @return Modified output stream. |
| 1349 | */ |
John Richardson | 25f2368 | 2017-11-27 14:35:09 +0000 | [diff] [blame] | 1350 | inline ::std::ostream &operator<<(::std::ostream &os, const HOGNormType &norm_type) |
| 1351 | { |
| 1352 | switch(norm_type) |
| 1353 | { |
| 1354 | case HOGNormType::L1_NORM: |
| 1355 | os << "L1_NORM"; |
| 1356 | break; |
| 1357 | case HOGNormType::L2_NORM: |
| 1358 | os << "L2_NORM"; |
| 1359 | break; |
| 1360 | case HOGNormType::L2HYS_NORM: |
| 1361 | os << "L2HYS_NORM"; |
| 1362 | break; |
| 1363 | default: |
| 1364 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 1365 | } |
| 1366 | |
| 1367 | return os; |
| 1368 | } |
| 1369 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 1370 | /** Formatted output of the HOGNormType type. |
| 1371 | * |
| 1372 | * @param[in] type Type to output |
| 1373 | * |
| 1374 | * @return Formatted string. |
| 1375 | */ |
John Richardson | 25f2368 | 2017-11-27 14:35:09 +0000 | [diff] [blame] | 1376 | inline std::string to_string(const HOGNormType &type) |
| 1377 | { |
| 1378 | std::stringstream str; |
| 1379 | str << type; |
| 1380 | return str.str(); |
| 1381 | } |
| 1382 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 1383 | /** Formatted output of the Size2D type. |
| 1384 | * |
| 1385 | * @param[out] os Output stream |
| 1386 | * @param[in] size Type to output |
| 1387 | * |
| 1388 | * @return Modified output stream. |
| 1389 | */ |
John Richardson | 25f2368 | 2017-11-27 14:35:09 +0000 | [diff] [blame] | 1390 | inline ::std::ostream &operator<<(::std::ostream &os, const Size2D &size) |
| 1391 | { |
| 1392 | os << size.width << "x" << size.height; |
| 1393 | |
| 1394 | return os; |
| 1395 | } |
| 1396 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 1397 | /** Formatted output of the Size2D type. |
| 1398 | * |
| 1399 | * @param[in] type Type to output |
| 1400 | * |
| 1401 | * @return Formatted string. |
| 1402 | */ |
John Richardson | 25f2368 | 2017-11-27 14:35:09 +0000 | [diff] [blame] | 1403 | inline std::string to_string(const Size2D &type) |
| 1404 | { |
| 1405 | std::stringstream str; |
| 1406 | str << type; |
| 1407 | return str.str(); |
| 1408 | } |
| 1409 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 1410 | /** Formatted output of the HOGInfo type. |
| 1411 | * |
| 1412 | * @param[out] os Output stream |
| 1413 | * @param[in] hog_info Type to output |
| 1414 | * |
| 1415 | * @return Modified output stream. |
| 1416 | */ |
John Richardson | 25f2368 | 2017-11-27 14:35:09 +0000 | [diff] [blame] | 1417 | inline ::std::ostream &operator<<(::std::ostream &os, const HOGInfo &hog_info) |
| 1418 | { |
| 1419 | os << "{CellSize=" << hog_info.cell_size() << "," |
| 1420 | << "BlockSize=" << hog_info.block_size() << "," |
| 1421 | << "DetectionWindowSize=" << hog_info.detection_window_size() << "," |
| 1422 | << "BlockStride=" << hog_info.block_stride() << "," |
| 1423 | << "NumBins=" << hog_info.num_bins() << "," |
| 1424 | << "NormType=" << hog_info.normalization_type() << "," |
| 1425 | << "L2HystThreshold=" << hog_info.l2_hyst_threshold() << "," |
| 1426 | << "PhaseType=" << hog_info.phase_type() << "}"; |
| 1427 | |
| 1428 | return os; |
| 1429 | } |
| 1430 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 1431 | /** Formatted output of the HOGInfo type. |
| 1432 | * |
| 1433 | * @param[in] type Type to output |
| 1434 | * |
| 1435 | * @return Formatted string. |
| 1436 | */ |
John Richardson | 25f2368 | 2017-11-27 14:35:09 +0000 | [diff] [blame] | 1437 | inline std::string to_string(const HOGInfo &type) |
| 1438 | { |
| 1439 | std::stringstream str; |
| 1440 | str << type; |
| 1441 | return str.str(); |
| 1442 | } |
| 1443 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 1444 | /** Formatted output of the ConvolutionMethod type. |
| 1445 | * |
| 1446 | * @param[out] os Output stream |
| 1447 | * @param[in] conv_method Type to output |
| 1448 | * |
| 1449 | * @return Modified output stream. |
| 1450 | */ |
Isabella Gottardi | f07d28d | 2018-02-06 14:52:43 +0000 | [diff] [blame] | 1451 | inline ::std::ostream &operator<<(::std::ostream &os, const ConvolutionMethod &conv_method) |
| 1452 | { |
| 1453 | switch(conv_method) |
| 1454 | { |
| 1455 | case ConvolutionMethod::GEMM: |
| 1456 | os << "GEMM"; |
| 1457 | break; |
| 1458 | case ConvolutionMethod::DIRECT: |
| 1459 | os << "DIRECT"; |
| 1460 | break; |
| 1461 | case ConvolutionMethod::WINOGRAD: |
| 1462 | os << "WINOGRAD"; |
| 1463 | break; |
| 1464 | default: |
| 1465 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 1466 | } |
| 1467 | |
| 1468 | return os; |
| 1469 | } |
| 1470 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 1471 | /** Formatted output of the ConvolutionMethod type. |
| 1472 | * |
| 1473 | * @param[in] conv_method Type to output |
| 1474 | * |
| 1475 | * @return Formatted string. |
| 1476 | */ |
Isabella Gottardi | f07d28d | 2018-02-06 14:52:43 +0000 | [diff] [blame] | 1477 | inline std::string to_string(const ConvolutionMethod &conv_method) |
| 1478 | { |
| 1479 | std::stringstream str; |
| 1480 | str << conv_method; |
| 1481 | return str.str(); |
| 1482 | } |
| 1483 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 1484 | /** Formatted output of the GPUTarget type. |
| 1485 | * |
| 1486 | * @param[out] os Output stream |
| 1487 | * @param[in] gpu_target Type to output |
| 1488 | * |
| 1489 | * @return Modified output stream. |
| 1490 | */ |
Isabella Gottardi | f07d28d | 2018-02-06 14:52:43 +0000 | [diff] [blame] | 1491 | inline ::std::ostream &operator<<(::std::ostream &os, const GPUTarget &gpu_target) |
| 1492 | { |
| 1493 | switch(gpu_target) |
| 1494 | { |
| 1495 | case GPUTarget::GPU_ARCH_MASK: |
| 1496 | os << "GPU_ARCH_MASK"; |
| 1497 | break; |
| 1498 | case GPUTarget::MIDGARD: |
| 1499 | os << "MIDGARD"; |
| 1500 | break; |
| 1501 | case GPUTarget::BIFROST: |
| 1502 | os << "BIFROST"; |
| 1503 | break; |
| 1504 | case GPUTarget::T600: |
| 1505 | os << "T600"; |
| 1506 | break; |
| 1507 | case GPUTarget::T700: |
| 1508 | os << "T700"; |
| 1509 | break; |
| 1510 | case GPUTarget::T800: |
| 1511 | os << "T800"; |
| 1512 | break; |
Michalis Spyrou | a967611 | 2018-02-22 18:07:43 +0000 | [diff] [blame] | 1513 | case GPUTarget::G71: |
| 1514 | os << "G71"; |
| 1515 | break; |
| 1516 | case GPUTarget::G72: |
| 1517 | os << "G72"; |
| 1518 | break; |
| 1519 | case GPUTarget::G51: |
| 1520 | os << "G51"; |
| 1521 | break; |
| 1522 | case GPUTarget::G51BIG: |
| 1523 | os << "G51BIG"; |
| 1524 | break; |
| 1525 | case GPUTarget::G51LIT: |
| 1526 | os << "G51LIT"; |
| 1527 | break; |
| 1528 | case GPUTarget::TNOX: |
| 1529 | os << "TNOX"; |
| 1530 | break; |
| 1531 | case GPUTarget::TTRX: |
| 1532 | os << "TTRX"; |
| 1533 | break; |
| 1534 | case GPUTarget::TBOX: |
| 1535 | os << "TBOX"; |
Isabella Gottardi | f07d28d | 2018-02-06 14:52:43 +0000 | [diff] [blame] | 1536 | break; |
| 1537 | default: |
| 1538 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 1539 | } |
| 1540 | |
| 1541 | return os; |
| 1542 | } |
| 1543 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 1544 | /** Formatted output of the GPUTarget type. |
| 1545 | * |
| 1546 | * @param[in] gpu_target Type to output |
| 1547 | * |
| 1548 | * @return Formatted string. |
| 1549 | */ |
Isabella Gottardi | f07d28d | 2018-02-06 14:52:43 +0000 | [diff] [blame] | 1550 | inline std::string to_string(const GPUTarget &gpu_target) |
| 1551 | { |
| 1552 | std::stringstream str; |
| 1553 | str << gpu_target; |
| 1554 | return str.str(); |
| 1555 | } |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame] | 1556 | |
John Richardson | 8de9261 | 2018-02-22 14:09:31 +0000 | [diff] [blame] | 1557 | /** Formatted output of the DetectionWindow type. |
| 1558 | * |
| 1559 | * @param[out] os Output stream |
| 1560 | * @param[in] detection_window Type to output |
| 1561 | * |
| 1562 | * @return Modified output stream. |
| 1563 | */ |
John Richardson | 684cb0f | 2018-01-09 11:17:00 +0000 | [diff] [blame] | 1564 | inline ::std::ostream &operator<<(::std::ostream &os, const DetectionWindow &detection_window) |
| 1565 | { |
| 1566 | os << "{x=" << detection_window.x << "," |
| 1567 | << "y=" << detection_window.y << "," |
| 1568 | << "width=" << detection_window.width << "," |
| 1569 | << "height=" << detection_window.height << "," |
| 1570 | << "idx_class=" << detection_window.idx_class << "," |
| 1571 | << "score=" << detection_window.score << "}"; |
| 1572 | |
| 1573 | return os; |
| 1574 | } |
| 1575 | |
John Richardson | 8de9261 | 2018-02-22 14:09:31 +0000 | [diff] [blame] | 1576 | /** Formatted output of the DetectionWindow type. |
| 1577 | * |
| 1578 | * @param[in] detection_window Type to output |
| 1579 | * |
| 1580 | * @return Formatted string. |
| 1581 | */ |
| 1582 | inline std::string to_string(const DetectionWindow &detection_window) |
| 1583 | { |
| 1584 | std::stringstream str; |
| 1585 | str << detection_window; |
| 1586 | return str.str(); |
| 1587 | } |
| 1588 | |
| 1589 | /** Formatted output of the Termination type. |
| 1590 | * |
| 1591 | * @param[out] os Output stream |
| 1592 | * @param[in] termination Type to output |
| 1593 | * |
| 1594 | * @return Modified output stream. |
| 1595 | */ |
| 1596 | inline ::std::ostream &operator<<(::std::ostream &os, const Termination &termination) |
| 1597 | { |
| 1598 | switch(termination) |
| 1599 | { |
| 1600 | case Termination::TERM_CRITERIA_EPSILON: |
| 1601 | os << "TERM_CRITERIA_EPSILON"; |
| 1602 | break; |
| 1603 | case Termination::TERM_CRITERIA_ITERATIONS: |
| 1604 | os << "TERM_CRITERIA_ITERATIONS"; |
| 1605 | break; |
| 1606 | case Termination::TERM_CRITERIA_BOTH: |
| 1607 | os << "TERM_CRITERIA_BOTH"; |
| 1608 | break; |
| 1609 | default: |
| 1610 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 1611 | } |
| 1612 | |
| 1613 | return os; |
| 1614 | } |
| 1615 | |
| 1616 | /** Formatted output of the Termination type. |
| 1617 | * |
| 1618 | * @param[in] termination Type to output |
| 1619 | * |
| 1620 | * @return Formatted string. |
| 1621 | */ |
| 1622 | inline std::string to_string(const Termination &termination) |
| 1623 | { |
| 1624 | std::stringstream str; |
| 1625 | str << termination; |
| 1626 | return str.str(); |
| 1627 | } |
| 1628 | |
Anthony Barbier | 671a11e | 2018-07-06 15:11:36 +0100 | [diff] [blame^] | 1629 | /** Formatted output of a vector of objects. |
| 1630 | * |
| 1631 | * @param[out] os Output stream |
| 1632 | * @param[in] args Vector of objects to print |
| 1633 | * |
| 1634 | * @return Modified output stream. |
| 1635 | */ |
| 1636 | template <typename T> |
| 1637 | inline ::std::ostream &operator<<(::std::ostream &os, const std::vector<T> &args) |
| 1638 | { |
| 1639 | os << "["; |
| 1640 | bool first = true; |
| 1641 | for(auto &arg : args) |
| 1642 | { |
| 1643 | if(first) |
| 1644 | { |
| 1645 | first = false; |
| 1646 | } |
| 1647 | else |
| 1648 | { |
| 1649 | os << ", "; |
| 1650 | } |
| 1651 | os << arg; |
| 1652 | } |
| 1653 | os << "]"; |
| 1654 | return os; |
| 1655 | } |
| 1656 | |
| 1657 | /** Formatted output of a vector of objects. |
| 1658 | * |
| 1659 | * @param[in] args Vector of objects to print |
| 1660 | * |
| 1661 | * @return String representing args. |
| 1662 | */ |
| 1663 | template <typename T> |
| 1664 | std::string to_string(const std::vector<T> &args) |
| 1665 | { |
| 1666 | std::stringstream str; |
| 1667 | str << args; |
| 1668 | return str.str(); |
| 1669 | } |
| 1670 | |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame] | 1671 | /** Formatted output of the WinogradInfo type. */ |
| 1672 | inline ::std::ostream &operator<<(::std::ostream &os, const WinogradInfo &info) |
| 1673 | { |
| 1674 | os << "{OutputTileSize=" << info.output_tile_size << "," |
| 1675 | << "KernelSize=" << info.kernel_size << "," |
| 1676 | << "PadStride=" << info.convolution_info << "," |
| 1677 | << "OutputDataLayout=" << info.output_data_layout << "}"; |
| 1678 | |
| 1679 | return os; |
| 1680 | } |
| 1681 | |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame] | 1682 | inline std::string to_string(const WinogradInfo &type) |
| 1683 | { |
| 1684 | std::stringstream str; |
| 1685 | str << type; |
| 1686 | return str.str(); |
| 1687 | } |
Anthony Barbier | 671a11e | 2018-07-06 15:11:36 +0100 | [diff] [blame^] | 1688 | |
| 1689 | /** Fallback method: try to use std::to_string: |
| 1690 | * |
| 1691 | * @param[in] val Value to convert to string |
| 1692 | * |
| 1693 | * @return String representing val. |
| 1694 | */ |
| 1695 | template <typename T> |
| 1696 | inline std::string to_string(const T &val) |
| 1697 | { |
| 1698 | return support::cpp11::to_string(val); |
| 1699 | } |
| 1700 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 1701 | } // namespace arm_compute |
John Richardson | 8de9261 | 2018-02-22 14:09:31 +0000 | [diff] [blame] | 1702 | #endif /* __ARM_COMPUTE_TEST_TYPE_PRINTER_H__ */ |