blob: 10e407ddfa8f8eb8d86ce9432f42f181417f2b7c [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 {
1223 case ReductionOperation::SUM_SQUARE:
1224 os << "SUM_SQUARE";
1225 break;
1226 default:
1227 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1228 }
1229
1230 return os;
1231}
1232
Alex Gildayc357c472018-03-21 13:54:09 +00001233/** Formatted output of the Reduction Operations.
1234 *
1235 * @param[in] op Type to output.
1236 *
1237 * @return Formatted string.
1238 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001239inline std::string to_string(const ReductionOperation &op)
1240{
1241 std::stringstream str;
1242 str << op;
1243 return str.str();
1244}
1245
Alex Gildayc357c472018-03-21 13:54:09 +00001246/** Formatted output of the Norm 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 NormType &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 Type.
1260 *
1261 * @param[in] type Type to output.
1262 *
1263 * @return Formatted string.
1264 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001265inline std::string to_string(const PoolingType &type)
1266{
1267 std::stringstream str;
1268 str << type;
1269 return str.str();
1270}
1271
Alex Gildayc357c472018-03-21 13:54:09 +00001272/** Formatted output of the Pooling Layer Info.
1273 *
1274 * @param[in] info Type to output.
1275 *
1276 * @return Formatted string.
1277 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001278inline std::string to_string(const PoolingLayerInfo &info)
1279{
1280 std::stringstream str;
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001281 str << "{Type=" << info.pool_type() << ","
1282 << "IsGlobalPooling=" << info.is_global_pooling();
1283 if(!info.is_global_pooling())
1284 {
1285 str << ","
Isabella Gottardi6e464c32018-01-26 12:32:45 +00001286 << "PoolSize=" << info.pool_size().width << "," << info.pool_size().height << ","
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001287 << "PadStride=" << info.pad_stride_info();
1288 }
1289 str << "}";
Anthony Barbier2a07e182017-08-04 18:20:27 +01001290 return str.str();
1291}
1292
Alex Gildayc357c472018-03-21 13:54:09 +00001293/** Formatted output of the KeyPoint type.
1294 *
1295 * @param[out] os Output stream
1296 * @param[in] point Type to output.
1297 *
1298 * @return Modified output stream.
1299 */
Moritz Pflanzer6c6597c2017-09-24 12:09:41 +01001300inline ::std::ostream &operator<<(::std::ostream &os, const KeyPoint &point)
1301{
1302 os << "{x=" << point.x << ","
1303 << "y=" << point.y << ","
1304 << "strength=" << point.strength << ","
1305 << "scale=" << point.scale << ","
1306 << "orientation=" << point.orientation << ","
1307 << "tracking_status=" << point.tracking_status << ","
1308 << "error=" << point.error << "}";
1309
1310 return os;
1311}
John Richardson63e50412017-10-13 20:51:42 +01001312
Alex Gildayc357c472018-03-21 13:54:09 +00001313/** Formatted output of the PhaseType type.
1314 *
1315 * @param[out] os Output stream
1316 * @param[in] phase_type Type to output.
1317 *
1318 * @return Modified output stream.
1319 */
John Richardson63e50412017-10-13 20:51:42 +01001320inline ::std::ostream &operator<<(::std::ostream &os, const PhaseType &phase_type)
1321{
1322 switch(phase_type)
1323 {
1324 case PhaseType::SIGNED:
1325 os << "SIGNED";
1326 break;
1327 case PhaseType::UNSIGNED:
1328 os << "UNSIGNED";
1329 break;
1330 default:
1331 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1332 }
1333
1334 return os;
1335}
1336
Alex Gildayc357c472018-03-21 13:54:09 +00001337/** Formatted output of the PhaseType type.
1338 *
1339 * @param[in] type Type to output.
1340 *
1341 * @return Formatted string.
1342 */
John Richardson63e50412017-10-13 20:51:42 +01001343inline std::string to_string(const arm_compute::PhaseType &type)
1344{
1345 std::stringstream str;
1346 str << type;
1347 return str.str();
1348}
John Richardson3c5f9492017-10-04 15:27:37 +01001349
Alex Gildayc357c472018-03-21 13:54:09 +00001350/** Formatted output of the MagnitudeType type.
1351 *
1352 * @param[out] os Output stream
1353 * @param[in] magnitude_type Type to output.
1354 *
1355 * @return Modified output stream.
1356 */
John Richardson3c5f9492017-10-04 15:27:37 +01001357inline ::std::ostream &operator<<(::std::ostream &os, const MagnitudeType &magnitude_type)
1358{
1359 switch(magnitude_type)
1360 {
1361 case MagnitudeType::L1NORM:
1362 os << "L1NORM";
1363 break;
1364 case MagnitudeType::L2NORM:
1365 os << "L2NORM";
1366 break;
1367 default:
1368 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1369 }
1370
1371 return os;
1372}
1373
Alex Gildayc357c472018-03-21 13:54:09 +00001374/** Formatted output of the MagnitudeType type.
1375 *
1376 * @param[in] type Type to output.
1377 *
1378 * @return Formatted string.
1379 */
John Richardson3c5f9492017-10-04 15:27:37 +01001380inline std::string to_string(const arm_compute::MagnitudeType &type)
1381{
1382 std::stringstream str;
1383 str << type;
1384 return str.str();
1385}
John Richardson1c529922017-11-01 10:57:48 +00001386
Alex Gildayc357c472018-03-21 13:54:09 +00001387/** Formatted output of the HOGNormType type.
1388 *
1389 * @param[out] os Output stream
1390 * @param[in] norm_type Type to output
1391 *
1392 * @return Modified output stream.
1393 */
John Richardson25f23682017-11-27 14:35:09 +00001394inline ::std::ostream &operator<<(::std::ostream &os, const HOGNormType &norm_type)
1395{
1396 switch(norm_type)
1397 {
1398 case HOGNormType::L1_NORM:
1399 os << "L1_NORM";
1400 break;
1401 case HOGNormType::L2_NORM:
1402 os << "L2_NORM";
1403 break;
1404 case HOGNormType::L2HYS_NORM:
1405 os << "L2HYS_NORM";
1406 break;
1407 default:
1408 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1409 }
1410
1411 return os;
1412}
1413
Alex Gildayc357c472018-03-21 13:54:09 +00001414/** Formatted output of the HOGNormType type.
1415 *
1416 * @param[in] type Type to output
1417 *
1418 * @return Formatted string.
1419 */
John Richardson25f23682017-11-27 14:35:09 +00001420inline std::string to_string(const HOGNormType &type)
1421{
1422 std::stringstream str;
1423 str << type;
1424 return str.str();
1425}
1426
Alex Gildayc357c472018-03-21 13:54:09 +00001427/** Formatted output of the Size2D type.
1428 *
1429 * @param[out] os Output stream
1430 * @param[in] size Type to output
1431 *
1432 * @return Modified output stream.
1433 */
John Richardson25f23682017-11-27 14:35:09 +00001434inline ::std::ostream &operator<<(::std::ostream &os, const Size2D &size)
1435{
1436 os << size.width << "x" << size.height;
1437
1438 return os;
1439}
1440
Alex Gildayc357c472018-03-21 13:54:09 +00001441/** Formatted output of the Size2D type.
1442 *
1443 * @param[in] type Type to output
1444 *
1445 * @return Formatted string.
1446 */
John Richardson25f23682017-11-27 14:35:09 +00001447inline std::string to_string(const Size2D &type)
1448{
1449 std::stringstream str;
1450 str << type;
1451 return str.str();
1452}
1453
Alex Gildayc357c472018-03-21 13:54:09 +00001454/** Formatted output of the HOGInfo type.
1455 *
1456 * @param[out] os Output stream
1457 * @param[in] hog_info Type to output
1458 *
1459 * @return Modified output stream.
1460 */
John Richardson25f23682017-11-27 14:35:09 +00001461inline ::std::ostream &operator<<(::std::ostream &os, const HOGInfo &hog_info)
1462{
1463 os << "{CellSize=" << hog_info.cell_size() << ","
1464 << "BlockSize=" << hog_info.block_size() << ","
1465 << "DetectionWindowSize=" << hog_info.detection_window_size() << ","
1466 << "BlockStride=" << hog_info.block_stride() << ","
1467 << "NumBins=" << hog_info.num_bins() << ","
1468 << "NormType=" << hog_info.normalization_type() << ","
1469 << "L2HystThreshold=" << hog_info.l2_hyst_threshold() << ","
1470 << "PhaseType=" << hog_info.phase_type() << "}";
1471
1472 return os;
1473}
1474
Alex Gildayc357c472018-03-21 13:54:09 +00001475/** Formatted output of the HOGInfo type.
1476 *
1477 * @param[in] type Type to output
1478 *
1479 * @return Formatted string.
1480 */
John Richardson25f23682017-11-27 14:35:09 +00001481inline std::string to_string(const HOGInfo &type)
1482{
1483 std::stringstream str;
1484 str << type;
1485 return str.str();
1486}
1487
Alex Gildayc357c472018-03-21 13:54:09 +00001488/** Formatted output of the ConvolutionMethod type.
1489 *
1490 * @param[out] os Output stream
1491 * @param[in] conv_method Type to output
1492 *
1493 * @return Modified output stream.
1494 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001495inline ::std::ostream &operator<<(::std::ostream &os, const ConvolutionMethod &conv_method)
1496{
1497 switch(conv_method)
1498 {
1499 case ConvolutionMethod::GEMM:
1500 os << "GEMM";
1501 break;
1502 case ConvolutionMethod::DIRECT:
1503 os << "DIRECT";
1504 break;
1505 case ConvolutionMethod::WINOGRAD:
1506 os << "WINOGRAD";
1507 break;
1508 default:
1509 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1510 }
1511
1512 return os;
1513}
1514
Alex Gildayc357c472018-03-21 13:54:09 +00001515/** Formatted output of the ConvolutionMethod type.
1516 *
1517 * @param[in] conv_method Type to output
1518 *
1519 * @return Formatted string.
1520 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001521inline std::string to_string(const ConvolutionMethod &conv_method)
1522{
1523 std::stringstream str;
1524 str << conv_method;
1525 return str.str();
1526}
1527
Alex Gildayc357c472018-03-21 13:54:09 +00001528/** Formatted output of the GPUTarget type.
1529 *
1530 * @param[out] os Output stream
1531 * @param[in] gpu_target Type to output
1532 *
1533 * @return Modified output stream.
1534 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001535inline ::std::ostream &operator<<(::std::ostream &os, const GPUTarget &gpu_target)
1536{
1537 switch(gpu_target)
1538 {
1539 case GPUTarget::GPU_ARCH_MASK:
1540 os << "GPU_ARCH_MASK";
1541 break;
1542 case GPUTarget::MIDGARD:
1543 os << "MIDGARD";
1544 break;
1545 case GPUTarget::BIFROST:
1546 os << "BIFROST";
1547 break;
1548 case GPUTarget::T600:
1549 os << "T600";
1550 break;
1551 case GPUTarget::T700:
1552 os << "T700";
1553 break;
1554 case GPUTarget::T800:
1555 os << "T800";
1556 break;
Michalis Spyroua9676112018-02-22 18:07:43 +00001557 case GPUTarget::G71:
1558 os << "G71";
1559 break;
1560 case GPUTarget::G72:
1561 os << "G72";
1562 break;
1563 case GPUTarget::G51:
1564 os << "G51";
1565 break;
1566 case GPUTarget::G51BIG:
1567 os << "G51BIG";
1568 break;
1569 case GPUTarget::G51LIT:
1570 os << "G51LIT";
1571 break;
Georgios Pinitasb03f7c52018-07-12 10:49:53 +01001572 case GPUTarget::G76:
1573 os << "G76";
Michalis Spyroua9676112018-02-22 18:07:43 +00001574 break;
1575 case GPUTarget::TTRX:
1576 os << "TTRX";
1577 break;
1578 case GPUTarget::TBOX:
1579 os << "TBOX";
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001580 break;
1581 default:
1582 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1583 }
1584
1585 return os;
1586}
1587
Alex Gildayc357c472018-03-21 13:54:09 +00001588/** Formatted output of the GPUTarget type.
1589 *
1590 * @param[in] gpu_target Type to output
1591 *
1592 * @return Formatted string.
1593 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001594inline std::string to_string(const GPUTarget &gpu_target)
1595{
1596 std::stringstream str;
1597 str << gpu_target;
1598 return str.str();
1599}
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00001600
John Richardson8de92612018-02-22 14:09:31 +00001601/** Formatted output of the DetectionWindow type.
1602 *
1603 * @param[out] os Output stream
1604 * @param[in] detection_window Type to output
1605 *
1606 * @return Modified output stream.
1607 */
John Richardson684cb0f2018-01-09 11:17:00 +00001608inline ::std::ostream &operator<<(::std::ostream &os, const DetectionWindow &detection_window)
1609{
1610 os << "{x=" << detection_window.x << ","
1611 << "y=" << detection_window.y << ","
1612 << "width=" << detection_window.width << ","
1613 << "height=" << detection_window.height << ","
1614 << "idx_class=" << detection_window.idx_class << ","
1615 << "score=" << detection_window.score << "}";
1616
1617 return os;
1618}
1619
John Richardson8de92612018-02-22 14:09:31 +00001620/** Formatted output of the DetectionWindow type.
1621 *
1622 * @param[in] detection_window Type to output
1623 *
1624 * @return Formatted string.
1625 */
1626inline std::string to_string(const DetectionWindow &detection_window)
1627{
1628 std::stringstream str;
1629 str << detection_window;
1630 return str.str();
1631}
1632
1633/** Formatted output of the Termination type.
1634 *
1635 * @param[out] os Output stream
1636 * @param[in] termination Type to output
1637 *
1638 * @return Modified output stream.
1639 */
1640inline ::std::ostream &operator<<(::std::ostream &os, const Termination &termination)
1641{
1642 switch(termination)
1643 {
1644 case Termination::TERM_CRITERIA_EPSILON:
1645 os << "TERM_CRITERIA_EPSILON";
1646 break;
1647 case Termination::TERM_CRITERIA_ITERATIONS:
1648 os << "TERM_CRITERIA_ITERATIONS";
1649 break;
1650 case Termination::TERM_CRITERIA_BOTH:
1651 os << "TERM_CRITERIA_BOTH";
1652 break;
1653 default:
1654 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1655 }
1656
1657 return os;
1658}
1659
1660/** Formatted output of the Termination type.
1661 *
1662 * @param[in] termination Type to output
1663 *
1664 * @return Formatted string.
1665 */
1666inline std::string to_string(const Termination &termination)
1667{
1668 std::stringstream str;
1669 str << termination;
1670 return str.str();
1671}
1672
Anthony Barbier8914e322018-08-10 15:28:25 +01001673/** Formatted output of the CPUModel type.
1674 *
1675 * @param[out] os Output stream
1676 * @param[in] cpu_model Model to output
1677 *
1678 * @return Modified output stream.
1679 */
1680inline ::std::ostream &operator<<(::std::ostream &os, const CPUModel &cpu_model)
1681{
1682 switch(cpu_model)
1683 {
1684 case CPUModel::GENERIC:
1685 os << "GENERIC";
1686 break;
1687 case CPUModel::GENERIC_FP16:
1688 os << "GENERIC_FP16";
1689 break;
1690 case CPUModel::GENERIC_FP16_DOT:
1691 os << "GENERIC_FP16_DOT";
1692 break;
1693 case CPUModel::A53:
1694 os << "A53";
1695 break;
1696 case CPUModel::A55r0:
1697 os << "A55r0";
1698 break;
1699 case CPUModel::A55r1:
1700 os << "A55r1";
1701 break;
1702 default:
1703 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1704 }
1705
1706 return os;
1707}
1708
1709/** Formatted output of the CPUModel type.
1710 *
1711 * @param[in] cpu_model Model to output
1712 *
1713 * @return Formatted string.
1714 */
1715inline std::string to_string(const CPUModel &cpu_model)
1716{
1717 std::stringstream str;
1718 str << cpu_model;
1719 return str.str();
1720}
Anthony Barbier671a11e2018-07-06 15:11:36 +01001721/** Formatted output of a vector of objects.
1722 *
1723 * @param[out] os Output stream
1724 * @param[in] args Vector of objects to print
1725 *
1726 * @return Modified output stream.
1727 */
1728template <typename T>
1729inline ::std::ostream &operator<<(::std::ostream &os, const std::vector<T> &args)
1730{
1731 os << "[";
1732 bool first = true;
1733 for(auto &arg : args)
1734 {
1735 if(first)
1736 {
1737 first = false;
1738 }
1739 else
1740 {
1741 os << ", ";
1742 }
1743 os << arg;
1744 }
1745 os << "]";
1746 return os;
1747}
1748
1749/** Formatted output of a vector of objects.
1750 *
1751 * @param[in] args Vector of objects to print
1752 *
1753 * @return String representing args.
1754 */
1755template <typename T>
1756std::string to_string(const std::vector<T> &args)
1757{
1758 std::stringstream str;
1759 str << args;
1760 return str.str();
1761}
1762
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00001763/** Formatted output of the WinogradInfo type. */
1764inline ::std::ostream &operator<<(::std::ostream &os, const WinogradInfo &info)
1765{
1766 os << "{OutputTileSize=" << info.output_tile_size << ","
1767 << "KernelSize=" << info.kernel_size << ","
1768 << "PadStride=" << info.convolution_info << ","
1769 << "OutputDataLayout=" << info.output_data_layout << "}";
1770
1771 return os;
1772}
1773
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00001774inline std::string to_string(const WinogradInfo &type)
1775{
1776 std::stringstream str;
1777 str << type;
1778 return str.str();
1779}
Anthony Barbier671a11e2018-07-06 15:11:36 +01001780
1781/** Fallback method: try to use std::to_string:
1782 *
1783 * @param[in] val Value to convert to string
1784 *
1785 * @return String representing val.
1786 */
1787template <typename T>
1788inline std::string to_string(const T &val)
1789{
1790 return support::cpp11::to_string(val);
1791}
1792
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001793} // namespace arm_compute
Anthony Barbier4dbc0a92018-08-27 13:39:47 +01001794
1795#endif /* __ARM_COMPUTE_TYPE_PRINTER_H__ */