blob: df16cba9b54a8c9b62ff604eaff8862e6a59eada [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
giuros01c04a0e82018-10-03 12:44:35 +0100236/** Formatted output of the BoundingBoxTransformInfo type.
237 *
238 * @param[out] os Output stream.
239 * @param[in] bbox_info Type to output.
240 *
241 * @return Modified output stream.
242 */
243inline ::std::ostream &operator<<(::std::ostream &os, const BoundingBoxTransformInfo &bbox_info)
244{
245 auto weights = bbox_info.weights();
246 os << "(" << bbox_info.img_width() << "x" << bbox_info.img_height() << ")~" << bbox_info.scale() << "(weights = {" << weights[0] << ", " << weights[1] << ", " << weights[2] << ", " << weights[3] <<
247 "})";
248 return os;
249}
250
251/** Formatted output of the BoundingBoxTransformInfo type.
252 *
253 * @param[in] bbox_info Type to output.
254 *
255 * @return Formatted string.
256 */
257inline std::string to_string(const BoundingBoxTransformInfo &bbox_info)
258{
259 std::stringstream str;
260 str << bbox_info;
261 return str.str();
262}
263
Alex Gildayc357c472018-03-21 13:54:09 +0000264/** Formatted output of the QuantizationInfo type.
265 *
266 * @param[out] os Output stream.
267 * @param[in] quantization_info Type to output.
268 *
269 * @return Modified output stream.
270 */
Chunosovd621bca2017-11-03 17:33:15 +0700271inline ::std::ostream &operator<<(::std::ostream &os, const QuantizationInfo &quantization_info)
272{
273 os << "Scale:" << quantization_info.scale << "~"
274 << "Offset:" << quantization_info.offset;
275 return os;
276}
277
Alex Gildayc357c472018-03-21 13:54:09 +0000278/** Formatted output of the QuantizationInfo type.
279 *
280 * @param[in] quantization_info Type to output.
281 *
282 * @return Formatted string.
283 */
Chunosovd621bca2017-11-03 17:33:15 +0700284inline std::string to_string(const QuantizationInfo &quantization_info)
285{
286 std::stringstream str;
287 str << quantization_info;
288 return str.str();
289}
290
Alex Gildayc357c472018-03-21 13:54:09 +0000291/** Formatted output of the activation function type.
292 *
293 * @param[out] os Output stream.
294 * @param[in] act_function Type to output.
295 *
296 * @return Modified output stream.
297 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100298inline ::std::ostream &operator<<(::std::ostream &os, const ActivationLayerInfo::ActivationFunction &act_function)
299{
300 switch(act_function)
301 {
302 case ActivationLayerInfo::ActivationFunction::ABS:
303 os << "ABS";
304 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100305 case ActivationLayerInfo::ActivationFunction::LINEAR:
306 os << "LINEAR";
307 break;
308 case ActivationLayerInfo::ActivationFunction::LOGISTIC:
309 os << "LOGISTIC";
310 break;
311 case ActivationLayerInfo::ActivationFunction::RELU:
312 os << "RELU";
313 break;
Georgios Pinitas579c0492017-07-12 16:12:12 +0100314 case ActivationLayerInfo::ActivationFunction::BOUNDED_RELU:
315 os << "BOUNDED_RELU";
316 break;
317 case ActivationLayerInfo::ActivationFunction::LEAKY_RELU:
318 os << "LEAKY_RELU";
319 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100320 case ActivationLayerInfo::ActivationFunction::SOFT_RELU:
321 os << "SOFT_RELU";
322 break;
323 case ActivationLayerInfo::ActivationFunction::SQRT:
324 os << "SQRT";
325 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100326 case ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU:
327 os << "LU_BOUNDED_RELU";
Kevin Petitd9f80712017-12-06 12:18:48 +0000328 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100329 case ActivationLayerInfo::ActivationFunction::SQUARE:
330 os << "SQUARE";
331 break;
332 case ActivationLayerInfo::ActivationFunction::TANH:
333 os << "TANH";
334 break;
335 default:
336 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
337 }
338
339 return os;
340}
341
Alex Gildayc357c472018-03-21 13:54:09 +0000342/** Formatted output of the activation function info type.
343 *
344 * @param[in] info Type to output.
345 *
346 * @return Formatted string.
347 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100348inline std::string to_string(const arm_compute::ActivationLayerInfo &info)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100349{
350 std::stringstream str;
Isabella Gottardi3f217ec2018-02-12 14:59:19 +0000351 if(info.enabled())
352 {
353 str << info.activation();
354 }
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100355 return str.str();
356}
357
Alex Gildayc357c472018-03-21 13:54:09 +0000358/** Formatted output of the activation function type.
359 *
360 * @param[in] function Type to output.
361 *
362 * @return Formatted string.
363 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100364inline std::string to_string(const arm_compute::ActivationLayerInfo::ActivationFunction &function)
365{
366 std::stringstream str;
367 str << function;
368 return str.str();
369}
370
Alex Gildayc357c472018-03-21 13:54:09 +0000371/** Formatted output of the NormType type.
372 *
373 * @param[out] os Output stream.
374 * @param[in] norm_type Type to output.
375 *
376 * @return Modified output stream.
377 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100378inline ::std::ostream &operator<<(::std::ostream &os, const NormType &norm_type)
379{
380 switch(norm_type)
381 {
382 case NormType::CROSS_MAP:
383 os << "CROSS_MAP";
384 break;
385 case NormType::IN_MAP_1D:
386 os << "IN_MAP_1D";
387 break;
388 case NormType::IN_MAP_2D:
389 os << "IN_MAP_2D";
390 break;
391 default:
392 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
393 }
394
395 return os;
396}
397
Alex Gildayc357c472018-03-21 13:54:09 +0000398/** Formatted output of @ref NormalizationLayerInfo.
399 *
400 * @param[in] info Type to output.
401 *
402 * @return Formatted string.
403 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100404inline std::string to_string(const arm_compute::NormalizationLayerInfo &info)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100405{
406 std::stringstream str;
Michalis Spyroud466c2d2018-01-30 10:54:39 +0000407 str << info.type() << ":NormSize=" << info.norm_size();
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100408 return str.str();
409}
410
Alex Gildayc357c472018-03-21 13:54:09 +0000411/** Formatted output of @ref NormalizationLayerInfo.
412 *
413 * @param[out] os Output stream.
414 * @param[in] info Type to output.
415 *
416 * @return Modified output stream.
417 */
Georgios Pinitas6f669f02017-09-26 12:32:57 +0100418inline ::std::ostream &operator<<(::std::ostream &os, const NormalizationLayerInfo &info)
419{
Michalis Spyroud466c2d2018-01-30 10:54:39 +0000420 os << info.type() << ":NormSize=" << info.norm_size();
Georgios Pinitas6f669f02017-09-26 12:32:57 +0100421 return os;
422}
423
Alex Gildayc357c472018-03-21 13:54:09 +0000424/** Formatted output of the PoolingType type.
425 *
426 * @param[out] os Output stream.
427 * @param[in] pool_type Type to output.
428 *
429 * @return Modified output stream.
430 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100431inline ::std::ostream &operator<<(::std::ostream &os, const PoolingType &pool_type)
432{
433 switch(pool_type)
434 {
435 case PoolingType::AVG:
436 os << "AVG";
437 break;
438 case PoolingType::MAX:
439 os << "MAX";
440 break;
Georgios Pinitascdf51452017-08-31 14:21:36 +0100441 case PoolingType::L2:
442 os << "L2";
443 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100444 default:
445 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
446 }
447
448 return os;
449}
450
Alex Gildayc357c472018-03-21 13:54:09 +0000451/** Formatted output of @ref PoolingLayerInfo.
452 *
453 * @param[out] os Output stream.
454 * @param[in] info Type to output.
455 *
456 * @return Modified output stream.
457 */
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100458inline ::std::ostream &operator<<(::std::ostream &os, const PoolingLayerInfo &info)
459{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100460 os << info.pool_type();
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100461
462 return os;
463}
464
Alex Gildayc357c472018-03-21 13:54:09 +0000465/** Formatted output of @ref RoundingPolicy.
466 *
467 * @param[in] rounding_policy Type to output.
468 *
469 * @return Formatted string.
470 */
John Richardsondd715f22017-09-18 16:10:48 +0100471inline std::string to_string(const RoundingPolicy &rounding_policy)
472{
473 std::stringstream str;
474 str << rounding_policy;
475 return str.str();
476}
477
Alex Gildayc357c472018-03-21 13:54:09 +0000478/** Formatted output of the DataLayout type.
479 *
480 * @param[out] os Output stream.
481 * @param[in] data_layout Type to output.
482 *
483 * @return Modified output stream.
484 */
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000485inline ::std::ostream &operator<<(::std::ostream &os, const DataLayout &data_layout)
486{
487 switch(data_layout)
488 {
489 case DataLayout::UNKNOWN:
490 os << "UNKNOWN";
491 break;
492 case DataLayout::NHWC:
493 os << "NHWC";
494 break;
495 case DataLayout::NCHW:
496 os << "NCHW";
497 break;
498 default:
499 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
500 }
501
502 return os;
503}
504
Alex Gildayc357c472018-03-21 13:54:09 +0000505/** Formatted output of the DataLayout type.
506 *
507 * @param[in] data_layout Type to output.
508 *
509 * @return Formatted string.
510 */
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000511inline std::string to_string(const arm_compute::DataLayout &data_layout)
512{
513 std::stringstream str;
514 str << data_layout;
515 return str.str();
516}
517
Georgios Pinitase2220552018-07-20 13:23:44 +0100518/** Formatted output of the DataLayoutDimension type.
519 *
520 * @param[out] os Output stream.
521 * @param[in] data_layout_dim Data layout dimension to print.
522 *
523 * @return Modified output stream.
524 */
525inline ::std::ostream &operator<<(::std::ostream &os, const DataLayoutDimension &data_layout_dim)
526{
527 switch(data_layout_dim)
528 {
529 case DataLayoutDimension::WIDTH:
530 os << "WIDTH";
531 break;
532 case DataLayoutDimension::HEIGHT:
533 os << "HEIGHT";
534 break;
535 case DataLayoutDimension::CHANNEL:
536 os << "CHANNEL";
537 break;
538 case DataLayoutDimension::BATCHES:
539 os << "BATCHES";
540 break;
541 default:
542 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
543 }
544 return os;
545}
546
Alex Gildayc357c472018-03-21 13:54:09 +0000547/** Formatted output of the DataType type.
548 *
549 * @param[out] os Output stream.
550 * @param[in] data_type Type to output.
551 *
552 * @return Modified output stream.
553 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100554inline ::std::ostream &operator<<(::std::ostream &os, const DataType &data_type)
555{
556 switch(data_type)
557 {
558 case DataType::UNKNOWN:
559 os << "UNKNOWN";
560 break;
561 case DataType::U8:
562 os << "U8";
563 break;
Chunosovd621bca2017-11-03 17:33:15 +0700564 case DataType::QASYMM8:
565 os << "QASYMM8";
566 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100567 case DataType::S8:
568 os << "S8";
569 break;
570 case DataType::U16:
571 os << "U16";
572 break;
573 case DataType::S16:
574 os << "S16";
575 break;
576 case DataType::U32:
577 os << "U32";
578 break;
579 case DataType::S32:
580 os << "S32";
581 break;
582 case DataType::U64:
583 os << "U64";
584 break;
585 case DataType::S64:
586 os << "S64";
587 break;
588 case DataType::F16:
589 os << "F16";
590 break;
591 case DataType::F32:
592 os << "F32";
593 break;
594 case DataType::F64:
595 os << "F64";
596 break;
597 case DataType::SIZET:
598 os << "SIZET";
599 break;
600 default:
601 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
602 }
603
604 return os;
605}
606
Alex Gildayc357c472018-03-21 13:54:09 +0000607/** Formatted output of the DataType type.
608 *
609 * @param[in] data_type Type to output.
610 *
611 * @return Formatted string.
612 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100613inline std::string to_string(const arm_compute::DataType &data_type)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100614{
615 std::stringstream str;
616 str << data_type;
617 return str.str();
618}
619
Alex Gildayc357c472018-03-21 13:54:09 +0000620/** Formatted output of the Format type.
621 *
622 * @param[out] os Output stream.
623 * @param[in] format Type to output.
624 *
625 * @return Modified output stream.
626 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100627inline ::std::ostream &operator<<(::std::ostream &os, const Format &format)
628{
629 switch(format)
630 {
631 case Format::UNKNOWN:
632 os << "UNKNOWN";
633 break;
634 case Format::U8:
635 os << "U8";
636 break;
637 case Format::S16:
638 os << "S16";
639 break;
640 case Format::U16:
641 os << "U16";
642 break;
643 case Format::S32:
644 os << "S32";
645 break;
646 case Format::U32:
647 os << "U32";
648 break;
649 case Format::F16:
650 os << "F16";
651 break;
652 case Format::F32:
653 os << "F32";
654 break;
655 case Format::UV88:
656 os << "UV88";
657 break;
658 case Format::RGB888:
659 os << "RGB888";
660 break;
661 case Format::RGBA8888:
662 os << "RGBA8888";
663 break;
664 case Format::YUV444:
665 os << "YUV444";
666 break;
667 case Format::YUYV422:
668 os << "YUYV422";
669 break;
670 case Format::NV12:
671 os << "NV12";
672 break;
673 case Format::NV21:
674 os << "NV21";
675 break;
676 case Format::IYUV:
677 os << "IYUV";
678 break;
679 case Format::UYVY422:
680 os << "UYVY422";
681 break;
682 default:
683 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
684 }
685
686 return os;
687}
688
Alex Gildayc357c472018-03-21 13:54:09 +0000689/** Formatted output of the Format type.
690 *
691 * @param[in] format Type to output.
692 *
693 * @return Formatted string.
694 */
Moritz Pflanzer7655a672017-09-23 11:57:33 +0100695inline std::string to_string(const Format &format)
696{
697 std::stringstream str;
698 str << format;
699 return str.str();
700}
701
Alex Gildayc357c472018-03-21 13:54:09 +0000702/** Formatted output of the Channel type.
703 *
704 * @param[out] os Output stream.
705 * @param[in] channel Type to output.
706 *
707 * @return Modified output stream.
708 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100709inline ::std::ostream &operator<<(::std::ostream &os, const Channel &channel)
710{
711 switch(channel)
712 {
713 case Channel::UNKNOWN:
714 os << "UNKNOWN";
715 break;
716 case Channel::C0:
717 os << "C0";
718 break;
719 case Channel::C1:
720 os << "C1";
721 break;
722 case Channel::C2:
723 os << "C2";
724 break;
725 case Channel::C3:
726 os << "C3";
727 break;
728 case Channel::R:
729 os << "R";
730 break;
731 case Channel::G:
732 os << "G";
733 break;
734 case Channel::B:
735 os << "B";
736 break;
737 case Channel::A:
738 os << "A";
739 break;
740 case Channel::Y:
741 os << "Y";
742 break;
743 case Channel::U:
744 os << "U";
745 break;
746 case Channel::V:
747 os << "V";
748 break;
749 default:
750 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
751 }
752
753 return os;
754}
755
Alex Gildayc357c472018-03-21 13:54:09 +0000756/** Formatted output of the Channel type.
757 *
758 * @param[in] channel Type to output.
759 *
760 * @return Formatted string.
761 */
Ioan-Cristian Szabo9414f642017-10-27 17:35:40 +0100762inline std::string to_string(const Channel &channel)
763{
764 std::stringstream str;
765 str << channel;
766 return str.str();
767}
768
Alex Gildayc357c472018-03-21 13:54:09 +0000769/** Formatted output of the BorderMode type.
770 *
771 * @param[out] os Output stream.
772 * @param[in] mode Type to output.
773 *
774 * @return Modified output stream.
775 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100776inline ::std::ostream &operator<<(::std::ostream &os, const BorderMode &mode)
777{
778 switch(mode)
779 {
780 case BorderMode::UNDEFINED:
781 os << "UNDEFINED";
782 break;
783 case BorderMode::CONSTANT:
784 os << "CONSTANT";
785 break;
786 case BorderMode::REPLICATE:
787 os << "REPLICATE";
788 break;
789 default:
790 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
791 }
792
793 return os;
794}
795
Alex Gildayc357c472018-03-21 13:54:09 +0000796/** Formatted output of the BorderSize type.
797 *
798 * @param[out] os Output stream.
799 * @param[in] border Type to output.
800 *
801 * @return Modified output stream.
802 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100803inline ::std::ostream &operator<<(::std::ostream &os, const BorderSize &border)
804{
Moritz Pflanzerc87fbf82017-07-18 14:02:10 +0100805 os << border.top << ","
806 << border.right << ","
807 << border.bottom << ","
808 << border.left;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100809
810 return os;
811}
Anthony Barbier2a07e182017-08-04 18:20:27 +0100812
Giuseppe Rossinid7647d42018-07-17 18:13:13 +0100813/** Formatted output of the PaddingList type.
814 *
815 * @param[out] os Output stream.
816 * @param[in] padding Type to output.
817 *
818 * @return Modified output stream.
819 */
820inline ::std::ostream &operator<<(::std::ostream &os, const PaddingList &padding)
821{
822 os << "{";
823 for(auto const &p : padding)
824 {
825 os << "{" << p.first << "," << p.second << "}";
826 }
827 os << "}";
828 return os;
829}
830
Alex Gildayc357c472018-03-21 13:54:09 +0000831/** Formatted output of the InterpolationPolicy type.
832 *
833 * @param[out] os Output stream.
834 * @param[in] policy Type to output.
835 *
836 * @return Modified output stream.
837 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100838inline ::std::ostream &operator<<(::std::ostream &os, const InterpolationPolicy &policy)
839{
840 switch(policy)
841 {
842 case InterpolationPolicy::NEAREST_NEIGHBOR:
843 os << "NEAREST_NEIGHBOR";
844 break;
845 case InterpolationPolicy::BILINEAR:
846 os << "BILINEAR";
847 break;
848 case InterpolationPolicy::AREA:
849 os << "AREA";
850 break;
851 default:
852 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
853 }
854
855 return os;
856}
857
Alex Gildayc357c472018-03-21 13:54:09 +0000858/** Formatted output of the SamplingPolicy type.
859 *
860 * @param[out] os Output stream.
861 * @param[in] policy Type to output.
862 *
863 * @return Modified output stream.
864 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700865inline ::std::ostream &operator<<(::std::ostream &os, const SamplingPolicy &policy)
866{
867 switch(policy)
868 {
869 case SamplingPolicy::CENTER:
870 os << "CENTER";
871 break;
872 case SamplingPolicy::TOP_LEFT:
873 os << "TOP_LEFT";
874 break;
875 default:
876 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
877 }
878
879 return os;
880}
881
Alex Gildayc357c472018-03-21 13:54:09 +0000882/** Formatted output of the TensorInfo type.
883 *
Anthony Barbier366628a2018-08-01 13:55:03 +0100884 * @param[out] os Output stream.
885 * @param[in] info Type to output.
886 *
887 * @return Modified output stream.
888 */
889inline ::std::ostream &operator<<(::std::ostream &os, const TensorInfo &info)
890{
891 os << "{Shape=" << info.tensor_shape() << ","
892 << "Type=" << info.data_type() << ","
893 << "Channels=" << info.num_channels() << "}";
894 return os;
895}
896/** Formatted output of the TensorInfo type.
897 *
Alex Gildayc357c472018-03-21 13:54:09 +0000898 * @param[in] info Type to output.
899 *
900 * @return Formatted string.
901 */
Georgios Pinitas3faea252017-10-30 14:13:50 +0000902inline std::string to_string(const TensorInfo &info)
903{
904 std::stringstream str;
Anthony Barbier366628a2018-08-01 13:55:03 +0100905 str << info;
Georgios Pinitas3faea252017-10-30 14:13:50 +0000906 return str.str();
907}
908
Abe Mbise925ca0f2017-10-02 19:16:33 +0100909//FIXME: Check why this doesn't work and the TensorShape and Coordinates overload are needed
Alex Gildayc357c472018-03-21 13:54:09 +0000910/** Formatted output of the Dimensions type.
911 *
912 * @param[in] dimensions Type to output.
913 *
914 * @return Formatted string.
915 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100916template <typename T>
917inline std::string to_string(const Dimensions<T> &dimensions)
918{
919 std::stringstream str;
920 str << dimensions;
921 return str.str();
922}
923
Alex Gildayc357c472018-03-21 13:54:09 +0000924/** Formatted output of the Strides type.
925 *
926 * @param[in] stride Type to output.
927 *
928 * @return Formatted string.
929 */
John Richardsona36eae12017-09-26 16:55:59 +0100930inline std::string to_string(const Strides &stride)
931{
932 std::stringstream str;
933 str << stride;
934 return str.str();
935}
936
Alex Gildayc357c472018-03-21 13:54:09 +0000937/** Formatted output of the TensorShape type.
938 *
939 * @param[in] shape Type to output.
940 *
941 * @return Formatted string.
942 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100943inline std::string to_string(const TensorShape &shape)
944{
945 std::stringstream str;
946 str << shape;
947 return str.str();
948}
949
Alex Gildayc357c472018-03-21 13:54:09 +0000950/** Formatted output of the Coordinates type.
951 *
952 * @param[in] coord Type to output.
953 *
954 * @return Formatted string.
955 */
Abe Mbise925ca0f2017-10-02 19:16:33 +0100956inline std::string to_string(const Coordinates &coord)
957{
958 std::stringstream str;
959 str << coord;
960 return str.str();
961}
962
Anthony Barbierb940fd62018-06-04 14:14:32 +0100963/** Formatted output of the GEMMReshapeInfo type.
964 *
965 * @param[out] os Output stream.
966 * @param[in] info Type to output.
967 *
968 * @return Modified output stream.
969 */
970inline ::std::ostream &operator<<(::std::ostream &os, const GEMMReshapeInfo &info)
971{
972 os << "{m=" << info.m() << ",";
973 os << "n=" << info.n() << ",";
974 os << "k=" << info.k() << ",";
975 os << "mult_transpose1xW_width=" << info.mult_transpose1xW_width() << ",";
976 os << "mult_interleave4x4_height=" << info.mult_interleave4x4_height();
977 os << "}";
978
979 return os;
980}
981
982/** Formatted output of the GEMMInfo type.
983 *
984 * @param[out] os Output stream.
985 * @param[in] info Type to output.
986 *
987 * @return Modified output stream.
988 */
989inline ::std::ostream &operator<<(::std::ostream &os, const GEMMInfo &info)
990{
991 os << "{is_a_reshaped=" << info.is_a_reshaped() << ",";
992 os << "is_b_reshaped=" << info.is_b_reshaped() << ",";
993 os << "reshape_b_only_on_first_run=" << info.reshape_b_only_on_first_run() << ",";
Anthony Barbierb940fd62018-06-04 14:14:32 +0100994 os << "}";
995
996 return os;
997}
998
999/** Formatted output of the Window::Dimension type.
1000 *
1001 * @param[out] os Output stream.
1002 * @param[in] dim Type to output.
1003 *
1004 * @return Modified output stream.
1005 */
1006inline ::std::ostream &operator<<(::std::ostream &os, const Window::Dimension &dim)
1007{
1008 os << "{start=" << dim.start() << ", end=" << dim.end() << ", step=" << dim.step() << "}";
1009
1010 return os;
1011}
1012/** Formatted output of the Window type.
1013 *
1014 * @param[out] os Output stream.
1015 * @param[in] win Type to output.
1016 *
1017 * @return Modified output stream.
1018 */
1019inline ::std::ostream &operator<<(::std::ostream &os, const Window &win)
1020{
1021 os << "{";
1022 for(unsigned int i = 0; i < Coordinates::num_max_dimensions; i++)
1023 {
1024 if(i > 0)
1025 {
1026 os << ", ";
1027 }
1028 os << win[i];
1029 }
1030 os << "}";
1031
1032 return os;
1033}
1034
1035/** Formatted output of the WeightsInfo type.
1036 *
1037 * @param[in] info Type to output.
1038 *
1039 * @return Formatted string.
1040 */
1041inline std::string to_string(const WeightsInfo &info)
1042{
1043 std::stringstream str;
1044 str << info;
1045 return str.str();
1046}
1047
1048/** Formatted output of the GEMMReshapeInfo type.
1049 *
1050 * @param[in] info Type to output.
1051 *
1052 * @return Formatted string.
1053 */
1054inline std::string to_string(const GEMMReshapeInfo &info)
1055{
1056 std::stringstream str;
1057 str << info;
1058 return str.str();
1059}
1060
1061/** Formatted output of the GEMMInfo type.
1062 *
1063 * @param[in] info Type to output.
1064 *
1065 * @return Formatted string.
1066 */
1067inline std::string to_string(const GEMMInfo &info)
1068{
1069 std::stringstream str;
1070 str << info;
1071 return str.str();
1072}
1073
1074/** Formatted output of the Window::Dimension type.
1075 *
1076 * @param[in] dim Type to output.
1077 *
1078 * @return Formatted string.
1079 */
1080inline std::string to_string(const Window::Dimension &dim)
1081{
1082 std::stringstream str;
1083 str << dim;
1084 return str.str();
1085}
1086/** Formatted output of the Window type.
1087 *
1088 * @param[in] win Type to output.
1089 *
1090 * @return Formatted string.
1091 */
1092inline std::string to_string(const Window &win)
1093{
1094 std::stringstream str;
1095 str << win;
1096 return str.str();
1097}
1098
Alex Gildayc357c472018-03-21 13:54:09 +00001099/** Formatted output of the Rectangle type.
1100 *
1101 * @param[out] os Output stream.
1102 * @param[in] rect Type to output.
1103 *
1104 * @return Modified output stream.
1105 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001106inline ::std::ostream &operator<<(::std::ostream &os, const Rectangle &rect)
1107{
1108 os << rect.width << "x" << rect.height;
1109 os << "+" << rect.x << "+" << rect.y;
1110
1111 return os;
1112}
1113
Alex Gildayc357c472018-03-21 13:54:09 +00001114/** Formatted output of the PadStrideInfo type.
1115 *
1116 * @param[out] os Output stream.
1117 * @param[in] pad_stride_info Type to output.
1118 *
1119 * @return Modified output stream.
1120 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001121inline ::std::ostream &operator<<(::std::ostream &os, const PadStrideInfo &pad_stride_info)
1122{
1123 os << pad_stride_info.stride().first << "," << pad_stride_info.stride().second;
1124 os << ";";
Jaroslaw Rzepeckia1ed41f2017-10-13 11:13:58 +01001125 os << pad_stride_info.pad_left() << "," << pad_stride_info.pad_right() << ","
1126 << pad_stride_info.pad_top() << "," << pad_stride_info.pad_bottom();
Anthony Barbier2a07e182017-08-04 18:20:27 +01001127
1128 return os;
1129}
1130
Alex Gildayc357c472018-03-21 13:54:09 +00001131/** Formatted output of the PadStrideInfo type.
1132 *
1133 * @param[in] pad_stride_info Type to output.
1134 *
1135 * @return Formatted string.
1136 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001137inline std::string to_string(const PadStrideInfo &pad_stride_info)
1138{
1139 std::stringstream str;
1140 str << pad_stride_info;
1141 return str.str();
1142}
1143
Alex Gildayc357c472018-03-21 13:54:09 +00001144/** Formatted output of the BorderMode type.
1145 *
1146 * @param[in] mode Type to output.
1147 *
1148 * @return Formatted string.
1149 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001150inline std::string to_string(const BorderMode &mode)
1151{
1152 std::stringstream str;
1153 str << mode;
1154 return str.str();
1155}
1156
Alex Gildayc357c472018-03-21 13:54:09 +00001157/** Formatted output of the BorderSize type.
1158 *
1159 * @param[in] border Type to output.
1160 *
1161 * @return Formatted string.
1162 */
John Richardsonb482ce12017-09-18 12:44:01 +01001163inline std::string to_string(const BorderSize &border)
1164{
1165 std::stringstream str;
1166 str << border;
1167 return str.str();
1168}
1169
Giuseppe Rossinid7647d42018-07-17 18:13:13 +01001170/** Formatted output of the PaddingList type.
1171 *
1172 * @param[in] padding Type to output.
1173 *
1174 * @return Formatted string.
1175 */
1176inline std::string to_string(const PaddingList &padding)
1177{
1178 std::stringstream str;
1179 str << padding;
1180 return str.str();
1181}
1182
Alex Gildayc357c472018-03-21 13:54:09 +00001183/** Formatted output of the InterpolationPolicy type.
1184 *
1185 * @param[in] policy Type to output.
1186 *
1187 * @return Formatted string.
1188 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001189inline std::string to_string(const InterpolationPolicy &policy)
1190{
1191 std::stringstream str;
1192 str << policy;
1193 return str.str();
1194}
1195
Alex Gildayc357c472018-03-21 13:54:09 +00001196/** Formatted output of the SamplingPolicy type.
1197 *
1198 * @param[in] policy Type to output.
1199 *
1200 * @return Formatted string.
1201 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +07001202inline std::string to_string(const SamplingPolicy &policy)
1203{
1204 std::stringstream str;
1205 str << policy;
1206 return str.str();
1207}
1208
Alex Gildayc357c472018-03-21 13:54:09 +00001209/** Formatted output of the ConvertPolicy type.
1210 *
1211 * @param[out] os Output stream.
1212 * @param[in] policy Type to output.
1213 *
1214 * @return Modified output stream.
1215 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001216inline ::std::ostream &operator<<(::std::ostream &os, const ConvertPolicy &policy)
1217{
1218 switch(policy)
1219 {
1220 case ConvertPolicy::WRAP:
1221 os << "WRAP";
1222 break;
1223 case ConvertPolicy::SATURATE:
1224 os << "SATURATE";
1225 break;
1226 default:
1227 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1228 }
1229
1230 return os;
1231}
1232
1233inline std::string to_string(const ConvertPolicy &policy)
1234{
1235 std::stringstream str;
1236 str << policy;
1237 return str.str();
1238}
1239
Alex Gildayc357c472018-03-21 13:54:09 +00001240/** Formatted output of the Reduction Operations.
1241 *
1242 * @param[out] os Output stream.
1243 * @param[in] op Type to output.
1244 *
1245 * @return Modified output stream.
1246 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001247inline ::std::ostream &operator<<(::std::ostream &os, const ReductionOperation &op)
1248{
1249 switch(op)
1250 {
Michalis Spyrou7e9391b2018-10-05 14:49:28 +01001251 case ReductionOperation::SUM:
1252 os << "SUM";
1253 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +01001254 case ReductionOperation::SUM_SQUARE:
1255 os << "SUM_SQUARE";
1256 break;
Michalis Spyrou7e9391b2018-10-05 14:49:28 +01001257 case ReductionOperation::MEAN_SUM:
1258 os << "MEAN_SUM";
1259 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +01001260 default:
1261 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1262 }
1263
1264 return os;
1265}
1266
Alex Gildayc357c472018-03-21 13:54:09 +00001267/** Formatted output of the Reduction Operations.
1268 *
1269 * @param[in] op Type to output.
1270 *
1271 * @return Formatted string.
1272 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001273inline std::string to_string(const ReductionOperation &op)
1274{
1275 std::stringstream str;
1276 str << op;
1277 return str.str();
1278}
1279
Alex Gildayc357c472018-03-21 13:54:09 +00001280/** Formatted output of the Norm Type.
1281 *
1282 * @param[in] type Type to output.
1283 *
1284 * @return Formatted string.
1285 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001286inline std::string to_string(const NormType &type)
1287{
1288 std::stringstream str;
1289 str << type;
1290 return str.str();
1291}
1292
Alex Gildayc357c472018-03-21 13:54:09 +00001293/** Formatted output of the Pooling Type.
1294 *
1295 * @param[in] type Type to output.
1296 *
1297 * @return Formatted string.
1298 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001299inline std::string to_string(const PoolingType &type)
1300{
1301 std::stringstream str;
1302 str << type;
1303 return str.str();
1304}
1305
Alex Gildayc357c472018-03-21 13:54:09 +00001306/** Formatted output of the Pooling Layer Info.
1307 *
1308 * @param[in] info Type to output.
1309 *
1310 * @return Formatted string.
1311 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001312inline std::string to_string(const PoolingLayerInfo &info)
1313{
1314 std::stringstream str;
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001315 str << "{Type=" << info.pool_type() << ","
1316 << "IsGlobalPooling=" << info.is_global_pooling();
1317 if(!info.is_global_pooling())
1318 {
1319 str << ","
Isabella Gottardi6e464c32018-01-26 12:32:45 +00001320 << "PoolSize=" << info.pool_size().width << "," << info.pool_size().height << ","
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001321 << "PadStride=" << info.pad_stride_info();
1322 }
1323 str << "}";
Anthony Barbier2a07e182017-08-04 18:20:27 +01001324 return str.str();
1325}
1326
Michalis Spyrou6c7c38e2018-08-29 16:28:11 +01001327/** Formatted output of the PriorBoxLayerInfo.
1328 *
1329 * @param[in] info Type to output.
1330 *
1331 * @return Formatted string.
1332 */
1333inline std::string to_string(const PriorBoxLayerInfo &info)
1334{
1335 std::stringstream str;
1336 str << "{";
1337 str << "Clip:" << info.clip()
1338 << "Flip:" << info.flip()
1339 << "StepX:" << info.steps()[0]
1340 << "StepY:" << info.steps()[1]
1341 << "MinSizes:" << info.min_sizes().size()
1342 << "MaxSizes:" << info.max_sizes().size()
1343 << "ImgSizeX:" << info.img_size().x
1344 << "ImgSizeY:" << info.img_size().y
1345 << "Offset:" << info.offset()
1346 << "Variances:" << info.variances().size();
1347 str << "}";
1348 return str.str();
1349}
1350
Alex Gildayc357c472018-03-21 13:54:09 +00001351/** Formatted output of the KeyPoint type.
1352 *
1353 * @param[out] os Output stream
1354 * @param[in] point Type to output.
1355 *
1356 * @return Modified output stream.
1357 */
Moritz Pflanzer6c6597c2017-09-24 12:09:41 +01001358inline ::std::ostream &operator<<(::std::ostream &os, const KeyPoint &point)
1359{
1360 os << "{x=" << point.x << ","
1361 << "y=" << point.y << ","
1362 << "strength=" << point.strength << ","
1363 << "scale=" << point.scale << ","
1364 << "orientation=" << point.orientation << ","
1365 << "tracking_status=" << point.tracking_status << ","
1366 << "error=" << point.error << "}";
1367
1368 return os;
1369}
John Richardson63e50412017-10-13 20:51:42 +01001370
Alex Gildayc357c472018-03-21 13:54:09 +00001371/** Formatted output of the PhaseType type.
1372 *
1373 * @param[out] os Output stream
1374 * @param[in] phase_type Type to output.
1375 *
1376 * @return Modified output stream.
1377 */
John Richardson63e50412017-10-13 20:51:42 +01001378inline ::std::ostream &operator<<(::std::ostream &os, const PhaseType &phase_type)
1379{
1380 switch(phase_type)
1381 {
1382 case PhaseType::SIGNED:
1383 os << "SIGNED";
1384 break;
1385 case PhaseType::UNSIGNED:
1386 os << "UNSIGNED";
1387 break;
1388 default:
1389 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1390 }
1391
1392 return os;
1393}
1394
Alex Gildayc357c472018-03-21 13:54:09 +00001395/** Formatted output of the PhaseType type.
1396 *
1397 * @param[in] type Type to output.
1398 *
1399 * @return Formatted string.
1400 */
John Richardson63e50412017-10-13 20:51:42 +01001401inline std::string to_string(const arm_compute::PhaseType &type)
1402{
1403 std::stringstream str;
1404 str << type;
1405 return str.str();
1406}
John Richardson3c5f9492017-10-04 15:27:37 +01001407
Alex Gildayc357c472018-03-21 13:54:09 +00001408/** Formatted output of the MagnitudeType type.
1409 *
1410 * @param[out] os Output stream
1411 * @param[in] magnitude_type Type to output.
1412 *
1413 * @return Modified output stream.
1414 */
John Richardson3c5f9492017-10-04 15:27:37 +01001415inline ::std::ostream &operator<<(::std::ostream &os, const MagnitudeType &magnitude_type)
1416{
1417 switch(magnitude_type)
1418 {
1419 case MagnitudeType::L1NORM:
1420 os << "L1NORM";
1421 break;
1422 case MagnitudeType::L2NORM:
1423 os << "L2NORM";
1424 break;
1425 default:
1426 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1427 }
1428
1429 return os;
1430}
1431
Alex Gildayc357c472018-03-21 13:54:09 +00001432/** Formatted output of the MagnitudeType type.
1433 *
1434 * @param[in] type Type to output.
1435 *
1436 * @return Formatted string.
1437 */
John Richardson3c5f9492017-10-04 15:27:37 +01001438inline std::string to_string(const arm_compute::MagnitudeType &type)
1439{
1440 std::stringstream str;
1441 str << type;
1442 return str.str();
1443}
John Richardson1c529922017-11-01 10:57:48 +00001444
Alex Gildayc357c472018-03-21 13:54:09 +00001445/** Formatted output of the HOGNormType type.
1446 *
1447 * @param[out] os Output stream
1448 * @param[in] norm_type Type to output
1449 *
1450 * @return Modified output stream.
1451 */
John Richardson25f23682017-11-27 14:35:09 +00001452inline ::std::ostream &operator<<(::std::ostream &os, const HOGNormType &norm_type)
1453{
1454 switch(norm_type)
1455 {
1456 case HOGNormType::L1_NORM:
1457 os << "L1_NORM";
1458 break;
1459 case HOGNormType::L2_NORM:
1460 os << "L2_NORM";
1461 break;
1462 case HOGNormType::L2HYS_NORM:
1463 os << "L2HYS_NORM";
1464 break;
1465 default:
1466 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1467 }
1468
1469 return os;
1470}
1471
Alex Gildayc357c472018-03-21 13:54:09 +00001472/** Formatted output of the HOGNormType type.
1473 *
1474 * @param[in] type Type to output
1475 *
1476 * @return Formatted string.
1477 */
John Richardson25f23682017-11-27 14:35:09 +00001478inline std::string to_string(const HOGNormType &type)
1479{
1480 std::stringstream str;
1481 str << type;
1482 return str.str();
1483}
1484
Alex Gildayc357c472018-03-21 13:54:09 +00001485/** Formatted output of the Size2D type.
1486 *
1487 * @param[out] os Output stream
1488 * @param[in] size Type to output
1489 *
1490 * @return Modified output stream.
1491 */
John Richardson25f23682017-11-27 14:35:09 +00001492inline ::std::ostream &operator<<(::std::ostream &os, const Size2D &size)
1493{
1494 os << size.width << "x" << size.height;
1495
1496 return os;
1497}
1498
Alex Gildayc357c472018-03-21 13:54:09 +00001499/** Formatted output of the Size2D type.
1500 *
1501 * @param[in] type Type to output
1502 *
1503 * @return Formatted string.
1504 */
John Richardson25f23682017-11-27 14:35:09 +00001505inline std::string to_string(const Size2D &type)
1506{
1507 std::stringstream str;
1508 str << type;
1509 return str.str();
1510}
1511
Alex Gildayc357c472018-03-21 13:54:09 +00001512/** Formatted output of the HOGInfo type.
1513 *
1514 * @param[out] os Output stream
1515 * @param[in] hog_info Type to output
1516 *
1517 * @return Modified output stream.
1518 */
John Richardson25f23682017-11-27 14:35:09 +00001519inline ::std::ostream &operator<<(::std::ostream &os, const HOGInfo &hog_info)
1520{
1521 os << "{CellSize=" << hog_info.cell_size() << ","
1522 << "BlockSize=" << hog_info.block_size() << ","
1523 << "DetectionWindowSize=" << hog_info.detection_window_size() << ","
1524 << "BlockStride=" << hog_info.block_stride() << ","
1525 << "NumBins=" << hog_info.num_bins() << ","
1526 << "NormType=" << hog_info.normalization_type() << ","
1527 << "L2HystThreshold=" << hog_info.l2_hyst_threshold() << ","
1528 << "PhaseType=" << hog_info.phase_type() << "}";
1529
1530 return os;
1531}
1532
Alex Gildayc357c472018-03-21 13:54:09 +00001533/** Formatted output of the HOGInfo type.
1534 *
1535 * @param[in] type Type to output
1536 *
1537 * @return Formatted string.
1538 */
John Richardson25f23682017-11-27 14:35:09 +00001539inline std::string to_string(const HOGInfo &type)
1540{
1541 std::stringstream str;
1542 str << type;
1543 return str.str();
1544}
1545
Alex Gildayc357c472018-03-21 13:54:09 +00001546/** Formatted output of the ConvolutionMethod type.
1547 *
1548 * @param[out] os Output stream
1549 * @param[in] conv_method Type to output
1550 *
1551 * @return Modified output stream.
1552 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001553inline ::std::ostream &operator<<(::std::ostream &os, const ConvolutionMethod &conv_method)
1554{
1555 switch(conv_method)
1556 {
1557 case ConvolutionMethod::GEMM:
1558 os << "GEMM";
1559 break;
1560 case ConvolutionMethod::DIRECT:
1561 os << "DIRECT";
1562 break;
1563 case ConvolutionMethod::WINOGRAD:
1564 os << "WINOGRAD";
1565 break;
1566 default:
1567 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1568 }
1569
1570 return os;
1571}
1572
Alex Gildayc357c472018-03-21 13:54:09 +00001573/** Formatted output of the ConvolutionMethod type.
1574 *
1575 * @param[in] conv_method Type to output
1576 *
1577 * @return Formatted string.
1578 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001579inline std::string to_string(const ConvolutionMethod &conv_method)
1580{
1581 std::stringstream str;
1582 str << conv_method;
1583 return str.str();
1584}
1585
Alex Gildayc357c472018-03-21 13:54:09 +00001586/** Formatted output of the GPUTarget type.
1587 *
1588 * @param[out] os Output stream
1589 * @param[in] gpu_target Type to output
1590 *
1591 * @return Modified output stream.
1592 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001593inline ::std::ostream &operator<<(::std::ostream &os, const GPUTarget &gpu_target)
1594{
1595 switch(gpu_target)
1596 {
1597 case GPUTarget::GPU_ARCH_MASK:
1598 os << "GPU_ARCH_MASK";
1599 break;
1600 case GPUTarget::MIDGARD:
1601 os << "MIDGARD";
1602 break;
1603 case GPUTarget::BIFROST:
1604 os << "BIFROST";
1605 break;
1606 case GPUTarget::T600:
1607 os << "T600";
1608 break;
1609 case GPUTarget::T700:
1610 os << "T700";
1611 break;
1612 case GPUTarget::T800:
1613 os << "T800";
1614 break;
Michalis Spyroua9676112018-02-22 18:07:43 +00001615 case GPUTarget::G71:
1616 os << "G71";
1617 break;
1618 case GPUTarget::G72:
1619 os << "G72";
1620 break;
1621 case GPUTarget::G51:
1622 os << "G51";
1623 break;
1624 case GPUTarget::G51BIG:
1625 os << "G51BIG";
1626 break;
1627 case GPUTarget::G51LIT:
1628 os << "G51LIT";
1629 break;
Georgios Pinitasb03f7c52018-07-12 10:49:53 +01001630 case GPUTarget::G76:
1631 os << "G76";
Michalis Spyroua9676112018-02-22 18:07:43 +00001632 break;
1633 case GPUTarget::TTRX:
1634 os << "TTRX";
1635 break;
1636 case GPUTarget::TBOX:
1637 os << "TBOX";
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001638 break;
1639 default:
1640 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1641 }
1642
1643 return os;
1644}
1645
Alex Gildayc357c472018-03-21 13:54:09 +00001646/** Formatted output of the GPUTarget type.
1647 *
1648 * @param[in] gpu_target Type to output
1649 *
1650 * @return Formatted string.
1651 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001652inline std::string to_string(const GPUTarget &gpu_target)
1653{
1654 std::stringstream str;
1655 str << gpu_target;
1656 return str.str();
1657}
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00001658
John Richardson8de92612018-02-22 14:09:31 +00001659/** Formatted output of the DetectionWindow type.
1660 *
1661 * @param[out] os Output stream
1662 * @param[in] detection_window Type to output
1663 *
1664 * @return Modified output stream.
1665 */
John Richardson684cb0f2018-01-09 11:17:00 +00001666inline ::std::ostream &operator<<(::std::ostream &os, const DetectionWindow &detection_window)
1667{
1668 os << "{x=" << detection_window.x << ","
1669 << "y=" << detection_window.y << ","
1670 << "width=" << detection_window.width << ","
1671 << "height=" << detection_window.height << ","
1672 << "idx_class=" << detection_window.idx_class << ","
1673 << "score=" << detection_window.score << "}";
1674
1675 return os;
1676}
1677
John Richardson8de92612018-02-22 14:09:31 +00001678/** Formatted output of the DetectionWindow type.
1679 *
1680 * @param[in] detection_window Type to output
1681 *
1682 * @return Formatted string.
1683 */
1684inline std::string to_string(const DetectionWindow &detection_window)
1685{
1686 std::stringstream str;
1687 str << detection_window;
1688 return str.str();
1689}
1690
1691/** Formatted output of the Termination type.
1692 *
1693 * @param[out] os Output stream
1694 * @param[in] termination Type to output
1695 *
1696 * @return Modified output stream.
1697 */
1698inline ::std::ostream &operator<<(::std::ostream &os, const Termination &termination)
1699{
1700 switch(termination)
1701 {
1702 case Termination::TERM_CRITERIA_EPSILON:
1703 os << "TERM_CRITERIA_EPSILON";
1704 break;
1705 case Termination::TERM_CRITERIA_ITERATIONS:
1706 os << "TERM_CRITERIA_ITERATIONS";
1707 break;
1708 case Termination::TERM_CRITERIA_BOTH:
1709 os << "TERM_CRITERIA_BOTH";
1710 break;
1711 default:
1712 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1713 }
1714
1715 return os;
1716}
1717
1718/** Formatted output of the Termination type.
1719 *
1720 * @param[in] termination Type to output
1721 *
1722 * @return Formatted string.
1723 */
1724inline std::string to_string(const Termination &termination)
1725{
1726 std::stringstream str;
1727 str << termination;
1728 return str.str();
1729}
1730
Anthony Barbier8914e322018-08-10 15:28:25 +01001731/** Formatted output of the CPUModel type.
1732 *
1733 * @param[out] os Output stream
1734 * @param[in] cpu_model Model to output
1735 *
1736 * @return Modified output stream.
1737 */
1738inline ::std::ostream &operator<<(::std::ostream &os, const CPUModel &cpu_model)
1739{
1740 switch(cpu_model)
1741 {
1742 case CPUModel::GENERIC:
1743 os << "GENERIC";
1744 break;
1745 case CPUModel::GENERIC_FP16:
1746 os << "GENERIC_FP16";
1747 break;
1748 case CPUModel::GENERIC_FP16_DOT:
1749 os << "GENERIC_FP16_DOT";
1750 break;
1751 case CPUModel::A53:
1752 os << "A53";
1753 break;
1754 case CPUModel::A55r0:
1755 os << "A55r0";
1756 break;
1757 case CPUModel::A55r1:
1758 os << "A55r1";
1759 break;
1760 default:
1761 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1762 }
1763
1764 return os;
1765}
1766
1767/** Formatted output of the CPUModel type.
1768 *
1769 * @param[in] cpu_model Model to output
1770 *
1771 * @return Formatted string.
1772 */
1773inline std::string to_string(const CPUModel &cpu_model)
1774{
1775 std::stringstream str;
1776 str << cpu_model;
1777 return str.str();
1778}
Anthony Barbier671a11e2018-07-06 15:11:36 +01001779/** Formatted output of a vector of objects.
1780 *
1781 * @param[out] os Output stream
1782 * @param[in] args Vector of objects to print
1783 *
1784 * @return Modified output stream.
1785 */
1786template <typename T>
1787inline ::std::ostream &operator<<(::std::ostream &os, const std::vector<T> &args)
1788{
1789 os << "[";
1790 bool first = true;
1791 for(auto &arg : args)
1792 {
1793 if(first)
1794 {
1795 first = false;
1796 }
1797 else
1798 {
1799 os << ", ";
1800 }
1801 os << arg;
1802 }
1803 os << "]";
1804 return os;
1805}
1806
Michalis Spyrou6c7c38e2018-08-29 16:28:11 +01001807/** Formatted output of @ref PriorBoxLayerInfo.
1808 *
1809 * @param[out] os Output stream.
1810 * @param[in] info Type to output.
1811 *
1812 * @return Modified output stream.
1813 */
1814inline ::std::ostream &operator<<(::std::ostream &os, const PriorBoxLayerInfo &info)
1815{
1816 os << "Clip:" << info.clip()
1817 << "Flip:" << info.flip()
1818 << "StepX:" << info.steps()[0]
1819 << "StepY:" << info.steps()[1]
1820 << "MinSizes:" << info.min_sizes()
1821 << "MaxSizes:" << info.max_sizes()
1822 << "ImgSizeX:" << info.img_size().x
1823 << "ImgSizeY:" << info.img_size().y
1824 << "Offset:" << info.offset()
1825 << "Variances:" << info.variances();
1826
1827 return os;
1828}
1829
Anthony Barbier671a11e2018-07-06 15:11:36 +01001830/** Formatted output of a vector of objects.
1831 *
1832 * @param[in] args Vector of objects to print
1833 *
1834 * @return String representing args.
1835 */
1836template <typename T>
1837std::string to_string(const std::vector<T> &args)
1838{
1839 std::stringstream str;
1840 str << args;
1841 return str.str();
1842}
1843
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00001844/** Formatted output of the WinogradInfo type. */
1845inline ::std::ostream &operator<<(::std::ostream &os, const WinogradInfo &info)
1846{
1847 os << "{OutputTileSize=" << info.output_tile_size << ","
1848 << "KernelSize=" << info.kernel_size << ","
1849 << "PadStride=" << info.convolution_info << ","
1850 << "OutputDataLayout=" << info.output_data_layout << "}";
1851
1852 return os;
1853}
1854
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00001855inline std::string to_string(const WinogradInfo &type)
1856{
1857 std::stringstream str;
1858 str << type;
1859 return str.str();
1860}
Anthony Barbier671a11e2018-07-06 15:11:36 +01001861
1862/** Fallback method: try to use std::to_string:
1863 *
1864 * @param[in] val Value to convert to string
1865 *
1866 * @return String representing val.
1867 */
1868template <typename T>
1869inline std::string to_string(const T &val)
1870{
1871 return support::cpp11::to_string(val);
1872}
1873
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001874} // namespace arm_compute
Anthony Barbier4dbc0a92018-08-27 13:39:47 +01001875
1876#endif /* __ARM_COMPUTE_TYPE_PRINTER_H__ */