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