blob: 1d881f8c060c496b2b64747df40158620f174ddb [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001/*
Michalis Spyroud466c2d2018-01-30 10:54:39 +00002 * Copyright (c) 2017-2018 ARM Limited.
Anthony Barbier6ff3b192017-09-04 18:44:23 +01003 *
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 Barbier4dbc0a92018-08-27 13:39:47 +010024#ifndef __ARM_COMPUTE_TYPE_PRINTER_H__
25#define __ARM_COMPUTE_TYPE_PRINTER_H__
Anthony Barbier6ff3b192017-09-04 18:44:23 +010026
Isabella Gottardif07d28d2018-02-06 14:52:43 +000027#include "arm_compute/core/CL/CLTypes.h"
Anthony Barbier8914e322018-08-10 15:28:25 +010028#include "arm_compute/core/CPP/CPPTypes.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010029#include "arm_compute/core/Dimensions.h"
30#include "arm_compute/core/Error.h"
Michele Di Giorgiob8fc60f2018-04-25 11:58:07 +010031#include "arm_compute/core/GPUTarget.h"
John Richardson25f23682017-11-27 14:35:09 +000032#include "arm_compute/core/HOGInfo.h"
33#include "arm_compute/core/Size2D.h"
John Richardsona36eae12017-09-26 16:55:59 +010034#include "arm_compute/core/Strides.h"
Georgios Pinitas3faea252017-10-30 14:13:50 +000035#include "arm_compute/core/TensorInfo.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010036#include "arm_compute/core/Types.h"
37
38#include <ostream>
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010039#include <sstream>
40#include <string>
Anthony Barbier6ff3b192017-09-04 18:44:23 +010041
42namespace arm_compute
43{
Anthony Barbierb940fd62018-06-04 14:14:32 +010044/** Formatted output if arg is not null
45 *
46 * @param[in] arg Object to print
47 *
48 * @return String representing arg.
49 */
50template <typename T>
51std::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 Gildayc357c472018-03-21 13:54:09 +000062/** 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 Barbier6ff3b192017-09-04 18:44:23 +010069template <typename T>
70inline ::std::ostream &operator<<(::std::ostream &os, const Dimensions<T> &dimensions)
71{
Anthony Barbier6ff3b192017-09-04 18:44:23 +010072 if(dimensions.num_dimensions() > 0)
73 {
74 os << dimensions[0];
75
76 for(unsigned int d = 1; d < dimensions.num_dimensions(); ++d)
77 {
Moritz Pflanzerc87fbf82017-07-18 14:02:10 +010078 os << "x" << dimensions[d];
Anthony Barbier6ff3b192017-09-04 18:44:23 +010079 }
80 }
81
Anthony Barbier6ff3b192017-09-04 18:44:23 +010082 return os;
83}
84
Alex Gildayc357c472018-03-21 13:54:09 +000085/** 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 Gottardi3b77e9d2017-06-22 11:05:41 +010092inline ::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 Gildayc357c472018-03-21 13:54:09 +0000112/** Formatted output of the NonLinearFilterFunction type.
113 *
114 * @param[in] function Type to output.
115 *
116 * @return Formatted string.
117 */
John Richardson6f4d49f2017-09-07 11:21:10 +0100118inline std::string to_string(const NonLinearFilterFunction &function)
119{
120 std::stringstream str;
121 str << function;
122 return str.str();
123}
124
Alex Gildayc357c472018-03-21 13:54:09 +0000125/** 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 Gottardi3b77e9d2017-06-22 11:05:41 +0100132inline ::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 Gildayc357c472018-03-21 13:54:09 +0000155/** Formatted output of the MatrixPattern type.
156 *
157 * @param[in] pattern Type to output.
158 *
159 * @return Formatted string.
160 */
John Richardson6f4d49f2017-09-07 11:21:10 +0100161inline std::string to_string(const MatrixPattern &pattern)
162{
163 std::stringstream str;
164 str << pattern;
165 return str.str();
166}
167
Alex Gildayc357c472018-03-21 13:54:09 +0000168/** 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 Barbier2a07e182017-08-04 18:20:27 +0100175inline ::std::ostream &operator<<(::std::ostream &os, const RoundingPolicy &rounding_policy)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100176{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100177 switch(rounding_policy)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100178 {
Anthony Barbier2a07e182017-08-04 18:20:27 +0100179 case RoundingPolicy::TO_ZERO:
180 os << "TO_ZERO";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100181 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100182 case RoundingPolicy::TO_NEAREST_UP:
183 os << "TO_NEAREST_UP";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100184 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100185 case RoundingPolicy::TO_NEAREST_EVEN:
186 os << "TO_NEAREST_EVEN";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100187 break;
188 default:
189 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
190 }
191
192 return os;
193}
194
Alex Gildayc357c472018-03-21 13:54:09 +0000195/** 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 Barbier2a07e182017-08-04 18:20:27 +0100202inline ::std::ostream &operator<<(::std::ostream &os, const WeightsInfo &weights_info)
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100203{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100204 os << weights_info.are_reshaped() << ";";
205 os << weights_info.num_kernels() << ";" << weights_info.kernel_size().first << "," << weights_info.kernel_size().second;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100206
207 return os;
208}
209
Alex Gildayc357c472018-03-21 13:54:09 +0000210/** 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 Barbier2a07e182017-08-04 18:20:27 +0100217inline ::std::ostream &operator<<(::std::ostream &os, const ROIPoolingLayerInfo &pool_info)
Sanghoon Lee70f82912017-08-24 14:21:24 +0100218{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100219 os << pool_info.pooled_width() << "x" << pool_info.pooled_height() << "~" << pool_info.spatial_scale();
Georgios Pinitasd9769582017-08-03 10:19:40 +0100220 return os;
221}
222
Alex Gildayc357c472018-03-21 13:54:09 +0000223/** Formatted output of the QuantizationInfo type.
224 *
225 * @param[out] os Output stream.
226 * @param[in] quantization_info Type to output.
227 *
228 * @return Modified output stream.
229 */
Chunosovd621bca2017-11-03 17:33:15 +0700230inline ::std::ostream &operator<<(::std::ostream &os, const QuantizationInfo &quantization_info)
231{
232 os << "Scale:" << quantization_info.scale << "~"
233 << "Offset:" << quantization_info.offset;
234 return os;
235}
236
Alex Gildayc357c472018-03-21 13:54:09 +0000237/** Formatted output of the QuantizationInfo type.
238 *
239 * @param[in] quantization_info Type to output.
240 *
241 * @return Formatted string.
242 */
Chunosovd621bca2017-11-03 17:33:15 +0700243inline std::string to_string(const QuantizationInfo &quantization_info)
244{
245 std::stringstream str;
246 str << quantization_info;
247 return str.str();
248}
249
Alex Gildayc357c472018-03-21 13:54:09 +0000250/** Formatted output of the activation function type.
251 *
252 * @param[out] os Output stream.
253 * @param[in] act_function Type to output.
254 *
255 * @return Modified output stream.
256 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100257inline ::std::ostream &operator<<(::std::ostream &os, const ActivationLayerInfo::ActivationFunction &act_function)
258{
259 switch(act_function)
260 {
261 case ActivationLayerInfo::ActivationFunction::ABS:
262 os << "ABS";
263 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100264 case ActivationLayerInfo::ActivationFunction::LINEAR:
265 os << "LINEAR";
266 break;
267 case ActivationLayerInfo::ActivationFunction::LOGISTIC:
268 os << "LOGISTIC";
269 break;
270 case ActivationLayerInfo::ActivationFunction::RELU:
271 os << "RELU";
272 break;
Georgios Pinitas579c0492017-07-12 16:12:12 +0100273 case ActivationLayerInfo::ActivationFunction::BOUNDED_RELU:
274 os << "BOUNDED_RELU";
275 break;
276 case ActivationLayerInfo::ActivationFunction::LEAKY_RELU:
277 os << "LEAKY_RELU";
278 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100279 case ActivationLayerInfo::ActivationFunction::SOFT_RELU:
280 os << "SOFT_RELU";
281 break;
282 case ActivationLayerInfo::ActivationFunction::SQRT:
283 os << "SQRT";
284 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100285 case ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU:
286 os << "LU_BOUNDED_RELU";
Kevin Petitd9f80712017-12-06 12:18:48 +0000287 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100288 case ActivationLayerInfo::ActivationFunction::SQUARE:
289 os << "SQUARE";
290 break;
291 case ActivationLayerInfo::ActivationFunction::TANH:
292 os << "TANH";
293 break;
294 default:
295 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
296 }
297
298 return os;
299}
300
Alex Gildayc357c472018-03-21 13:54:09 +0000301/** Formatted output of the activation function info type.
302 *
303 * @param[in] info Type to output.
304 *
305 * @return Formatted string.
306 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100307inline std::string to_string(const arm_compute::ActivationLayerInfo &info)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100308{
309 std::stringstream str;
Isabella Gottardi3f217ec2018-02-12 14:59:19 +0000310 if(info.enabled())
311 {
312 str << info.activation();
313 }
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100314 return str.str();
315}
316
Alex Gildayc357c472018-03-21 13:54:09 +0000317/** Formatted output of the activation function type.
318 *
319 * @param[in] function Type to output.
320 *
321 * @return Formatted string.
322 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100323inline std::string to_string(const arm_compute::ActivationLayerInfo::ActivationFunction &function)
324{
325 std::stringstream str;
326 str << function;
327 return str.str();
328}
329
Alex Gildayc357c472018-03-21 13:54:09 +0000330/** Formatted output of the NormType type.
331 *
332 * @param[out] os Output stream.
333 * @param[in] norm_type Type to output.
334 *
335 * @return Modified output stream.
336 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100337inline ::std::ostream &operator<<(::std::ostream &os, const NormType &norm_type)
338{
339 switch(norm_type)
340 {
341 case NormType::CROSS_MAP:
342 os << "CROSS_MAP";
343 break;
344 case NormType::IN_MAP_1D:
345 os << "IN_MAP_1D";
346 break;
347 case NormType::IN_MAP_2D:
348 os << "IN_MAP_2D";
349 break;
350 default:
351 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
352 }
353
354 return os;
355}
356
Alex Gildayc357c472018-03-21 13:54:09 +0000357/** Formatted output of @ref NormalizationLayerInfo.
358 *
359 * @param[in] info Type to output.
360 *
361 * @return Formatted string.
362 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100363inline std::string to_string(const arm_compute::NormalizationLayerInfo &info)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100364{
365 std::stringstream str;
Michalis Spyroud466c2d2018-01-30 10:54:39 +0000366 str << info.type() << ":NormSize=" << info.norm_size();
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100367 return str.str();
368}
369
Alex Gildayc357c472018-03-21 13:54:09 +0000370/** Formatted output of @ref NormalizationLayerInfo.
371 *
372 * @param[out] os Output stream.
373 * @param[in] info Type to output.
374 *
375 * @return Modified output stream.
376 */
Georgios Pinitas6f669f02017-09-26 12:32:57 +0100377inline ::std::ostream &operator<<(::std::ostream &os, const NormalizationLayerInfo &info)
378{
Michalis Spyroud466c2d2018-01-30 10:54:39 +0000379 os << info.type() << ":NormSize=" << info.norm_size();
Georgios Pinitas6f669f02017-09-26 12:32:57 +0100380 return os;
381}
382
Alex Gildayc357c472018-03-21 13:54:09 +0000383/** Formatted output of the PoolingType type.
384 *
385 * @param[out] os Output stream.
386 * @param[in] pool_type Type to output.
387 *
388 * @return Modified output stream.
389 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100390inline ::std::ostream &operator<<(::std::ostream &os, const PoolingType &pool_type)
391{
392 switch(pool_type)
393 {
394 case PoolingType::AVG:
395 os << "AVG";
396 break;
397 case PoolingType::MAX:
398 os << "MAX";
399 break;
Georgios Pinitascdf51452017-08-31 14:21:36 +0100400 case PoolingType::L2:
401 os << "L2";
402 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100403 default:
404 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
405 }
406
407 return os;
408}
409
Alex Gildayc357c472018-03-21 13:54:09 +0000410/** Formatted output of @ref PoolingLayerInfo.
411 *
412 * @param[out] os Output stream.
413 * @param[in] info Type to output.
414 *
415 * @return Modified output stream.
416 */
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100417inline ::std::ostream &operator<<(::std::ostream &os, const PoolingLayerInfo &info)
418{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100419 os << info.pool_type();
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100420
421 return os;
422}
423
Alex Gildayc357c472018-03-21 13:54:09 +0000424/** Formatted output of @ref RoundingPolicy.
425 *
426 * @param[in] rounding_policy Type to output.
427 *
428 * @return Formatted string.
429 */
John Richardsondd715f22017-09-18 16:10:48 +0100430inline std::string to_string(const RoundingPolicy &rounding_policy)
431{
432 std::stringstream str;
433 str << rounding_policy;
434 return str.str();
435}
436
Alex Gildayc357c472018-03-21 13:54:09 +0000437/** Formatted output of the DataLayout type.
438 *
439 * @param[out] os Output stream.
440 * @param[in] data_layout Type to output.
441 *
442 * @return Modified output stream.
443 */
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000444inline ::std::ostream &operator<<(::std::ostream &os, const DataLayout &data_layout)
445{
446 switch(data_layout)
447 {
448 case DataLayout::UNKNOWN:
449 os << "UNKNOWN";
450 break;
451 case DataLayout::NHWC:
452 os << "NHWC";
453 break;
454 case DataLayout::NCHW:
455 os << "NCHW";
456 break;
457 default:
458 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
459 }
460
461 return os;
462}
463
Alex Gildayc357c472018-03-21 13:54:09 +0000464/** Formatted output of the DataLayout type.
465 *
466 * @param[in] data_layout Type to output.
467 *
468 * @return Formatted string.
469 */
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000470inline std::string to_string(const arm_compute::DataLayout &data_layout)
471{
472 std::stringstream str;
473 str << data_layout;
474 return str.str();
475}
476
Georgios Pinitase2220552018-07-20 13:23:44 +0100477/** Formatted output of the DataLayoutDimension type.
478 *
479 * @param[out] os Output stream.
480 * @param[in] data_layout_dim Data layout dimension to print.
481 *
482 * @return Modified output stream.
483 */
484inline ::std::ostream &operator<<(::std::ostream &os, const DataLayoutDimension &data_layout_dim)
485{
486 switch(data_layout_dim)
487 {
488 case DataLayoutDimension::WIDTH:
489 os << "WIDTH";
490 break;
491 case DataLayoutDimension::HEIGHT:
492 os << "HEIGHT";
493 break;
494 case DataLayoutDimension::CHANNEL:
495 os << "CHANNEL";
496 break;
497 case DataLayoutDimension::BATCHES:
498 os << "BATCHES";
499 break;
500 default:
501 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
502 }
503 return os;
504}
505
Alex Gildayc357c472018-03-21 13:54:09 +0000506/** Formatted output of the DataType type.
507 *
508 * @param[out] os Output stream.
509 * @param[in] data_type Type to output.
510 *
511 * @return Modified output stream.
512 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100513inline ::std::ostream &operator<<(::std::ostream &os, const DataType &data_type)
514{
515 switch(data_type)
516 {
517 case DataType::UNKNOWN:
518 os << "UNKNOWN";
519 break;
520 case DataType::U8:
521 os << "U8";
522 break;
Chunosovd621bca2017-11-03 17:33:15 +0700523 case DataType::QASYMM8:
524 os << "QASYMM8";
525 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100526 case DataType::S8:
527 os << "S8";
528 break;
529 case DataType::U16:
530 os << "U16";
531 break;
532 case DataType::S16:
533 os << "S16";
534 break;
535 case DataType::U32:
536 os << "U32";
537 break;
538 case DataType::S32:
539 os << "S32";
540 break;
541 case DataType::U64:
542 os << "U64";
543 break;
544 case DataType::S64:
545 os << "S64";
546 break;
547 case DataType::F16:
548 os << "F16";
549 break;
550 case DataType::F32:
551 os << "F32";
552 break;
553 case DataType::F64:
554 os << "F64";
555 break;
556 case DataType::SIZET:
557 os << "SIZET";
558 break;
559 default:
560 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
561 }
562
563 return os;
564}
565
Alex Gildayc357c472018-03-21 13:54:09 +0000566/** Formatted output of the DataType type.
567 *
568 * @param[in] data_type Type to output.
569 *
570 * @return Formatted string.
571 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100572inline std::string to_string(const arm_compute::DataType &data_type)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100573{
574 std::stringstream str;
575 str << data_type;
576 return str.str();
577}
578
Alex Gildayc357c472018-03-21 13:54:09 +0000579/** Formatted output of the Format type.
580 *
581 * @param[out] os Output stream.
582 * @param[in] format Type to output.
583 *
584 * @return Modified output stream.
585 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100586inline ::std::ostream &operator<<(::std::ostream &os, const Format &format)
587{
588 switch(format)
589 {
590 case Format::UNKNOWN:
591 os << "UNKNOWN";
592 break;
593 case Format::U8:
594 os << "U8";
595 break;
596 case Format::S16:
597 os << "S16";
598 break;
599 case Format::U16:
600 os << "U16";
601 break;
602 case Format::S32:
603 os << "S32";
604 break;
605 case Format::U32:
606 os << "U32";
607 break;
608 case Format::F16:
609 os << "F16";
610 break;
611 case Format::F32:
612 os << "F32";
613 break;
614 case Format::UV88:
615 os << "UV88";
616 break;
617 case Format::RGB888:
618 os << "RGB888";
619 break;
620 case Format::RGBA8888:
621 os << "RGBA8888";
622 break;
623 case Format::YUV444:
624 os << "YUV444";
625 break;
626 case Format::YUYV422:
627 os << "YUYV422";
628 break;
629 case Format::NV12:
630 os << "NV12";
631 break;
632 case Format::NV21:
633 os << "NV21";
634 break;
635 case Format::IYUV:
636 os << "IYUV";
637 break;
638 case Format::UYVY422:
639 os << "UYVY422";
640 break;
641 default:
642 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
643 }
644
645 return os;
646}
647
Alex Gildayc357c472018-03-21 13:54:09 +0000648/** Formatted output of the Format type.
649 *
650 * @param[in] format Type to output.
651 *
652 * @return Formatted string.
653 */
Moritz Pflanzer7655a672017-09-23 11:57:33 +0100654inline std::string to_string(const Format &format)
655{
656 std::stringstream str;
657 str << format;
658 return str.str();
659}
660
Alex Gildayc357c472018-03-21 13:54:09 +0000661/** Formatted output of the Channel type.
662 *
663 * @param[out] os Output stream.
664 * @param[in] channel Type to output.
665 *
666 * @return Modified output stream.
667 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100668inline ::std::ostream &operator<<(::std::ostream &os, const Channel &channel)
669{
670 switch(channel)
671 {
672 case Channel::UNKNOWN:
673 os << "UNKNOWN";
674 break;
675 case Channel::C0:
676 os << "C0";
677 break;
678 case Channel::C1:
679 os << "C1";
680 break;
681 case Channel::C2:
682 os << "C2";
683 break;
684 case Channel::C3:
685 os << "C3";
686 break;
687 case Channel::R:
688 os << "R";
689 break;
690 case Channel::G:
691 os << "G";
692 break;
693 case Channel::B:
694 os << "B";
695 break;
696 case Channel::A:
697 os << "A";
698 break;
699 case Channel::Y:
700 os << "Y";
701 break;
702 case Channel::U:
703 os << "U";
704 break;
705 case Channel::V:
706 os << "V";
707 break;
708 default:
709 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
710 }
711
712 return os;
713}
714
Alex Gildayc357c472018-03-21 13:54:09 +0000715/** Formatted output of the Channel type.
716 *
717 * @param[in] channel Type to output.
718 *
719 * @return Formatted string.
720 */
Ioan-Cristian Szabo9414f642017-10-27 17:35:40 +0100721inline std::string to_string(const Channel &channel)
722{
723 std::stringstream str;
724 str << channel;
725 return str.str();
726}
727
Alex Gildayc357c472018-03-21 13:54:09 +0000728/** Formatted output of the BorderMode type.
729 *
730 * @param[out] os Output stream.
731 * @param[in] mode Type to output.
732 *
733 * @return Modified output stream.
734 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100735inline ::std::ostream &operator<<(::std::ostream &os, const BorderMode &mode)
736{
737 switch(mode)
738 {
739 case BorderMode::UNDEFINED:
740 os << "UNDEFINED";
741 break;
742 case BorderMode::CONSTANT:
743 os << "CONSTANT";
744 break;
745 case BorderMode::REPLICATE:
746 os << "REPLICATE";
747 break;
748 default:
749 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
750 }
751
752 return os;
753}
754
Alex Gildayc357c472018-03-21 13:54:09 +0000755/** Formatted output of the BorderSize type.
756 *
757 * @param[out] os Output stream.
758 * @param[in] border Type to output.
759 *
760 * @return Modified output stream.
761 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100762inline ::std::ostream &operator<<(::std::ostream &os, const BorderSize &border)
763{
Moritz Pflanzerc87fbf82017-07-18 14:02:10 +0100764 os << border.top << ","
765 << border.right << ","
766 << border.bottom << ","
767 << border.left;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100768
769 return os;
770}
Anthony Barbier2a07e182017-08-04 18:20:27 +0100771
Alex Gildayc357c472018-03-21 13:54:09 +0000772/** Formatted output of the InterpolationPolicy type.
773 *
774 * @param[out] os Output stream.
775 * @param[in] policy Type to output.
776 *
777 * @return Modified output stream.
778 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100779inline ::std::ostream &operator<<(::std::ostream &os, const InterpolationPolicy &policy)
780{
781 switch(policy)
782 {
783 case InterpolationPolicy::NEAREST_NEIGHBOR:
784 os << "NEAREST_NEIGHBOR";
785 break;
786 case InterpolationPolicy::BILINEAR:
787 os << "BILINEAR";
788 break;
789 case InterpolationPolicy::AREA:
790 os << "AREA";
791 break;
792 default:
793 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
794 }
795
796 return os;
797}
798
Alex Gildayc357c472018-03-21 13:54:09 +0000799/** Formatted output of the SamplingPolicy type.
800 *
801 * @param[out] os Output stream.
802 * @param[in] policy Type to output.
803 *
804 * @return Modified output stream.
805 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700806inline ::std::ostream &operator<<(::std::ostream &os, const SamplingPolicy &policy)
807{
808 switch(policy)
809 {
810 case SamplingPolicy::CENTER:
811 os << "CENTER";
812 break;
813 case SamplingPolicy::TOP_LEFT:
814 os << "TOP_LEFT";
815 break;
816 default:
817 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
818 }
819
820 return os;
821}
822
Alex Gildayc357c472018-03-21 13:54:09 +0000823/** Formatted output of the TensorInfo type.
824 *
Anthony Barbier366628a2018-08-01 13:55:03 +0100825 * @param[out] os Output stream.
826 * @param[in] info Type to output.
827 *
828 * @return Modified output stream.
829 */
830inline ::std::ostream &operator<<(::std::ostream &os, const TensorInfo &info)
831{
832 os << "{Shape=" << info.tensor_shape() << ","
833 << "Type=" << info.data_type() << ","
834 << "Channels=" << info.num_channels() << "}";
835 return os;
836}
837/** Formatted output of the TensorInfo type.
838 *
Alex Gildayc357c472018-03-21 13:54:09 +0000839 * @param[in] info Type to output.
840 *
841 * @return Formatted string.
842 */
Georgios Pinitas3faea252017-10-30 14:13:50 +0000843inline std::string to_string(const TensorInfo &info)
844{
845 std::stringstream str;
Anthony Barbier366628a2018-08-01 13:55:03 +0100846 str << info;
Georgios Pinitas3faea252017-10-30 14:13:50 +0000847 return str.str();
848}
849
Abe Mbise925ca0f2017-10-02 19:16:33 +0100850//FIXME: Check why this doesn't work and the TensorShape and Coordinates overload are needed
Alex Gildayc357c472018-03-21 13:54:09 +0000851/** Formatted output of the Dimensions type.
852 *
853 * @param[in] dimensions Type to output.
854 *
855 * @return Formatted string.
856 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100857template <typename T>
858inline std::string to_string(const Dimensions<T> &dimensions)
859{
860 std::stringstream str;
861 str << dimensions;
862 return str.str();
863}
864
Alex Gildayc357c472018-03-21 13:54:09 +0000865/** Formatted output of the Strides type.
866 *
867 * @param[in] stride Type to output.
868 *
869 * @return Formatted string.
870 */
John Richardsona36eae12017-09-26 16:55:59 +0100871inline std::string to_string(const Strides &stride)
872{
873 std::stringstream str;
874 str << stride;
875 return str.str();
876}
877
Alex Gildayc357c472018-03-21 13:54:09 +0000878/** Formatted output of the TensorShape type.
879 *
880 * @param[in] shape Type to output.
881 *
882 * @return Formatted string.
883 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100884inline std::string to_string(const TensorShape &shape)
885{
886 std::stringstream str;
887 str << shape;
888 return str.str();
889}
890
Alex Gildayc357c472018-03-21 13:54:09 +0000891/** Formatted output of the Coordinates type.
892 *
893 * @param[in] coord Type to output.
894 *
895 * @return Formatted string.
896 */
Abe Mbise925ca0f2017-10-02 19:16:33 +0100897inline std::string to_string(const Coordinates &coord)
898{
899 std::stringstream str;
900 str << coord;
901 return str.str();
902}
903
Anthony Barbierb940fd62018-06-04 14:14:32 +0100904/** Formatted output of the GEMMReshapeInfo type.
905 *
906 * @param[out] os Output stream.
907 * @param[in] info Type to output.
908 *
909 * @return Modified output stream.
910 */
911inline ::std::ostream &operator<<(::std::ostream &os, const GEMMReshapeInfo &info)
912{
913 os << "{m=" << info.m() << ",";
914 os << "n=" << info.n() << ",";
915 os << "k=" << info.k() << ",";
916 os << "mult_transpose1xW_width=" << info.mult_transpose1xW_width() << ",";
917 os << "mult_interleave4x4_height=" << info.mult_interleave4x4_height();
918 os << "}";
919
920 return os;
921}
922
923/** Formatted output of the GEMMInfo type.
924 *
925 * @param[out] os Output stream.
926 * @param[in] info Type to output.
927 *
928 * @return Modified output stream.
929 */
930inline ::std::ostream &operator<<(::std::ostream &os, const GEMMInfo &info)
931{
932 os << "{is_a_reshaped=" << info.is_a_reshaped() << ",";
933 os << "is_b_reshaped=" << info.is_b_reshaped() << ",";
934 os << "reshape_b_only_on_first_run=" << info.reshape_b_only_on_first_run() << ",";
Anthony Barbierb940fd62018-06-04 14:14:32 +0100935 os << "}";
936
937 return os;
938}
939
940/** Formatted output of the Window::Dimension type.
941 *
942 * @param[out] os Output stream.
943 * @param[in] dim Type to output.
944 *
945 * @return Modified output stream.
946 */
947inline ::std::ostream &operator<<(::std::ostream &os, const Window::Dimension &dim)
948{
949 os << "{start=" << dim.start() << ", end=" << dim.end() << ", step=" << dim.step() << "}";
950
951 return os;
952}
953/** Formatted output of the Window type.
954 *
955 * @param[out] os Output stream.
956 * @param[in] win Type to output.
957 *
958 * @return Modified output stream.
959 */
960inline ::std::ostream &operator<<(::std::ostream &os, const Window &win)
961{
962 os << "{";
963 for(unsigned int i = 0; i < Coordinates::num_max_dimensions; i++)
964 {
965 if(i > 0)
966 {
967 os << ", ";
968 }
969 os << win[i];
970 }
971 os << "}";
972
973 return os;
974}
975
976/** Formatted output of the WeightsInfo type.
977 *
978 * @param[in] info Type to output.
979 *
980 * @return Formatted string.
981 */
982inline std::string to_string(const WeightsInfo &info)
983{
984 std::stringstream str;
985 str << info;
986 return str.str();
987}
988
989/** Formatted output of the GEMMReshapeInfo type.
990 *
991 * @param[in] info Type to output.
992 *
993 * @return Formatted string.
994 */
995inline std::string to_string(const GEMMReshapeInfo &info)
996{
997 std::stringstream str;
998 str << info;
999 return str.str();
1000}
1001
1002/** Formatted output of the GEMMInfo type.
1003 *
1004 * @param[in] info Type to output.
1005 *
1006 * @return Formatted string.
1007 */
1008inline std::string to_string(const GEMMInfo &info)
1009{
1010 std::stringstream str;
1011 str << info;
1012 return str.str();
1013}
1014
1015/** Formatted output of the Window::Dimension type.
1016 *
1017 * @param[in] dim Type to output.
1018 *
1019 * @return Formatted string.
1020 */
1021inline std::string to_string(const Window::Dimension &dim)
1022{
1023 std::stringstream str;
1024 str << dim;
1025 return str.str();
1026}
1027/** Formatted output of the Window type.
1028 *
1029 * @param[in] win Type to output.
1030 *
1031 * @return Formatted string.
1032 */
1033inline std::string to_string(const Window &win)
1034{
1035 std::stringstream str;
1036 str << win;
1037 return str.str();
1038}
1039
Alex Gildayc357c472018-03-21 13:54:09 +00001040/** Formatted output of the Rectangle type.
1041 *
1042 * @param[out] os Output stream.
1043 * @param[in] rect Type to output.
1044 *
1045 * @return Modified output stream.
1046 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001047inline ::std::ostream &operator<<(::std::ostream &os, const Rectangle &rect)
1048{
1049 os << rect.width << "x" << rect.height;
1050 os << "+" << rect.x << "+" << rect.y;
1051
1052 return os;
1053}
1054
Alex Gildayc357c472018-03-21 13:54:09 +00001055/** Formatted output of the PadStrideInfo type.
1056 *
1057 * @param[out] os Output stream.
1058 * @param[in] pad_stride_info Type to output.
1059 *
1060 * @return Modified output stream.
1061 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001062inline ::std::ostream &operator<<(::std::ostream &os, const PadStrideInfo &pad_stride_info)
1063{
1064 os << pad_stride_info.stride().first << "," << pad_stride_info.stride().second;
1065 os << ";";
Jaroslaw Rzepeckia1ed41f2017-10-13 11:13:58 +01001066 os << pad_stride_info.pad_left() << "," << pad_stride_info.pad_right() << ","
1067 << pad_stride_info.pad_top() << "," << pad_stride_info.pad_bottom();
Anthony Barbier2a07e182017-08-04 18:20:27 +01001068
1069 return os;
1070}
1071
Alex Gildayc357c472018-03-21 13:54:09 +00001072/** Formatted output of the PadStrideInfo type.
1073 *
1074 * @param[in] pad_stride_info Type to output.
1075 *
1076 * @return Formatted string.
1077 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001078inline std::string to_string(const PadStrideInfo &pad_stride_info)
1079{
1080 std::stringstream str;
1081 str << pad_stride_info;
1082 return str.str();
1083}
1084
Alex Gildayc357c472018-03-21 13:54:09 +00001085/** Formatted output of the BorderMode type.
1086 *
1087 * @param[in] mode Type to output.
1088 *
1089 * @return Formatted string.
1090 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001091inline std::string to_string(const BorderMode &mode)
1092{
1093 std::stringstream str;
1094 str << mode;
1095 return str.str();
1096}
1097
Alex Gildayc357c472018-03-21 13:54:09 +00001098/** Formatted output of the BorderSize type.
1099 *
1100 * @param[in] border Type to output.
1101 *
1102 * @return Formatted string.
1103 */
John Richardsonb482ce12017-09-18 12:44:01 +01001104inline std::string to_string(const BorderSize &border)
1105{
1106 std::stringstream str;
1107 str << border;
1108 return str.str();
1109}
1110
Alex Gildayc357c472018-03-21 13:54:09 +00001111/** Formatted output of the InterpolationPolicy type.
1112 *
1113 * @param[in] policy Type to output.
1114 *
1115 * @return Formatted string.
1116 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001117inline std::string to_string(const InterpolationPolicy &policy)
1118{
1119 std::stringstream str;
1120 str << policy;
1121 return str.str();
1122}
1123
Alex Gildayc357c472018-03-21 13:54:09 +00001124/** Formatted output of the SamplingPolicy type.
1125 *
1126 * @param[in] policy Type to output.
1127 *
1128 * @return Formatted string.
1129 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +07001130inline std::string to_string(const SamplingPolicy &policy)
1131{
1132 std::stringstream str;
1133 str << policy;
1134 return str.str();
1135}
1136
Alex Gildayc357c472018-03-21 13:54:09 +00001137/** Formatted output of the ConvertPolicy type.
1138 *
1139 * @param[out] os Output stream.
1140 * @param[in] policy Type to output.
1141 *
1142 * @return Modified output stream.
1143 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001144inline ::std::ostream &operator<<(::std::ostream &os, const ConvertPolicy &policy)
1145{
1146 switch(policy)
1147 {
1148 case ConvertPolicy::WRAP:
1149 os << "WRAP";
1150 break;
1151 case ConvertPolicy::SATURATE:
1152 os << "SATURATE";
1153 break;
1154 default:
1155 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1156 }
1157
1158 return os;
1159}
1160
1161inline std::string to_string(const ConvertPolicy &policy)
1162{
1163 std::stringstream str;
1164 str << policy;
1165 return str.str();
1166}
1167
Alex Gildayc357c472018-03-21 13:54:09 +00001168/** Formatted output of the Reduction Operations.
1169 *
1170 * @param[out] os Output stream.
1171 * @param[in] op Type to output.
1172 *
1173 * @return Modified output stream.
1174 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001175inline ::std::ostream &operator<<(::std::ostream &os, const ReductionOperation &op)
1176{
1177 switch(op)
1178 {
1179 case ReductionOperation::SUM_SQUARE:
1180 os << "SUM_SQUARE";
1181 break;
1182 default:
1183 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1184 }
1185
1186 return os;
1187}
1188
Alex Gildayc357c472018-03-21 13:54:09 +00001189/** Formatted output of the Reduction Operations.
1190 *
1191 * @param[in] op Type to output.
1192 *
1193 * @return Formatted string.
1194 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001195inline std::string to_string(const ReductionOperation &op)
1196{
1197 std::stringstream str;
1198 str << op;
1199 return str.str();
1200}
1201
Alex Gildayc357c472018-03-21 13:54:09 +00001202/** Formatted output of the Norm Type.
1203 *
1204 * @param[in] type Type to output.
1205 *
1206 * @return Formatted string.
1207 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001208inline std::string to_string(const NormType &type)
1209{
1210 std::stringstream str;
1211 str << type;
1212 return str.str();
1213}
1214
Alex Gildayc357c472018-03-21 13:54:09 +00001215/** Formatted output of the Pooling Type.
1216 *
1217 * @param[in] type Type to output.
1218 *
1219 * @return Formatted string.
1220 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001221inline std::string to_string(const PoolingType &type)
1222{
1223 std::stringstream str;
1224 str << type;
1225 return str.str();
1226}
1227
Alex Gildayc357c472018-03-21 13:54:09 +00001228/** Formatted output of the Pooling Layer Info.
1229 *
1230 * @param[in] info Type to output.
1231 *
1232 * @return Formatted string.
1233 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001234inline std::string to_string(const PoolingLayerInfo &info)
1235{
1236 std::stringstream str;
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001237 str << "{Type=" << info.pool_type() << ","
1238 << "IsGlobalPooling=" << info.is_global_pooling();
1239 if(!info.is_global_pooling())
1240 {
1241 str << ","
Isabella Gottardi6e464c32018-01-26 12:32:45 +00001242 << "PoolSize=" << info.pool_size().width << "," << info.pool_size().height << ","
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001243 << "PadStride=" << info.pad_stride_info();
1244 }
1245 str << "}";
Anthony Barbier2a07e182017-08-04 18:20:27 +01001246 return str.str();
1247}
1248
Alex Gildayc357c472018-03-21 13:54:09 +00001249/** Formatted output of the KeyPoint type.
1250 *
1251 * @param[out] os Output stream
1252 * @param[in] point Type to output.
1253 *
1254 * @return Modified output stream.
1255 */
Moritz Pflanzer6c6597c2017-09-24 12:09:41 +01001256inline ::std::ostream &operator<<(::std::ostream &os, const KeyPoint &point)
1257{
1258 os << "{x=" << point.x << ","
1259 << "y=" << point.y << ","
1260 << "strength=" << point.strength << ","
1261 << "scale=" << point.scale << ","
1262 << "orientation=" << point.orientation << ","
1263 << "tracking_status=" << point.tracking_status << ","
1264 << "error=" << point.error << "}";
1265
1266 return os;
1267}
John Richardson63e50412017-10-13 20:51:42 +01001268
Alex Gildayc357c472018-03-21 13:54:09 +00001269/** Formatted output of the PhaseType type.
1270 *
1271 * @param[out] os Output stream
1272 * @param[in] phase_type Type to output.
1273 *
1274 * @return Modified output stream.
1275 */
John Richardson63e50412017-10-13 20:51:42 +01001276inline ::std::ostream &operator<<(::std::ostream &os, const PhaseType &phase_type)
1277{
1278 switch(phase_type)
1279 {
1280 case PhaseType::SIGNED:
1281 os << "SIGNED";
1282 break;
1283 case PhaseType::UNSIGNED:
1284 os << "UNSIGNED";
1285 break;
1286 default:
1287 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1288 }
1289
1290 return os;
1291}
1292
Alex Gildayc357c472018-03-21 13:54:09 +00001293/** Formatted output of the PhaseType type.
1294 *
1295 * @param[in] type Type to output.
1296 *
1297 * @return Formatted string.
1298 */
John Richardson63e50412017-10-13 20:51:42 +01001299inline std::string to_string(const arm_compute::PhaseType &type)
1300{
1301 std::stringstream str;
1302 str << type;
1303 return str.str();
1304}
John Richardson3c5f9492017-10-04 15:27:37 +01001305
Alex Gildayc357c472018-03-21 13:54:09 +00001306/** Formatted output of the MagnitudeType type.
1307 *
1308 * @param[out] os Output stream
1309 * @param[in] magnitude_type Type to output.
1310 *
1311 * @return Modified output stream.
1312 */
John Richardson3c5f9492017-10-04 15:27:37 +01001313inline ::std::ostream &operator<<(::std::ostream &os, const MagnitudeType &magnitude_type)
1314{
1315 switch(magnitude_type)
1316 {
1317 case MagnitudeType::L1NORM:
1318 os << "L1NORM";
1319 break;
1320 case MagnitudeType::L2NORM:
1321 os << "L2NORM";
1322 break;
1323 default:
1324 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1325 }
1326
1327 return os;
1328}
1329
Alex Gildayc357c472018-03-21 13:54:09 +00001330/** Formatted output of the MagnitudeType type.
1331 *
1332 * @param[in] type Type to output.
1333 *
1334 * @return Formatted string.
1335 */
John Richardson3c5f9492017-10-04 15:27:37 +01001336inline std::string to_string(const arm_compute::MagnitudeType &type)
1337{
1338 std::stringstream str;
1339 str << type;
1340 return str.str();
1341}
John Richardson1c529922017-11-01 10:57:48 +00001342
Alex Gildayc357c472018-03-21 13:54:09 +00001343/** Formatted output of the HOGNormType type.
1344 *
1345 * @param[out] os Output stream
1346 * @param[in] norm_type Type to output
1347 *
1348 * @return Modified output stream.
1349 */
John Richardson25f23682017-11-27 14:35:09 +00001350inline ::std::ostream &operator<<(::std::ostream &os, const HOGNormType &norm_type)
1351{
1352 switch(norm_type)
1353 {
1354 case HOGNormType::L1_NORM:
1355 os << "L1_NORM";
1356 break;
1357 case HOGNormType::L2_NORM:
1358 os << "L2_NORM";
1359 break;
1360 case HOGNormType::L2HYS_NORM:
1361 os << "L2HYS_NORM";
1362 break;
1363 default:
1364 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1365 }
1366
1367 return os;
1368}
1369
Alex Gildayc357c472018-03-21 13:54:09 +00001370/** Formatted output of the HOGNormType type.
1371 *
1372 * @param[in] type Type to output
1373 *
1374 * @return Formatted string.
1375 */
John Richardson25f23682017-11-27 14:35:09 +00001376inline std::string to_string(const HOGNormType &type)
1377{
1378 std::stringstream str;
1379 str << type;
1380 return str.str();
1381}
1382
Alex Gildayc357c472018-03-21 13:54:09 +00001383/** Formatted output of the Size2D type.
1384 *
1385 * @param[out] os Output stream
1386 * @param[in] size Type to output
1387 *
1388 * @return Modified output stream.
1389 */
John Richardson25f23682017-11-27 14:35:09 +00001390inline ::std::ostream &operator<<(::std::ostream &os, const Size2D &size)
1391{
1392 os << size.width << "x" << size.height;
1393
1394 return os;
1395}
1396
Alex Gildayc357c472018-03-21 13:54:09 +00001397/** Formatted output of the Size2D type.
1398 *
1399 * @param[in] type Type to output
1400 *
1401 * @return Formatted string.
1402 */
John Richardson25f23682017-11-27 14:35:09 +00001403inline std::string to_string(const Size2D &type)
1404{
1405 std::stringstream str;
1406 str << type;
1407 return str.str();
1408}
1409
Alex Gildayc357c472018-03-21 13:54:09 +00001410/** Formatted output of the HOGInfo type.
1411 *
1412 * @param[out] os Output stream
1413 * @param[in] hog_info Type to output
1414 *
1415 * @return Modified output stream.
1416 */
John Richardson25f23682017-11-27 14:35:09 +00001417inline ::std::ostream &operator<<(::std::ostream &os, const HOGInfo &hog_info)
1418{
1419 os << "{CellSize=" << hog_info.cell_size() << ","
1420 << "BlockSize=" << hog_info.block_size() << ","
1421 << "DetectionWindowSize=" << hog_info.detection_window_size() << ","
1422 << "BlockStride=" << hog_info.block_stride() << ","
1423 << "NumBins=" << hog_info.num_bins() << ","
1424 << "NormType=" << hog_info.normalization_type() << ","
1425 << "L2HystThreshold=" << hog_info.l2_hyst_threshold() << ","
1426 << "PhaseType=" << hog_info.phase_type() << "}";
1427
1428 return os;
1429}
1430
Alex Gildayc357c472018-03-21 13:54:09 +00001431/** Formatted output of the HOGInfo type.
1432 *
1433 * @param[in] type Type to output
1434 *
1435 * @return Formatted string.
1436 */
John Richardson25f23682017-11-27 14:35:09 +00001437inline std::string to_string(const HOGInfo &type)
1438{
1439 std::stringstream str;
1440 str << type;
1441 return str.str();
1442}
1443
Alex Gildayc357c472018-03-21 13:54:09 +00001444/** Formatted output of the ConvolutionMethod type.
1445 *
1446 * @param[out] os Output stream
1447 * @param[in] conv_method Type to output
1448 *
1449 * @return Modified output stream.
1450 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001451inline ::std::ostream &operator<<(::std::ostream &os, const ConvolutionMethod &conv_method)
1452{
1453 switch(conv_method)
1454 {
1455 case ConvolutionMethod::GEMM:
1456 os << "GEMM";
1457 break;
1458 case ConvolutionMethod::DIRECT:
1459 os << "DIRECT";
1460 break;
1461 case ConvolutionMethod::WINOGRAD:
1462 os << "WINOGRAD";
1463 break;
1464 default:
1465 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1466 }
1467
1468 return os;
1469}
1470
Alex Gildayc357c472018-03-21 13:54:09 +00001471/** Formatted output of the ConvolutionMethod type.
1472 *
1473 * @param[in] conv_method Type to output
1474 *
1475 * @return Formatted string.
1476 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001477inline std::string to_string(const ConvolutionMethod &conv_method)
1478{
1479 std::stringstream str;
1480 str << conv_method;
1481 return str.str();
1482}
1483
Alex Gildayc357c472018-03-21 13:54:09 +00001484/** Formatted output of the GPUTarget type.
1485 *
1486 * @param[out] os Output stream
1487 * @param[in] gpu_target Type to output
1488 *
1489 * @return Modified output stream.
1490 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001491inline ::std::ostream &operator<<(::std::ostream &os, const GPUTarget &gpu_target)
1492{
1493 switch(gpu_target)
1494 {
1495 case GPUTarget::GPU_ARCH_MASK:
1496 os << "GPU_ARCH_MASK";
1497 break;
1498 case GPUTarget::MIDGARD:
1499 os << "MIDGARD";
1500 break;
1501 case GPUTarget::BIFROST:
1502 os << "BIFROST";
1503 break;
1504 case GPUTarget::T600:
1505 os << "T600";
1506 break;
1507 case GPUTarget::T700:
1508 os << "T700";
1509 break;
1510 case GPUTarget::T800:
1511 os << "T800";
1512 break;
Michalis Spyroua9676112018-02-22 18:07:43 +00001513 case GPUTarget::G71:
1514 os << "G71";
1515 break;
1516 case GPUTarget::G72:
1517 os << "G72";
1518 break;
1519 case GPUTarget::G51:
1520 os << "G51";
1521 break;
1522 case GPUTarget::G51BIG:
1523 os << "G51BIG";
1524 break;
1525 case GPUTarget::G51LIT:
1526 os << "G51LIT";
1527 break;
Georgios Pinitasb03f7c52018-07-12 10:49:53 +01001528 case GPUTarget::G76:
1529 os << "G76";
Michalis Spyroua9676112018-02-22 18:07:43 +00001530 break;
1531 case GPUTarget::TTRX:
1532 os << "TTRX";
1533 break;
1534 case GPUTarget::TBOX:
1535 os << "TBOX";
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001536 break;
1537 default:
1538 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1539 }
1540
1541 return os;
1542}
1543
Alex Gildayc357c472018-03-21 13:54:09 +00001544/** Formatted output of the GPUTarget type.
1545 *
1546 * @param[in] gpu_target Type to output
1547 *
1548 * @return Formatted string.
1549 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001550inline std::string to_string(const GPUTarget &gpu_target)
1551{
1552 std::stringstream str;
1553 str << gpu_target;
1554 return str.str();
1555}
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00001556
John Richardson8de92612018-02-22 14:09:31 +00001557/** Formatted output of the DetectionWindow type.
1558 *
1559 * @param[out] os Output stream
1560 * @param[in] detection_window Type to output
1561 *
1562 * @return Modified output stream.
1563 */
John Richardson684cb0f2018-01-09 11:17:00 +00001564inline ::std::ostream &operator<<(::std::ostream &os, const DetectionWindow &detection_window)
1565{
1566 os << "{x=" << detection_window.x << ","
1567 << "y=" << detection_window.y << ","
1568 << "width=" << detection_window.width << ","
1569 << "height=" << detection_window.height << ","
1570 << "idx_class=" << detection_window.idx_class << ","
1571 << "score=" << detection_window.score << "}";
1572
1573 return os;
1574}
1575
John Richardson8de92612018-02-22 14:09:31 +00001576/** Formatted output of the DetectionWindow type.
1577 *
1578 * @param[in] detection_window Type to output
1579 *
1580 * @return Formatted string.
1581 */
1582inline std::string to_string(const DetectionWindow &detection_window)
1583{
1584 std::stringstream str;
1585 str << detection_window;
1586 return str.str();
1587}
1588
1589/** Formatted output of the Termination type.
1590 *
1591 * @param[out] os Output stream
1592 * @param[in] termination Type to output
1593 *
1594 * @return Modified output stream.
1595 */
1596inline ::std::ostream &operator<<(::std::ostream &os, const Termination &termination)
1597{
1598 switch(termination)
1599 {
1600 case Termination::TERM_CRITERIA_EPSILON:
1601 os << "TERM_CRITERIA_EPSILON";
1602 break;
1603 case Termination::TERM_CRITERIA_ITERATIONS:
1604 os << "TERM_CRITERIA_ITERATIONS";
1605 break;
1606 case Termination::TERM_CRITERIA_BOTH:
1607 os << "TERM_CRITERIA_BOTH";
1608 break;
1609 default:
1610 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1611 }
1612
1613 return os;
1614}
1615
1616/** Formatted output of the Termination type.
1617 *
1618 * @param[in] termination Type to output
1619 *
1620 * @return Formatted string.
1621 */
1622inline std::string to_string(const Termination &termination)
1623{
1624 std::stringstream str;
1625 str << termination;
1626 return str.str();
1627}
1628
Anthony Barbier8914e322018-08-10 15:28:25 +01001629/** Formatted output of the CPUModel type.
1630 *
1631 * @param[out] os Output stream
1632 * @param[in] cpu_model Model to output
1633 *
1634 * @return Modified output stream.
1635 */
1636inline ::std::ostream &operator<<(::std::ostream &os, const CPUModel &cpu_model)
1637{
1638 switch(cpu_model)
1639 {
1640 case CPUModel::GENERIC:
1641 os << "GENERIC";
1642 break;
1643 case CPUModel::GENERIC_FP16:
1644 os << "GENERIC_FP16";
1645 break;
1646 case CPUModel::GENERIC_FP16_DOT:
1647 os << "GENERIC_FP16_DOT";
1648 break;
1649 case CPUModel::A53:
1650 os << "A53";
1651 break;
1652 case CPUModel::A55r0:
1653 os << "A55r0";
1654 break;
1655 case CPUModel::A55r1:
1656 os << "A55r1";
1657 break;
1658 default:
1659 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1660 }
1661
1662 return os;
1663}
1664
1665/** Formatted output of the CPUModel type.
1666 *
1667 * @param[in] cpu_model Model to output
1668 *
1669 * @return Formatted string.
1670 */
1671inline std::string to_string(const CPUModel &cpu_model)
1672{
1673 std::stringstream str;
1674 str << cpu_model;
1675 return str.str();
1676}
Anthony Barbier671a11e2018-07-06 15:11:36 +01001677/** Formatted output of a vector of objects.
1678 *
1679 * @param[out] os Output stream
1680 * @param[in] args Vector of objects to print
1681 *
1682 * @return Modified output stream.
1683 */
1684template <typename T>
1685inline ::std::ostream &operator<<(::std::ostream &os, const std::vector<T> &args)
1686{
1687 os << "[";
1688 bool first = true;
1689 for(auto &arg : args)
1690 {
1691 if(first)
1692 {
1693 first = false;
1694 }
1695 else
1696 {
1697 os << ", ";
1698 }
1699 os << arg;
1700 }
1701 os << "]";
1702 return os;
1703}
1704
1705/** Formatted output of a vector of objects.
1706 *
1707 * @param[in] args Vector of objects to print
1708 *
1709 * @return String representing args.
1710 */
1711template <typename T>
1712std::string to_string(const std::vector<T> &args)
1713{
1714 std::stringstream str;
1715 str << args;
1716 return str.str();
1717}
1718
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00001719/** Formatted output of the WinogradInfo type. */
1720inline ::std::ostream &operator<<(::std::ostream &os, const WinogradInfo &info)
1721{
1722 os << "{OutputTileSize=" << info.output_tile_size << ","
1723 << "KernelSize=" << info.kernel_size << ","
1724 << "PadStride=" << info.convolution_info << ","
1725 << "OutputDataLayout=" << info.output_data_layout << "}";
1726
1727 return os;
1728}
1729
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00001730inline std::string to_string(const WinogradInfo &type)
1731{
1732 std::stringstream str;
1733 str << type;
1734 return str.str();
1735}
Anthony Barbier671a11e2018-07-06 15:11:36 +01001736
1737/** Fallback method: try to use std::to_string:
1738 *
1739 * @param[in] val Value to convert to string
1740 *
1741 * @return String representing val.
1742 */
1743template <typename T>
1744inline std::string to_string(const T &val)
1745{
1746 return support::cpp11::to_string(val);
1747}
1748
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001749} // namespace arm_compute
Anthony Barbier4dbc0a92018-08-27 13:39:47 +01001750
1751#endif /* __ARM_COMPUTE_TYPE_PRINTER_H__ */