blob: d31c16c32ba22fdb5371fd58b2877fcab73c2bb5 [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
Giuseppe Rossinid7647d42018-07-17 18:13:13 +0100772/** Formatted output of the PaddingList type.
773 *
774 * @param[out] os Output stream.
775 * @param[in] padding Type to output.
776 *
777 * @return Modified output stream.
778 */
779inline ::std::ostream &operator<<(::std::ostream &os, const PaddingList &padding)
780{
781 os << "{";
782 for(auto const &p : padding)
783 {
784 os << "{" << p.first << "," << p.second << "}";
785 }
786 os << "}";
787 return os;
788}
789
Alex Gildayc357c472018-03-21 13:54:09 +0000790/** Formatted output of the InterpolationPolicy type.
791 *
792 * @param[out] os Output stream.
793 * @param[in] policy Type to output.
794 *
795 * @return Modified output stream.
796 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100797inline ::std::ostream &operator<<(::std::ostream &os, const InterpolationPolicy &policy)
798{
799 switch(policy)
800 {
801 case InterpolationPolicy::NEAREST_NEIGHBOR:
802 os << "NEAREST_NEIGHBOR";
803 break;
804 case InterpolationPolicy::BILINEAR:
805 os << "BILINEAR";
806 break;
807 case InterpolationPolicy::AREA:
808 os << "AREA";
809 break;
810 default:
811 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
812 }
813
814 return os;
815}
816
Alex Gildayc357c472018-03-21 13:54:09 +0000817/** Formatted output of the SamplingPolicy type.
818 *
819 * @param[out] os Output stream.
820 * @param[in] policy Type to output.
821 *
822 * @return Modified output stream.
823 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700824inline ::std::ostream &operator<<(::std::ostream &os, const SamplingPolicy &policy)
825{
826 switch(policy)
827 {
828 case SamplingPolicy::CENTER:
829 os << "CENTER";
830 break;
831 case SamplingPolicy::TOP_LEFT:
832 os << "TOP_LEFT";
833 break;
834 default:
835 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
836 }
837
838 return os;
839}
840
Alex Gildayc357c472018-03-21 13:54:09 +0000841/** Formatted output of the TensorInfo type.
842 *
Anthony Barbier366628a2018-08-01 13:55:03 +0100843 * @param[out] os Output stream.
844 * @param[in] info Type to output.
845 *
846 * @return Modified output stream.
847 */
848inline ::std::ostream &operator<<(::std::ostream &os, const TensorInfo &info)
849{
850 os << "{Shape=" << info.tensor_shape() << ","
851 << "Type=" << info.data_type() << ","
852 << "Channels=" << info.num_channels() << "}";
853 return os;
854}
855/** Formatted output of the TensorInfo type.
856 *
Alex Gildayc357c472018-03-21 13:54:09 +0000857 * @param[in] info Type to output.
858 *
859 * @return Formatted string.
860 */
Georgios Pinitas3faea252017-10-30 14:13:50 +0000861inline std::string to_string(const TensorInfo &info)
862{
863 std::stringstream str;
Anthony Barbier366628a2018-08-01 13:55:03 +0100864 str << info;
Georgios Pinitas3faea252017-10-30 14:13:50 +0000865 return str.str();
866}
867
Abe Mbise925ca0f2017-10-02 19:16:33 +0100868//FIXME: Check why this doesn't work and the TensorShape and Coordinates overload are needed
Alex Gildayc357c472018-03-21 13:54:09 +0000869/** Formatted output of the Dimensions type.
870 *
871 * @param[in] dimensions Type to output.
872 *
873 * @return Formatted string.
874 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100875template <typename T>
876inline std::string to_string(const Dimensions<T> &dimensions)
877{
878 std::stringstream str;
879 str << dimensions;
880 return str.str();
881}
882
Alex Gildayc357c472018-03-21 13:54:09 +0000883/** Formatted output of the Strides type.
884 *
885 * @param[in] stride Type to output.
886 *
887 * @return Formatted string.
888 */
John Richardsona36eae12017-09-26 16:55:59 +0100889inline std::string to_string(const Strides &stride)
890{
891 std::stringstream str;
892 str << stride;
893 return str.str();
894}
895
Alex Gildayc357c472018-03-21 13:54:09 +0000896/** Formatted output of the TensorShape type.
897 *
898 * @param[in] shape Type to output.
899 *
900 * @return Formatted string.
901 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100902inline std::string to_string(const TensorShape &shape)
903{
904 std::stringstream str;
905 str << shape;
906 return str.str();
907}
908
Alex Gildayc357c472018-03-21 13:54:09 +0000909/** Formatted output of the Coordinates type.
910 *
911 * @param[in] coord Type to output.
912 *
913 * @return Formatted string.
914 */
Abe Mbise925ca0f2017-10-02 19:16:33 +0100915inline std::string to_string(const Coordinates &coord)
916{
917 std::stringstream str;
918 str << coord;
919 return str.str();
920}
921
Anthony Barbierb940fd62018-06-04 14:14:32 +0100922/** Formatted output of the GEMMReshapeInfo type.
923 *
924 * @param[out] os Output stream.
925 * @param[in] info Type to output.
926 *
927 * @return Modified output stream.
928 */
929inline ::std::ostream &operator<<(::std::ostream &os, const GEMMReshapeInfo &info)
930{
931 os << "{m=" << info.m() << ",";
932 os << "n=" << info.n() << ",";
933 os << "k=" << info.k() << ",";
934 os << "mult_transpose1xW_width=" << info.mult_transpose1xW_width() << ",";
935 os << "mult_interleave4x4_height=" << info.mult_interleave4x4_height();
936 os << "}";
937
938 return os;
939}
940
941/** Formatted output of the GEMMInfo type.
942 *
943 * @param[out] os Output stream.
944 * @param[in] info Type to output.
945 *
946 * @return Modified output stream.
947 */
948inline ::std::ostream &operator<<(::std::ostream &os, const GEMMInfo &info)
949{
950 os << "{is_a_reshaped=" << info.is_a_reshaped() << ",";
951 os << "is_b_reshaped=" << info.is_b_reshaped() << ",";
952 os << "reshape_b_only_on_first_run=" << info.reshape_b_only_on_first_run() << ",";
Anthony Barbierb940fd62018-06-04 14:14:32 +0100953 os << "}";
954
955 return os;
956}
957
958/** Formatted output of the Window::Dimension type.
959 *
960 * @param[out] os Output stream.
961 * @param[in] dim Type to output.
962 *
963 * @return Modified output stream.
964 */
965inline ::std::ostream &operator<<(::std::ostream &os, const Window::Dimension &dim)
966{
967 os << "{start=" << dim.start() << ", end=" << dim.end() << ", step=" << dim.step() << "}";
968
969 return os;
970}
971/** Formatted output of the Window type.
972 *
973 * @param[out] os Output stream.
974 * @param[in] win Type to output.
975 *
976 * @return Modified output stream.
977 */
978inline ::std::ostream &operator<<(::std::ostream &os, const Window &win)
979{
980 os << "{";
981 for(unsigned int i = 0; i < Coordinates::num_max_dimensions; i++)
982 {
983 if(i > 0)
984 {
985 os << ", ";
986 }
987 os << win[i];
988 }
989 os << "}";
990
991 return os;
992}
993
994/** Formatted output of the WeightsInfo type.
995 *
996 * @param[in] info Type to output.
997 *
998 * @return Formatted string.
999 */
1000inline std::string to_string(const WeightsInfo &info)
1001{
1002 std::stringstream str;
1003 str << info;
1004 return str.str();
1005}
1006
1007/** Formatted output of the GEMMReshapeInfo type.
1008 *
1009 * @param[in] info Type to output.
1010 *
1011 * @return Formatted string.
1012 */
1013inline std::string to_string(const GEMMReshapeInfo &info)
1014{
1015 std::stringstream str;
1016 str << info;
1017 return str.str();
1018}
1019
1020/** Formatted output of the GEMMInfo type.
1021 *
1022 * @param[in] info Type to output.
1023 *
1024 * @return Formatted string.
1025 */
1026inline std::string to_string(const GEMMInfo &info)
1027{
1028 std::stringstream str;
1029 str << info;
1030 return str.str();
1031}
1032
1033/** Formatted output of the Window::Dimension type.
1034 *
1035 * @param[in] dim Type to output.
1036 *
1037 * @return Formatted string.
1038 */
1039inline std::string to_string(const Window::Dimension &dim)
1040{
1041 std::stringstream str;
1042 str << dim;
1043 return str.str();
1044}
1045/** Formatted output of the Window type.
1046 *
1047 * @param[in] win Type to output.
1048 *
1049 * @return Formatted string.
1050 */
1051inline std::string to_string(const Window &win)
1052{
1053 std::stringstream str;
1054 str << win;
1055 return str.str();
1056}
1057
Alex Gildayc357c472018-03-21 13:54:09 +00001058/** Formatted output of the Rectangle type.
1059 *
1060 * @param[out] os Output stream.
1061 * @param[in] rect Type to output.
1062 *
1063 * @return Modified output stream.
1064 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001065inline ::std::ostream &operator<<(::std::ostream &os, const Rectangle &rect)
1066{
1067 os << rect.width << "x" << rect.height;
1068 os << "+" << rect.x << "+" << rect.y;
1069
1070 return os;
1071}
1072
Alex Gildayc357c472018-03-21 13:54:09 +00001073/** Formatted output of the PadStrideInfo type.
1074 *
1075 * @param[out] os Output stream.
1076 * @param[in] pad_stride_info Type to output.
1077 *
1078 * @return Modified output stream.
1079 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001080inline ::std::ostream &operator<<(::std::ostream &os, const PadStrideInfo &pad_stride_info)
1081{
1082 os << pad_stride_info.stride().first << "," << pad_stride_info.stride().second;
1083 os << ";";
Jaroslaw Rzepeckia1ed41f2017-10-13 11:13:58 +01001084 os << pad_stride_info.pad_left() << "," << pad_stride_info.pad_right() << ","
1085 << pad_stride_info.pad_top() << "," << pad_stride_info.pad_bottom();
Anthony Barbier2a07e182017-08-04 18:20:27 +01001086
1087 return os;
1088}
1089
Alex Gildayc357c472018-03-21 13:54:09 +00001090/** Formatted output of the PadStrideInfo type.
1091 *
1092 * @param[in] pad_stride_info Type to output.
1093 *
1094 * @return Formatted string.
1095 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001096inline std::string to_string(const PadStrideInfo &pad_stride_info)
1097{
1098 std::stringstream str;
1099 str << pad_stride_info;
1100 return str.str();
1101}
1102
Alex Gildayc357c472018-03-21 13:54:09 +00001103/** Formatted output of the BorderMode type.
1104 *
1105 * @param[in] mode Type to output.
1106 *
1107 * @return Formatted string.
1108 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001109inline std::string to_string(const BorderMode &mode)
1110{
1111 std::stringstream str;
1112 str << mode;
1113 return str.str();
1114}
1115
Alex Gildayc357c472018-03-21 13:54:09 +00001116/** Formatted output of the BorderSize type.
1117 *
1118 * @param[in] border Type to output.
1119 *
1120 * @return Formatted string.
1121 */
John Richardsonb482ce12017-09-18 12:44:01 +01001122inline std::string to_string(const BorderSize &border)
1123{
1124 std::stringstream str;
1125 str << border;
1126 return str.str();
1127}
1128
Giuseppe Rossinid7647d42018-07-17 18:13:13 +01001129/** Formatted output of the PaddingList type.
1130 *
1131 * @param[in] padding Type to output.
1132 *
1133 * @return Formatted string.
1134 */
1135inline std::string to_string(const PaddingList &padding)
1136{
1137 std::stringstream str;
1138 str << padding;
1139 return str.str();
1140}
1141
Alex Gildayc357c472018-03-21 13:54:09 +00001142/** Formatted output of the InterpolationPolicy type.
1143 *
1144 * @param[in] policy Type to output.
1145 *
1146 * @return Formatted string.
1147 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001148inline std::string to_string(const InterpolationPolicy &policy)
1149{
1150 std::stringstream str;
1151 str << policy;
1152 return str.str();
1153}
1154
Alex Gildayc357c472018-03-21 13:54:09 +00001155/** Formatted output of the SamplingPolicy type.
1156 *
1157 * @param[in] policy Type to output.
1158 *
1159 * @return Formatted string.
1160 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +07001161inline std::string to_string(const SamplingPolicy &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 ConvertPolicy type.
1169 *
1170 * @param[out] os Output stream.
1171 * @param[in] policy 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 ConvertPolicy &policy)
1176{
1177 switch(policy)
1178 {
1179 case ConvertPolicy::WRAP:
1180 os << "WRAP";
1181 break;
1182 case ConvertPolicy::SATURATE:
1183 os << "SATURATE";
1184 break;
1185 default:
1186 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1187 }
1188
1189 return os;
1190}
1191
1192inline std::string to_string(const ConvertPolicy &policy)
1193{
1194 std::stringstream str;
1195 str << policy;
1196 return str.str();
1197}
1198
Alex Gildayc357c472018-03-21 13:54:09 +00001199/** Formatted output of the Reduction Operations.
1200 *
1201 * @param[out] os Output stream.
1202 * @param[in] op Type to output.
1203 *
1204 * @return Modified output stream.
1205 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001206inline ::std::ostream &operator<<(::std::ostream &os, const ReductionOperation &op)
1207{
1208 switch(op)
1209 {
1210 case ReductionOperation::SUM_SQUARE:
1211 os << "SUM_SQUARE";
1212 break;
1213 default:
1214 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1215 }
1216
1217 return os;
1218}
1219
Alex Gildayc357c472018-03-21 13:54:09 +00001220/** Formatted output of the Reduction Operations.
1221 *
1222 * @param[in] op Type to output.
1223 *
1224 * @return Formatted string.
1225 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001226inline std::string to_string(const ReductionOperation &op)
1227{
1228 std::stringstream str;
1229 str << op;
1230 return str.str();
1231}
1232
Alex Gildayc357c472018-03-21 13:54:09 +00001233/** Formatted output of the Norm Type.
1234 *
1235 * @param[in] type Type to output.
1236 *
1237 * @return Formatted string.
1238 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001239inline std::string to_string(const NormType &type)
1240{
1241 std::stringstream str;
1242 str << type;
1243 return str.str();
1244}
1245
Alex Gildayc357c472018-03-21 13:54:09 +00001246/** Formatted output of the Pooling Type.
1247 *
1248 * @param[in] type Type to output.
1249 *
1250 * @return Formatted string.
1251 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001252inline std::string to_string(const PoolingType &type)
1253{
1254 std::stringstream str;
1255 str << type;
1256 return str.str();
1257}
1258
Alex Gildayc357c472018-03-21 13:54:09 +00001259/** Formatted output of the Pooling Layer Info.
1260 *
1261 * @param[in] info Type to output.
1262 *
1263 * @return Formatted string.
1264 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001265inline std::string to_string(const PoolingLayerInfo &info)
1266{
1267 std::stringstream str;
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001268 str << "{Type=" << info.pool_type() << ","
1269 << "IsGlobalPooling=" << info.is_global_pooling();
1270 if(!info.is_global_pooling())
1271 {
1272 str << ","
Isabella Gottardi6e464c32018-01-26 12:32:45 +00001273 << "PoolSize=" << info.pool_size().width << "," << info.pool_size().height << ","
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001274 << "PadStride=" << info.pad_stride_info();
1275 }
1276 str << "}";
Anthony Barbier2a07e182017-08-04 18:20:27 +01001277 return str.str();
1278}
1279
Alex Gildayc357c472018-03-21 13:54:09 +00001280/** Formatted output of the KeyPoint type.
1281 *
1282 * @param[out] os Output stream
1283 * @param[in] point Type to output.
1284 *
1285 * @return Modified output stream.
1286 */
Moritz Pflanzer6c6597c2017-09-24 12:09:41 +01001287inline ::std::ostream &operator<<(::std::ostream &os, const KeyPoint &point)
1288{
1289 os << "{x=" << point.x << ","
1290 << "y=" << point.y << ","
1291 << "strength=" << point.strength << ","
1292 << "scale=" << point.scale << ","
1293 << "orientation=" << point.orientation << ","
1294 << "tracking_status=" << point.tracking_status << ","
1295 << "error=" << point.error << "}";
1296
1297 return os;
1298}
John Richardson63e50412017-10-13 20:51:42 +01001299
Alex Gildayc357c472018-03-21 13:54:09 +00001300/** Formatted output of the PhaseType type.
1301 *
1302 * @param[out] os Output stream
1303 * @param[in] phase_type Type to output.
1304 *
1305 * @return Modified output stream.
1306 */
John Richardson63e50412017-10-13 20:51:42 +01001307inline ::std::ostream &operator<<(::std::ostream &os, const PhaseType &phase_type)
1308{
1309 switch(phase_type)
1310 {
1311 case PhaseType::SIGNED:
1312 os << "SIGNED";
1313 break;
1314 case PhaseType::UNSIGNED:
1315 os << "UNSIGNED";
1316 break;
1317 default:
1318 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1319 }
1320
1321 return os;
1322}
1323
Alex Gildayc357c472018-03-21 13:54:09 +00001324/** Formatted output of the PhaseType type.
1325 *
1326 * @param[in] type Type to output.
1327 *
1328 * @return Formatted string.
1329 */
John Richardson63e50412017-10-13 20:51:42 +01001330inline std::string to_string(const arm_compute::PhaseType &type)
1331{
1332 std::stringstream str;
1333 str << type;
1334 return str.str();
1335}
John Richardson3c5f9492017-10-04 15:27:37 +01001336
Alex Gildayc357c472018-03-21 13:54:09 +00001337/** Formatted output of the MagnitudeType type.
1338 *
1339 * @param[out] os Output stream
1340 * @param[in] magnitude_type Type to output.
1341 *
1342 * @return Modified output stream.
1343 */
John Richardson3c5f9492017-10-04 15:27:37 +01001344inline ::std::ostream &operator<<(::std::ostream &os, const MagnitudeType &magnitude_type)
1345{
1346 switch(magnitude_type)
1347 {
1348 case MagnitudeType::L1NORM:
1349 os << "L1NORM";
1350 break;
1351 case MagnitudeType::L2NORM:
1352 os << "L2NORM";
1353 break;
1354 default:
1355 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1356 }
1357
1358 return os;
1359}
1360
Alex Gildayc357c472018-03-21 13:54:09 +00001361/** Formatted output of the MagnitudeType type.
1362 *
1363 * @param[in] type Type to output.
1364 *
1365 * @return Formatted string.
1366 */
John Richardson3c5f9492017-10-04 15:27:37 +01001367inline std::string to_string(const arm_compute::MagnitudeType &type)
1368{
1369 std::stringstream str;
1370 str << type;
1371 return str.str();
1372}
John Richardson1c529922017-11-01 10:57:48 +00001373
Alex Gildayc357c472018-03-21 13:54:09 +00001374/** Formatted output of the HOGNormType type.
1375 *
1376 * @param[out] os Output stream
1377 * @param[in] norm_type Type to output
1378 *
1379 * @return Modified output stream.
1380 */
John Richardson25f23682017-11-27 14:35:09 +00001381inline ::std::ostream &operator<<(::std::ostream &os, const HOGNormType &norm_type)
1382{
1383 switch(norm_type)
1384 {
1385 case HOGNormType::L1_NORM:
1386 os << "L1_NORM";
1387 break;
1388 case HOGNormType::L2_NORM:
1389 os << "L2_NORM";
1390 break;
1391 case HOGNormType::L2HYS_NORM:
1392 os << "L2HYS_NORM";
1393 break;
1394 default:
1395 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1396 }
1397
1398 return os;
1399}
1400
Alex Gildayc357c472018-03-21 13:54:09 +00001401/** Formatted output of the HOGNormType type.
1402 *
1403 * @param[in] type Type to output
1404 *
1405 * @return Formatted string.
1406 */
John Richardson25f23682017-11-27 14:35:09 +00001407inline std::string to_string(const HOGNormType &type)
1408{
1409 std::stringstream str;
1410 str << type;
1411 return str.str();
1412}
1413
Alex Gildayc357c472018-03-21 13:54:09 +00001414/** Formatted output of the Size2D type.
1415 *
1416 * @param[out] os Output stream
1417 * @param[in] size Type to output
1418 *
1419 * @return Modified output stream.
1420 */
John Richardson25f23682017-11-27 14:35:09 +00001421inline ::std::ostream &operator<<(::std::ostream &os, const Size2D &size)
1422{
1423 os << size.width << "x" << size.height;
1424
1425 return os;
1426}
1427
Alex Gildayc357c472018-03-21 13:54:09 +00001428/** Formatted output of the Size2D type.
1429 *
1430 * @param[in] type Type to output
1431 *
1432 * @return Formatted string.
1433 */
John Richardson25f23682017-11-27 14:35:09 +00001434inline std::string to_string(const Size2D &type)
1435{
1436 std::stringstream str;
1437 str << type;
1438 return str.str();
1439}
1440
Alex Gildayc357c472018-03-21 13:54:09 +00001441/** Formatted output of the HOGInfo type.
1442 *
1443 * @param[out] os Output stream
1444 * @param[in] hog_info Type to output
1445 *
1446 * @return Modified output stream.
1447 */
John Richardson25f23682017-11-27 14:35:09 +00001448inline ::std::ostream &operator<<(::std::ostream &os, const HOGInfo &hog_info)
1449{
1450 os << "{CellSize=" << hog_info.cell_size() << ","
1451 << "BlockSize=" << hog_info.block_size() << ","
1452 << "DetectionWindowSize=" << hog_info.detection_window_size() << ","
1453 << "BlockStride=" << hog_info.block_stride() << ","
1454 << "NumBins=" << hog_info.num_bins() << ","
1455 << "NormType=" << hog_info.normalization_type() << ","
1456 << "L2HystThreshold=" << hog_info.l2_hyst_threshold() << ","
1457 << "PhaseType=" << hog_info.phase_type() << "}";
1458
1459 return os;
1460}
1461
Alex Gildayc357c472018-03-21 13:54:09 +00001462/** Formatted output of the HOGInfo type.
1463 *
1464 * @param[in] type Type to output
1465 *
1466 * @return Formatted string.
1467 */
John Richardson25f23682017-11-27 14:35:09 +00001468inline std::string to_string(const HOGInfo &type)
1469{
1470 std::stringstream str;
1471 str << type;
1472 return str.str();
1473}
1474
Alex Gildayc357c472018-03-21 13:54:09 +00001475/** Formatted output of the ConvolutionMethod type.
1476 *
1477 * @param[out] os Output stream
1478 * @param[in] conv_method Type to output
1479 *
1480 * @return Modified output stream.
1481 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001482inline ::std::ostream &operator<<(::std::ostream &os, const ConvolutionMethod &conv_method)
1483{
1484 switch(conv_method)
1485 {
1486 case ConvolutionMethod::GEMM:
1487 os << "GEMM";
1488 break;
1489 case ConvolutionMethod::DIRECT:
1490 os << "DIRECT";
1491 break;
1492 case ConvolutionMethod::WINOGRAD:
1493 os << "WINOGRAD";
1494 break;
1495 default:
1496 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1497 }
1498
1499 return os;
1500}
1501
Alex Gildayc357c472018-03-21 13:54:09 +00001502/** Formatted output of the ConvolutionMethod type.
1503 *
1504 * @param[in] conv_method Type to output
1505 *
1506 * @return Formatted string.
1507 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001508inline std::string to_string(const ConvolutionMethod &conv_method)
1509{
1510 std::stringstream str;
1511 str << conv_method;
1512 return str.str();
1513}
1514
Alex Gildayc357c472018-03-21 13:54:09 +00001515/** Formatted output of the GPUTarget type.
1516 *
1517 * @param[out] os Output stream
1518 * @param[in] gpu_target Type to output
1519 *
1520 * @return Modified output stream.
1521 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001522inline ::std::ostream &operator<<(::std::ostream &os, const GPUTarget &gpu_target)
1523{
1524 switch(gpu_target)
1525 {
1526 case GPUTarget::GPU_ARCH_MASK:
1527 os << "GPU_ARCH_MASK";
1528 break;
1529 case GPUTarget::MIDGARD:
1530 os << "MIDGARD";
1531 break;
1532 case GPUTarget::BIFROST:
1533 os << "BIFROST";
1534 break;
1535 case GPUTarget::T600:
1536 os << "T600";
1537 break;
1538 case GPUTarget::T700:
1539 os << "T700";
1540 break;
1541 case GPUTarget::T800:
1542 os << "T800";
1543 break;
Michalis Spyroua9676112018-02-22 18:07:43 +00001544 case GPUTarget::G71:
1545 os << "G71";
1546 break;
1547 case GPUTarget::G72:
1548 os << "G72";
1549 break;
1550 case GPUTarget::G51:
1551 os << "G51";
1552 break;
1553 case GPUTarget::G51BIG:
1554 os << "G51BIG";
1555 break;
1556 case GPUTarget::G51LIT:
1557 os << "G51LIT";
1558 break;
Georgios Pinitasb03f7c52018-07-12 10:49:53 +01001559 case GPUTarget::G76:
1560 os << "G76";
Michalis Spyroua9676112018-02-22 18:07:43 +00001561 break;
1562 case GPUTarget::TTRX:
1563 os << "TTRX";
1564 break;
1565 case GPUTarget::TBOX:
1566 os << "TBOX";
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001567 break;
1568 default:
1569 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1570 }
1571
1572 return os;
1573}
1574
Alex Gildayc357c472018-03-21 13:54:09 +00001575/** Formatted output of the GPUTarget type.
1576 *
1577 * @param[in] gpu_target Type to output
1578 *
1579 * @return Formatted string.
1580 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001581inline std::string to_string(const GPUTarget &gpu_target)
1582{
1583 std::stringstream str;
1584 str << gpu_target;
1585 return str.str();
1586}
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00001587
John Richardson8de92612018-02-22 14:09:31 +00001588/** Formatted output of the DetectionWindow type.
1589 *
1590 * @param[out] os Output stream
1591 * @param[in] detection_window Type to output
1592 *
1593 * @return Modified output stream.
1594 */
John Richardson684cb0f2018-01-09 11:17:00 +00001595inline ::std::ostream &operator<<(::std::ostream &os, const DetectionWindow &detection_window)
1596{
1597 os << "{x=" << detection_window.x << ","
1598 << "y=" << detection_window.y << ","
1599 << "width=" << detection_window.width << ","
1600 << "height=" << detection_window.height << ","
1601 << "idx_class=" << detection_window.idx_class << ","
1602 << "score=" << detection_window.score << "}";
1603
1604 return os;
1605}
1606
John Richardson8de92612018-02-22 14:09:31 +00001607/** Formatted output of the DetectionWindow type.
1608 *
1609 * @param[in] detection_window Type to output
1610 *
1611 * @return Formatted string.
1612 */
1613inline std::string to_string(const DetectionWindow &detection_window)
1614{
1615 std::stringstream str;
1616 str << detection_window;
1617 return str.str();
1618}
1619
1620/** Formatted output of the Termination type.
1621 *
1622 * @param[out] os Output stream
1623 * @param[in] termination Type to output
1624 *
1625 * @return Modified output stream.
1626 */
1627inline ::std::ostream &operator<<(::std::ostream &os, const Termination &termination)
1628{
1629 switch(termination)
1630 {
1631 case Termination::TERM_CRITERIA_EPSILON:
1632 os << "TERM_CRITERIA_EPSILON";
1633 break;
1634 case Termination::TERM_CRITERIA_ITERATIONS:
1635 os << "TERM_CRITERIA_ITERATIONS";
1636 break;
1637 case Termination::TERM_CRITERIA_BOTH:
1638 os << "TERM_CRITERIA_BOTH";
1639 break;
1640 default:
1641 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1642 }
1643
1644 return os;
1645}
1646
1647/** Formatted output of the Termination type.
1648 *
1649 * @param[in] termination Type to output
1650 *
1651 * @return Formatted string.
1652 */
1653inline std::string to_string(const Termination &termination)
1654{
1655 std::stringstream str;
1656 str << termination;
1657 return str.str();
1658}
1659
Anthony Barbier8914e322018-08-10 15:28:25 +01001660/** Formatted output of the CPUModel type.
1661 *
1662 * @param[out] os Output stream
1663 * @param[in] cpu_model Model to output
1664 *
1665 * @return Modified output stream.
1666 */
1667inline ::std::ostream &operator<<(::std::ostream &os, const CPUModel &cpu_model)
1668{
1669 switch(cpu_model)
1670 {
1671 case CPUModel::GENERIC:
1672 os << "GENERIC";
1673 break;
1674 case CPUModel::GENERIC_FP16:
1675 os << "GENERIC_FP16";
1676 break;
1677 case CPUModel::GENERIC_FP16_DOT:
1678 os << "GENERIC_FP16_DOT";
1679 break;
1680 case CPUModel::A53:
1681 os << "A53";
1682 break;
1683 case CPUModel::A55r0:
1684 os << "A55r0";
1685 break;
1686 case CPUModel::A55r1:
1687 os << "A55r1";
1688 break;
1689 default:
1690 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1691 }
1692
1693 return os;
1694}
1695
1696/** Formatted output of the CPUModel type.
1697 *
1698 * @param[in] cpu_model Model to output
1699 *
1700 * @return Formatted string.
1701 */
1702inline std::string to_string(const CPUModel &cpu_model)
1703{
1704 std::stringstream str;
1705 str << cpu_model;
1706 return str.str();
1707}
Anthony Barbier671a11e2018-07-06 15:11:36 +01001708/** Formatted output of a vector of objects.
1709 *
1710 * @param[out] os Output stream
1711 * @param[in] args Vector of objects to print
1712 *
1713 * @return Modified output stream.
1714 */
1715template <typename T>
1716inline ::std::ostream &operator<<(::std::ostream &os, const std::vector<T> &args)
1717{
1718 os << "[";
1719 bool first = true;
1720 for(auto &arg : args)
1721 {
1722 if(first)
1723 {
1724 first = false;
1725 }
1726 else
1727 {
1728 os << ", ";
1729 }
1730 os << arg;
1731 }
1732 os << "]";
1733 return os;
1734}
1735
1736/** Formatted output of a vector of objects.
1737 *
1738 * @param[in] args Vector of objects to print
1739 *
1740 * @return String representing args.
1741 */
1742template <typename T>
1743std::string to_string(const std::vector<T> &args)
1744{
1745 std::stringstream str;
1746 str << args;
1747 return str.str();
1748}
1749
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00001750/** Formatted output of the WinogradInfo type. */
1751inline ::std::ostream &operator<<(::std::ostream &os, const WinogradInfo &info)
1752{
1753 os << "{OutputTileSize=" << info.output_tile_size << ","
1754 << "KernelSize=" << info.kernel_size << ","
1755 << "PadStride=" << info.convolution_info << ","
1756 << "OutputDataLayout=" << info.output_data_layout << "}";
1757
1758 return os;
1759}
1760
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00001761inline std::string to_string(const WinogradInfo &type)
1762{
1763 std::stringstream str;
1764 str << type;
1765 return str.str();
1766}
Anthony Barbier671a11e2018-07-06 15:11:36 +01001767
1768/** Fallback method: try to use std::to_string:
1769 *
1770 * @param[in] val Value to convert to string
1771 *
1772 * @return String representing val.
1773 */
1774template <typename T>
1775inline std::string to_string(const T &val)
1776{
1777 return support::cpp11::to_string(val);
1778}
1779
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001780} // namespace arm_compute
Anthony Barbier4dbc0a92018-08-27 13:39:47 +01001781
1782#endif /* __ARM_COMPUTE_TYPE_PRINTER_H__ */