blob: b868aa94a1eb7b14b9735ba56d88eb53b0071958 [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
giuros0118870812018-09-13 09:31:40 +0100223/** Formatted output of the ROIPoolingInfo type.
224 *
225 * @param[in] pool_info Type to output.
226 *
227 * @return Formatted string.
228 */
229inline std::string to_string(const ROIPoolingLayerInfo &pool_info)
230{
231 std::stringstream str;
232 str << pool_info;
233 return str.str();
234}
235
Alex Gildayc357c472018-03-21 13:54:09 +0000236/** Formatted output of the QuantizationInfo type.
237 *
238 * @param[out] os Output stream.
239 * @param[in] quantization_info Type to output.
240 *
241 * @return Modified output stream.
242 */
Chunosovd621bca2017-11-03 17:33:15 +0700243inline ::std::ostream &operator<<(::std::ostream &os, const QuantizationInfo &quantization_info)
244{
245 os << "Scale:" << quantization_info.scale << "~"
246 << "Offset:" << quantization_info.offset;
247 return os;
248}
249
Alex Gildayc357c472018-03-21 13:54:09 +0000250/** Formatted output of the QuantizationInfo type.
251 *
252 * @param[in] quantization_info Type to output.
253 *
254 * @return Formatted string.
255 */
Chunosovd621bca2017-11-03 17:33:15 +0700256inline std::string to_string(const QuantizationInfo &quantization_info)
257{
258 std::stringstream str;
259 str << quantization_info;
260 return str.str();
261}
262
Alex Gildayc357c472018-03-21 13:54:09 +0000263/** Formatted output of the activation function type.
264 *
265 * @param[out] os Output stream.
266 * @param[in] act_function Type to output.
267 *
268 * @return Modified output stream.
269 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100270inline ::std::ostream &operator<<(::std::ostream &os, const ActivationLayerInfo::ActivationFunction &act_function)
271{
272 switch(act_function)
273 {
274 case ActivationLayerInfo::ActivationFunction::ABS:
275 os << "ABS";
276 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100277 case ActivationLayerInfo::ActivationFunction::LINEAR:
278 os << "LINEAR";
279 break;
280 case ActivationLayerInfo::ActivationFunction::LOGISTIC:
281 os << "LOGISTIC";
282 break;
283 case ActivationLayerInfo::ActivationFunction::RELU:
284 os << "RELU";
285 break;
Georgios Pinitas579c0492017-07-12 16:12:12 +0100286 case ActivationLayerInfo::ActivationFunction::BOUNDED_RELU:
287 os << "BOUNDED_RELU";
288 break;
289 case ActivationLayerInfo::ActivationFunction::LEAKY_RELU:
290 os << "LEAKY_RELU";
291 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100292 case ActivationLayerInfo::ActivationFunction::SOFT_RELU:
293 os << "SOFT_RELU";
294 break;
295 case ActivationLayerInfo::ActivationFunction::SQRT:
296 os << "SQRT";
297 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100298 case ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU:
299 os << "LU_BOUNDED_RELU";
Kevin Petitd9f80712017-12-06 12:18:48 +0000300 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100301 case ActivationLayerInfo::ActivationFunction::SQUARE:
302 os << "SQUARE";
303 break;
304 case ActivationLayerInfo::ActivationFunction::TANH:
305 os << "TANH";
306 break;
307 default:
308 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
309 }
310
311 return os;
312}
313
Alex Gildayc357c472018-03-21 13:54:09 +0000314/** Formatted output of the activation function info type.
315 *
316 * @param[in] info Type to output.
317 *
318 * @return Formatted string.
319 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100320inline std::string to_string(const arm_compute::ActivationLayerInfo &info)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100321{
322 std::stringstream str;
Isabella Gottardi3f217ec2018-02-12 14:59:19 +0000323 if(info.enabled())
324 {
325 str << info.activation();
326 }
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100327 return str.str();
328}
329
Alex Gildayc357c472018-03-21 13:54:09 +0000330/** Formatted output of the activation function type.
331 *
332 * @param[in] function Type to output.
333 *
334 * @return Formatted string.
335 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100336inline std::string to_string(const arm_compute::ActivationLayerInfo::ActivationFunction &function)
337{
338 std::stringstream str;
339 str << function;
340 return str.str();
341}
342
Alex Gildayc357c472018-03-21 13:54:09 +0000343/** Formatted output of the NormType type.
344 *
345 * @param[out] os Output stream.
346 * @param[in] norm_type Type to output.
347 *
348 * @return Modified output stream.
349 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100350inline ::std::ostream &operator<<(::std::ostream &os, const NormType &norm_type)
351{
352 switch(norm_type)
353 {
354 case NormType::CROSS_MAP:
355 os << "CROSS_MAP";
356 break;
357 case NormType::IN_MAP_1D:
358 os << "IN_MAP_1D";
359 break;
360 case NormType::IN_MAP_2D:
361 os << "IN_MAP_2D";
362 break;
363 default:
364 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
365 }
366
367 return os;
368}
369
Alex Gildayc357c472018-03-21 13:54:09 +0000370/** Formatted output of @ref NormalizationLayerInfo.
371 *
372 * @param[in] info Type to output.
373 *
374 * @return Formatted string.
375 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100376inline std::string to_string(const arm_compute::NormalizationLayerInfo &info)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100377{
378 std::stringstream str;
Michalis Spyroud466c2d2018-01-30 10:54:39 +0000379 str << info.type() << ":NormSize=" << info.norm_size();
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100380 return str.str();
381}
382
Alex Gildayc357c472018-03-21 13:54:09 +0000383/** Formatted output of @ref NormalizationLayerInfo.
384 *
385 * @param[out] os Output stream.
386 * @param[in] info Type to output.
387 *
388 * @return Modified output stream.
389 */
Georgios Pinitas6f669f02017-09-26 12:32:57 +0100390inline ::std::ostream &operator<<(::std::ostream &os, const NormalizationLayerInfo &info)
391{
Michalis Spyroud466c2d2018-01-30 10:54:39 +0000392 os << info.type() << ":NormSize=" << info.norm_size();
Georgios Pinitas6f669f02017-09-26 12:32:57 +0100393 return os;
394}
395
Alex Gildayc357c472018-03-21 13:54:09 +0000396/** Formatted output of the PoolingType type.
397 *
398 * @param[out] os Output stream.
399 * @param[in] pool_type Type to output.
400 *
401 * @return Modified output stream.
402 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100403inline ::std::ostream &operator<<(::std::ostream &os, const PoolingType &pool_type)
404{
405 switch(pool_type)
406 {
407 case PoolingType::AVG:
408 os << "AVG";
409 break;
410 case PoolingType::MAX:
411 os << "MAX";
412 break;
Georgios Pinitascdf51452017-08-31 14:21:36 +0100413 case PoolingType::L2:
414 os << "L2";
415 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100416 default:
417 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
418 }
419
420 return os;
421}
422
Alex Gildayc357c472018-03-21 13:54:09 +0000423/** Formatted output of @ref PoolingLayerInfo.
424 *
425 * @param[out] os Output stream.
426 * @param[in] info Type to output.
427 *
428 * @return Modified output stream.
429 */
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100430inline ::std::ostream &operator<<(::std::ostream &os, const PoolingLayerInfo &info)
431{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100432 os << info.pool_type();
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100433
434 return os;
435}
436
Alex Gildayc357c472018-03-21 13:54:09 +0000437/** Formatted output of @ref RoundingPolicy.
438 *
439 * @param[in] rounding_policy Type to output.
440 *
441 * @return Formatted string.
442 */
John Richardsondd715f22017-09-18 16:10:48 +0100443inline std::string to_string(const RoundingPolicy &rounding_policy)
444{
445 std::stringstream str;
446 str << rounding_policy;
447 return str.str();
448}
449
Alex Gildayc357c472018-03-21 13:54:09 +0000450/** Formatted output of the DataLayout type.
451 *
452 * @param[out] os Output stream.
453 * @param[in] data_layout Type to output.
454 *
455 * @return Modified output stream.
456 */
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000457inline ::std::ostream &operator<<(::std::ostream &os, const DataLayout &data_layout)
458{
459 switch(data_layout)
460 {
461 case DataLayout::UNKNOWN:
462 os << "UNKNOWN";
463 break;
464 case DataLayout::NHWC:
465 os << "NHWC";
466 break;
467 case DataLayout::NCHW:
468 os << "NCHW";
469 break;
470 default:
471 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
472 }
473
474 return os;
475}
476
Alex Gildayc357c472018-03-21 13:54:09 +0000477/** Formatted output of the DataLayout type.
478 *
479 * @param[in] data_layout Type to output.
480 *
481 * @return Formatted string.
482 */
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000483inline std::string to_string(const arm_compute::DataLayout &data_layout)
484{
485 std::stringstream str;
486 str << data_layout;
487 return str.str();
488}
489
Georgios Pinitase2220552018-07-20 13:23:44 +0100490/** Formatted output of the DataLayoutDimension type.
491 *
492 * @param[out] os Output stream.
493 * @param[in] data_layout_dim Data layout dimension to print.
494 *
495 * @return Modified output stream.
496 */
497inline ::std::ostream &operator<<(::std::ostream &os, const DataLayoutDimension &data_layout_dim)
498{
499 switch(data_layout_dim)
500 {
501 case DataLayoutDimension::WIDTH:
502 os << "WIDTH";
503 break;
504 case DataLayoutDimension::HEIGHT:
505 os << "HEIGHT";
506 break;
507 case DataLayoutDimension::CHANNEL:
508 os << "CHANNEL";
509 break;
510 case DataLayoutDimension::BATCHES:
511 os << "BATCHES";
512 break;
513 default:
514 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
515 }
516 return os;
517}
518
Alex Gildayc357c472018-03-21 13:54:09 +0000519/** Formatted output of the DataType type.
520 *
521 * @param[out] os Output stream.
522 * @param[in] data_type Type to output.
523 *
524 * @return Modified output stream.
525 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100526inline ::std::ostream &operator<<(::std::ostream &os, const DataType &data_type)
527{
528 switch(data_type)
529 {
530 case DataType::UNKNOWN:
531 os << "UNKNOWN";
532 break;
533 case DataType::U8:
534 os << "U8";
535 break;
Chunosovd621bca2017-11-03 17:33:15 +0700536 case DataType::QASYMM8:
537 os << "QASYMM8";
538 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100539 case DataType::S8:
540 os << "S8";
541 break;
542 case DataType::U16:
543 os << "U16";
544 break;
545 case DataType::S16:
546 os << "S16";
547 break;
548 case DataType::U32:
549 os << "U32";
550 break;
551 case DataType::S32:
552 os << "S32";
553 break;
554 case DataType::U64:
555 os << "U64";
556 break;
557 case DataType::S64:
558 os << "S64";
559 break;
560 case DataType::F16:
561 os << "F16";
562 break;
563 case DataType::F32:
564 os << "F32";
565 break;
566 case DataType::F64:
567 os << "F64";
568 break;
569 case DataType::SIZET:
570 os << "SIZET";
571 break;
572 default:
573 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
574 }
575
576 return os;
577}
578
Alex Gildayc357c472018-03-21 13:54:09 +0000579/** Formatted output of the DataType type.
580 *
581 * @param[in] data_type Type to output.
582 *
583 * @return Formatted string.
584 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100585inline std::string to_string(const arm_compute::DataType &data_type)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100586{
587 std::stringstream str;
588 str << data_type;
589 return str.str();
590}
591
Alex Gildayc357c472018-03-21 13:54:09 +0000592/** Formatted output of the Format type.
593 *
594 * @param[out] os Output stream.
595 * @param[in] format Type to output.
596 *
597 * @return Modified output stream.
598 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100599inline ::std::ostream &operator<<(::std::ostream &os, const Format &format)
600{
601 switch(format)
602 {
603 case Format::UNKNOWN:
604 os << "UNKNOWN";
605 break;
606 case Format::U8:
607 os << "U8";
608 break;
609 case Format::S16:
610 os << "S16";
611 break;
612 case Format::U16:
613 os << "U16";
614 break;
615 case Format::S32:
616 os << "S32";
617 break;
618 case Format::U32:
619 os << "U32";
620 break;
621 case Format::F16:
622 os << "F16";
623 break;
624 case Format::F32:
625 os << "F32";
626 break;
627 case Format::UV88:
628 os << "UV88";
629 break;
630 case Format::RGB888:
631 os << "RGB888";
632 break;
633 case Format::RGBA8888:
634 os << "RGBA8888";
635 break;
636 case Format::YUV444:
637 os << "YUV444";
638 break;
639 case Format::YUYV422:
640 os << "YUYV422";
641 break;
642 case Format::NV12:
643 os << "NV12";
644 break;
645 case Format::NV21:
646 os << "NV21";
647 break;
648 case Format::IYUV:
649 os << "IYUV";
650 break;
651 case Format::UYVY422:
652 os << "UYVY422";
653 break;
654 default:
655 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
656 }
657
658 return os;
659}
660
Alex Gildayc357c472018-03-21 13:54:09 +0000661/** Formatted output of the Format type.
662 *
663 * @param[in] format Type to output.
664 *
665 * @return Formatted string.
666 */
Moritz Pflanzer7655a672017-09-23 11:57:33 +0100667inline std::string to_string(const Format &format)
668{
669 std::stringstream str;
670 str << format;
671 return str.str();
672}
673
Alex Gildayc357c472018-03-21 13:54:09 +0000674/** Formatted output of the Channel type.
675 *
676 * @param[out] os Output stream.
677 * @param[in] channel Type to output.
678 *
679 * @return Modified output stream.
680 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100681inline ::std::ostream &operator<<(::std::ostream &os, const Channel &channel)
682{
683 switch(channel)
684 {
685 case Channel::UNKNOWN:
686 os << "UNKNOWN";
687 break;
688 case Channel::C0:
689 os << "C0";
690 break;
691 case Channel::C1:
692 os << "C1";
693 break;
694 case Channel::C2:
695 os << "C2";
696 break;
697 case Channel::C3:
698 os << "C3";
699 break;
700 case Channel::R:
701 os << "R";
702 break;
703 case Channel::G:
704 os << "G";
705 break;
706 case Channel::B:
707 os << "B";
708 break;
709 case Channel::A:
710 os << "A";
711 break;
712 case Channel::Y:
713 os << "Y";
714 break;
715 case Channel::U:
716 os << "U";
717 break;
718 case Channel::V:
719 os << "V";
720 break;
721 default:
722 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
723 }
724
725 return os;
726}
727
Alex Gildayc357c472018-03-21 13:54:09 +0000728/** Formatted output of the Channel type.
729 *
730 * @param[in] channel Type to output.
731 *
732 * @return Formatted string.
733 */
Ioan-Cristian Szabo9414f642017-10-27 17:35:40 +0100734inline std::string to_string(const Channel &channel)
735{
736 std::stringstream str;
737 str << channel;
738 return str.str();
739}
740
Alex Gildayc357c472018-03-21 13:54:09 +0000741/** Formatted output of the BorderMode type.
742 *
743 * @param[out] os Output stream.
744 * @param[in] mode Type to output.
745 *
746 * @return Modified output stream.
747 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100748inline ::std::ostream &operator<<(::std::ostream &os, const BorderMode &mode)
749{
750 switch(mode)
751 {
752 case BorderMode::UNDEFINED:
753 os << "UNDEFINED";
754 break;
755 case BorderMode::CONSTANT:
756 os << "CONSTANT";
757 break;
758 case BorderMode::REPLICATE:
759 os << "REPLICATE";
760 break;
761 default:
762 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
763 }
764
765 return os;
766}
767
Alex Gildayc357c472018-03-21 13:54:09 +0000768/** Formatted output of the BorderSize type.
769 *
770 * @param[out] os Output stream.
771 * @param[in] border Type to output.
772 *
773 * @return Modified output stream.
774 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100775inline ::std::ostream &operator<<(::std::ostream &os, const BorderSize &border)
776{
Moritz Pflanzerc87fbf82017-07-18 14:02:10 +0100777 os << border.top << ","
778 << border.right << ","
779 << border.bottom << ","
780 << border.left;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100781
782 return os;
783}
Anthony Barbier2a07e182017-08-04 18:20:27 +0100784
Giuseppe Rossinid7647d42018-07-17 18:13:13 +0100785/** Formatted output of the PaddingList type.
786 *
787 * @param[out] os Output stream.
788 * @param[in] padding Type to output.
789 *
790 * @return Modified output stream.
791 */
792inline ::std::ostream &operator<<(::std::ostream &os, const PaddingList &padding)
793{
794 os << "{";
795 for(auto const &p : padding)
796 {
797 os << "{" << p.first << "," << p.second << "}";
798 }
799 os << "}";
800 return os;
801}
802
Alex Gildayc357c472018-03-21 13:54:09 +0000803/** Formatted output of the InterpolationPolicy type.
804 *
805 * @param[out] os Output stream.
806 * @param[in] policy Type to output.
807 *
808 * @return Modified output stream.
809 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100810inline ::std::ostream &operator<<(::std::ostream &os, const InterpolationPolicy &policy)
811{
812 switch(policy)
813 {
814 case InterpolationPolicy::NEAREST_NEIGHBOR:
815 os << "NEAREST_NEIGHBOR";
816 break;
817 case InterpolationPolicy::BILINEAR:
818 os << "BILINEAR";
819 break;
820 case InterpolationPolicy::AREA:
821 os << "AREA";
822 break;
823 default:
824 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
825 }
826
827 return os;
828}
829
Alex Gildayc357c472018-03-21 13:54:09 +0000830/** Formatted output of the SamplingPolicy type.
831 *
832 * @param[out] os Output stream.
833 * @param[in] policy Type to output.
834 *
835 * @return Modified output stream.
836 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700837inline ::std::ostream &operator<<(::std::ostream &os, const SamplingPolicy &policy)
838{
839 switch(policy)
840 {
841 case SamplingPolicy::CENTER:
842 os << "CENTER";
843 break;
844 case SamplingPolicy::TOP_LEFT:
845 os << "TOP_LEFT";
846 break;
847 default:
848 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
849 }
850
851 return os;
852}
853
Alex Gildayc357c472018-03-21 13:54:09 +0000854/** Formatted output of the TensorInfo type.
855 *
Anthony Barbier366628a2018-08-01 13:55:03 +0100856 * @param[out] os Output stream.
857 * @param[in] info Type to output.
858 *
859 * @return Modified output stream.
860 */
861inline ::std::ostream &operator<<(::std::ostream &os, const TensorInfo &info)
862{
863 os << "{Shape=" << info.tensor_shape() << ","
864 << "Type=" << info.data_type() << ","
865 << "Channels=" << info.num_channels() << "}";
866 return os;
867}
868/** Formatted output of the TensorInfo type.
869 *
Alex Gildayc357c472018-03-21 13:54:09 +0000870 * @param[in] info Type to output.
871 *
872 * @return Formatted string.
873 */
Georgios Pinitas3faea252017-10-30 14:13:50 +0000874inline std::string to_string(const TensorInfo &info)
875{
876 std::stringstream str;
Anthony Barbier366628a2018-08-01 13:55:03 +0100877 str << info;
Georgios Pinitas3faea252017-10-30 14:13:50 +0000878 return str.str();
879}
880
Abe Mbise925ca0f2017-10-02 19:16:33 +0100881//FIXME: Check why this doesn't work and the TensorShape and Coordinates overload are needed
Alex Gildayc357c472018-03-21 13:54:09 +0000882/** Formatted output of the Dimensions type.
883 *
884 * @param[in] dimensions Type to output.
885 *
886 * @return Formatted string.
887 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100888template <typename T>
889inline std::string to_string(const Dimensions<T> &dimensions)
890{
891 std::stringstream str;
892 str << dimensions;
893 return str.str();
894}
895
Alex Gildayc357c472018-03-21 13:54:09 +0000896/** Formatted output of the Strides type.
897 *
898 * @param[in] stride Type to output.
899 *
900 * @return Formatted string.
901 */
John Richardsona36eae12017-09-26 16:55:59 +0100902inline std::string to_string(const Strides &stride)
903{
904 std::stringstream str;
905 str << stride;
906 return str.str();
907}
908
Alex Gildayc357c472018-03-21 13:54:09 +0000909/** Formatted output of the TensorShape type.
910 *
911 * @param[in] shape Type to output.
912 *
913 * @return Formatted string.
914 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100915inline std::string to_string(const TensorShape &shape)
916{
917 std::stringstream str;
918 str << shape;
919 return str.str();
920}
921
Alex Gildayc357c472018-03-21 13:54:09 +0000922/** Formatted output of the Coordinates type.
923 *
924 * @param[in] coord Type to output.
925 *
926 * @return Formatted string.
927 */
Abe Mbise925ca0f2017-10-02 19:16:33 +0100928inline std::string to_string(const Coordinates &coord)
929{
930 std::stringstream str;
931 str << coord;
932 return str.str();
933}
934
Anthony Barbierb940fd62018-06-04 14:14:32 +0100935/** Formatted output of the GEMMReshapeInfo type.
936 *
937 * @param[out] os Output stream.
938 * @param[in] info Type to output.
939 *
940 * @return Modified output stream.
941 */
942inline ::std::ostream &operator<<(::std::ostream &os, const GEMMReshapeInfo &info)
943{
944 os << "{m=" << info.m() << ",";
945 os << "n=" << info.n() << ",";
946 os << "k=" << info.k() << ",";
947 os << "mult_transpose1xW_width=" << info.mult_transpose1xW_width() << ",";
948 os << "mult_interleave4x4_height=" << info.mult_interleave4x4_height();
949 os << "}";
950
951 return os;
952}
953
954/** Formatted output of the GEMMInfo type.
955 *
956 * @param[out] os Output stream.
957 * @param[in] info Type to output.
958 *
959 * @return Modified output stream.
960 */
961inline ::std::ostream &operator<<(::std::ostream &os, const GEMMInfo &info)
962{
963 os << "{is_a_reshaped=" << info.is_a_reshaped() << ",";
964 os << "is_b_reshaped=" << info.is_b_reshaped() << ",";
965 os << "reshape_b_only_on_first_run=" << info.reshape_b_only_on_first_run() << ",";
Anthony Barbierb940fd62018-06-04 14:14:32 +0100966 os << "}";
967
968 return os;
969}
970
971/** Formatted output of the Window::Dimension type.
972 *
973 * @param[out] os Output stream.
974 * @param[in] dim Type to output.
975 *
976 * @return Modified output stream.
977 */
978inline ::std::ostream &operator<<(::std::ostream &os, const Window::Dimension &dim)
979{
980 os << "{start=" << dim.start() << ", end=" << dim.end() << ", step=" << dim.step() << "}";
981
982 return os;
983}
984/** Formatted output of the Window type.
985 *
986 * @param[out] os Output stream.
987 * @param[in] win Type to output.
988 *
989 * @return Modified output stream.
990 */
991inline ::std::ostream &operator<<(::std::ostream &os, const Window &win)
992{
993 os << "{";
994 for(unsigned int i = 0; i < Coordinates::num_max_dimensions; i++)
995 {
996 if(i > 0)
997 {
998 os << ", ";
999 }
1000 os << win[i];
1001 }
1002 os << "}";
1003
1004 return os;
1005}
1006
1007/** Formatted output of the WeightsInfo type.
1008 *
1009 * @param[in] info Type to output.
1010 *
1011 * @return Formatted string.
1012 */
1013inline std::string to_string(const WeightsInfo &info)
1014{
1015 std::stringstream str;
1016 str << info;
1017 return str.str();
1018}
1019
1020/** Formatted output of the GEMMReshapeInfo type.
1021 *
1022 * @param[in] info Type to output.
1023 *
1024 * @return Formatted string.
1025 */
1026inline std::string to_string(const GEMMReshapeInfo &info)
1027{
1028 std::stringstream str;
1029 str << info;
1030 return str.str();
1031}
1032
1033/** Formatted output of the GEMMInfo type.
1034 *
1035 * @param[in] info Type to output.
1036 *
1037 * @return Formatted string.
1038 */
1039inline std::string to_string(const GEMMInfo &info)
1040{
1041 std::stringstream str;
1042 str << info;
1043 return str.str();
1044}
1045
1046/** Formatted output of the Window::Dimension type.
1047 *
1048 * @param[in] dim Type to output.
1049 *
1050 * @return Formatted string.
1051 */
1052inline std::string to_string(const Window::Dimension &dim)
1053{
1054 std::stringstream str;
1055 str << dim;
1056 return str.str();
1057}
1058/** Formatted output of the Window type.
1059 *
1060 * @param[in] win Type to output.
1061 *
1062 * @return Formatted string.
1063 */
1064inline std::string to_string(const Window &win)
1065{
1066 std::stringstream str;
1067 str << win;
1068 return str.str();
1069}
1070
Alex Gildayc357c472018-03-21 13:54:09 +00001071/** Formatted output of the Rectangle type.
1072 *
1073 * @param[out] os Output stream.
1074 * @param[in] rect Type to output.
1075 *
1076 * @return Modified output stream.
1077 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001078inline ::std::ostream &operator<<(::std::ostream &os, const Rectangle &rect)
1079{
1080 os << rect.width << "x" << rect.height;
1081 os << "+" << rect.x << "+" << rect.y;
1082
1083 return os;
1084}
1085
Alex Gildayc357c472018-03-21 13:54:09 +00001086/** Formatted output of the PadStrideInfo type.
1087 *
1088 * @param[out] os Output stream.
1089 * @param[in] pad_stride_info Type to output.
1090 *
1091 * @return Modified output stream.
1092 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001093inline ::std::ostream &operator<<(::std::ostream &os, const PadStrideInfo &pad_stride_info)
1094{
1095 os << pad_stride_info.stride().first << "," << pad_stride_info.stride().second;
1096 os << ";";
Jaroslaw Rzepeckia1ed41f2017-10-13 11:13:58 +01001097 os << pad_stride_info.pad_left() << "," << pad_stride_info.pad_right() << ","
1098 << pad_stride_info.pad_top() << "," << pad_stride_info.pad_bottom();
Anthony Barbier2a07e182017-08-04 18:20:27 +01001099
1100 return os;
1101}
1102
Alex Gildayc357c472018-03-21 13:54:09 +00001103/** Formatted output of the PadStrideInfo type.
1104 *
1105 * @param[in] pad_stride_info Type to output.
1106 *
1107 * @return Formatted string.
1108 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001109inline std::string to_string(const PadStrideInfo &pad_stride_info)
1110{
1111 std::stringstream str;
1112 str << pad_stride_info;
1113 return str.str();
1114}
1115
Alex Gildayc357c472018-03-21 13:54:09 +00001116/** Formatted output of the BorderMode type.
1117 *
1118 * @param[in] mode Type to output.
1119 *
1120 * @return Formatted string.
1121 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001122inline std::string to_string(const BorderMode &mode)
1123{
1124 std::stringstream str;
1125 str << mode;
1126 return str.str();
1127}
1128
Alex Gildayc357c472018-03-21 13:54:09 +00001129/** Formatted output of the BorderSize type.
1130 *
1131 * @param[in] border Type to output.
1132 *
1133 * @return Formatted string.
1134 */
John Richardsonb482ce12017-09-18 12:44:01 +01001135inline std::string to_string(const BorderSize &border)
1136{
1137 std::stringstream str;
1138 str << border;
1139 return str.str();
1140}
1141
Giuseppe Rossinid7647d42018-07-17 18:13:13 +01001142/** Formatted output of the PaddingList type.
1143 *
1144 * @param[in] padding Type to output.
1145 *
1146 * @return Formatted string.
1147 */
1148inline std::string to_string(const PaddingList &padding)
1149{
1150 std::stringstream str;
1151 str << padding;
1152 return str.str();
1153}
1154
Alex Gildayc357c472018-03-21 13:54:09 +00001155/** Formatted output of the InterpolationPolicy type.
1156 *
1157 * @param[in] policy Type to output.
1158 *
1159 * @return Formatted string.
1160 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001161inline std::string to_string(const InterpolationPolicy &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 SamplingPolicy type.
1169 *
1170 * @param[in] policy Type to output.
1171 *
1172 * @return Formatted string.
1173 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +07001174inline std::string to_string(const SamplingPolicy &policy)
1175{
1176 std::stringstream str;
1177 str << policy;
1178 return str.str();
1179}
1180
Alex Gildayc357c472018-03-21 13:54:09 +00001181/** Formatted output of the ConvertPolicy type.
1182 *
1183 * @param[out] os Output stream.
1184 * @param[in] policy Type to output.
1185 *
1186 * @return Modified output stream.
1187 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001188inline ::std::ostream &operator<<(::std::ostream &os, const ConvertPolicy &policy)
1189{
1190 switch(policy)
1191 {
1192 case ConvertPolicy::WRAP:
1193 os << "WRAP";
1194 break;
1195 case ConvertPolicy::SATURATE:
1196 os << "SATURATE";
1197 break;
1198 default:
1199 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1200 }
1201
1202 return os;
1203}
1204
1205inline std::string to_string(const ConvertPolicy &policy)
1206{
1207 std::stringstream str;
1208 str << policy;
1209 return str.str();
1210}
1211
Alex Gildayc357c472018-03-21 13:54:09 +00001212/** Formatted output of the Reduction Operations.
1213 *
1214 * @param[out] os Output stream.
1215 * @param[in] op Type to output.
1216 *
1217 * @return Modified output stream.
1218 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001219inline ::std::ostream &operator<<(::std::ostream &os, const ReductionOperation &op)
1220{
1221 switch(op)
1222 {
Michalis Spyrou7e9391b2018-10-05 14:49:28 +01001223 case ReductionOperation::SUM:
1224 os << "SUM";
1225 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +01001226 case ReductionOperation::SUM_SQUARE:
1227 os << "SUM_SQUARE";
1228 break;
Michalis Spyrou7e9391b2018-10-05 14:49:28 +01001229 case ReductionOperation::MEAN_SUM:
1230 os << "MEAN_SUM";
1231 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +01001232 default:
1233 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1234 }
1235
1236 return os;
1237}
1238
Alex Gildayc357c472018-03-21 13:54:09 +00001239/** Formatted output of the Reduction Operations.
1240 *
1241 * @param[in] op Type to output.
1242 *
1243 * @return Formatted string.
1244 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001245inline std::string to_string(const ReductionOperation &op)
1246{
1247 std::stringstream str;
1248 str << op;
1249 return str.str();
1250}
1251
Alex Gildayc357c472018-03-21 13:54:09 +00001252/** Formatted output of the Norm Type.
1253 *
1254 * @param[in] type Type to output.
1255 *
1256 * @return Formatted string.
1257 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001258inline std::string to_string(const NormType &type)
1259{
1260 std::stringstream str;
1261 str << type;
1262 return str.str();
1263}
1264
Alex Gildayc357c472018-03-21 13:54:09 +00001265/** Formatted output of the Pooling Type.
1266 *
1267 * @param[in] type Type to output.
1268 *
1269 * @return Formatted string.
1270 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001271inline std::string to_string(const PoolingType &type)
1272{
1273 std::stringstream str;
1274 str << type;
1275 return str.str();
1276}
1277
Alex Gildayc357c472018-03-21 13:54:09 +00001278/** Formatted output of the Pooling Layer Info.
1279 *
1280 * @param[in] info Type to output.
1281 *
1282 * @return Formatted string.
1283 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001284inline std::string to_string(const PoolingLayerInfo &info)
1285{
1286 std::stringstream str;
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001287 str << "{Type=" << info.pool_type() << ","
1288 << "IsGlobalPooling=" << info.is_global_pooling();
1289 if(!info.is_global_pooling())
1290 {
1291 str << ","
Isabella Gottardi6e464c32018-01-26 12:32:45 +00001292 << "PoolSize=" << info.pool_size().width << "," << info.pool_size().height << ","
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001293 << "PadStride=" << info.pad_stride_info();
1294 }
1295 str << "}";
Anthony Barbier2a07e182017-08-04 18:20:27 +01001296 return str.str();
1297}
1298
Alex Gildayc357c472018-03-21 13:54:09 +00001299/** Formatted output of the KeyPoint type.
1300 *
1301 * @param[out] os Output stream
1302 * @param[in] point Type to output.
1303 *
1304 * @return Modified output stream.
1305 */
Moritz Pflanzer6c6597c2017-09-24 12:09:41 +01001306inline ::std::ostream &operator<<(::std::ostream &os, const KeyPoint &point)
1307{
1308 os << "{x=" << point.x << ","
1309 << "y=" << point.y << ","
1310 << "strength=" << point.strength << ","
1311 << "scale=" << point.scale << ","
1312 << "orientation=" << point.orientation << ","
1313 << "tracking_status=" << point.tracking_status << ","
1314 << "error=" << point.error << "}";
1315
1316 return os;
1317}
John Richardson63e50412017-10-13 20:51:42 +01001318
Alex Gildayc357c472018-03-21 13:54:09 +00001319/** Formatted output of the PhaseType type.
1320 *
1321 * @param[out] os Output stream
1322 * @param[in] phase_type Type to output.
1323 *
1324 * @return Modified output stream.
1325 */
John Richardson63e50412017-10-13 20:51:42 +01001326inline ::std::ostream &operator<<(::std::ostream &os, const PhaseType &phase_type)
1327{
1328 switch(phase_type)
1329 {
1330 case PhaseType::SIGNED:
1331 os << "SIGNED";
1332 break;
1333 case PhaseType::UNSIGNED:
1334 os << "UNSIGNED";
1335 break;
1336 default:
1337 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1338 }
1339
1340 return os;
1341}
1342
Alex Gildayc357c472018-03-21 13:54:09 +00001343/** Formatted output of the PhaseType type.
1344 *
1345 * @param[in] type Type to output.
1346 *
1347 * @return Formatted string.
1348 */
John Richardson63e50412017-10-13 20:51:42 +01001349inline std::string to_string(const arm_compute::PhaseType &type)
1350{
1351 std::stringstream str;
1352 str << type;
1353 return str.str();
1354}
John Richardson3c5f9492017-10-04 15:27:37 +01001355
Alex Gildayc357c472018-03-21 13:54:09 +00001356/** Formatted output of the MagnitudeType type.
1357 *
1358 * @param[out] os Output stream
1359 * @param[in] magnitude_type Type to output.
1360 *
1361 * @return Modified output stream.
1362 */
John Richardson3c5f9492017-10-04 15:27:37 +01001363inline ::std::ostream &operator<<(::std::ostream &os, const MagnitudeType &magnitude_type)
1364{
1365 switch(magnitude_type)
1366 {
1367 case MagnitudeType::L1NORM:
1368 os << "L1NORM";
1369 break;
1370 case MagnitudeType::L2NORM:
1371 os << "L2NORM";
1372 break;
1373 default:
1374 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1375 }
1376
1377 return os;
1378}
1379
Alex Gildayc357c472018-03-21 13:54:09 +00001380/** Formatted output of the MagnitudeType type.
1381 *
1382 * @param[in] type Type to output.
1383 *
1384 * @return Formatted string.
1385 */
John Richardson3c5f9492017-10-04 15:27:37 +01001386inline std::string to_string(const arm_compute::MagnitudeType &type)
1387{
1388 std::stringstream str;
1389 str << type;
1390 return str.str();
1391}
John Richardson1c529922017-11-01 10:57:48 +00001392
Alex Gildayc357c472018-03-21 13:54:09 +00001393/** Formatted output of the HOGNormType type.
1394 *
1395 * @param[out] os Output stream
1396 * @param[in] norm_type Type to output
1397 *
1398 * @return Modified output stream.
1399 */
John Richardson25f23682017-11-27 14:35:09 +00001400inline ::std::ostream &operator<<(::std::ostream &os, const HOGNormType &norm_type)
1401{
1402 switch(norm_type)
1403 {
1404 case HOGNormType::L1_NORM:
1405 os << "L1_NORM";
1406 break;
1407 case HOGNormType::L2_NORM:
1408 os << "L2_NORM";
1409 break;
1410 case HOGNormType::L2HYS_NORM:
1411 os << "L2HYS_NORM";
1412 break;
1413 default:
1414 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1415 }
1416
1417 return os;
1418}
1419
Alex Gildayc357c472018-03-21 13:54:09 +00001420/** Formatted output of the HOGNormType type.
1421 *
1422 * @param[in] type Type to output
1423 *
1424 * @return Formatted string.
1425 */
John Richardson25f23682017-11-27 14:35:09 +00001426inline std::string to_string(const HOGNormType &type)
1427{
1428 std::stringstream str;
1429 str << type;
1430 return str.str();
1431}
1432
Alex Gildayc357c472018-03-21 13:54:09 +00001433/** Formatted output of the Size2D type.
1434 *
1435 * @param[out] os Output stream
1436 * @param[in] size Type to output
1437 *
1438 * @return Modified output stream.
1439 */
John Richardson25f23682017-11-27 14:35:09 +00001440inline ::std::ostream &operator<<(::std::ostream &os, const Size2D &size)
1441{
1442 os << size.width << "x" << size.height;
1443
1444 return os;
1445}
1446
Alex Gildayc357c472018-03-21 13:54:09 +00001447/** Formatted output of the Size2D type.
1448 *
1449 * @param[in] type Type to output
1450 *
1451 * @return Formatted string.
1452 */
John Richardson25f23682017-11-27 14:35:09 +00001453inline std::string to_string(const Size2D &type)
1454{
1455 std::stringstream str;
1456 str << type;
1457 return str.str();
1458}
1459
Alex Gildayc357c472018-03-21 13:54:09 +00001460/** Formatted output of the HOGInfo type.
1461 *
1462 * @param[out] os Output stream
1463 * @param[in] hog_info Type to output
1464 *
1465 * @return Modified output stream.
1466 */
John Richardson25f23682017-11-27 14:35:09 +00001467inline ::std::ostream &operator<<(::std::ostream &os, const HOGInfo &hog_info)
1468{
1469 os << "{CellSize=" << hog_info.cell_size() << ","
1470 << "BlockSize=" << hog_info.block_size() << ","
1471 << "DetectionWindowSize=" << hog_info.detection_window_size() << ","
1472 << "BlockStride=" << hog_info.block_stride() << ","
1473 << "NumBins=" << hog_info.num_bins() << ","
1474 << "NormType=" << hog_info.normalization_type() << ","
1475 << "L2HystThreshold=" << hog_info.l2_hyst_threshold() << ","
1476 << "PhaseType=" << hog_info.phase_type() << "}";
1477
1478 return os;
1479}
1480
Alex Gildayc357c472018-03-21 13:54:09 +00001481/** Formatted output of the HOGInfo type.
1482 *
1483 * @param[in] type Type to output
1484 *
1485 * @return Formatted string.
1486 */
John Richardson25f23682017-11-27 14:35:09 +00001487inline std::string to_string(const HOGInfo &type)
1488{
1489 std::stringstream str;
1490 str << type;
1491 return str.str();
1492}
1493
Alex Gildayc357c472018-03-21 13:54:09 +00001494/** Formatted output of the ConvolutionMethod type.
1495 *
1496 * @param[out] os Output stream
1497 * @param[in] conv_method Type to output
1498 *
1499 * @return Modified output stream.
1500 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001501inline ::std::ostream &operator<<(::std::ostream &os, const ConvolutionMethod &conv_method)
1502{
1503 switch(conv_method)
1504 {
1505 case ConvolutionMethod::GEMM:
1506 os << "GEMM";
1507 break;
1508 case ConvolutionMethod::DIRECT:
1509 os << "DIRECT";
1510 break;
1511 case ConvolutionMethod::WINOGRAD:
1512 os << "WINOGRAD";
1513 break;
1514 default:
1515 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1516 }
1517
1518 return os;
1519}
1520
Alex Gildayc357c472018-03-21 13:54:09 +00001521/** Formatted output of the ConvolutionMethod type.
1522 *
1523 * @param[in] conv_method Type to output
1524 *
1525 * @return Formatted string.
1526 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001527inline std::string to_string(const ConvolutionMethod &conv_method)
1528{
1529 std::stringstream str;
1530 str << conv_method;
1531 return str.str();
1532}
1533
Alex Gildayc357c472018-03-21 13:54:09 +00001534/** Formatted output of the GPUTarget type.
1535 *
1536 * @param[out] os Output stream
1537 * @param[in] gpu_target Type to output
1538 *
1539 * @return Modified output stream.
1540 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001541inline ::std::ostream &operator<<(::std::ostream &os, const GPUTarget &gpu_target)
1542{
1543 switch(gpu_target)
1544 {
1545 case GPUTarget::GPU_ARCH_MASK:
1546 os << "GPU_ARCH_MASK";
1547 break;
1548 case GPUTarget::MIDGARD:
1549 os << "MIDGARD";
1550 break;
1551 case GPUTarget::BIFROST:
1552 os << "BIFROST";
1553 break;
1554 case GPUTarget::T600:
1555 os << "T600";
1556 break;
1557 case GPUTarget::T700:
1558 os << "T700";
1559 break;
1560 case GPUTarget::T800:
1561 os << "T800";
1562 break;
Michalis Spyroua9676112018-02-22 18:07:43 +00001563 case GPUTarget::G71:
1564 os << "G71";
1565 break;
1566 case GPUTarget::G72:
1567 os << "G72";
1568 break;
1569 case GPUTarget::G51:
1570 os << "G51";
1571 break;
1572 case GPUTarget::G51BIG:
1573 os << "G51BIG";
1574 break;
1575 case GPUTarget::G51LIT:
1576 os << "G51LIT";
1577 break;
Georgios Pinitasb03f7c52018-07-12 10:49:53 +01001578 case GPUTarget::G76:
1579 os << "G76";
Michalis Spyroua9676112018-02-22 18:07:43 +00001580 break;
1581 case GPUTarget::TTRX:
1582 os << "TTRX";
1583 break;
1584 case GPUTarget::TBOX:
1585 os << "TBOX";
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001586 break;
1587 default:
1588 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1589 }
1590
1591 return os;
1592}
1593
Alex Gildayc357c472018-03-21 13:54:09 +00001594/** Formatted output of the GPUTarget type.
1595 *
1596 * @param[in] gpu_target Type to output
1597 *
1598 * @return Formatted string.
1599 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001600inline std::string to_string(const GPUTarget &gpu_target)
1601{
1602 std::stringstream str;
1603 str << gpu_target;
1604 return str.str();
1605}
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00001606
John Richardson8de92612018-02-22 14:09:31 +00001607/** Formatted output of the DetectionWindow type.
1608 *
1609 * @param[out] os Output stream
1610 * @param[in] detection_window Type to output
1611 *
1612 * @return Modified output stream.
1613 */
John Richardson684cb0f2018-01-09 11:17:00 +00001614inline ::std::ostream &operator<<(::std::ostream &os, const DetectionWindow &detection_window)
1615{
1616 os << "{x=" << detection_window.x << ","
1617 << "y=" << detection_window.y << ","
1618 << "width=" << detection_window.width << ","
1619 << "height=" << detection_window.height << ","
1620 << "idx_class=" << detection_window.idx_class << ","
1621 << "score=" << detection_window.score << "}";
1622
1623 return os;
1624}
1625
John Richardson8de92612018-02-22 14:09:31 +00001626/** Formatted output of the DetectionWindow type.
1627 *
1628 * @param[in] detection_window Type to output
1629 *
1630 * @return Formatted string.
1631 */
1632inline std::string to_string(const DetectionWindow &detection_window)
1633{
1634 std::stringstream str;
1635 str << detection_window;
1636 return str.str();
1637}
1638
1639/** Formatted output of the Termination type.
1640 *
1641 * @param[out] os Output stream
1642 * @param[in] termination Type to output
1643 *
1644 * @return Modified output stream.
1645 */
1646inline ::std::ostream &operator<<(::std::ostream &os, const Termination &termination)
1647{
1648 switch(termination)
1649 {
1650 case Termination::TERM_CRITERIA_EPSILON:
1651 os << "TERM_CRITERIA_EPSILON";
1652 break;
1653 case Termination::TERM_CRITERIA_ITERATIONS:
1654 os << "TERM_CRITERIA_ITERATIONS";
1655 break;
1656 case Termination::TERM_CRITERIA_BOTH:
1657 os << "TERM_CRITERIA_BOTH";
1658 break;
1659 default:
1660 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1661 }
1662
1663 return os;
1664}
1665
1666/** Formatted output of the Termination type.
1667 *
1668 * @param[in] termination Type to output
1669 *
1670 * @return Formatted string.
1671 */
1672inline std::string to_string(const Termination &termination)
1673{
1674 std::stringstream str;
1675 str << termination;
1676 return str.str();
1677}
1678
Anthony Barbier8914e322018-08-10 15:28:25 +01001679/** Formatted output of the CPUModel type.
1680 *
1681 * @param[out] os Output stream
1682 * @param[in] cpu_model Model to output
1683 *
1684 * @return Modified output stream.
1685 */
1686inline ::std::ostream &operator<<(::std::ostream &os, const CPUModel &cpu_model)
1687{
1688 switch(cpu_model)
1689 {
1690 case CPUModel::GENERIC:
1691 os << "GENERIC";
1692 break;
1693 case CPUModel::GENERIC_FP16:
1694 os << "GENERIC_FP16";
1695 break;
1696 case CPUModel::GENERIC_FP16_DOT:
1697 os << "GENERIC_FP16_DOT";
1698 break;
1699 case CPUModel::A53:
1700 os << "A53";
1701 break;
1702 case CPUModel::A55r0:
1703 os << "A55r0";
1704 break;
1705 case CPUModel::A55r1:
1706 os << "A55r1";
1707 break;
1708 default:
1709 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1710 }
1711
1712 return os;
1713}
1714
1715/** Formatted output of the CPUModel type.
1716 *
1717 * @param[in] cpu_model Model to output
1718 *
1719 * @return Formatted string.
1720 */
1721inline std::string to_string(const CPUModel &cpu_model)
1722{
1723 std::stringstream str;
1724 str << cpu_model;
1725 return str.str();
1726}
Anthony Barbier671a11e2018-07-06 15:11:36 +01001727/** Formatted output of a vector of objects.
1728 *
1729 * @param[out] os Output stream
1730 * @param[in] args Vector of objects to print
1731 *
1732 * @return Modified output stream.
1733 */
1734template <typename T>
1735inline ::std::ostream &operator<<(::std::ostream &os, const std::vector<T> &args)
1736{
1737 os << "[";
1738 bool first = true;
1739 for(auto &arg : args)
1740 {
1741 if(first)
1742 {
1743 first = false;
1744 }
1745 else
1746 {
1747 os << ", ";
1748 }
1749 os << arg;
1750 }
1751 os << "]";
1752 return os;
1753}
1754
1755/** Formatted output of a vector of objects.
1756 *
1757 * @param[in] args Vector of objects to print
1758 *
1759 * @return String representing args.
1760 */
1761template <typename T>
1762std::string to_string(const std::vector<T> &args)
1763{
1764 std::stringstream str;
1765 str << args;
1766 return str.str();
1767}
1768
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00001769/** Formatted output of the WinogradInfo type. */
1770inline ::std::ostream &operator<<(::std::ostream &os, const WinogradInfo &info)
1771{
1772 os << "{OutputTileSize=" << info.output_tile_size << ","
1773 << "KernelSize=" << info.kernel_size << ","
1774 << "PadStride=" << info.convolution_info << ","
1775 << "OutputDataLayout=" << info.output_data_layout << "}";
1776
1777 return os;
1778}
1779
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00001780inline std::string to_string(const WinogradInfo &type)
1781{
1782 std::stringstream str;
1783 str << type;
1784 return str.str();
1785}
Anthony Barbier671a11e2018-07-06 15:11:36 +01001786
1787/** Fallback method: try to use std::to_string:
1788 *
1789 * @param[in] val Value to convert to string
1790 *
1791 * @return String representing val.
1792 */
1793template <typename T>
1794inline std::string to_string(const T &val)
1795{
1796 return support::cpp11::to_string(val);
1797}
1798
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001799} // namespace arm_compute
Anthony Barbier4dbc0a92018-08-27 13:39:47 +01001800
1801#endif /* __ARM_COMPUTE_TYPE_PRINTER_H__ */