blob: 49edffbb3dde683f05e82b4ba5a41da9c98de17d [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001/*
Manuel Bottinib412fab2018-12-10 17:40:23 +00002 * Copyright (c) 2017-2019 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
Anthony Barbier8914e322018-08-10 15:28:25 +010027#include "arm_compute/core/CPP/CPPTypes.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010028#include "arm_compute/core/Dimensions.h"
29#include "arm_compute/core/Error.h"
Michele Di Giorgiob8fc60f2018-04-25 11:58:07 +010030#include "arm_compute/core/GPUTarget.h"
John Richardson25f23682017-11-27 14:35:09 +000031#include "arm_compute/core/HOGInfo.h"
32#include "arm_compute/core/Size2D.h"
John Richardsona36eae12017-09-26 16:55:59 +010033#include "arm_compute/core/Strides.h"
Georgios Pinitas3faea252017-10-30 14:13:50 +000034#include "arm_compute/core/TensorInfo.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010035#include "arm_compute/core/Types.h"
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +010036#include "arm_compute/runtime/CL/CLTunerTypes.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010037
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
Manuel Bottini5209be52019-02-13 16:34:56 +0000264/** Formatted output of the ComputeAnchorsInfo type.
265 *
266 * @param[out] os Output stream.
267 * @param[in] anchors_info Type to output.
268 *
269 * @return Modified output stream.
270 */
271inline ::std::ostream &operator<<(::std::ostream &os, const ComputeAnchorsInfo &anchors_info)
272{
273 os << "(" << anchors_info.feat_width() << "x" << anchors_info.feat_height() << ")~" << anchors_info.spatial_scale();
274 return os;
275}
276
277/** Formatted output of the ComputeAnchorsInfo type.
278 *
279 * @param[in] anchors_info Type to output.
280 *
281 * @return Formatted string.
282 */
283inline std::string to_string(const ComputeAnchorsInfo &anchors_info)
284{
285 std::stringstream str;
286 str << anchors_info;
287 return str.str();
288}
289
290/** Formatted output of the GenerateProposalsInfo type.
291 *
292 * @param[out] os Output stream.
293 * @param[in] proposals_info Type to output.
294 *
295 * @return Modified output stream.
296 */
297inline ::std::ostream &operator<<(::std::ostream &os, const GenerateProposalsInfo &proposals_info)
298{
299 os << "(" << proposals_info.im_width() << "x" << proposals_info.im_height() << ")~" << proposals_info.im_scale();
300 return os;
301}
302
303/** Formatted output of the GenerateProposalsInfo type.
304 *
305 * @param[in] proposals_info Type to output.
306 *
307 * @return Formatted string.
308 */
309inline std::string to_string(const GenerateProposalsInfo &proposals_info)
310{
311 std::stringstream str;
312 str << proposals_info;
313 return str.str();
314}
315
Alex Gildayc357c472018-03-21 13:54:09 +0000316/** Formatted output of the QuantizationInfo type.
317 *
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100318 * @param[out] os Output stream.
319 * @param[in] qinfo Type to output.
Alex Gildayc357c472018-03-21 13:54:09 +0000320 *
321 * @return Modified output stream.
322 */
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100323inline ::std::ostream &operator<<(::std::ostream &os, const QuantizationInfo &qinfo)
Chunosovd621bca2017-11-03 17:33:15 +0700324{
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100325 if(!qinfo.scale.empty())
326 {
327 os << "Scale:" << qinfo.scale[0] << "~";
328 }
329 if(!qinfo.empty())
330 {
331 os << "Offset:" << qinfo.offset[0];
332 }
Chunosovd621bca2017-11-03 17:33:15 +0700333 return os;
334}
335
Alex Gildayc357c472018-03-21 13:54:09 +0000336/** Formatted output of the QuantizationInfo type.
337 *
338 * @param[in] quantization_info Type to output.
339 *
340 * @return Formatted string.
341 */
Chunosovd621bca2017-11-03 17:33:15 +0700342inline std::string to_string(const QuantizationInfo &quantization_info)
343{
344 std::stringstream str;
345 str << quantization_info;
346 return str.str();
347}
348
Alex Gildayc357c472018-03-21 13:54:09 +0000349/** Formatted output of the activation function type.
350 *
351 * @param[out] os Output stream.
352 * @param[in] act_function Type to output.
353 *
354 * @return Modified output stream.
355 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100356inline ::std::ostream &operator<<(::std::ostream &os, const ActivationLayerInfo::ActivationFunction &act_function)
357{
358 switch(act_function)
359 {
360 case ActivationLayerInfo::ActivationFunction::ABS:
361 os << "ABS";
362 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100363 case ActivationLayerInfo::ActivationFunction::LINEAR:
364 os << "LINEAR";
365 break;
366 case ActivationLayerInfo::ActivationFunction::LOGISTIC:
367 os << "LOGISTIC";
368 break;
369 case ActivationLayerInfo::ActivationFunction::RELU:
370 os << "RELU";
371 break;
Georgios Pinitas579c0492017-07-12 16:12:12 +0100372 case ActivationLayerInfo::ActivationFunction::BOUNDED_RELU:
373 os << "BOUNDED_RELU";
374 break;
375 case ActivationLayerInfo::ActivationFunction::LEAKY_RELU:
376 os << "LEAKY_RELU";
377 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100378 case ActivationLayerInfo::ActivationFunction::SOFT_RELU:
379 os << "SOFT_RELU";
380 break;
381 case ActivationLayerInfo::ActivationFunction::SQRT:
382 os << "SQRT";
383 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100384 case ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU:
385 os << "LU_BOUNDED_RELU";
Kevin Petitd9f80712017-12-06 12:18:48 +0000386 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100387 case ActivationLayerInfo::ActivationFunction::SQUARE:
388 os << "SQUARE";
389 break;
390 case ActivationLayerInfo::ActivationFunction::TANH:
391 os << "TANH";
392 break;
Usama Arif6a98a6e2019-05-10 17:07:27 +0100393 case ActivationLayerInfo::ActivationFunction::IDENTITY:
394 os << "IDENTITY";
395 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100396 default:
397 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
398 }
399
400 return os;
401}
402
Alex Gildayc357c472018-03-21 13:54:09 +0000403/** Formatted output of the activation function info type.
404 *
405 * @param[in] info Type to output.
406 *
407 * @return Formatted string.
408 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100409inline std::string to_string(const arm_compute::ActivationLayerInfo &info)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100410{
411 std::stringstream str;
Isabella Gottardi3f217ec2018-02-12 14:59:19 +0000412 if(info.enabled())
413 {
414 str << info.activation();
415 }
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100416 return str.str();
417}
418
Alex Gildayc357c472018-03-21 13:54:09 +0000419/** Formatted output of the activation function type.
420 *
421 * @param[in] function Type to output.
422 *
423 * @return Formatted string.
424 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100425inline std::string to_string(const arm_compute::ActivationLayerInfo::ActivationFunction &function)
426{
427 std::stringstream str;
428 str << function;
429 return str.str();
430}
431
Alex Gildayc357c472018-03-21 13:54:09 +0000432/** Formatted output of the NormType type.
433 *
434 * @param[out] os Output stream.
435 * @param[in] norm_type Type to output.
436 *
437 * @return Modified output stream.
438 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100439inline ::std::ostream &operator<<(::std::ostream &os, const NormType &norm_type)
440{
441 switch(norm_type)
442 {
443 case NormType::CROSS_MAP:
444 os << "CROSS_MAP";
445 break;
446 case NormType::IN_MAP_1D:
447 os << "IN_MAP_1D";
448 break;
449 case NormType::IN_MAP_2D:
450 os << "IN_MAP_2D";
451 break;
452 default:
453 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
454 }
455
456 return os;
457}
458
Alex Gildayc357c472018-03-21 13:54:09 +0000459/** Formatted output of @ref NormalizationLayerInfo.
460 *
461 * @param[in] info Type to output.
462 *
463 * @return Formatted string.
464 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100465inline std::string to_string(const arm_compute::NormalizationLayerInfo &info)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100466{
467 std::stringstream str;
Michalis Spyroud466c2d2018-01-30 10:54:39 +0000468 str << info.type() << ":NormSize=" << info.norm_size();
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100469 return str.str();
470}
471
Alex Gildayc357c472018-03-21 13:54:09 +0000472/** Formatted output of @ref NormalizationLayerInfo.
473 *
474 * @param[out] os Output stream.
475 * @param[in] info Type to output.
476 *
477 * @return Modified output stream.
478 */
Georgios Pinitas6f669f02017-09-26 12:32:57 +0100479inline ::std::ostream &operator<<(::std::ostream &os, const NormalizationLayerInfo &info)
480{
Michalis Spyroud466c2d2018-01-30 10:54:39 +0000481 os << info.type() << ":NormSize=" << info.norm_size();
Georgios Pinitas6f669f02017-09-26 12:32:57 +0100482 return os;
483}
484
Alex Gildayc357c472018-03-21 13:54:09 +0000485/** Formatted output of the PoolingType type.
486 *
487 * @param[out] os Output stream.
488 * @param[in] pool_type Type to output.
489 *
490 * @return Modified output stream.
491 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100492inline ::std::ostream &operator<<(::std::ostream &os, const PoolingType &pool_type)
493{
494 switch(pool_type)
495 {
496 case PoolingType::AVG:
497 os << "AVG";
498 break;
499 case PoolingType::MAX:
500 os << "MAX";
501 break;
Georgios Pinitascdf51452017-08-31 14:21:36 +0100502 case PoolingType::L2:
503 os << "L2";
504 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100505 default:
506 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
507 }
508
509 return os;
510}
511
Alex Gildayc357c472018-03-21 13:54:09 +0000512/** Formatted output of @ref PoolingLayerInfo.
513 *
514 * @param[out] os Output stream.
515 * @param[in] info Type to output.
516 *
517 * @return Modified output stream.
518 */
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100519inline ::std::ostream &operator<<(::std::ostream &os, const PoolingLayerInfo &info)
520{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100521 os << info.pool_type();
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100522
523 return os;
524}
525
Alex Gildayc357c472018-03-21 13:54:09 +0000526/** Formatted output of @ref RoundingPolicy.
527 *
528 * @param[in] rounding_policy Type to output.
529 *
530 * @return Formatted string.
531 */
John Richardsondd715f22017-09-18 16:10:48 +0100532inline std::string to_string(const RoundingPolicy &rounding_policy)
533{
534 std::stringstream str;
535 str << rounding_policy;
536 return str.str();
537}
538
Vidhya Sudhan Loganathand646ae12018-11-19 15:18:20 +0000539/** [Print DataLayout type] **/
Alex Gildayc357c472018-03-21 13:54:09 +0000540/** Formatted output of the DataLayout type.
541 *
542 * @param[out] os Output stream.
543 * @param[in] data_layout Type to output.
544 *
545 * @return Modified output stream.
546 */
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000547inline ::std::ostream &operator<<(::std::ostream &os, const DataLayout &data_layout)
548{
549 switch(data_layout)
550 {
551 case DataLayout::UNKNOWN:
552 os << "UNKNOWN";
553 break;
554 case DataLayout::NHWC:
555 os << "NHWC";
556 break;
557 case DataLayout::NCHW:
558 os << "NCHW";
559 break;
560 default:
561 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
562 }
563
564 return os;
565}
566
Alex Gildayc357c472018-03-21 13:54:09 +0000567/** Formatted output of the DataLayout type.
568 *
569 * @param[in] data_layout Type to output.
570 *
571 * @return Formatted string.
572 */
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000573inline std::string to_string(const arm_compute::DataLayout &data_layout)
574{
575 std::stringstream str;
576 str << data_layout;
577 return str.str();
578}
Vidhya Sudhan Loganathand646ae12018-11-19 15:18:20 +0000579/** [Print DataLayout type] **/
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000580
Georgios Pinitase2220552018-07-20 13:23:44 +0100581/** Formatted output of the DataLayoutDimension type.
582 *
583 * @param[out] os Output stream.
584 * @param[in] data_layout_dim Data layout dimension to print.
585 *
586 * @return Modified output stream.
587 */
588inline ::std::ostream &operator<<(::std::ostream &os, const DataLayoutDimension &data_layout_dim)
589{
590 switch(data_layout_dim)
591 {
592 case DataLayoutDimension::WIDTH:
593 os << "WIDTH";
594 break;
595 case DataLayoutDimension::HEIGHT:
596 os << "HEIGHT";
597 break;
598 case DataLayoutDimension::CHANNEL:
599 os << "CHANNEL";
600 break;
601 case DataLayoutDimension::BATCHES:
602 os << "BATCHES";
603 break;
604 default:
605 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
606 }
607 return os;
608}
609
Alex Gildayc357c472018-03-21 13:54:09 +0000610/** Formatted output of the DataType type.
611 *
612 * @param[out] os Output stream.
613 * @param[in] data_type Type to output.
614 *
615 * @return Modified output stream.
616 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100617inline ::std::ostream &operator<<(::std::ostream &os, const DataType &data_type)
618{
619 switch(data_type)
620 {
621 case DataType::UNKNOWN:
622 os << "UNKNOWN";
623 break;
624 case DataType::U8:
625 os << "U8";
626 break;
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100627 case DataType::QSYMM8:
628 os << "QSYMM8";
629 break;
Chunosovd621bca2017-11-03 17:33:15 +0700630 case DataType::QASYMM8:
631 os << "QASYMM8";
632 break;
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100633 case DataType::QSYMM8_PER_CHANNEL:
634 os << "QSYMM8_PER_CHANNEL";
635 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100636 case DataType::S8:
637 os << "S8";
638 break;
639 case DataType::U16:
640 os << "U16";
641 break;
642 case DataType::S16:
643 os << "S16";
644 break;
Manuel Bottini3689fcd2019-06-14 17:18:12 +0100645 case DataType::QSYMM16:
646 os << "QSYMM16";
647 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100648 case DataType::U32:
649 os << "U32";
650 break;
651 case DataType::S32:
652 os << "S32";
653 break;
654 case DataType::U64:
655 os << "U64";
656 break;
657 case DataType::S64:
658 os << "S64";
659 break;
660 case DataType::F16:
661 os << "F16";
662 break;
663 case DataType::F32:
664 os << "F32";
665 break;
666 case DataType::F64:
667 os << "F64";
668 break;
669 case DataType::SIZET:
670 os << "SIZET";
671 break;
672 default:
673 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
674 }
675
676 return os;
677}
678
Alex Gildayc357c472018-03-21 13:54:09 +0000679/** Formatted output of the DataType type.
680 *
681 * @param[in] data_type Type to output.
682 *
683 * @return Formatted string.
684 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100685inline std::string to_string(const arm_compute::DataType &data_type)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100686{
687 std::stringstream str;
688 str << data_type;
689 return str.str();
690}
691
Alex Gildayc357c472018-03-21 13:54:09 +0000692/** Formatted output of the Format type.
693 *
694 * @param[out] os Output stream.
695 * @param[in] format Type to output.
696 *
697 * @return Modified output stream.
698 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100699inline ::std::ostream &operator<<(::std::ostream &os, const Format &format)
700{
701 switch(format)
702 {
703 case Format::UNKNOWN:
704 os << "UNKNOWN";
705 break;
706 case Format::U8:
707 os << "U8";
708 break;
709 case Format::S16:
710 os << "S16";
711 break;
712 case Format::U16:
713 os << "U16";
714 break;
715 case Format::S32:
716 os << "S32";
717 break;
718 case Format::U32:
719 os << "U32";
720 break;
721 case Format::F16:
722 os << "F16";
723 break;
724 case Format::F32:
725 os << "F32";
726 break;
727 case Format::UV88:
728 os << "UV88";
729 break;
730 case Format::RGB888:
731 os << "RGB888";
732 break;
733 case Format::RGBA8888:
734 os << "RGBA8888";
735 break;
736 case Format::YUV444:
737 os << "YUV444";
738 break;
739 case Format::YUYV422:
740 os << "YUYV422";
741 break;
742 case Format::NV12:
743 os << "NV12";
744 break;
745 case Format::NV21:
746 os << "NV21";
747 break;
748 case Format::IYUV:
749 os << "IYUV";
750 break;
751 case Format::UYVY422:
752 os << "UYVY422";
753 break;
754 default:
755 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
756 }
757
758 return os;
759}
760
Alex Gildayc357c472018-03-21 13:54:09 +0000761/** Formatted output of the Format type.
762 *
763 * @param[in] format Type to output.
764 *
765 * @return Formatted string.
766 */
Moritz Pflanzer7655a672017-09-23 11:57:33 +0100767inline std::string to_string(const Format &format)
768{
769 std::stringstream str;
770 str << format;
771 return str.str();
772}
773
Alex Gildayc357c472018-03-21 13:54:09 +0000774/** Formatted output of the Channel type.
775 *
776 * @param[out] os Output stream.
777 * @param[in] channel Type to output.
778 *
779 * @return Modified output stream.
780 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100781inline ::std::ostream &operator<<(::std::ostream &os, const Channel &channel)
782{
783 switch(channel)
784 {
785 case Channel::UNKNOWN:
786 os << "UNKNOWN";
787 break;
788 case Channel::C0:
789 os << "C0";
790 break;
791 case Channel::C1:
792 os << "C1";
793 break;
794 case Channel::C2:
795 os << "C2";
796 break;
797 case Channel::C3:
798 os << "C3";
799 break;
800 case Channel::R:
801 os << "R";
802 break;
803 case Channel::G:
804 os << "G";
805 break;
806 case Channel::B:
807 os << "B";
808 break;
809 case Channel::A:
810 os << "A";
811 break;
812 case Channel::Y:
813 os << "Y";
814 break;
815 case Channel::U:
816 os << "U";
817 break;
818 case Channel::V:
819 os << "V";
820 break;
821 default:
822 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
823 }
824
825 return os;
826}
827
Alex Gildayc357c472018-03-21 13:54:09 +0000828/** Formatted output of the Channel type.
829 *
830 * @param[in] channel Type to output.
831 *
832 * @return Formatted string.
833 */
Ioan-Cristian Szabo9414f642017-10-27 17:35:40 +0100834inline std::string to_string(const Channel &channel)
835{
836 std::stringstream str;
837 str << channel;
838 return str.str();
839}
840
Alex Gildayc357c472018-03-21 13:54:09 +0000841/** Formatted output of the BorderMode type.
842 *
843 * @param[out] os Output stream.
844 * @param[in] mode Type to output.
845 *
846 * @return Modified output stream.
847 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100848inline ::std::ostream &operator<<(::std::ostream &os, const BorderMode &mode)
849{
850 switch(mode)
851 {
852 case BorderMode::UNDEFINED:
853 os << "UNDEFINED";
854 break;
855 case BorderMode::CONSTANT:
856 os << "CONSTANT";
857 break;
858 case BorderMode::REPLICATE:
859 os << "REPLICATE";
860 break;
861 default:
862 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
863 }
864
865 return os;
866}
867
Alex Gildayc357c472018-03-21 13:54:09 +0000868/** Formatted output of the BorderSize type.
869 *
870 * @param[out] os Output stream.
871 * @param[in] border Type to output.
872 *
873 * @return Modified output stream.
874 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100875inline ::std::ostream &operator<<(::std::ostream &os, const BorderSize &border)
876{
Moritz Pflanzerc87fbf82017-07-18 14:02:10 +0100877 os << border.top << ","
878 << border.right << ","
879 << border.bottom << ","
880 << border.left;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100881
882 return os;
883}
Anthony Barbier2a07e182017-08-04 18:20:27 +0100884
Giuseppe Rossinid7647d42018-07-17 18:13:13 +0100885/** Formatted output of the PaddingList type.
886 *
887 * @param[out] os Output stream.
888 * @param[in] padding Type to output.
889 *
890 * @return Modified output stream.
891 */
892inline ::std::ostream &operator<<(::std::ostream &os, const PaddingList &padding)
893{
894 os << "{";
895 for(auto const &p : padding)
896 {
897 os << "{" << p.first << "," << p.second << "}";
898 }
899 os << "}";
900 return os;
901}
902
giuros013175fcf2018-11-21 09:59:17 +0000903/** Formatted output of the Multiples type.
904 *
905 * @param[out] os Output stream.
906 * @param[in] multiples Type to output.
907 *
908 * @return Modified output stream.
909 */
910inline ::std::ostream &operator<<(::std::ostream &os, const Multiples &multiples)
911{
912 os << "(";
913 for(size_t i = 0; i < multiples.size() - 1; i++)
914 {
915 os << multiples[i] << ", ";
916 }
917 os << multiples.back() << ")";
918 return os;
919}
920
Alex Gildayc357c472018-03-21 13:54:09 +0000921/** Formatted output of the InterpolationPolicy type.
922 *
923 * @param[out] os Output stream.
924 * @param[in] policy Type to output.
925 *
926 * @return Modified output stream.
927 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100928inline ::std::ostream &operator<<(::std::ostream &os, const InterpolationPolicy &policy)
929{
930 switch(policy)
931 {
932 case InterpolationPolicy::NEAREST_NEIGHBOR:
933 os << "NEAREST_NEIGHBOR";
934 break;
935 case InterpolationPolicy::BILINEAR:
936 os << "BILINEAR";
937 break;
938 case InterpolationPolicy::AREA:
939 os << "AREA";
940 break;
941 default:
942 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
943 }
944
945 return os;
946}
947
Alex Gildayc357c472018-03-21 13:54:09 +0000948/** Formatted output of the SamplingPolicy type.
949 *
950 * @param[out] os Output stream.
951 * @param[in] policy Type to output.
952 *
953 * @return Modified output stream.
954 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700955inline ::std::ostream &operator<<(::std::ostream &os, const SamplingPolicy &policy)
956{
957 switch(policy)
958 {
959 case SamplingPolicy::CENTER:
960 os << "CENTER";
961 break;
962 case SamplingPolicy::TOP_LEFT:
963 os << "TOP_LEFT";
964 break;
965 default:
966 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
967 }
968
969 return os;
970}
971
Alex Gildayc357c472018-03-21 13:54:09 +0000972/** Formatted output of the TensorInfo type.
973 *
Anthony Barbier366628a2018-08-01 13:55:03 +0100974 * @param[out] os Output stream.
975 * @param[in] info Type to output.
976 *
977 * @return Modified output stream.
978 */
979inline ::std::ostream &operator<<(::std::ostream &os, const TensorInfo &info)
980{
981 os << "{Shape=" << info.tensor_shape() << ","
982 << "Type=" << info.data_type() << ","
983 << "Channels=" << info.num_channels() << "}";
984 return os;
985}
986/** Formatted output of the TensorInfo type.
987 *
Alex Gildayc357c472018-03-21 13:54:09 +0000988 * @param[in] info Type to output.
989 *
990 * @return Formatted string.
991 */
Georgios Pinitas3faea252017-10-30 14:13:50 +0000992inline std::string to_string(const TensorInfo &info)
993{
994 std::stringstream str;
Anthony Barbier366628a2018-08-01 13:55:03 +0100995 str << info;
Georgios Pinitas3faea252017-10-30 14:13:50 +0000996 return str.str();
997}
998
Alex Gildayc357c472018-03-21 13:54:09 +0000999/** Formatted output of the Dimensions type.
1000 *
1001 * @param[in] dimensions Type to output.
1002 *
1003 * @return Formatted string.
1004 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001005template <typename T>
1006inline std::string to_string(const Dimensions<T> &dimensions)
1007{
1008 std::stringstream str;
1009 str << dimensions;
1010 return str.str();
1011}
1012
Alex Gildayc357c472018-03-21 13:54:09 +00001013/** Formatted output of the Strides type.
1014 *
1015 * @param[in] stride Type to output.
1016 *
1017 * @return Formatted string.
1018 */
John Richardsona36eae12017-09-26 16:55:59 +01001019inline std::string to_string(const Strides &stride)
1020{
1021 std::stringstream str;
1022 str << stride;
1023 return str.str();
1024}
1025
Alex Gildayc357c472018-03-21 13:54:09 +00001026/** Formatted output of the TensorShape type.
1027 *
1028 * @param[in] shape Type to output.
1029 *
1030 * @return Formatted string.
1031 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001032inline std::string to_string(const TensorShape &shape)
1033{
1034 std::stringstream str;
1035 str << shape;
1036 return str.str();
1037}
1038
Alex Gildayc357c472018-03-21 13:54:09 +00001039/** Formatted output of the Coordinates type.
1040 *
1041 * @param[in] coord Type to output.
1042 *
1043 * @return Formatted string.
1044 */
Abe Mbise925ca0f2017-10-02 19:16:33 +01001045inline std::string to_string(const Coordinates &coord)
1046{
1047 std::stringstream str;
1048 str << coord;
1049 return str.str();
1050}
1051
Anthony Barbierb940fd62018-06-04 14:14:32 +01001052/** Formatted output of the GEMMReshapeInfo type.
1053 *
1054 * @param[out] os Output stream.
1055 * @param[in] info Type to output.
1056 *
1057 * @return Modified output stream.
1058 */
1059inline ::std::ostream &operator<<(::std::ostream &os, const GEMMReshapeInfo &info)
1060{
1061 os << "{m=" << info.m() << ",";
1062 os << "n=" << info.n() << ",";
1063 os << "k=" << info.k() << ",";
1064 os << "mult_transpose1xW_width=" << info.mult_transpose1xW_width() << ",";
1065 os << "mult_interleave4x4_height=" << info.mult_interleave4x4_height();
1066 os << "}";
1067
1068 return os;
1069}
1070
1071/** Formatted output of the GEMMInfo type.
1072 *
1073 * @param[out] os Output stream.
1074 * @param[in] info Type to output.
1075 *
1076 * @return Modified output stream.
1077 */
1078inline ::std::ostream &operator<<(::std::ostream &os, const GEMMInfo &info)
1079{
1080 os << "{is_a_reshaped=" << info.is_a_reshaped() << ",";
1081 os << "is_b_reshaped=" << info.is_b_reshaped() << ",";
1082 os << "reshape_b_only_on_first_run=" << info.reshape_b_only_on_first_run() << ",";
Anthony Barbierb940fd62018-06-04 14:14:32 +01001083 os << "}";
1084
1085 return os;
1086}
1087
1088/** Formatted output of the Window::Dimension type.
1089 *
1090 * @param[out] os Output stream.
1091 * @param[in] dim Type to output.
1092 *
1093 * @return Modified output stream.
1094 */
1095inline ::std::ostream &operator<<(::std::ostream &os, const Window::Dimension &dim)
1096{
1097 os << "{start=" << dim.start() << ", end=" << dim.end() << ", step=" << dim.step() << "}";
1098
1099 return os;
1100}
1101/** Formatted output of the Window type.
1102 *
1103 * @param[out] os Output stream.
1104 * @param[in] win Type to output.
1105 *
1106 * @return Modified output stream.
1107 */
1108inline ::std::ostream &operator<<(::std::ostream &os, const Window &win)
1109{
1110 os << "{";
1111 for(unsigned int i = 0; i < Coordinates::num_max_dimensions; i++)
1112 {
1113 if(i > 0)
1114 {
1115 os << ", ";
1116 }
1117 os << win[i];
1118 }
1119 os << "}";
1120
1121 return os;
1122}
1123
1124/** Formatted output of the WeightsInfo type.
1125 *
1126 * @param[in] info Type to output.
1127 *
1128 * @return Formatted string.
1129 */
1130inline std::string to_string(const WeightsInfo &info)
1131{
1132 std::stringstream str;
1133 str << info;
1134 return str.str();
1135}
1136
1137/** Formatted output of the GEMMReshapeInfo type.
1138 *
1139 * @param[in] info Type to output.
1140 *
1141 * @return Formatted string.
1142 */
1143inline std::string to_string(const GEMMReshapeInfo &info)
1144{
1145 std::stringstream str;
1146 str << info;
1147 return str.str();
1148}
1149
1150/** Formatted output of the GEMMInfo type.
1151 *
1152 * @param[in] info Type to output.
1153 *
1154 * @return Formatted string.
1155 */
1156inline std::string to_string(const GEMMInfo &info)
1157{
1158 std::stringstream str;
1159 str << info;
1160 return str.str();
1161}
1162
1163/** Formatted output of the Window::Dimension type.
1164 *
1165 * @param[in] dim Type to output.
1166 *
1167 * @return Formatted string.
1168 */
1169inline std::string to_string(const Window::Dimension &dim)
1170{
1171 std::stringstream str;
1172 str << dim;
1173 return str.str();
1174}
1175/** Formatted output of the Window type.
1176 *
1177 * @param[in] win Type to output.
1178 *
1179 * @return Formatted string.
1180 */
1181inline std::string to_string(const Window &win)
1182{
1183 std::stringstream str;
1184 str << win;
1185 return str.str();
1186}
1187
Alex Gildayc357c472018-03-21 13:54:09 +00001188/** Formatted output of the Rectangle type.
1189 *
1190 * @param[out] os Output stream.
1191 * @param[in] rect Type to output.
1192 *
1193 * @return Modified output stream.
1194 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001195inline ::std::ostream &operator<<(::std::ostream &os, const Rectangle &rect)
1196{
1197 os << rect.width << "x" << rect.height;
1198 os << "+" << rect.x << "+" << rect.y;
1199
1200 return os;
1201}
1202
Usama Arif8cf8c112019-03-14 15:36:54 +00001203/** Formatted output of the PaddingMode type.
1204 *
1205 * @param[out] os Output stream.
1206 * @param[in] mode Type to output.
1207 *
1208 * @return Modified output stream.
1209 */
1210inline ::std::ostream &operator<<(::std::ostream &os, const PaddingMode &mode)
1211{
1212 switch(mode)
1213 {
1214 case PaddingMode::CONSTANT:
1215 os << "CONSTANT";
1216 break;
1217 case PaddingMode::REFLECT:
1218 os << "REFLECT";
1219 break;
1220 case PaddingMode::SYMMETRIC:
1221 os << "SYMMETRIC";
1222 break;
1223 default:
1224 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1225 }
1226
1227 return os;
1228}
1229
1230/** Formatted output of the PaddingMode type.
1231 *
1232 * @param[in] mode Type to output.
1233 *
1234 * @return Formatted string.
1235 */
1236inline std::string to_string(const PaddingMode &mode)
1237{
1238 std::stringstream str;
1239 str << mode;
1240 return str.str();
1241}
1242
Alex Gildayc357c472018-03-21 13:54:09 +00001243/** Formatted output of the PadStrideInfo type.
1244 *
1245 * @param[out] os Output stream.
1246 * @param[in] pad_stride_info Type to output.
1247 *
1248 * @return Modified output stream.
1249 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001250inline ::std::ostream &operator<<(::std::ostream &os, const PadStrideInfo &pad_stride_info)
1251{
1252 os << pad_stride_info.stride().first << "," << pad_stride_info.stride().second;
1253 os << ";";
Jaroslaw Rzepeckia1ed41f2017-10-13 11:13:58 +01001254 os << pad_stride_info.pad_left() << "," << pad_stride_info.pad_right() << ","
1255 << pad_stride_info.pad_top() << "," << pad_stride_info.pad_bottom();
Anthony Barbier2a07e182017-08-04 18:20:27 +01001256
1257 return os;
1258}
1259
Alex Gildayc357c472018-03-21 13:54:09 +00001260/** Formatted output of the PadStrideInfo type.
1261 *
1262 * @param[in] pad_stride_info Type to output.
1263 *
1264 * @return Formatted string.
1265 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001266inline std::string to_string(const PadStrideInfo &pad_stride_info)
1267{
1268 std::stringstream str;
1269 str << pad_stride_info;
1270 return str.str();
1271}
1272
Alex Gildayc357c472018-03-21 13:54:09 +00001273/** Formatted output of the BorderMode type.
1274 *
1275 * @param[in] mode Type to output.
1276 *
1277 * @return Formatted string.
1278 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001279inline std::string to_string(const BorderMode &mode)
1280{
1281 std::stringstream str;
1282 str << mode;
1283 return str.str();
1284}
1285
Alex Gildayc357c472018-03-21 13:54:09 +00001286/** Formatted output of the BorderSize type.
1287 *
1288 * @param[in] border Type to output.
1289 *
1290 * @return Formatted string.
1291 */
John Richardsonb482ce12017-09-18 12:44:01 +01001292inline std::string to_string(const BorderSize &border)
1293{
1294 std::stringstream str;
1295 str << border;
1296 return str.str();
1297}
1298
Giuseppe Rossinid7647d42018-07-17 18:13:13 +01001299/** Formatted output of the PaddingList type.
1300 *
1301 * @param[in] padding Type to output.
1302 *
1303 * @return Formatted string.
1304 */
1305inline std::string to_string(const PaddingList &padding)
1306{
1307 std::stringstream str;
1308 str << padding;
1309 return str.str();
1310}
1311
giuros013175fcf2018-11-21 09:59:17 +00001312/** Formatted output of the Multiples type.
1313 *
1314 * @param[in] multiples Type to output.
1315 *
1316 * @return Formatted string.
1317 */
1318inline std::string to_string(const Multiples &multiples)
1319{
1320 std::stringstream str;
1321 str << multiples;
1322 return str.str();
1323}
1324
Alex Gildayc357c472018-03-21 13:54:09 +00001325/** Formatted output of the InterpolationPolicy type.
1326 *
1327 * @param[in] policy Type to output.
1328 *
1329 * @return Formatted string.
1330 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001331inline std::string to_string(const InterpolationPolicy &policy)
1332{
1333 std::stringstream str;
1334 str << policy;
1335 return str.str();
1336}
1337
Alex Gildayc357c472018-03-21 13:54:09 +00001338/** Formatted output of the SamplingPolicy type.
1339 *
1340 * @param[in] policy Type to output.
1341 *
1342 * @return Formatted string.
1343 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +07001344inline std::string to_string(const SamplingPolicy &policy)
1345{
1346 std::stringstream str;
1347 str << policy;
1348 return str.str();
1349}
1350
Alex Gildayc357c472018-03-21 13:54:09 +00001351/** Formatted output of the ConvertPolicy type.
1352 *
1353 * @param[out] os Output stream.
1354 * @param[in] policy Type to output.
1355 *
1356 * @return Modified output stream.
1357 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001358inline ::std::ostream &operator<<(::std::ostream &os, const ConvertPolicy &policy)
1359{
1360 switch(policy)
1361 {
1362 case ConvertPolicy::WRAP:
1363 os << "WRAP";
1364 break;
1365 case ConvertPolicy::SATURATE:
1366 os << "SATURATE";
1367 break;
1368 default:
1369 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1370 }
1371
1372 return os;
1373}
1374
1375inline std::string to_string(const ConvertPolicy &policy)
1376{
1377 std::stringstream str;
1378 str << policy;
1379 return str.str();
1380}
1381
giuros01164a2722018-11-20 18:34:46 +00001382/** Formatted output of the ArithmeticOperation type.
1383 *
1384 * @param[out] os Output stream.
1385 * @param[in] op Operation to output.
1386 *
1387 * @return Modified output stream.
1388 */
1389inline ::std::ostream &operator<<(::std::ostream &os, const ArithmeticOperation &op)
1390{
1391 switch(op)
1392 {
1393 case ArithmeticOperation::ADD:
1394 os << "ADD";
1395 break;
1396 case ArithmeticOperation::SUB:
1397 os << "SUB";
1398 break;
1399 case ArithmeticOperation::DIV:
1400 os << "DIV";
1401 break;
1402 case ArithmeticOperation::MAX:
1403 os << "MAX";
1404 break;
1405 case ArithmeticOperation::MIN:
1406 os << "MIN";
1407 break;
1408 case ArithmeticOperation::SQUARED_DIFF:
1409 os << "SQUARED_DIFF";
1410 break;
Usama Arif52c54f62019-05-14 10:22:36 +01001411 case ArithmeticOperation::POWER:
1412 os << "POWER";
1413 break;
giuros01164a2722018-11-20 18:34:46 +00001414 default:
1415 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1416 }
1417
1418 return os;
1419}
1420
1421/** Formatted output of the Arithmetic Operation
1422 *
1423 * @param[in] op Type to output.
1424 *
1425 * @return Formatted string.
1426 */
1427inline std::string to_string(const ArithmeticOperation &op)
1428{
1429 std::stringstream str;
1430 str << op;
1431 return str.str();
1432}
1433
Alex Gildayc357c472018-03-21 13:54:09 +00001434/** Formatted output of the Reduction Operations.
1435 *
1436 * @param[out] os Output stream.
1437 * @param[in] op Type to output.
1438 *
1439 * @return Modified output stream.
1440 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001441inline ::std::ostream &operator<<(::std::ostream &os, const ReductionOperation &op)
1442{
1443 switch(op)
1444 {
Michalis Spyrou7e9391b2018-10-05 14:49:28 +01001445 case ReductionOperation::SUM:
1446 os << "SUM";
1447 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +01001448 case ReductionOperation::SUM_SQUARE:
1449 os << "SUM_SQUARE";
1450 break;
Michalis Spyrou7e9391b2018-10-05 14:49:28 +01001451 case ReductionOperation::MEAN_SUM:
1452 os << "MEAN_SUM";
1453 break;
Michalis Spyrou7930db42018-11-22 17:36:28 +00001454 case ReductionOperation::ARG_IDX_MAX:
1455 os << "ARG_IDX_MAX";
1456 break;
1457 case ReductionOperation::ARG_IDX_MIN:
1458 os << "ARG_IDX_MIN";
1459 break;
Manuel Bottinib412fab2018-12-10 17:40:23 +00001460 case ReductionOperation::PROD:
1461 os << "PROD";
1462 break;
Usama Arifa4a08ad2019-05-20 12:38:33 +01001463 case ReductionOperation::MIN:
1464 os << "MIN";
1465 break;
Usama Arif28f0dd92019-05-20 13:44:34 +01001466 case ReductionOperation::MAX:
1467 os << "MAX";
1468 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +01001469 default:
1470 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1471 }
1472
1473 return os;
1474}
1475
Alex Gildayc357c472018-03-21 13:54:09 +00001476/** Formatted output of the Reduction Operations.
1477 *
1478 * @param[in] op Type to output.
1479 *
1480 * @return Formatted string.
1481 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001482inline std::string to_string(const ReductionOperation &op)
1483{
1484 std::stringstream str;
1485 str << op;
1486 return str.str();
1487}
1488
Georgios Pinitas7900a9e2018-11-23 11:44:58 +00001489/** Formatted output of the Comparison Operations.
1490 *
1491 * @param[out] os Output stream.
1492 * @param[in] op Type to output.
1493 *
1494 * @return Modified output stream.
1495 */
1496inline ::std::ostream &operator<<(::std::ostream &os, const ComparisonOperation &op)
1497{
1498 switch(op)
1499 {
1500 case ComparisonOperation::Equal:
1501 os << "Equal";
1502 break;
1503 case ComparisonOperation::NotEqual:
1504 os << "NotEqual";
1505 break;
1506 case ComparisonOperation::Greater:
1507 os << "Greater";
1508 break;
1509 case ComparisonOperation::GreaterEqual:
1510 os << "GreaterEqual";
1511 break;
1512 case ComparisonOperation::Less:
1513 os << "Less";
1514 break;
1515 case ComparisonOperation::LessEqual:
1516 os << "LessEqual";
1517 break;
1518 default:
1519 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1520 }
1521
1522 return os;
1523}
1524
Michalis Spyroue9362622018-11-23 17:41:37 +00001525/** Formatted output of the Elementwise unary Operations.
1526 *
1527 * @param[out] os Output stream.
1528 * @param[in] op Type to output.
1529 *
1530 * @return Modified output stream.
1531 */
1532inline ::std::ostream &operator<<(::std::ostream &os, const ElementWiseUnary &op)
1533{
1534 switch(op)
1535 {
1536 case ElementWiseUnary::RSQRT:
1537 os << "RSQRT";
1538 break;
1539 case ElementWiseUnary::EXP:
1540 os << "EXP";
1541 break;
Usama Arifeb312ef2019-05-13 17:45:54 +01001542 case ElementWiseUnary::NEG:
1543 os << "NEG";
1544 break;
Usama Arifac33d7e2019-05-20 14:21:40 +01001545 case ElementWiseUnary::LOG:
1546 os << "LOG";
1547 break;
Usama Arif6a4d5422019-05-24 14:53:59 +01001548 case ElementWiseUnary::ROUND:
1549 os << "ROUND";
1550 break;
Michalis Spyroue9362622018-11-23 17:41:37 +00001551 default:
1552 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1553 }
1554
1555 return os;
1556}
1557
Georgios Pinitas7900a9e2018-11-23 11:44:58 +00001558/** Formatted output of the Comparison Operations.
1559 *
1560 * @param[in] op Type to output.
1561 *
1562 * @return Formatted string.
1563 */
1564inline std::string to_string(const ComparisonOperation &op)
1565{
1566 std::stringstream str;
1567 str << op;
1568 return str.str();
1569}
1570
Michalis Spyroue9362622018-11-23 17:41:37 +00001571/** Formatted output of the Elementwise unary Operations.
1572 *
1573 * @param[in] op Type to output.
1574 *
1575 * @return Formatted string.
1576 */
1577inline std::string to_string(const ElementWiseUnary &op)
1578{
1579 std::stringstream str;
1580 str << op;
1581 return str.str();
1582}
1583
Alex Gildayc357c472018-03-21 13:54:09 +00001584/** Formatted output of the Norm Type.
1585 *
1586 * @param[in] type Type to output.
1587 *
1588 * @return Formatted string.
1589 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001590inline std::string to_string(const NormType &type)
1591{
1592 std::stringstream str;
1593 str << type;
1594 return str.str();
1595}
1596
Alex Gildayc357c472018-03-21 13:54:09 +00001597/** Formatted output of the Pooling Type.
1598 *
1599 * @param[in] type Type to output.
1600 *
1601 * @return Formatted string.
1602 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001603inline std::string to_string(const PoolingType &type)
1604{
1605 std::stringstream str;
1606 str << type;
1607 return str.str();
1608}
1609
Alex Gildayc357c472018-03-21 13:54:09 +00001610/** Formatted output of the Pooling Layer Info.
1611 *
1612 * @param[in] info Type to output.
1613 *
1614 * @return Formatted string.
1615 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001616inline std::string to_string(const PoolingLayerInfo &info)
1617{
1618 std::stringstream str;
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001619 str << "{Type=" << info.pool_type() << ","
1620 << "IsGlobalPooling=" << info.is_global_pooling();
1621 if(!info.is_global_pooling())
1622 {
1623 str << ","
Isabella Gottardi6e464c32018-01-26 12:32:45 +00001624 << "PoolSize=" << info.pool_size().width << "," << info.pool_size().height << ","
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001625 << "PadStride=" << info.pad_stride_info();
1626 }
1627 str << "}";
Anthony Barbier2a07e182017-08-04 18:20:27 +01001628 return str.str();
1629}
1630
Michalis Spyrou6c7c38e2018-08-29 16:28:11 +01001631/** Formatted output of the PriorBoxLayerInfo.
1632 *
1633 * @param[in] info Type to output.
1634 *
1635 * @return Formatted string.
1636 */
1637inline std::string to_string(const PriorBoxLayerInfo &info)
1638{
1639 std::stringstream str;
1640 str << "{";
1641 str << "Clip:" << info.clip()
1642 << "Flip:" << info.flip()
1643 << "StepX:" << info.steps()[0]
1644 << "StepY:" << info.steps()[1]
1645 << "MinSizes:" << info.min_sizes().size()
1646 << "MaxSizes:" << info.max_sizes().size()
1647 << "ImgSizeX:" << info.img_size().x
1648 << "ImgSizeY:" << info.img_size().y
1649 << "Offset:" << info.offset()
1650 << "Variances:" << info.variances().size();
1651 str << "}";
1652 return str.str();
1653}
1654
Alex Gildayc357c472018-03-21 13:54:09 +00001655/** Formatted output of the KeyPoint type.
1656 *
1657 * @param[out] os Output stream
1658 * @param[in] point Type to output.
1659 *
1660 * @return Modified output stream.
1661 */
Moritz Pflanzer6c6597c2017-09-24 12:09:41 +01001662inline ::std::ostream &operator<<(::std::ostream &os, const KeyPoint &point)
1663{
1664 os << "{x=" << point.x << ","
1665 << "y=" << point.y << ","
1666 << "strength=" << point.strength << ","
1667 << "scale=" << point.scale << ","
1668 << "orientation=" << point.orientation << ","
1669 << "tracking_status=" << point.tracking_status << ","
1670 << "error=" << point.error << "}";
1671
1672 return os;
1673}
John Richardson63e50412017-10-13 20:51:42 +01001674
Alex Gildayc357c472018-03-21 13:54:09 +00001675/** Formatted output of the PhaseType type.
1676 *
1677 * @param[out] os Output stream
1678 * @param[in] phase_type Type to output.
1679 *
1680 * @return Modified output stream.
1681 */
John Richardson63e50412017-10-13 20:51:42 +01001682inline ::std::ostream &operator<<(::std::ostream &os, const PhaseType &phase_type)
1683{
1684 switch(phase_type)
1685 {
1686 case PhaseType::SIGNED:
1687 os << "SIGNED";
1688 break;
1689 case PhaseType::UNSIGNED:
1690 os << "UNSIGNED";
1691 break;
1692 default:
1693 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1694 }
1695
1696 return os;
1697}
1698
Alex Gildayc357c472018-03-21 13:54:09 +00001699/** Formatted output of the PhaseType type.
1700 *
1701 * @param[in] type Type to output.
1702 *
1703 * @return Formatted string.
1704 */
John Richardson63e50412017-10-13 20:51:42 +01001705inline std::string to_string(const arm_compute::PhaseType &type)
1706{
1707 std::stringstream str;
1708 str << type;
1709 return str.str();
1710}
John Richardson3c5f9492017-10-04 15:27:37 +01001711
Alex Gildayc357c472018-03-21 13:54:09 +00001712/** Formatted output of the MagnitudeType type.
1713 *
1714 * @param[out] os Output stream
1715 * @param[in] magnitude_type Type to output.
1716 *
1717 * @return Modified output stream.
1718 */
John Richardson3c5f9492017-10-04 15:27:37 +01001719inline ::std::ostream &operator<<(::std::ostream &os, const MagnitudeType &magnitude_type)
1720{
1721 switch(magnitude_type)
1722 {
1723 case MagnitudeType::L1NORM:
1724 os << "L1NORM";
1725 break;
1726 case MagnitudeType::L2NORM:
1727 os << "L2NORM";
1728 break;
1729 default:
1730 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1731 }
1732
1733 return os;
1734}
1735
Alex Gildayc357c472018-03-21 13:54:09 +00001736/** Formatted output of the MagnitudeType type.
1737 *
1738 * @param[in] type Type to output.
1739 *
1740 * @return Formatted string.
1741 */
John Richardson3c5f9492017-10-04 15:27:37 +01001742inline std::string to_string(const arm_compute::MagnitudeType &type)
1743{
1744 std::stringstream str;
1745 str << type;
1746 return str.str();
1747}
John Richardson1c529922017-11-01 10:57:48 +00001748
Alex Gildayc357c472018-03-21 13:54:09 +00001749/** Formatted output of the HOGNormType type.
1750 *
1751 * @param[out] os Output stream
1752 * @param[in] norm_type Type to output
1753 *
1754 * @return Modified output stream.
1755 */
John Richardson25f23682017-11-27 14:35:09 +00001756inline ::std::ostream &operator<<(::std::ostream &os, const HOGNormType &norm_type)
1757{
1758 switch(norm_type)
1759 {
1760 case HOGNormType::L1_NORM:
1761 os << "L1_NORM";
1762 break;
1763 case HOGNormType::L2_NORM:
1764 os << "L2_NORM";
1765 break;
1766 case HOGNormType::L2HYS_NORM:
1767 os << "L2HYS_NORM";
1768 break;
1769 default:
1770 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1771 }
1772
1773 return os;
1774}
1775
Alex Gildayc357c472018-03-21 13:54:09 +00001776/** Formatted output of the HOGNormType type.
1777 *
1778 * @param[in] type Type to output
1779 *
1780 * @return Formatted string.
1781 */
John Richardson25f23682017-11-27 14:35:09 +00001782inline std::string to_string(const HOGNormType &type)
1783{
1784 std::stringstream str;
1785 str << type;
1786 return str.str();
1787}
1788
Alex Gildayc357c472018-03-21 13:54:09 +00001789/** Formatted output of the Size2D type.
1790 *
1791 * @param[out] os Output stream
1792 * @param[in] size Type to output
1793 *
1794 * @return Modified output stream.
1795 */
John Richardson25f23682017-11-27 14:35:09 +00001796inline ::std::ostream &operator<<(::std::ostream &os, const Size2D &size)
1797{
1798 os << size.width << "x" << size.height;
1799
1800 return os;
1801}
1802
Alex Gildayc357c472018-03-21 13:54:09 +00001803/** Formatted output of the Size2D type.
1804 *
1805 * @param[in] type Type to output
1806 *
1807 * @return Formatted string.
1808 */
John Richardson25f23682017-11-27 14:35:09 +00001809inline std::string to_string(const Size2D &type)
1810{
1811 std::stringstream str;
1812 str << type;
1813 return str.str();
1814}
1815
Alex Gildayc357c472018-03-21 13:54:09 +00001816/** Formatted output of the HOGInfo type.
1817 *
1818 * @param[out] os Output stream
1819 * @param[in] hog_info Type to output
1820 *
1821 * @return Modified output stream.
1822 */
John Richardson25f23682017-11-27 14:35:09 +00001823inline ::std::ostream &operator<<(::std::ostream &os, const HOGInfo &hog_info)
1824{
1825 os << "{CellSize=" << hog_info.cell_size() << ","
1826 << "BlockSize=" << hog_info.block_size() << ","
1827 << "DetectionWindowSize=" << hog_info.detection_window_size() << ","
1828 << "BlockStride=" << hog_info.block_stride() << ","
1829 << "NumBins=" << hog_info.num_bins() << ","
1830 << "NormType=" << hog_info.normalization_type() << ","
1831 << "L2HystThreshold=" << hog_info.l2_hyst_threshold() << ","
1832 << "PhaseType=" << hog_info.phase_type() << "}";
1833
1834 return os;
1835}
1836
Alex Gildayc357c472018-03-21 13:54:09 +00001837/** Formatted output of the HOGInfo type.
1838 *
1839 * @param[in] type Type to output
1840 *
1841 * @return Formatted string.
1842 */
John Richardson25f23682017-11-27 14:35:09 +00001843inline std::string to_string(const HOGInfo &type)
1844{
1845 std::stringstream str;
1846 str << type;
1847 return str.str();
1848}
1849
Alex Gildayc357c472018-03-21 13:54:09 +00001850/** Formatted output of the ConvolutionMethod type.
1851 *
1852 * @param[out] os Output stream
1853 * @param[in] conv_method Type to output
1854 *
1855 * @return Modified output stream.
1856 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001857inline ::std::ostream &operator<<(::std::ostream &os, const ConvolutionMethod &conv_method)
1858{
1859 switch(conv_method)
1860 {
1861 case ConvolutionMethod::GEMM:
1862 os << "GEMM";
1863 break;
1864 case ConvolutionMethod::DIRECT:
1865 os << "DIRECT";
1866 break;
1867 case ConvolutionMethod::WINOGRAD:
1868 os << "WINOGRAD";
1869 break;
1870 default:
1871 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1872 }
1873
1874 return os;
1875}
1876
Alex Gildayc357c472018-03-21 13:54:09 +00001877/** Formatted output of the ConvolutionMethod type.
1878 *
1879 * @param[in] conv_method Type to output
1880 *
1881 * @return Formatted string.
1882 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001883inline std::string to_string(const ConvolutionMethod &conv_method)
1884{
1885 std::stringstream str;
1886 str << conv_method;
1887 return str.str();
1888}
1889
Alex Gildayc357c472018-03-21 13:54:09 +00001890/** Formatted output of the GPUTarget type.
1891 *
1892 * @param[out] os Output stream
1893 * @param[in] gpu_target Type to output
1894 *
1895 * @return Modified output stream.
1896 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001897inline ::std::ostream &operator<<(::std::ostream &os, const GPUTarget &gpu_target)
1898{
1899 switch(gpu_target)
1900 {
1901 case GPUTarget::GPU_ARCH_MASK:
1902 os << "GPU_ARCH_MASK";
1903 break;
1904 case GPUTarget::MIDGARD:
1905 os << "MIDGARD";
1906 break;
1907 case GPUTarget::BIFROST:
1908 os << "BIFROST";
1909 break;
1910 case GPUTarget::T600:
1911 os << "T600";
1912 break;
1913 case GPUTarget::T700:
1914 os << "T700";
1915 break;
1916 case GPUTarget::T800:
1917 os << "T800";
1918 break;
Michalis Spyroua9676112018-02-22 18:07:43 +00001919 case GPUTarget::G71:
1920 os << "G71";
1921 break;
1922 case GPUTarget::G72:
1923 os << "G72";
1924 break;
1925 case GPUTarget::G51:
1926 os << "G51";
1927 break;
1928 case GPUTarget::G51BIG:
1929 os << "G51BIG";
1930 break;
1931 case GPUTarget::G51LIT:
1932 os << "G51LIT";
1933 break;
Georgios Pinitasb03f7c52018-07-12 10:49:53 +01001934 case GPUTarget::G76:
1935 os << "G76";
Michalis Spyroua9676112018-02-22 18:07:43 +00001936 break;
1937 case GPUTarget::TTRX:
1938 os << "TTRX";
1939 break;
1940 case GPUTarget::TBOX:
1941 os << "TBOX";
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001942 break;
1943 default:
1944 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1945 }
1946
1947 return os;
1948}
1949
Alex Gildayc357c472018-03-21 13:54:09 +00001950/** Formatted output of the GPUTarget type.
1951 *
1952 * @param[in] gpu_target Type to output
1953 *
1954 * @return Formatted string.
1955 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001956inline std::string to_string(const GPUTarget &gpu_target)
1957{
1958 std::stringstream str;
1959 str << gpu_target;
1960 return str.str();
1961}
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00001962
John Richardson8de92612018-02-22 14:09:31 +00001963/** Formatted output of the DetectionWindow type.
1964 *
1965 * @param[out] os Output stream
1966 * @param[in] detection_window Type to output
1967 *
1968 * @return Modified output stream.
1969 */
John Richardson684cb0f2018-01-09 11:17:00 +00001970inline ::std::ostream &operator<<(::std::ostream &os, const DetectionWindow &detection_window)
1971{
1972 os << "{x=" << detection_window.x << ","
1973 << "y=" << detection_window.y << ","
1974 << "width=" << detection_window.width << ","
1975 << "height=" << detection_window.height << ","
1976 << "idx_class=" << detection_window.idx_class << ","
1977 << "score=" << detection_window.score << "}";
1978
1979 return os;
1980}
1981
Isabella Gottardi05e56442018-11-16 11:26:52 +00001982/** Formatted output of the DetectionOutputLayerCodeType type.
1983 *
1984 * @param[out] os Output stream
1985 * @param[in] detection_code Type to output
1986 *
1987 * @return Modified output stream.
1988 */
1989inline ::std::ostream &operator<<(::std::ostream &os, const DetectionOutputLayerCodeType &detection_code)
1990{
1991 switch(detection_code)
1992 {
1993 case DetectionOutputLayerCodeType::CENTER_SIZE:
1994 os << "CENTER_SIZE";
1995 break;
1996 case DetectionOutputLayerCodeType::CORNER:
1997 os << "CORNER";
1998 break;
1999 case DetectionOutputLayerCodeType::CORNER_SIZE:
2000 os << "CORNER_SIZE";
2001 break;
2002 case DetectionOutputLayerCodeType::TF_CENTER:
2003 os << "TF_CENTER";
2004 break;
2005 default:
2006 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2007 }
2008
2009 return os;
2010}
2011/** Formatted output of the DetectionOutputLayerCodeType type.
2012 *
2013 * @param[in] detection_code Type to output
2014 *
2015 * @return Formatted string.
2016 */
2017inline std::string to_string(const DetectionOutputLayerCodeType &detection_code)
2018{
2019 std::stringstream str;
2020 str << detection_code;
2021 return str.str();
2022}
2023
2024/** Formatted output of the DetectionOutputLayerInfo type.
2025 *
2026 * @param[out] os Output stream
2027 * @param[in] detection_info Type to output
2028 *
2029 * @return Modified output stream.
2030 */
2031inline ::std::ostream &operator<<(::std::ostream &os, const DetectionOutputLayerInfo &detection_info)
2032{
2033 os << "{Classes=" << detection_info.num_classes() << ","
2034 << "ShareLocation=" << detection_info.share_location() << ","
2035 << "CodeType=" << detection_info.code_type() << ","
2036 << "VarianceEncodedInTarget=" << detection_info.variance_encoded_in_target() << ","
2037 << "KeepTopK=" << detection_info.keep_top_k() << ","
2038 << "NMSThreshold=" << detection_info.nms_threshold() << ","
2039 << "Eta=" << detection_info.eta() << ","
2040 << "BackgroundLabelId=" << detection_info.background_label_id() << ","
2041 << "ConfidenceThreshold=" << detection_info.confidence_threshold() << ","
2042 << "TopK=" << detection_info.top_k() << ","
2043 << "NumLocClasses=" << detection_info.num_loc_classes()
2044 << "}";
2045
2046 return os;
2047}
2048
2049/** Formatted output of the DetectionOutputLayerInfo type.
2050 *
2051 * @param[in] detection_info Type to output
2052 *
2053 * @return Formatted string.
2054 */
2055inline std::string to_string(const DetectionOutputLayerInfo &detection_info)
2056{
2057 std::stringstream str;
2058 str << detection_info;
2059 return str.str();
2060}
John Richardson8de92612018-02-22 14:09:31 +00002061/** Formatted output of the DetectionWindow type.
2062 *
2063 * @param[in] detection_window Type to output
2064 *
2065 * @return Formatted string.
2066 */
2067inline std::string to_string(const DetectionWindow &detection_window)
2068{
2069 std::stringstream str;
2070 str << detection_window;
2071 return str.str();
2072}
2073
2074/** Formatted output of the Termination type.
2075 *
2076 * @param[out] os Output stream
2077 * @param[in] termination Type to output
2078 *
2079 * @return Modified output stream.
2080 */
2081inline ::std::ostream &operator<<(::std::ostream &os, const Termination &termination)
2082{
2083 switch(termination)
2084 {
2085 case Termination::TERM_CRITERIA_EPSILON:
2086 os << "TERM_CRITERIA_EPSILON";
2087 break;
2088 case Termination::TERM_CRITERIA_ITERATIONS:
2089 os << "TERM_CRITERIA_ITERATIONS";
2090 break;
2091 case Termination::TERM_CRITERIA_BOTH:
2092 os << "TERM_CRITERIA_BOTH";
2093 break;
2094 default:
2095 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2096 }
2097
2098 return os;
2099}
2100
2101/** Formatted output of the Termination type.
2102 *
2103 * @param[in] termination Type to output
2104 *
2105 * @return Formatted string.
2106 */
2107inline std::string to_string(const Termination &termination)
2108{
2109 std::stringstream str;
2110 str << termination;
2111 return str.str();
2112}
2113
Anthony Barbier8914e322018-08-10 15:28:25 +01002114/** Formatted output of the CPUModel type.
2115 *
2116 * @param[out] os Output stream
2117 * @param[in] cpu_model Model to output
2118 *
2119 * @return Modified output stream.
2120 */
2121inline ::std::ostream &operator<<(::std::ostream &os, const CPUModel &cpu_model)
2122{
2123 switch(cpu_model)
2124 {
2125 case CPUModel::GENERIC:
2126 os << "GENERIC";
2127 break;
2128 case CPUModel::GENERIC_FP16:
2129 os << "GENERIC_FP16";
2130 break;
2131 case CPUModel::GENERIC_FP16_DOT:
2132 os << "GENERIC_FP16_DOT";
2133 break;
2134 case CPUModel::A53:
2135 os << "A53";
2136 break;
2137 case CPUModel::A55r0:
2138 os << "A55r0";
2139 break;
2140 case CPUModel::A55r1:
2141 os << "A55r1";
2142 break;
2143 default:
2144 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2145 }
2146
2147 return os;
2148}
2149
2150/** Formatted output of the CPUModel type.
2151 *
2152 * @param[in] cpu_model Model to output
2153 *
2154 * @return Formatted string.
2155 */
2156inline std::string to_string(const CPUModel &cpu_model)
2157{
2158 std::stringstream str;
2159 str << cpu_model;
2160 return str.str();
2161}
Anthony Barbier671a11e2018-07-06 15:11:36 +01002162/** Formatted output of a vector of objects.
2163 *
2164 * @param[out] os Output stream
2165 * @param[in] args Vector of objects to print
2166 *
2167 * @return Modified output stream.
2168 */
2169template <typename T>
2170inline ::std::ostream &operator<<(::std::ostream &os, const std::vector<T> &args)
2171{
2172 os << "[";
2173 bool first = true;
2174 for(auto &arg : args)
2175 {
2176 if(first)
2177 {
2178 first = false;
2179 }
2180 else
2181 {
2182 os << ", ";
2183 }
2184 os << arg;
2185 }
2186 os << "]";
2187 return os;
2188}
2189
Michalis Spyrou6c7c38e2018-08-29 16:28:11 +01002190/** Formatted output of @ref PriorBoxLayerInfo.
2191 *
2192 * @param[out] os Output stream.
2193 * @param[in] info Type to output.
2194 *
2195 * @return Modified output stream.
2196 */
2197inline ::std::ostream &operator<<(::std::ostream &os, const PriorBoxLayerInfo &info)
2198{
2199 os << "Clip:" << info.clip()
2200 << "Flip:" << info.flip()
2201 << "StepX:" << info.steps()[0]
2202 << "StepY:" << info.steps()[1]
2203 << "MinSizes:" << info.min_sizes()
2204 << "MaxSizes:" << info.max_sizes()
2205 << "ImgSizeX:" << info.img_size().x
2206 << "ImgSizeY:" << info.img_size().y
2207 << "Offset:" << info.offset()
2208 << "Variances:" << info.variances();
2209
2210 return os;
2211}
2212
Anthony Barbier671a11e2018-07-06 15:11:36 +01002213/** Formatted output of a vector of objects.
2214 *
2215 * @param[in] args Vector of objects to print
2216 *
2217 * @return String representing args.
2218 */
2219template <typename T>
2220std::string to_string(const std::vector<T> &args)
2221{
2222 std::stringstream str;
2223 str << args;
2224 return str.str();
2225}
2226
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00002227/** Formatted output of the WinogradInfo type. */
2228inline ::std::ostream &operator<<(::std::ostream &os, const WinogradInfo &info)
2229{
2230 os << "{OutputTileSize=" << info.output_tile_size << ","
2231 << "KernelSize=" << info.kernel_size << ","
2232 << "PadStride=" << info.convolution_info << ","
2233 << "OutputDataLayout=" << info.output_data_layout << "}";
2234
2235 return os;
2236}
2237
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00002238inline std::string to_string(const WinogradInfo &type)
2239{
2240 std::stringstream str;
2241 str << type;
2242 return str.str();
2243}
Anthony Barbier671a11e2018-07-06 15:11:36 +01002244
2245/** Fallback method: try to use std::to_string:
2246 *
2247 * @param[in] val Value to convert to string
2248 *
2249 * @return String representing val.
2250 */
2251template <typename T>
2252inline std::string to_string(const T &val)
2253{
2254 return support::cpp11::to_string(val);
2255}
2256
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +01002257/** Convert a CLTunerMode value to a string
2258 *
2259 * @param val CLTunerMode value to be converted
2260 *
2261 * @return String representing the corresponding CLTunerMode.
2262 */
2263inline std::string to_string(const CLTunerMode val)
2264{
2265 switch(val)
2266 {
2267 case CLTunerMode::EXHAUSTIVE:
2268 {
2269 return std::string("Exhaustive");
2270 }
2271 case CLTunerMode::NORMAL:
2272 {
2273 return std::string("Normal");
2274 }
2275 case CLTunerMode::RAPID:
2276 {
2277 return std::string("Rapid");
2278 }
2279 default:
2280 {
2281 ARM_COMPUTE_ERROR("Invalid tuner mode.");
2282 return std::string("UNDEFINED");
2283 }
2284 }
2285}
2286/** [Print CLTunerMode type] **/
2287/** Formatted output of the CLTunerMode type.
2288 *
2289 * @param[out] os Output stream.
2290 * @param[in] val CLTunerMode to output.
2291 *
2292 * @return Modified output stream.
2293 */
2294inline ::std::ostream &operator<<(::std::ostream &os, const CLTunerMode &val)
2295{
2296 os << to_string(val);
2297 return os;
2298}
2299
Anthony Barbier6ff3b192017-09-04 18:44:23 +01002300} // namespace arm_compute
Anthony Barbier4dbc0a92018-08-27 13:39:47 +01002301
2302#endif /* __ARM_COMPUTE_TYPE_PRINTER_H__ */