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 | |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame^] | 478 | /** Formatted output of the DataLayoutDimension type. |
| 479 | * |
| 480 | * @param[out] os Output stream. |
| 481 | * @param[in] data_layout_dim Data layout dimension to print. |
| 482 | * |
| 483 | * @return Modified output stream. |
| 484 | */ |
| 485 | inline ::std::ostream &operator<<(::std::ostream &os, const DataLayoutDimension &data_layout_dim) |
| 486 | { |
| 487 | switch(data_layout_dim) |
| 488 | { |
| 489 | case DataLayoutDimension::WIDTH: |
| 490 | os << "WIDTH"; |
| 491 | break; |
| 492 | case DataLayoutDimension::HEIGHT: |
| 493 | os << "HEIGHT"; |
| 494 | break; |
| 495 | case DataLayoutDimension::CHANNEL: |
| 496 | os << "CHANNEL"; |
| 497 | break; |
| 498 | case DataLayoutDimension::BATCHES: |
| 499 | os << "BATCHES"; |
| 500 | break; |
| 501 | default: |
| 502 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 503 | } |
| 504 | return os; |
| 505 | } |
| 506 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 507 | /** Formatted output of the DataType type. |
| 508 | * |
| 509 | * @param[out] os Output stream. |
| 510 | * @param[in] data_type Type to output. |
| 511 | * |
| 512 | * @return Modified output stream. |
| 513 | */ |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 514 | inline ::std::ostream &operator<<(::std::ostream &os, const DataType &data_type) |
| 515 | { |
| 516 | switch(data_type) |
| 517 | { |
| 518 | case DataType::UNKNOWN: |
| 519 | os << "UNKNOWN"; |
| 520 | break; |
| 521 | case DataType::U8: |
| 522 | os << "U8"; |
| 523 | break; |
Chunosov | d621bca | 2017-11-03 17:33:15 +0700 | [diff] [blame] | 524 | case DataType::QASYMM8: |
| 525 | os << "QASYMM8"; |
| 526 | break; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 527 | case DataType::S8: |
| 528 | os << "S8"; |
| 529 | break; |
| 530 | case DataType::U16: |
| 531 | os << "U16"; |
| 532 | break; |
| 533 | case DataType::S16: |
| 534 | os << "S16"; |
| 535 | break; |
| 536 | case DataType::U32: |
| 537 | os << "U32"; |
| 538 | break; |
| 539 | case DataType::S32: |
| 540 | os << "S32"; |
| 541 | break; |
| 542 | case DataType::U64: |
| 543 | os << "U64"; |
| 544 | break; |
| 545 | case DataType::S64: |
| 546 | os << "S64"; |
| 547 | break; |
| 548 | case DataType::F16: |
| 549 | os << "F16"; |
| 550 | break; |
| 551 | case DataType::F32: |
| 552 | os << "F32"; |
| 553 | break; |
| 554 | case DataType::F64: |
| 555 | os << "F64"; |
| 556 | break; |
| 557 | case DataType::SIZET: |
| 558 | os << "SIZET"; |
| 559 | break; |
| 560 | default: |
| 561 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 562 | } |
| 563 | |
| 564 | return os; |
| 565 | } |
| 566 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 567 | /** Formatted output of the DataType type. |
| 568 | * |
| 569 | * @param[in] data_type Type to output. |
| 570 | * |
| 571 | * @return Formatted string. |
| 572 | */ |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 573 | inline std::string to_string(const arm_compute::DataType &data_type) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 574 | { |
| 575 | std::stringstream str; |
| 576 | str << data_type; |
| 577 | return str.str(); |
| 578 | } |
| 579 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 580 | /** Formatted output of the Format type. |
| 581 | * |
| 582 | * @param[out] os Output stream. |
| 583 | * @param[in] format Type to output. |
| 584 | * |
| 585 | * @return Modified output stream. |
| 586 | */ |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 587 | inline ::std::ostream &operator<<(::std::ostream &os, const Format &format) |
| 588 | { |
| 589 | switch(format) |
| 590 | { |
| 591 | case Format::UNKNOWN: |
| 592 | os << "UNKNOWN"; |
| 593 | break; |
| 594 | case Format::U8: |
| 595 | os << "U8"; |
| 596 | break; |
| 597 | case Format::S16: |
| 598 | os << "S16"; |
| 599 | break; |
| 600 | case Format::U16: |
| 601 | os << "U16"; |
| 602 | break; |
| 603 | case Format::S32: |
| 604 | os << "S32"; |
| 605 | break; |
| 606 | case Format::U32: |
| 607 | os << "U32"; |
| 608 | break; |
| 609 | case Format::F16: |
| 610 | os << "F16"; |
| 611 | break; |
| 612 | case Format::F32: |
| 613 | os << "F32"; |
| 614 | break; |
| 615 | case Format::UV88: |
| 616 | os << "UV88"; |
| 617 | break; |
| 618 | case Format::RGB888: |
| 619 | os << "RGB888"; |
| 620 | break; |
| 621 | case Format::RGBA8888: |
| 622 | os << "RGBA8888"; |
| 623 | break; |
| 624 | case Format::YUV444: |
| 625 | os << "YUV444"; |
| 626 | break; |
| 627 | case Format::YUYV422: |
| 628 | os << "YUYV422"; |
| 629 | break; |
| 630 | case Format::NV12: |
| 631 | os << "NV12"; |
| 632 | break; |
| 633 | case Format::NV21: |
| 634 | os << "NV21"; |
| 635 | break; |
| 636 | case Format::IYUV: |
| 637 | os << "IYUV"; |
| 638 | break; |
| 639 | case Format::UYVY422: |
| 640 | os << "UYVY422"; |
| 641 | break; |
| 642 | default: |
| 643 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 644 | } |
| 645 | |
| 646 | return os; |
| 647 | } |
| 648 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 649 | /** Formatted output of the Format type. |
| 650 | * |
| 651 | * @param[in] format Type to output. |
| 652 | * |
| 653 | * @return Formatted string. |
| 654 | */ |
Moritz Pflanzer | 7655a67 | 2017-09-23 11:57:33 +0100 | [diff] [blame] | 655 | inline std::string to_string(const Format &format) |
| 656 | { |
| 657 | std::stringstream str; |
| 658 | str << format; |
| 659 | return str.str(); |
| 660 | } |
| 661 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 662 | /** Formatted output of the Channel type. |
| 663 | * |
| 664 | * @param[out] os Output stream. |
| 665 | * @param[in] channel Type to output. |
| 666 | * |
| 667 | * @return Modified output stream. |
| 668 | */ |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 669 | inline ::std::ostream &operator<<(::std::ostream &os, const Channel &channel) |
| 670 | { |
| 671 | switch(channel) |
| 672 | { |
| 673 | case Channel::UNKNOWN: |
| 674 | os << "UNKNOWN"; |
| 675 | break; |
| 676 | case Channel::C0: |
| 677 | os << "C0"; |
| 678 | break; |
| 679 | case Channel::C1: |
| 680 | os << "C1"; |
| 681 | break; |
| 682 | case Channel::C2: |
| 683 | os << "C2"; |
| 684 | break; |
| 685 | case Channel::C3: |
| 686 | os << "C3"; |
| 687 | break; |
| 688 | case Channel::R: |
| 689 | os << "R"; |
| 690 | break; |
| 691 | case Channel::G: |
| 692 | os << "G"; |
| 693 | break; |
| 694 | case Channel::B: |
| 695 | os << "B"; |
| 696 | break; |
| 697 | case Channel::A: |
| 698 | os << "A"; |
| 699 | break; |
| 700 | case Channel::Y: |
| 701 | os << "Y"; |
| 702 | break; |
| 703 | case Channel::U: |
| 704 | os << "U"; |
| 705 | break; |
| 706 | case Channel::V: |
| 707 | os << "V"; |
| 708 | break; |
| 709 | default: |
| 710 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 711 | } |
| 712 | |
| 713 | return os; |
| 714 | } |
| 715 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 716 | /** Formatted output of the Channel type. |
| 717 | * |
| 718 | * @param[in] channel Type to output. |
| 719 | * |
| 720 | * @return Formatted string. |
| 721 | */ |
Ioan-Cristian Szabo | 9414f64 | 2017-10-27 17:35:40 +0100 | [diff] [blame] | 722 | inline std::string to_string(const Channel &channel) |
| 723 | { |
| 724 | std::stringstream str; |
| 725 | str << channel; |
| 726 | return str.str(); |
| 727 | } |
| 728 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 729 | /** Formatted output of the BorderMode type. |
| 730 | * |
| 731 | * @param[out] os Output stream. |
| 732 | * @param[in] mode Type to output. |
| 733 | * |
| 734 | * @return Modified output stream. |
| 735 | */ |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 736 | inline ::std::ostream &operator<<(::std::ostream &os, const BorderMode &mode) |
| 737 | { |
| 738 | switch(mode) |
| 739 | { |
| 740 | case BorderMode::UNDEFINED: |
| 741 | os << "UNDEFINED"; |
| 742 | break; |
| 743 | case BorderMode::CONSTANT: |
| 744 | os << "CONSTANT"; |
| 745 | break; |
| 746 | case BorderMode::REPLICATE: |
| 747 | os << "REPLICATE"; |
| 748 | break; |
| 749 | default: |
| 750 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 751 | } |
| 752 | |
| 753 | return os; |
| 754 | } |
| 755 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 756 | /** Formatted output of the BorderSize type. |
| 757 | * |
| 758 | * @param[out] os Output stream. |
| 759 | * @param[in] border Type to output. |
| 760 | * |
| 761 | * @return Modified output stream. |
| 762 | */ |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 763 | inline ::std::ostream &operator<<(::std::ostream &os, const BorderSize &border) |
| 764 | { |
Moritz Pflanzer | c87fbf8 | 2017-07-18 14:02:10 +0100 | [diff] [blame] | 765 | os << border.top << "," |
| 766 | << border.right << "," |
| 767 | << border.bottom << "," |
| 768 | << border.left; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 769 | |
| 770 | return os; |
| 771 | } |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 772 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 773 | /** Formatted output of the InterpolationPolicy type. |
| 774 | * |
| 775 | * @param[out] os Output stream. |
| 776 | * @param[in] policy Type to output. |
| 777 | * |
| 778 | * @return Modified output stream. |
| 779 | */ |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 780 | inline ::std::ostream &operator<<(::std::ostream &os, const InterpolationPolicy &policy) |
| 781 | { |
| 782 | switch(policy) |
| 783 | { |
| 784 | case InterpolationPolicy::NEAREST_NEIGHBOR: |
| 785 | os << "NEAREST_NEIGHBOR"; |
| 786 | break; |
| 787 | case InterpolationPolicy::BILINEAR: |
| 788 | os << "BILINEAR"; |
| 789 | break; |
| 790 | case InterpolationPolicy::AREA: |
| 791 | os << "AREA"; |
| 792 | break; |
| 793 | default: |
| 794 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 795 | } |
| 796 | |
| 797 | return os; |
| 798 | } |
| 799 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 800 | /** Formatted output of the SamplingPolicy type. |
| 801 | * |
| 802 | * @param[out] os Output stream. |
| 803 | * @param[in] policy Type to output. |
| 804 | * |
| 805 | * @return Modified output stream. |
| 806 | */ |
Daniil Efremov | 02bf80d | 2017-11-22 00:26:51 +0700 | [diff] [blame] | 807 | inline ::std::ostream &operator<<(::std::ostream &os, const SamplingPolicy &policy) |
| 808 | { |
| 809 | switch(policy) |
| 810 | { |
| 811 | case SamplingPolicy::CENTER: |
| 812 | os << "CENTER"; |
| 813 | break; |
| 814 | case SamplingPolicy::TOP_LEFT: |
| 815 | os << "TOP_LEFT"; |
| 816 | break; |
| 817 | default: |
| 818 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 819 | } |
| 820 | |
| 821 | return os; |
| 822 | } |
| 823 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 824 | /** Formatted output of the TensorInfo type. |
| 825 | * |
| 826 | * @param[in] info Type to output. |
| 827 | * |
| 828 | * @return Formatted string. |
| 829 | */ |
Georgios Pinitas | 3faea25 | 2017-10-30 14:13:50 +0000 | [diff] [blame] | 830 | inline std::string to_string(const TensorInfo &info) |
| 831 | { |
| 832 | std::stringstream str; |
| 833 | str << "{Shape=" << info.tensor_shape() << "," |
| 834 | << "Type=" << info.data_type() << "," |
Vidhya Sudhan Loganathan | 7485d5a | 2018-07-04 09:34:00 +0100 | [diff] [blame] | 835 | << "Channels=" << info.num_channels() << "}"; |
Georgios Pinitas | 3faea25 | 2017-10-30 14:13:50 +0000 | [diff] [blame] | 836 | return str.str(); |
| 837 | } |
| 838 | |
Abe Mbise | 925ca0f | 2017-10-02 19:16:33 +0100 | [diff] [blame] | 839 | //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] | 840 | /** Formatted output of the Dimensions type. |
| 841 | * |
| 842 | * @param[in] dimensions Type to output. |
| 843 | * |
| 844 | * @return Formatted string. |
| 845 | */ |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 846 | template <typename T> |
| 847 | inline std::string to_string(const Dimensions<T> &dimensions) |
| 848 | { |
| 849 | std::stringstream str; |
| 850 | str << dimensions; |
| 851 | return str.str(); |
| 852 | } |
| 853 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 854 | /** Formatted output of the Strides type. |
| 855 | * |
| 856 | * @param[in] stride Type to output. |
| 857 | * |
| 858 | * @return Formatted string. |
| 859 | */ |
John Richardson | a36eae1 | 2017-09-26 16:55:59 +0100 | [diff] [blame] | 860 | inline std::string to_string(const Strides &stride) |
| 861 | { |
| 862 | std::stringstream str; |
| 863 | str << stride; |
| 864 | return str.str(); |
| 865 | } |
| 866 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 867 | /** Formatted output of the TensorShape type. |
| 868 | * |
| 869 | * @param[in] shape Type to output. |
| 870 | * |
| 871 | * @return Formatted string. |
| 872 | */ |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 873 | inline std::string to_string(const TensorShape &shape) |
| 874 | { |
| 875 | std::stringstream str; |
| 876 | str << shape; |
| 877 | return str.str(); |
| 878 | } |
| 879 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 880 | /** Formatted output of the Coordinates type. |
| 881 | * |
| 882 | * @param[in] coord Type to output. |
| 883 | * |
| 884 | * @return Formatted string. |
| 885 | */ |
Abe Mbise | 925ca0f | 2017-10-02 19:16:33 +0100 | [diff] [blame] | 886 | inline std::string to_string(const Coordinates &coord) |
| 887 | { |
| 888 | std::stringstream str; |
| 889 | str << coord; |
| 890 | return str.str(); |
| 891 | } |
| 892 | |
Anthony Barbier | b940fd6 | 2018-06-04 14:14:32 +0100 | [diff] [blame] | 893 | /** Formatted output of the GEMMReshapeInfo type. |
| 894 | * |
| 895 | * @param[out] os Output stream. |
| 896 | * @param[in] info Type to output. |
| 897 | * |
| 898 | * @return Modified output stream. |
| 899 | */ |
| 900 | inline ::std::ostream &operator<<(::std::ostream &os, const GEMMReshapeInfo &info) |
| 901 | { |
| 902 | os << "{m=" << info.m() << ","; |
| 903 | os << "n=" << info.n() << ","; |
| 904 | os << "k=" << info.k() << ","; |
| 905 | os << "mult_transpose1xW_width=" << info.mult_transpose1xW_width() << ","; |
| 906 | os << "mult_interleave4x4_height=" << info.mult_interleave4x4_height(); |
| 907 | os << "}"; |
| 908 | |
| 909 | return os; |
| 910 | } |
| 911 | |
| 912 | /** Formatted output of the GEMMInfo type. |
| 913 | * |
| 914 | * @param[out] os Output stream. |
| 915 | * @param[in] info Type to output. |
| 916 | * |
| 917 | * @return Modified output stream. |
| 918 | */ |
| 919 | inline ::std::ostream &operator<<(::std::ostream &os, const GEMMInfo &info) |
| 920 | { |
| 921 | os << "{is_a_reshaped=" << info.is_a_reshaped() << ","; |
| 922 | os << "is_b_reshaped=" << info.is_b_reshaped() << ","; |
| 923 | 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] | 924 | os << "}"; |
| 925 | |
| 926 | return os; |
| 927 | } |
| 928 | |
| 929 | /** Formatted output of the Window::Dimension type. |
| 930 | * |
| 931 | * @param[out] os Output stream. |
| 932 | * @param[in] dim Type to output. |
| 933 | * |
| 934 | * @return Modified output stream. |
| 935 | */ |
| 936 | inline ::std::ostream &operator<<(::std::ostream &os, const Window::Dimension &dim) |
| 937 | { |
| 938 | os << "{start=" << dim.start() << ", end=" << dim.end() << ", step=" << dim.step() << "}"; |
| 939 | |
| 940 | return os; |
| 941 | } |
| 942 | /** Formatted output of the Window type. |
| 943 | * |
| 944 | * @param[out] os Output stream. |
| 945 | * @param[in] win Type to output. |
| 946 | * |
| 947 | * @return Modified output stream. |
| 948 | */ |
| 949 | inline ::std::ostream &operator<<(::std::ostream &os, const Window &win) |
| 950 | { |
| 951 | os << "{"; |
| 952 | for(unsigned int i = 0; i < Coordinates::num_max_dimensions; i++) |
| 953 | { |
| 954 | if(i > 0) |
| 955 | { |
| 956 | os << ", "; |
| 957 | } |
| 958 | os << win[i]; |
| 959 | } |
| 960 | os << "}"; |
| 961 | |
| 962 | return os; |
| 963 | } |
| 964 | |
| 965 | /** Formatted output of the WeightsInfo type. |
| 966 | * |
| 967 | * @param[in] info Type to output. |
| 968 | * |
| 969 | * @return Formatted string. |
| 970 | */ |
| 971 | inline std::string to_string(const WeightsInfo &info) |
| 972 | { |
| 973 | std::stringstream str; |
| 974 | str << info; |
| 975 | return str.str(); |
| 976 | } |
| 977 | |
| 978 | /** Formatted output of the GEMMReshapeInfo type. |
| 979 | * |
| 980 | * @param[in] info Type to output. |
| 981 | * |
| 982 | * @return Formatted string. |
| 983 | */ |
| 984 | inline std::string to_string(const GEMMReshapeInfo &info) |
| 985 | { |
| 986 | std::stringstream str; |
| 987 | str << info; |
| 988 | return str.str(); |
| 989 | } |
| 990 | |
| 991 | /** Formatted output of the GEMMInfo type. |
| 992 | * |
| 993 | * @param[in] info Type to output. |
| 994 | * |
| 995 | * @return Formatted string. |
| 996 | */ |
| 997 | inline std::string to_string(const GEMMInfo &info) |
| 998 | { |
| 999 | std::stringstream str; |
| 1000 | str << info; |
| 1001 | return str.str(); |
| 1002 | } |
| 1003 | |
| 1004 | /** Formatted output of the Window::Dimension type. |
| 1005 | * |
| 1006 | * @param[in] dim Type to output. |
| 1007 | * |
| 1008 | * @return Formatted string. |
| 1009 | */ |
| 1010 | inline std::string to_string(const Window::Dimension &dim) |
| 1011 | { |
| 1012 | std::stringstream str; |
| 1013 | str << dim; |
| 1014 | return str.str(); |
| 1015 | } |
| 1016 | /** Formatted output of the Window type. |
| 1017 | * |
| 1018 | * @param[in] win Type to output. |
| 1019 | * |
| 1020 | * @return Formatted string. |
| 1021 | */ |
| 1022 | inline std::string to_string(const Window &win) |
| 1023 | { |
| 1024 | std::stringstream str; |
| 1025 | str << win; |
| 1026 | return str.str(); |
| 1027 | } |
| 1028 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 1029 | /** Formatted output of the Rectangle type. |
| 1030 | * |
| 1031 | * @param[out] os Output stream. |
| 1032 | * @param[in] rect Type to output. |
| 1033 | * |
| 1034 | * @return Modified output stream. |
| 1035 | */ |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 1036 | inline ::std::ostream &operator<<(::std::ostream &os, const Rectangle &rect) |
| 1037 | { |
| 1038 | os << rect.width << "x" << rect.height; |
| 1039 | os << "+" << rect.x << "+" << rect.y; |
| 1040 | |
| 1041 | return os; |
| 1042 | } |
| 1043 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 1044 | /** Formatted output of the PadStrideInfo type. |
| 1045 | * |
| 1046 | * @param[out] os Output stream. |
| 1047 | * @param[in] pad_stride_info Type to output. |
| 1048 | * |
| 1049 | * @return Modified output stream. |
| 1050 | */ |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 1051 | inline ::std::ostream &operator<<(::std::ostream &os, const PadStrideInfo &pad_stride_info) |
| 1052 | { |
| 1053 | os << pad_stride_info.stride().first << "," << pad_stride_info.stride().second; |
| 1054 | os << ";"; |
Jaroslaw Rzepecki | a1ed41f | 2017-10-13 11:13:58 +0100 | [diff] [blame] | 1055 | os << pad_stride_info.pad_left() << "," << pad_stride_info.pad_right() << "," |
| 1056 | << pad_stride_info.pad_top() << "," << pad_stride_info.pad_bottom(); |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 1057 | |
| 1058 | return os; |
| 1059 | } |
| 1060 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 1061 | /** Formatted output of the PadStrideInfo type. |
| 1062 | * |
| 1063 | * @param[in] pad_stride_info Type to output. |
| 1064 | * |
| 1065 | * @return Formatted string. |
| 1066 | */ |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 1067 | inline std::string to_string(const PadStrideInfo &pad_stride_info) |
| 1068 | { |
| 1069 | std::stringstream str; |
| 1070 | str << pad_stride_info; |
| 1071 | return str.str(); |
| 1072 | } |
| 1073 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 1074 | /** Formatted output of the BorderMode type. |
| 1075 | * |
| 1076 | * @param[in] mode Type to output. |
| 1077 | * |
| 1078 | * @return Formatted string. |
| 1079 | */ |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 1080 | inline std::string to_string(const BorderMode &mode) |
| 1081 | { |
| 1082 | std::stringstream str; |
| 1083 | str << mode; |
| 1084 | return str.str(); |
| 1085 | } |
| 1086 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 1087 | /** Formatted output of the BorderSize type. |
| 1088 | * |
| 1089 | * @param[in] border Type to output. |
| 1090 | * |
| 1091 | * @return Formatted string. |
| 1092 | */ |
John Richardson | b482ce1 | 2017-09-18 12:44:01 +0100 | [diff] [blame] | 1093 | inline std::string to_string(const BorderSize &border) |
| 1094 | { |
| 1095 | std::stringstream str; |
| 1096 | str << border; |
| 1097 | return str.str(); |
| 1098 | } |
| 1099 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 1100 | /** Formatted output of the InterpolationPolicy type. |
| 1101 | * |
| 1102 | * @param[in] policy Type to output. |
| 1103 | * |
| 1104 | * @return Formatted string. |
| 1105 | */ |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 1106 | inline std::string to_string(const InterpolationPolicy &policy) |
| 1107 | { |
| 1108 | std::stringstream str; |
| 1109 | str << policy; |
| 1110 | return str.str(); |
| 1111 | } |
| 1112 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 1113 | /** Formatted output of the SamplingPolicy type. |
| 1114 | * |
| 1115 | * @param[in] policy Type to output. |
| 1116 | * |
| 1117 | * @return Formatted string. |
| 1118 | */ |
Daniil Efremov | 02bf80d | 2017-11-22 00:26:51 +0700 | [diff] [blame] | 1119 | inline std::string to_string(const SamplingPolicy &policy) |
| 1120 | { |
| 1121 | std::stringstream str; |
| 1122 | str << policy; |
| 1123 | return str.str(); |
| 1124 | } |
| 1125 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 1126 | /** Formatted output of the ConvertPolicy type. |
| 1127 | * |
| 1128 | * @param[out] os Output stream. |
| 1129 | * @param[in] policy Type to output. |
| 1130 | * |
| 1131 | * @return Modified output stream. |
| 1132 | */ |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 1133 | inline ::std::ostream &operator<<(::std::ostream &os, const ConvertPolicy &policy) |
| 1134 | { |
| 1135 | switch(policy) |
| 1136 | { |
| 1137 | case ConvertPolicy::WRAP: |
| 1138 | os << "WRAP"; |
| 1139 | break; |
| 1140 | case ConvertPolicy::SATURATE: |
| 1141 | os << "SATURATE"; |
| 1142 | break; |
| 1143 | default: |
| 1144 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 1145 | } |
| 1146 | |
| 1147 | return os; |
| 1148 | } |
| 1149 | |
| 1150 | inline std::string to_string(const ConvertPolicy &policy) |
| 1151 | { |
| 1152 | std::stringstream str; |
| 1153 | str << policy; |
| 1154 | return str.str(); |
| 1155 | } |
| 1156 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 1157 | /** Formatted output of the Reduction Operations. |
| 1158 | * |
| 1159 | * @param[out] os Output stream. |
| 1160 | * @param[in] op Type to output. |
| 1161 | * |
| 1162 | * @return Modified output stream. |
| 1163 | */ |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 1164 | inline ::std::ostream &operator<<(::std::ostream &os, const ReductionOperation &op) |
| 1165 | { |
| 1166 | switch(op) |
| 1167 | { |
| 1168 | case ReductionOperation::SUM_SQUARE: |
| 1169 | os << "SUM_SQUARE"; |
| 1170 | break; |
| 1171 | default: |
| 1172 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 1173 | } |
| 1174 | |
| 1175 | return os; |
| 1176 | } |
| 1177 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 1178 | /** Formatted output of the Reduction Operations. |
| 1179 | * |
| 1180 | * @param[in] op Type to output. |
| 1181 | * |
| 1182 | * @return Formatted string. |
| 1183 | */ |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 1184 | inline std::string to_string(const ReductionOperation &op) |
| 1185 | { |
| 1186 | std::stringstream str; |
| 1187 | str << op; |
| 1188 | return str.str(); |
| 1189 | } |
| 1190 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 1191 | /** Formatted output of the Norm Type. |
| 1192 | * |
| 1193 | * @param[in] type Type to output. |
| 1194 | * |
| 1195 | * @return Formatted string. |
| 1196 | */ |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 1197 | inline std::string to_string(const NormType &type) |
| 1198 | { |
| 1199 | std::stringstream str; |
| 1200 | str << type; |
| 1201 | return str.str(); |
| 1202 | } |
| 1203 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 1204 | /** Formatted output of the Pooling Type. |
| 1205 | * |
| 1206 | * @param[in] type Type to output. |
| 1207 | * |
| 1208 | * @return Formatted string. |
| 1209 | */ |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 1210 | inline std::string to_string(const PoolingType &type) |
| 1211 | { |
| 1212 | std::stringstream str; |
| 1213 | str << type; |
| 1214 | return str.str(); |
| 1215 | } |
| 1216 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 1217 | /** Formatted output of the Pooling Layer Info. |
| 1218 | * |
| 1219 | * @param[in] info Type to output. |
| 1220 | * |
| 1221 | * @return Formatted string. |
| 1222 | */ |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 1223 | inline std::string to_string(const PoolingLayerInfo &info) |
| 1224 | { |
| 1225 | std::stringstream str; |
Georgios Pinitas | 4c2dd54 | 2017-11-13 12:58:41 +0000 | [diff] [blame] | 1226 | str << "{Type=" << info.pool_type() << "," |
| 1227 | << "IsGlobalPooling=" << info.is_global_pooling(); |
| 1228 | if(!info.is_global_pooling()) |
| 1229 | { |
| 1230 | str << "," |
Isabella Gottardi | 6e464c3 | 2018-01-26 12:32:45 +0000 | [diff] [blame] | 1231 | << "PoolSize=" << info.pool_size().width << "," << info.pool_size().height << "," |
Georgios Pinitas | 4c2dd54 | 2017-11-13 12:58:41 +0000 | [diff] [blame] | 1232 | << "PadStride=" << info.pad_stride_info(); |
| 1233 | } |
| 1234 | str << "}"; |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 1235 | return str.str(); |
| 1236 | } |
| 1237 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 1238 | /** Formatted output of the KeyPoint type. |
| 1239 | * |
| 1240 | * @param[out] os Output stream |
| 1241 | * @param[in] point Type to output. |
| 1242 | * |
| 1243 | * @return Modified output stream. |
| 1244 | */ |
Moritz Pflanzer | 6c6597c | 2017-09-24 12:09:41 +0100 | [diff] [blame] | 1245 | inline ::std::ostream &operator<<(::std::ostream &os, const KeyPoint &point) |
| 1246 | { |
| 1247 | os << "{x=" << point.x << "," |
| 1248 | << "y=" << point.y << "," |
| 1249 | << "strength=" << point.strength << "," |
| 1250 | << "scale=" << point.scale << "," |
| 1251 | << "orientation=" << point.orientation << "," |
| 1252 | << "tracking_status=" << point.tracking_status << "," |
| 1253 | << "error=" << point.error << "}"; |
| 1254 | |
| 1255 | return os; |
| 1256 | } |
John Richardson | 63e5041 | 2017-10-13 20:51:42 +0100 | [diff] [blame] | 1257 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 1258 | /** Formatted output of the PhaseType type. |
| 1259 | * |
| 1260 | * @param[out] os Output stream |
| 1261 | * @param[in] phase_type Type to output. |
| 1262 | * |
| 1263 | * @return Modified output stream. |
| 1264 | */ |
John Richardson | 63e5041 | 2017-10-13 20:51:42 +0100 | [diff] [blame] | 1265 | inline ::std::ostream &operator<<(::std::ostream &os, const PhaseType &phase_type) |
| 1266 | { |
| 1267 | switch(phase_type) |
| 1268 | { |
| 1269 | case PhaseType::SIGNED: |
| 1270 | os << "SIGNED"; |
| 1271 | break; |
| 1272 | case PhaseType::UNSIGNED: |
| 1273 | os << "UNSIGNED"; |
| 1274 | break; |
| 1275 | default: |
| 1276 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 1277 | } |
| 1278 | |
| 1279 | return os; |
| 1280 | } |
| 1281 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 1282 | /** Formatted output of the PhaseType type. |
| 1283 | * |
| 1284 | * @param[in] type Type to output. |
| 1285 | * |
| 1286 | * @return Formatted string. |
| 1287 | */ |
John Richardson | 63e5041 | 2017-10-13 20:51:42 +0100 | [diff] [blame] | 1288 | inline std::string to_string(const arm_compute::PhaseType &type) |
| 1289 | { |
| 1290 | std::stringstream str; |
| 1291 | str << type; |
| 1292 | return str.str(); |
| 1293 | } |
John Richardson | 3c5f949 | 2017-10-04 15:27:37 +0100 | [diff] [blame] | 1294 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 1295 | /** Formatted output of the MagnitudeType type. |
| 1296 | * |
| 1297 | * @param[out] os Output stream |
| 1298 | * @param[in] magnitude_type Type to output. |
| 1299 | * |
| 1300 | * @return Modified output stream. |
| 1301 | */ |
John Richardson | 3c5f949 | 2017-10-04 15:27:37 +0100 | [diff] [blame] | 1302 | inline ::std::ostream &operator<<(::std::ostream &os, const MagnitudeType &magnitude_type) |
| 1303 | { |
| 1304 | switch(magnitude_type) |
| 1305 | { |
| 1306 | case MagnitudeType::L1NORM: |
| 1307 | os << "L1NORM"; |
| 1308 | break; |
| 1309 | case MagnitudeType::L2NORM: |
| 1310 | os << "L2NORM"; |
| 1311 | break; |
| 1312 | default: |
| 1313 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 1314 | } |
| 1315 | |
| 1316 | return os; |
| 1317 | } |
| 1318 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 1319 | /** Formatted output of the MagnitudeType type. |
| 1320 | * |
| 1321 | * @param[in] type Type to output. |
| 1322 | * |
| 1323 | * @return Formatted string. |
| 1324 | */ |
John Richardson | 3c5f949 | 2017-10-04 15:27:37 +0100 | [diff] [blame] | 1325 | inline std::string to_string(const arm_compute::MagnitudeType &type) |
| 1326 | { |
| 1327 | std::stringstream str; |
| 1328 | str << type; |
| 1329 | return str.str(); |
| 1330 | } |
John Richardson | 1c52992 | 2017-11-01 10:57:48 +0000 | [diff] [blame] | 1331 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 1332 | /** Formatted output of the GradientDimension type. |
| 1333 | * |
| 1334 | * @param[out] os Output stream |
| 1335 | * @param[in] dim Type to output |
| 1336 | * |
| 1337 | * @return Modified output stream. |
| 1338 | */ |
John Richardson | 1c52992 | 2017-11-01 10:57:48 +0000 | [diff] [blame] | 1339 | inline ::std::ostream &operator<<(::std::ostream &os, const GradientDimension &dim) |
| 1340 | { |
| 1341 | switch(dim) |
| 1342 | { |
| 1343 | case GradientDimension::GRAD_X: |
| 1344 | os << "GRAD_X"; |
| 1345 | break; |
| 1346 | case GradientDimension::GRAD_Y: |
| 1347 | os << "GRAD_Y"; |
| 1348 | break; |
| 1349 | case GradientDimension::GRAD_XY: |
| 1350 | os << "GRAD_XY"; |
| 1351 | break; |
| 1352 | default: |
| 1353 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 1354 | } |
| 1355 | |
| 1356 | return os; |
| 1357 | } |
| 1358 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 1359 | /** Formatted output of the GradientDimension type. |
| 1360 | * |
| 1361 | * @param[in] type Type to output |
| 1362 | * |
| 1363 | * @return Formatted string. |
| 1364 | */ |
John Richardson | 1c52992 | 2017-11-01 10:57:48 +0000 | [diff] [blame] | 1365 | inline std::string to_string(const arm_compute::GradientDimension &type) |
| 1366 | { |
| 1367 | std::stringstream str; |
| 1368 | str << type; |
| 1369 | return str.str(); |
| 1370 | } |
John Richardson | 25f2368 | 2017-11-27 14:35:09 +0000 | [diff] [blame] | 1371 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 1372 | /** Formatted output of the HOGNormType type. |
| 1373 | * |
| 1374 | * @param[out] os Output stream |
| 1375 | * @param[in] norm_type Type to output |
| 1376 | * |
| 1377 | * @return Modified output stream. |
| 1378 | */ |
John Richardson | 25f2368 | 2017-11-27 14:35:09 +0000 | [diff] [blame] | 1379 | inline ::std::ostream &operator<<(::std::ostream &os, const HOGNormType &norm_type) |
| 1380 | { |
| 1381 | switch(norm_type) |
| 1382 | { |
| 1383 | case HOGNormType::L1_NORM: |
| 1384 | os << "L1_NORM"; |
| 1385 | break; |
| 1386 | case HOGNormType::L2_NORM: |
| 1387 | os << "L2_NORM"; |
| 1388 | break; |
| 1389 | case HOGNormType::L2HYS_NORM: |
| 1390 | os << "L2HYS_NORM"; |
| 1391 | break; |
| 1392 | default: |
| 1393 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 1394 | } |
| 1395 | |
| 1396 | return os; |
| 1397 | } |
| 1398 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 1399 | /** Formatted output of the HOGNormType type. |
| 1400 | * |
| 1401 | * @param[in] type Type to output |
| 1402 | * |
| 1403 | * @return Formatted string. |
| 1404 | */ |
John Richardson | 25f2368 | 2017-11-27 14:35:09 +0000 | [diff] [blame] | 1405 | inline std::string to_string(const HOGNormType &type) |
| 1406 | { |
| 1407 | std::stringstream str; |
| 1408 | str << type; |
| 1409 | return str.str(); |
| 1410 | } |
| 1411 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 1412 | /** Formatted output of the Size2D type. |
| 1413 | * |
| 1414 | * @param[out] os Output stream |
| 1415 | * @param[in] size Type to output |
| 1416 | * |
| 1417 | * @return Modified output stream. |
| 1418 | */ |
John Richardson | 25f2368 | 2017-11-27 14:35:09 +0000 | [diff] [blame] | 1419 | inline ::std::ostream &operator<<(::std::ostream &os, const Size2D &size) |
| 1420 | { |
| 1421 | os << size.width << "x" << size.height; |
| 1422 | |
| 1423 | return os; |
| 1424 | } |
| 1425 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 1426 | /** Formatted output of the Size2D type. |
| 1427 | * |
| 1428 | * @param[in] type Type to output |
| 1429 | * |
| 1430 | * @return Formatted string. |
| 1431 | */ |
John Richardson | 25f2368 | 2017-11-27 14:35:09 +0000 | [diff] [blame] | 1432 | inline std::string to_string(const Size2D &type) |
| 1433 | { |
| 1434 | std::stringstream str; |
| 1435 | str << type; |
| 1436 | return str.str(); |
| 1437 | } |
| 1438 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 1439 | /** Formatted output of the HOGInfo type. |
| 1440 | * |
| 1441 | * @param[out] os Output stream |
| 1442 | * @param[in] hog_info Type to output |
| 1443 | * |
| 1444 | * @return Modified output stream. |
| 1445 | */ |
John Richardson | 25f2368 | 2017-11-27 14:35:09 +0000 | [diff] [blame] | 1446 | inline ::std::ostream &operator<<(::std::ostream &os, const HOGInfo &hog_info) |
| 1447 | { |
| 1448 | os << "{CellSize=" << hog_info.cell_size() << "," |
| 1449 | << "BlockSize=" << hog_info.block_size() << "," |
| 1450 | << "DetectionWindowSize=" << hog_info.detection_window_size() << "," |
| 1451 | << "BlockStride=" << hog_info.block_stride() << "," |
| 1452 | << "NumBins=" << hog_info.num_bins() << "," |
| 1453 | << "NormType=" << hog_info.normalization_type() << "," |
| 1454 | << "L2HystThreshold=" << hog_info.l2_hyst_threshold() << "," |
| 1455 | << "PhaseType=" << hog_info.phase_type() << "}"; |
| 1456 | |
| 1457 | return os; |
| 1458 | } |
| 1459 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 1460 | /** Formatted output of the HOGInfo type. |
| 1461 | * |
| 1462 | * @param[in] type Type to output |
| 1463 | * |
| 1464 | * @return Formatted string. |
| 1465 | */ |
John Richardson | 25f2368 | 2017-11-27 14:35:09 +0000 | [diff] [blame] | 1466 | inline std::string to_string(const HOGInfo &type) |
| 1467 | { |
| 1468 | std::stringstream str; |
| 1469 | str << type; |
| 1470 | return str.str(); |
| 1471 | } |
| 1472 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 1473 | /** Formatted output of the ConvolutionMethod type. |
| 1474 | * |
| 1475 | * @param[out] os Output stream |
| 1476 | * @param[in] conv_method Type to output |
| 1477 | * |
| 1478 | * @return Modified output stream. |
| 1479 | */ |
Isabella Gottardi | f07d28d | 2018-02-06 14:52:43 +0000 | [diff] [blame] | 1480 | inline ::std::ostream &operator<<(::std::ostream &os, const ConvolutionMethod &conv_method) |
| 1481 | { |
| 1482 | switch(conv_method) |
| 1483 | { |
| 1484 | case ConvolutionMethod::GEMM: |
| 1485 | os << "GEMM"; |
| 1486 | break; |
| 1487 | case ConvolutionMethod::DIRECT: |
| 1488 | os << "DIRECT"; |
| 1489 | break; |
| 1490 | case ConvolutionMethod::WINOGRAD: |
| 1491 | os << "WINOGRAD"; |
| 1492 | break; |
| 1493 | default: |
| 1494 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 1495 | } |
| 1496 | |
| 1497 | return os; |
| 1498 | } |
| 1499 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 1500 | /** Formatted output of the ConvolutionMethod type. |
| 1501 | * |
| 1502 | * @param[in] conv_method Type to output |
| 1503 | * |
| 1504 | * @return Formatted string. |
| 1505 | */ |
Isabella Gottardi | f07d28d | 2018-02-06 14:52:43 +0000 | [diff] [blame] | 1506 | inline std::string to_string(const ConvolutionMethod &conv_method) |
| 1507 | { |
| 1508 | std::stringstream str; |
| 1509 | str << conv_method; |
| 1510 | return str.str(); |
| 1511 | } |
| 1512 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 1513 | /** Formatted output of the GPUTarget type. |
| 1514 | * |
| 1515 | * @param[out] os Output stream |
| 1516 | * @param[in] gpu_target Type to output |
| 1517 | * |
| 1518 | * @return Modified output stream. |
| 1519 | */ |
Isabella Gottardi | f07d28d | 2018-02-06 14:52:43 +0000 | [diff] [blame] | 1520 | inline ::std::ostream &operator<<(::std::ostream &os, const GPUTarget &gpu_target) |
| 1521 | { |
| 1522 | switch(gpu_target) |
| 1523 | { |
| 1524 | case GPUTarget::GPU_ARCH_MASK: |
| 1525 | os << "GPU_ARCH_MASK"; |
| 1526 | break; |
| 1527 | case GPUTarget::MIDGARD: |
| 1528 | os << "MIDGARD"; |
| 1529 | break; |
| 1530 | case GPUTarget::BIFROST: |
| 1531 | os << "BIFROST"; |
| 1532 | break; |
| 1533 | case GPUTarget::T600: |
| 1534 | os << "T600"; |
| 1535 | break; |
| 1536 | case GPUTarget::T700: |
| 1537 | os << "T700"; |
| 1538 | break; |
| 1539 | case GPUTarget::T800: |
| 1540 | os << "T800"; |
| 1541 | break; |
Michalis Spyrou | a967611 | 2018-02-22 18:07:43 +0000 | [diff] [blame] | 1542 | case GPUTarget::G71: |
| 1543 | os << "G71"; |
| 1544 | break; |
| 1545 | case GPUTarget::G72: |
| 1546 | os << "G72"; |
| 1547 | break; |
| 1548 | case GPUTarget::G51: |
| 1549 | os << "G51"; |
| 1550 | break; |
| 1551 | case GPUTarget::G51BIG: |
| 1552 | os << "G51BIG"; |
| 1553 | break; |
| 1554 | case GPUTarget::G51LIT: |
| 1555 | os << "G51LIT"; |
| 1556 | break; |
Georgios Pinitas | b03f7c5 | 2018-07-12 10:49:53 +0100 | [diff] [blame] | 1557 | case GPUTarget::G76: |
| 1558 | os << "G76"; |
Michalis Spyrou | a967611 | 2018-02-22 18:07:43 +0000 | [diff] [blame] | 1559 | break; |
| 1560 | case GPUTarget::TTRX: |
| 1561 | os << "TTRX"; |
| 1562 | break; |
| 1563 | case GPUTarget::TBOX: |
| 1564 | os << "TBOX"; |
Isabella Gottardi | f07d28d | 2018-02-06 14:52:43 +0000 | [diff] [blame] | 1565 | break; |
| 1566 | default: |
| 1567 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 1568 | } |
| 1569 | |
| 1570 | return os; |
| 1571 | } |
| 1572 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 1573 | /** Formatted output of the GPUTarget type. |
| 1574 | * |
| 1575 | * @param[in] gpu_target Type to output |
| 1576 | * |
| 1577 | * @return Formatted string. |
| 1578 | */ |
Isabella Gottardi | f07d28d | 2018-02-06 14:52:43 +0000 | [diff] [blame] | 1579 | inline std::string to_string(const GPUTarget &gpu_target) |
| 1580 | { |
| 1581 | std::stringstream str; |
| 1582 | str << gpu_target; |
| 1583 | return str.str(); |
| 1584 | } |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame] | 1585 | |
John Richardson | 8de9261 | 2018-02-22 14:09:31 +0000 | [diff] [blame] | 1586 | /** Formatted output of the DetectionWindow type. |
| 1587 | * |
| 1588 | * @param[out] os Output stream |
| 1589 | * @param[in] detection_window Type to output |
| 1590 | * |
| 1591 | * @return Modified output stream. |
| 1592 | */ |
John Richardson | 684cb0f | 2018-01-09 11:17:00 +0000 | [diff] [blame] | 1593 | inline ::std::ostream &operator<<(::std::ostream &os, const DetectionWindow &detection_window) |
| 1594 | { |
| 1595 | os << "{x=" << detection_window.x << "," |
| 1596 | << "y=" << detection_window.y << "," |
| 1597 | << "width=" << detection_window.width << "," |
| 1598 | << "height=" << detection_window.height << "," |
| 1599 | << "idx_class=" << detection_window.idx_class << "," |
| 1600 | << "score=" << detection_window.score << "}"; |
| 1601 | |
| 1602 | return os; |
| 1603 | } |
| 1604 | |
John Richardson | 8de9261 | 2018-02-22 14:09:31 +0000 | [diff] [blame] | 1605 | /** Formatted output of the DetectionWindow type. |
| 1606 | * |
| 1607 | * @param[in] detection_window Type to output |
| 1608 | * |
| 1609 | * @return Formatted string. |
| 1610 | */ |
| 1611 | inline std::string to_string(const DetectionWindow &detection_window) |
| 1612 | { |
| 1613 | std::stringstream str; |
| 1614 | str << detection_window; |
| 1615 | return str.str(); |
| 1616 | } |
| 1617 | |
| 1618 | /** Formatted output of the Termination type. |
| 1619 | * |
| 1620 | * @param[out] os Output stream |
| 1621 | * @param[in] termination Type to output |
| 1622 | * |
| 1623 | * @return Modified output stream. |
| 1624 | */ |
| 1625 | inline ::std::ostream &operator<<(::std::ostream &os, const Termination &termination) |
| 1626 | { |
| 1627 | switch(termination) |
| 1628 | { |
| 1629 | case Termination::TERM_CRITERIA_EPSILON: |
| 1630 | os << "TERM_CRITERIA_EPSILON"; |
| 1631 | break; |
| 1632 | case Termination::TERM_CRITERIA_ITERATIONS: |
| 1633 | os << "TERM_CRITERIA_ITERATIONS"; |
| 1634 | break; |
| 1635 | case Termination::TERM_CRITERIA_BOTH: |
| 1636 | os << "TERM_CRITERIA_BOTH"; |
| 1637 | break; |
| 1638 | default: |
| 1639 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 1640 | } |
| 1641 | |
| 1642 | return os; |
| 1643 | } |
| 1644 | |
| 1645 | /** Formatted output of the Termination type. |
| 1646 | * |
| 1647 | * @param[in] termination Type to output |
| 1648 | * |
| 1649 | * @return Formatted string. |
| 1650 | */ |
| 1651 | inline std::string to_string(const Termination &termination) |
| 1652 | { |
| 1653 | std::stringstream str; |
| 1654 | str << termination; |
| 1655 | return str.str(); |
| 1656 | } |
| 1657 | |
Anthony Barbier | 671a11e | 2018-07-06 15:11:36 +0100 | [diff] [blame] | 1658 | /** Formatted output of a vector of objects. |
| 1659 | * |
| 1660 | * @param[out] os Output stream |
| 1661 | * @param[in] args Vector of objects to print |
| 1662 | * |
| 1663 | * @return Modified output stream. |
| 1664 | */ |
| 1665 | template <typename T> |
| 1666 | inline ::std::ostream &operator<<(::std::ostream &os, const std::vector<T> &args) |
| 1667 | { |
| 1668 | os << "["; |
| 1669 | bool first = true; |
| 1670 | for(auto &arg : args) |
| 1671 | { |
| 1672 | if(first) |
| 1673 | { |
| 1674 | first = false; |
| 1675 | } |
| 1676 | else |
| 1677 | { |
| 1678 | os << ", "; |
| 1679 | } |
| 1680 | os << arg; |
| 1681 | } |
| 1682 | os << "]"; |
| 1683 | return os; |
| 1684 | } |
| 1685 | |
| 1686 | /** Formatted output of a vector of objects. |
| 1687 | * |
| 1688 | * @param[in] args Vector of objects to print |
| 1689 | * |
| 1690 | * @return String representing args. |
| 1691 | */ |
| 1692 | template <typename T> |
| 1693 | std::string to_string(const std::vector<T> &args) |
| 1694 | { |
| 1695 | std::stringstream str; |
| 1696 | str << args; |
| 1697 | return str.str(); |
| 1698 | } |
| 1699 | |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame] | 1700 | /** Formatted output of the WinogradInfo type. */ |
| 1701 | inline ::std::ostream &operator<<(::std::ostream &os, const WinogradInfo &info) |
| 1702 | { |
| 1703 | os << "{OutputTileSize=" << info.output_tile_size << "," |
| 1704 | << "KernelSize=" << info.kernel_size << "," |
| 1705 | << "PadStride=" << info.convolution_info << "," |
| 1706 | << "OutputDataLayout=" << info.output_data_layout << "}"; |
| 1707 | |
| 1708 | return os; |
| 1709 | } |
| 1710 | |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame] | 1711 | inline std::string to_string(const WinogradInfo &type) |
| 1712 | { |
| 1713 | std::stringstream str; |
| 1714 | str << type; |
| 1715 | return str.str(); |
| 1716 | } |
Anthony Barbier | 671a11e | 2018-07-06 15:11:36 +0100 | [diff] [blame] | 1717 | |
| 1718 | /** Fallback method: try to use std::to_string: |
| 1719 | * |
| 1720 | * @param[in] val Value to convert to string |
| 1721 | * |
| 1722 | * @return String representing val. |
| 1723 | */ |
| 1724 | template <typename T> |
| 1725 | inline std::string to_string(const T &val) |
| 1726 | { |
| 1727 | return support::cpp11::to_string(val); |
| 1728 | } |
| 1729 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 1730 | } // namespace arm_compute |
John Richardson | 8de9261 | 2018-02-22 14:09:31 +0000 | [diff] [blame] | 1731 | #endif /* __ARM_COMPUTE_TEST_TYPE_PRINTER_H__ */ |