blob: cf351724f040451030b34b28cbabed85e4f02da2 [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;
645 case DataType::U32:
646 os << "U32";
647 break;
648 case DataType::S32:
649 os << "S32";
650 break;
651 case DataType::U64:
652 os << "U64";
653 break;
654 case DataType::S64:
655 os << "S64";
656 break;
657 case DataType::F16:
658 os << "F16";
659 break;
660 case DataType::F32:
661 os << "F32";
662 break;
663 case DataType::F64:
664 os << "F64";
665 break;
666 case DataType::SIZET:
667 os << "SIZET";
668 break;
669 default:
670 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
671 }
672
673 return os;
674}
675
Alex Gildayc357c472018-03-21 13:54:09 +0000676/** Formatted output of the DataType type.
677 *
678 * @param[in] data_type Type to output.
679 *
680 * @return Formatted string.
681 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100682inline std::string to_string(const arm_compute::DataType &data_type)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100683{
684 std::stringstream str;
685 str << data_type;
686 return str.str();
687}
688
Alex Gildayc357c472018-03-21 13:54:09 +0000689/** Formatted output of the Format type.
690 *
691 * @param[out] os Output stream.
692 * @param[in] format Type to output.
693 *
694 * @return Modified output stream.
695 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100696inline ::std::ostream &operator<<(::std::ostream &os, const Format &format)
697{
698 switch(format)
699 {
700 case Format::UNKNOWN:
701 os << "UNKNOWN";
702 break;
703 case Format::U8:
704 os << "U8";
705 break;
706 case Format::S16:
707 os << "S16";
708 break;
709 case Format::U16:
710 os << "U16";
711 break;
712 case Format::S32:
713 os << "S32";
714 break;
715 case Format::U32:
716 os << "U32";
717 break;
718 case Format::F16:
719 os << "F16";
720 break;
721 case Format::F32:
722 os << "F32";
723 break;
724 case Format::UV88:
725 os << "UV88";
726 break;
727 case Format::RGB888:
728 os << "RGB888";
729 break;
730 case Format::RGBA8888:
731 os << "RGBA8888";
732 break;
733 case Format::YUV444:
734 os << "YUV444";
735 break;
736 case Format::YUYV422:
737 os << "YUYV422";
738 break;
739 case Format::NV12:
740 os << "NV12";
741 break;
742 case Format::NV21:
743 os << "NV21";
744 break;
745 case Format::IYUV:
746 os << "IYUV";
747 break;
748 case Format::UYVY422:
749 os << "UYVY422";
750 break;
751 default:
752 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
753 }
754
755 return os;
756}
757
Alex Gildayc357c472018-03-21 13:54:09 +0000758/** Formatted output of the Format type.
759 *
760 * @param[in] format Type to output.
761 *
762 * @return Formatted string.
763 */
Moritz Pflanzer7655a672017-09-23 11:57:33 +0100764inline std::string to_string(const Format &format)
765{
766 std::stringstream str;
767 str << format;
768 return str.str();
769}
770
Alex Gildayc357c472018-03-21 13:54:09 +0000771/** Formatted output of the Channel type.
772 *
773 * @param[out] os Output stream.
774 * @param[in] channel Type to output.
775 *
776 * @return Modified output stream.
777 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100778inline ::std::ostream &operator<<(::std::ostream &os, const Channel &channel)
779{
780 switch(channel)
781 {
782 case Channel::UNKNOWN:
783 os << "UNKNOWN";
784 break;
785 case Channel::C0:
786 os << "C0";
787 break;
788 case Channel::C1:
789 os << "C1";
790 break;
791 case Channel::C2:
792 os << "C2";
793 break;
794 case Channel::C3:
795 os << "C3";
796 break;
797 case Channel::R:
798 os << "R";
799 break;
800 case Channel::G:
801 os << "G";
802 break;
803 case Channel::B:
804 os << "B";
805 break;
806 case Channel::A:
807 os << "A";
808 break;
809 case Channel::Y:
810 os << "Y";
811 break;
812 case Channel::U:
813 os << "U";
814 break;
815 case Channel::V:
816 os << "V";
817 break;
818 default:
819 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
820 }
821
822 return os;
823}
824
Alex Gildayc357c472018-03-21 13:54:09 +0000825/** Formatted output of the Channel type.
826 *
827 * @param[in] channel Type to output.
828 *
829 * @return Formatted string.
830 */
Ioan-Cristian Szabo9414f642017-10-27 17:35:40 +0100831inline std::string to_string(const Channel &channel)
832{
833 std::stringstream str;
834 str << channel;
835 return str.str();
836}
837
Alex Gildayc357c472018-03-21 13:54:09 +0000838/** Formatted output of the BorderMode type.
839 *
840 * @param[out] os Output stream.
841 * @param[in] mode Type to output.
842 *
843 * @return Modified output stream.
844 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100845inline ::std::ostream &operator<<(::std::ostream &os, const BorderMode &mode)
846{
847 switch(mode)
848 {
849 case BorderMode::UNDEFINED:
850 os << "UNDEFINED";
851 break;
852 case BorderMode::CONSTANT:
853 os << "CONSTANT";
854 break;
855 case BorderMode::REPLICATE:
856 os << "REPLICATE";
857 break;
858 default:
859 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
860 }
861
862 return os;
863}
864
Alex Gildayc357c472018-03-21 13:54:09 +0000865/** Formatted output of the BorderSize type.
866 *
867 * @param[out] os Output stream.
868 * @param[in] border Type to output.
869 *
870 * @return Modified output stream.
871 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100872inline ::std::ostream &operator<<(::std::ostream &os, const BorderSize &border)
873{
Moritz Pflanzerc87fbf82017-07-18 14:02:10 +0100874 os << border.top << ","
875 << border.right << ","
876 << border.bottom << ","
877 << border.left;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100878
879 return os;
880}
Anthony Barbier2a07e182017-08-04 18:20:27 +0100881
Giuseppe Rossinid7647d42018-07-17 18:13:13 +0100882/** Formatted output of the PaddingList type.
883 *
884 * @param[out] os Output stream.
885 * @param[in] padding Type to output.
886 *
887 * @return Modified output stream.
888 */
889inline ::std::ostream &operator<<(::std::ostream &os, const PaddingList &padding)
890{
891 os << "{";
892 for(auto const &p : padding)
893 {
894 os << "{" << p.first << "," << p.second << "}";
895 }
896 os << "}";
897 return os;
898}
899
giuros013175fcf2018-11-21 09:59:17 +0000900/** Formatted output of the Multiples type.
901 *
902 * @param[out] os Output stream.
903 * @param[in] multiples Type to output.
904 *
905 * @return Modified output stream.
906 */
907inline ::std::ostream &operator<<(::std::ostream &os, const Multiples &multiples)
908{
909 os << "(";
910 for(size_t i = 0; i < multiples.size() - 1; i++)
911 {
912 os << multiples[i] << ", ";
913 }
914 os << multiples.back() << ")";
915 return os;
916}
917
Alex Gildayc357c472018-03-21 13:54:09 +0000918/** Formatted output of the InterpolationPolicy type.
919 *
920 * @param[out] os Output stream.
921 * @param[in] policy Type to output.
922 *
923 * @return Modified output stream.
924 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100925inline ::std::ostream &operator<<(::std::ostream &os, const InterpolationPolicy &policy)
926{
927 switch(policy)
928 {
929 case InterpolationPolicy::NEAREST_NEIGHBOR:
930 os << "NEAREST_NEIGHBOR";
931 break;
932 case InterpolationPolicy::BILINEAR:
933 os << "BILINEAR";
934 break;
935 case InterpolationPolicy::AREA:
936 os << "AREA";
937 break;
938 default:
939 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
940 }
941
942 return os;
943}
944
Alex Gildayc357c472018-03-21 13:54:09 +0000945/** Formatted output of the SamplingPolicy type.
946 *
947 * @param[out] os Output stream.
948 * @param[in] policy Type to output.
949 *
950 * @return Modified output stream.
951 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700952inline ::std::ostream &operator<<(::std::ostream &os, const SamplingPolicy &policy)
953{
954 switch(policy)
955 {
956 case SamplingPolicy::CENTER:
957 os << "CENTER";
958 break;
959 case SamplingPolicy::TOP_LEFT:
960 os << "TOP_LEFT";
961 break;
962 default:
963 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
964 }
965
966 return os;
967}
968
Alex Gildayc357c472018-03-21 13:54:09 +0000969/** Formatted output of the TensorInfo type.
970 *
Anthony Barbier366628a2018-08-01 13:55:03 +0100971 * @param[out] os Output stream.
972 * @param[in] info Type to output.
973 *
974 * @return Modified output stream.
975 */
976inline ::std::ostream &operator<<(::std::ostream &os, const TensorInfo &info)
977{
978 os << "{Shape=" << info.tensor_shape() << ","
979 << "Type=" << info.data_type() << ","
980 << "Channels=" << info.num_channels() << "}";
981 return os;
982}
983/** Formatted output of the TensorInfo type.
984 *
Alex Gildayc357c472018-03-21 13:54:09 +0000985 * @param[in] info Type to output.
986 *
987 * @return Formatted string.
988 */
Georgios Pinitas3faea252017-10-30 14:13:50 +0000989inline std::string to_string(const TensorInfo &info)
990{
991 std::stringstream str;
Anthony Barbier366628a2018-08-01 13:55:03 +0100992 str << info;
Georgios Pinitas3faea252017-10-30 14:13:50 +0000993 return str.str();
994}
995
Alex Gildayc357c472018-03-21 13:54:09 +0000996/** Formatted output of the Dimensions type.
997 *
998 * @param[in] dimensions Type to output.
999 *
1000 * @return Formatted string.
1001 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001002template <typename T>
1003inline std::string to_string(const Dimensions<T> &dimensions)
1004{
1005 std::stringstream str;
1006 str << dimensions;
1007 return str.str();
1008}
1009
Alex Gildayc357c472018-03-21 13:54:09 +00001010/** Formatted output of the Strides type.
1011 *
1012 * @param[in] stride Type to output.
1013 *
1014 * @return Formatted string.
1015 */
John Richardsona36eae12017-09-26 16:55:59 +01001016inline std::string to_string(const Strides &stride)
1017{
1018 std::stringstream str;
1019 str << stride;
1020 return str.str();
1021}
1022
Alex Gildayc357c472018-03-21 13:54:09 +00001023/** Formatted output of the TensorShape type.
1024 *
1025 * @param[in] shape Type to output.
1026 *
1027 * @return Formatted string.
1028 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001029inline std::string to_string(const TensorShape &shape)
1030{
1031 std::stringstream str;
1032 str << shape;
1033 return str.str();
1034}
1035
Alex Gildayc357c472018-03-21 13:54:09 +00001036/** Formatted output of the Coordinates type.
1037 *
1038 * @param[in] coord Type to output.
1039 *
1040 * @return Formatted string.
1041 */
Abe Mbise925ca0f2017-10-02 19:16:33 +01001042inline std::string to_string(const Coordinates &coord)
1043{
1044 std::stringstream str;
1045 str << coord;
1046 return str.str();
1047}
1048
Anthony Barbierb940fd62018-06-04 14:14:32 +01001049/** Formatted output of the GEMMReshapeInfo type.
1050 *
1051 * @param[out] os Output stream.
1052 * @param[in] info Type to output.
1053 *
1054 * @return Modified output stream.
1055 */
1056inline ::std::ostream &operator<<(::std::ostream &os, const GEMMReshapeInfo &info)
1057{
1058 os << "{m=" << info.m() << ",";
1059 os << "n=" << info.n() << ",";
1060 os << "k=" << info.k() << ",";
1061 os << "mult_transpose1xW_width=" << info.mult_transpose1xW_width() << ",";
1062 os << "mult_interleave4x4_height=" << info.mult_interleave4x4_height();
1063 os << "}";
1064
1065 return os;
1066}
1067
1068/** Formatted output of the GEMMInfo type.
1069 *
1070 * @param[out] os Output stream.
1071 * @param[in] info Type to output.
1072 *
1073 * @return Modified output stream.
1074 */
1075inline ::std::ostream &operator<<(::std::ostream &os, const GEMMInfo &info)
1076{
1077 os << "{is_a_reshaped=" << info.is_a_reshaped() << ",";
1078 os << "is_b_reshaped=" << info.is_b_reshaped() << ",";
1079 os << "reshape_b_only_on_first_run=" << info.reshape_b_only_on_first_run() << ",";
Anthony Barbierb940fd62018-06-04 14:14:32 +01001080 os << "}";
1081
1082 return os;
1083}
1084
1085/** Formatted output of the Window::Dimension type.
1086 *
1087 * @param[out] os Output stream.
1088 * @param[in] dim Type to output.
1089 *
1090 * @return Modified output stream.
1091 */
1092inline ::std::ostream &operator<<(::std::ostream &os, const Window::Dimension &dim)
1093{
1094 os << "{start=" << dim.start() << ", end=" << dim.end() << ", step=" << dim.step() << "}";
1095
1096 return os;
1097}
1098/** Formatted output of the Window type.
1099 *
1100 * @param[out] os Output stream.
1101 * @param[in] win Type to output.
1102 *
1103 * @return Modified output stream.
1104 */
1105inline ::std::ostream &operator<<(::std::ostream &os, const Window &win)
1106{
1107 os << "{";
1108 for(unsigned int i = 0; i < Coordinates::num_max_dimensions; i++)
1109 {
1110 if(i > 0)
1111 {
1112 os << ", ";
1113 }
1114 os << win[i];
1115 }
1116 os << "}";
1117
1118 return os;
1119}
1120
1121/** Formatted output of the WeightsInfo type.
1122 *
1123 * @param[in] info Type to output.
1124 *
1125 * @return Formatted string.
1126 */
1127inline std::string to_string(const WeightsInfo &info)
1128{
1129 std::stringstream str;
1130 str << info;
1131 return str.str();
1132}
1133
1134/** Formatted output of the GEMMReshapeInfo type.
1135 *
1136 * @param[in] info Type to output.
1137 *
1138 * @return Formatted string.
1139 */
1140inline std::string to_string(const GEMMReshapeInfo &info)
1141{
1142 std::stringstream str;
1143 str << info;
1144 return str.str();
1145}
1146
1147/** Formatted output of the GEMMInfo type.
1148 *
1149 * @param[in] info Type to output.
1150 *
1151 * @return Formatted string.
1152 */
1153inline std::string to_string(const GEMMInfo &info)
1154{
1155 std::stringstream str;
1156 str << info;
1157 return str.str();
1158}
1159
1160/** Formatted output of the Window::Dimension type.
1161 *
1162 * @param[in] dim Type to output.
1163 *
1164 * @return Formatted string.
1165 */
1166inline std::string to_string(const Window::Dimension &dim)
1167{
1168 std::stringstream str;
1169 str << dim;
1170 return str.str();
1171}
1172/** Formatted output of the Window type.
1173 *
1174 * @param[in] win Type to output.
1175 *
1176 * @return Formatted string.
1177 */
1178inline std::string to_string(const Window &win)
1179{
1180 std::stringstream str;
1181 str << win;
1182 return str.str();
1183}
1184
Alex Gildayc357c472018-03-21 13:54:09 +00001185/** Formatted output of the Rectangle type.
1186 *
1187 * @param[out] os Output stream.
1188 * @param[in] rect Type to output.
1189 *
1190 * @return Modified output stream.
1191 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001192inline ::std::ostream &operator<<(::std::ostream &os, const Rectangle &rect)
1193{
1194 os << rect.width << "x" << rect.height;
1195 os << "+" << rect.x << "+" << rect.y;
1196
1197 return os;
1198}
1199
Usama Arif8cf8c112019-03-14 15:36:54 +00001200/** Formatted output of the PaddingMode type.
1201 *
1202 * @param[out] os Output stream.
1203 * @param[in] mode Type to output.
1204 *
1205 * @return Modified output stream.
1206 */
1207inline ::std::ostream &operator<<(::std::ostream &os, const PaddingMode &mode)
1208{
1209 switch(mode)
1210 {
1211 case PaddingMode::CONSTANT:
1212 os << "CONSTANT";
1213 break;
1214 case PaddingMode::REFLECT:
1215 os << "REFLECT";
1216 break;
1217 case PaddingMode::SYMMETRIC:
1218 os << "SYMMETRIC";
1219 break;
1220 default:
1221 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1222 }
1223
1224 return os;
1225}
1226
1227/** Formatted output of the PaddingMode type.
1228 *
1229 * @param[in] mode Type to output.
1230 *
1231 * @return Formatted string.
1232 */
1233inline std::string to_string(const PaddingMode &mode)
1234{
1235 std::stringstream str;
1236 str << mode;
1237 return str.str();
1238}
1239
Alex Gildayc357c472018-03-21 13:54:09 +00001240/** Formatted output of the PadStrideInfo type.
1241 *
1242 * @param[out] os Output stream.
1243 * @param[in] pad_stride_info 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 PadStrideInfo &pad_stride_info)
1248{
1249 os << pad_stride_info.stride().first << "," << pad_stride_info.stride().second;
1250 os << ";";
Jaroslaw Rzepeckia1ed41f2017-10-13 11:13:58 +01001251 os << pad_stride_info.pad_left() << "," << pad_stride_info.pad_right() << ","
1252 << pad_stride_info.pad_top() << "," << pad_stride_info.pad_bottom();
Anthony Barbier2a07e182017-08-04 18:20:27 +01001253
1254 return os;
1255}
1256
Alex Gildayc357c472018-03-21 13:54:09 +00001257/** Formatted output of the PadStrideInfo type.
1258 *
1259 * @param[in] pad_stride_info Type to output.
1260 *
1261 * @return Formatted string.
1262 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001263inline std::string to_string(const PadStrideInfo &pad_stride_info)
1264{
1265 std::stringstream str;
1266 str << pad_stride_info;
1267 return str.str();
1268}
1269
Alex Gildayc357c472018-03-21 13:54:09 +00001270/** Formatted output of the BorderMode type.
1271 *
1272 * @param[in] mode Type to output.
1273 *
1274 * @return Formatted string.
1275 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001276inline std::string to_string(const BorderMode &mode)
1277{
1278 std::stringstream str;
1279 str << mode;
1280 return str.str();
1281}
1282
Alex Gildayc357c472018-03-21 13:54:09 +00001283/** Formatted output of the BorderSize type.
1284 *
1285 * @param[in] border Type to output.
1286 *
1287 * @return Formatted string.
1288 */
John Richardsonb482ce12017-09-18 12:44:01 +01001289inline std::string to_string(const BorderSize &border)
1290{
1291 std::stringstream str;
1292 str << border;
1293 return str.str();
1294}
1295
Giuseppe Rossinid7647d42018-07-17 18:13:13 +01001296/** Formatted output of the PaddingList type.
1297 *
1298 * @param[in] padding Type to output.
1299 *
1300 * @return Formatted string.
1301 */
1302inline std::string to_string(const PaddingList &padding)
1303{
1304 std::stringstream str;
1305 str << padding;
1306 return str.str();
1307}
1308
giuros013175fcf2018-11-21 09:59:17 +00001309/** Formatted output of the Multiples type.
1310 *
1311 * @param[in] multiples Type to output.
1312 *
1313 * @return Formatted string.
1314 */
1315inline std::string to_string(const Multiples &multiples)
1316{
1317 std::stringstream str;
1318 str << multiples;
1319 return str.str();
1320}
1321
Alex Gildayc357c472018-03-21 13:54:09 +00001322/** Formatted output of the InterpolationPolicy type.
1323 *
1324 * @param[in] policy Type to output.
1325 *
1326 * @return Formatted string.
1327 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001328inline std::string to_string(const InterpolationPolicy &policy)
1329{
1330 std::stringstream str;
1331 str << policy;
1332 return str.str();
1333}
1334
Alex Gildayc357c472018-03-21 13:54:09 +00001335/** Formatted output of the SamplingPolicy type.
1336 *
1337 * @param[in] policy Type to output.
1338 *
1339 * @return Formatted string.
1340 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +07001341inline std::string to_string(const SamplingPolicy &policy)
1342{
1343 std::stringstream str;
1344 str << policy;
1345 return str.str();
1346}
1347
Alex Gildayc357c472018-03-21 13:54:09 +00001348/** Formatted output of the ConvertPolicy type.
1349 *
1350 * @param[out] os Output stream.
1351 * @param[in] policy Type to output.
1352 *
1353 * @return Modified output stream.
1354 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001355inline ::std::ostream &operator<<(::std::ostream &os, const ConvertPolicy &policy)
1356{
1357 switch(policy)
1358 {
1359 case ConvertPolicy::WRAP:
1360 os << "WRAP";
1361 break;
1362 case ConvertPolicy::SATURATE:
1363 os << "SATURATE";
1364 break;
1365 default:
1366 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1367 }
1368
1369 return os;
1370}
1371
1372inline std::string to_string(const ConvertPolicy &policy)
1373{
1374 std::stringstream str;
1375 str << policy;
1376 return str.str();
1377}
1378
giuros01164a2722018-11-20 18:34:46 +00001379/** Formatted output of the ArithmeticOperation type.
1380 *
1381 * @param[out] os Output stream.
1382 * @param[in] op Operation to output.
1383 *
1384 * @return Modified output stream.
1385 */
1386inline ::std::ostream &operator<<(::std::ostream &os, const ArithmeticOperation &op)
1387{
1388 switch(op)
1389 {
1390 case ArithmeticOperation::ADD:
1391 os << "ADD";
1392 break;
1393 case ArithmeticOperation::SUB:
1394 os << "SUB";
1395 break;
1396 case ArithmeticOperation::DIV:
1397 os << "DIV";
1398 break;
1399 case ArithmeticOperation::MAX:
1400 os << "MAX";
1401 break;
1402 case ArithmeticOperation::MIN:
1403 os << "MIN";
1404 break;
1405 case ArithmeticOperation::SQUARED_DIFF:
1406 os << "SQUARED_DIFF";
1407 break;
Usama Arif52c54f62019-05-14 10:22:36 +01001408 case ArithmeticOperation::POWER:
1409 os << "POWER";
1410 break;
giuros01164a2722018-11-20 18:34:46 +00001411 default:
1412 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1413 }
1414
1415 return os;
1416}
1417
1418/** Formatted output of the Arithmetic Operation
1419 *
1420 * @param[in] op Type to output.
1421 *
1422 * @return Formatted string.
1423 */
1424inline std::string to_string(const ArithmeticOperation &op)
1425{
1426 std::stringstream str;
1427 str << op;
1428 return str.str();
1429}
1430
Alex Gildayc357c472018-03-21 13:54:09 +00001431/** Formatted output of the Reduction Operations.
1432 *
1433 * @param[out] os Output stream.
1434 * @param[in] op Type to output.
1435 *
1436 * @return Modified output stream.
1437 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001438inline ::std::ostream &operator<<(::std::ostream &os, const ReductionOperation &op)
1439{
1440 switch(op)
1441 {
Michalis Spyrou7e9391b2018-10-05 14:49:28 +01001442 case ReductionOperation::SUM:
1443 os << "SUM";
1444 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +01001445 case ReductionOperation::SUM_SQUARE:
1446 os << "SUM_SQUARE";
1447 break;
Michalis Spyrou7e9391b2018-10-05 14:49:28 +01001448 case ReductionOperation::MEAN_SUM:
1449 os << "MEAN_SUM";
1450 break;
Michalis Spyrou7930db42018-11-22 17:36:28 +00001451 case ReductionOperation::ARG_IDX_MAX:
1452 os << "ARG_IDX_MAX";
1453 break;
1454 case ReductionOperation::ARG_IDX_MIN:
1455 os << "ARG_IDX_MIN";
1456 break;
Manuel Bottinib412fab2018-12-10 17:40:23 +00001457 case ReductionOperation::PROD:
1458 os << "PROD";
1459 break;
Usama Arifa4a08ad2019-05-20 12:38:33 +01001460 case ReductionOperation::MIN:
1461 os << "MIN";
1462 break;
Usama Arif28f0dd92019-05-20 13:44:34 +01001463 case ReductionOperation::MAX:
1464 os << "MAX";
1465 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +01001466 default:
1467 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1468 }
1469
1470 return os;
1471}
1472
Alex Gildayc357c472018-03-21 13:54:09 +00001473/** Formatted output of the Reduction Operations.
1474 *
1475 * @param[in] op Type to output.
1476 *
1477 * @return Formatted string.
1478 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001479inline std::string to_string(const ReductionOperation &op)
1480{
1481 std::stringstream str;
1482 str << op;
1483 return str.str();
1484}
1485
Georgios Pinitas7900a9e2018-11-23 11:44:58 +00001486/** Formatted output of the Comparison Operations.
1487 *
1488 * @param[out] os Output stream.
1489 * @param[in] op Type to output.
1490 *
1491 * @return Modified output stream.
1492 */
1493inline ::std::ostream &operator<<(::std::ostream &os, const ComparisonOperation &op)
1494{
1495 switch(op)
1496 {
1497 case ComparisonOperation::Equal:
1498 os << "Equal";
1499 break;
1500 case ComparisonOperation::NotEqual:
1501 os << "NotEqual";
1502 break;
1503 case ComparisonOperation::Greater:
1504 os << "Greater";
1505 break;
1506 case ComparisonOperation::GreaterEqual:
1507 os << "GreaterEqual";
1508 break;
1509 case ComparisonOperation::Less:
1510 os << "Less";
1511 break;
1512 case ComparisonOperation::LessEqual:
1513 os << "LessEqual";
1514 break;
1515 default:
1516 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1517 }
1518
1519 return os;
1520}
1521
Michalis Spyroue9362622018-11-23 17:41:37 +00001522/** Formatted output of the Elementwise unary Operations.
1523 *
1524 * @param[out] os Output stream.
1525 * @param[in] op Type to output.
1526 *
1527 * @return Modified output stream.
1528 */
1529inline ::std::ostream &operator<<(::std::ostream &os, const ElementWiseUnary &op)
1530{
1531 switch(op)
1532 {
1533 case ElementWiseUnary::RSQRT:
1534 os << "RSQRT";
1535 break;
1536 case ElementWiseUnary::EXP:
1537 os << "EXP";
1538 break;
Usama Arifeb312ef2019-05-13 17:45:54 +01001539 case ElementWiseUnary::NEG:
1540 os << "NEG";
1541 break;
Usama Arifac33d7e2019-05-20 14:21:40 +01001542 case ElementWiseUnary::LOG:
1543 os << "LOG";
1544 break;
Usama Arif6a4d5422019-05-24 14:53:59 +01001545 case ElementWiseUnary::ROUND:
1546 os << "ROUND";
1547 break;
Michalis Spyroue9362622018-11-23 17:41:37 +00001548 default:
1549 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1550 }
1551
1552 return os;
1553}
1554
Georgios Pinitas7900a9e2018-11-23 11:44:58 +00001555/** Formatted output of the Comparison Operations.
1556 *
1557 * @param[in] op Type to output.
1558 *
1559 * @return Formatted string.
1560 */
1561inline std::string to_string(const ComparisonOperation &op)
1562{
1563 std::stringstream str;
1564 str << op;
1565 return str.str();
1566}
1567
Michalis Spyroue9362622018-11-23 17:41:37 +00001568/** Formatted output of the Elementwise unary Operations.
1569 *
1570 * @param[in] op Type to output.
1571 *
1572 * @return Formatted string.
1573 */
1574inline std::string to_string(const ElementWiseUnary &op)
1575{
1576 std::stringstream str;
1577 str << op;
1578 return str.str();
1579}
1580
Alex Gildayc357c472018-03-21 13:54:09 +00001581/** Formatted output of the Norm Type.
1582 *
1583 * @param[in] type Type to output.
1584 *
1585 * @return Formatted string.
1586 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001587inline std::string to_string(const NormType &type)
1588{
1589 std::stringstream str;
1590 str << type;
1591 return str.str();
1592}
1593
Alex Gildayc357c472018-03-21 13:54:09 +00001594/** Formatted output of the Pooling Type.
1595 *
1596 * @param[in] type Type to output.
1597 *
1598 * @return Formatted string.
1599 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001600inline std::string to_string(const PoolingType &type)
1601{
1602 std::stringstream str;
1603 str << type;
1604 return str.str();
1605}
1606
Alex Gildayc357c472018-03-21 13:54:09 +00001607/** Formatted output of the Pooling Layer Info.
1608 *
1609 * @param[in] info Type to output.
1610 *
1611 * @return Formatted string.
1612 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001613inline std::string to_string(const PoolingLayerInfo &info)
1614{
1615 std::stringstream str;
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001616 str << "{Type=" << info.pool_type() << ","
1617 << "IsGlobalPooling=" << info.is_global_pooling();
1618 if(!info.is_global_pooling())
1619 {
1620 str << ","
Isabella Gottardi6e464c32018-01-26 12:32:45 +00001621 << "PoolSize=" << info.pool_size().width << "," << info.pool_size().height << ","
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001622 << "PadStride=" << info.pad_stride_info();
1623 }
1624 str << "}";
Anthony Barbier2a07e182017-08-04 18:20:27 +01001625 return str.str();
1626}
1627
Michalis Spyrou6c7c38e2018-08-29 16:28:11 +01001628/** Formatted output of the PriorBoxLayerInfo.
1629 *
1630 * @param[in] info Type to output.
1631 *
1632 * @return Formatted string.
1633 */
1634inline std::string to_string(const PriorBoxLayerInfo &info)
1635{
1636 std::stringstream str;
1637 str << "{";
1638 str << "Clip:" << info.clip()
1639 << "Flip:" << info.flip()
1640 << "StepX:" << info.steps()[0]
1641 << "StepY:" << info.steps()[1]
1642 << "MinSizes:" << info.min_sizes().size()
1643 << "MaxSizes:" << info.max_sizes().size()
1644 << "ImgSizeX:" << info.img_size().x
1645 << "ImgSizeY:" << info.img_size().y
1646 << "Offset:" << info.offset()
1647 << "Variances:" << info.variances().size();
1648 str << "}";
1649 return str.str();
1650}
1651
Alex Gildayc357c472018-03-21 13:54:09 +00001652/** Formatted output of the KeyPoint type.
1653 *
1654 * @param[out] os Output stream
1655 * @param[in] point Type to output.
1656 *
1657 * @return Modified output stream.
1658 */
Moritz Pflanzer6c6597c2017-09-24 12:09:41 +01001659inline ::std::ostream &operator<<(::std::ostream &os, const KeyPoint &point)
1660{
1661 os << "{x=" << point.x << ","
1662 << "y=" << point.y << ","
1663 << "strength=" << point.strength << ","
1664 << "scale=" << point.scale << ","
1665 << "orientation=" << point.orientation << ","
1666 << "tracking_status=" << point.tracking_status << ","
1667 << "error=" << point.error << "}";
1668
1669 return os;
1670}
John Richardson63e50412017-10-13 20:51:42 +01001671
Alex Gildayc357c472018-03-21 13:54:09 +00001672/** Formatted output of the PhaseType type.
1673 *
1674 * @param[out] os Output stream
1675 * @param[in] phase_type Type to output.
1676 *
1677 * @return Modified output stream.
1678 */
John Richardson63e50412017-10-13 20:51:42 +01001679inline ::std::ostream &operator<<(::std::ostream &os, const PhaseType &phase_type)
1680{
1681 switch(phase_type)
1682 {
1683 case PhaseType::SIGNED:
1684 os << "SIGNED";
1685 break;
1686 case PhaseType::UNSIGNED:
1687 os << "UNSIGNED";
1688 break;
1689 default:
1690 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1691 }
1692
1693 return os;
1694}
1695
Alex Gildayc357c472018-03-21 13:54:09 +00001696/** Formatted output of the PhaseType type.
1697 *
1698 * @param[in] type Type to output.
1699 *
1700 * @return Formatted string.
1701 */
John Richardson63e50412017-10-13 20:51:42 +01001702inline std::string to_string(const arm_compute::PhaseType &type)
1703{
1704 std::stringstream str;
1705 str << type;
1706 return str.str();
1707}
John Richardson3c5f9492017-10-04 15:27:37 +01001708
Alex Gildayc357c472018-03-21 13:54:09 +00001709/** Formatted output of the MagnitudeType type.
1710 *
1711 * @param[out] os Output stream
1712 * @param[in] magnitude_type Type to output.
1713 *
1714 * @return Modified output stream.
1715 */
John Richardson3c5f9492017-10-04 15:27:37 +01001716inline ::std::ostream &operator<<(::std::ostream &os, const MagnitudeType &magnitude_type)
1717{
1718 switch(magnitude_type)
1719 {
1720 case MagnitudeType::L1NORM:
1721 os << "L1NORM";
1722 break;
1723 case MagnitudeType::L2NORM:
1724 os << "L2NORM";
1725 break;
1726 default:
1727 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1728 }
1729
1730 return os;
1731}
1732
Alex Gildayc357c472018-03-21 13:54:09 +00001733/** Formatted output of the MagnitudeType type.
1734 *
1735 * @param[in] type Type to output.
1736 *
1737 * @return Formatted string.
1738 */
John Richardson3c5f9492017-10-04 15:27:37 +01001739inline std::string to_string(const arm_compute::MagnitudeType &type)
1740{
1741 std::stringstream str;
1742 str << type;
1743 return str.str();
1744}
John Richardson1c529922017-11-01 10:57:48 +00001745
Alex Gildayc357c472018-03-21 13:54:09 +00001746/** Formatted output of the HOGNormType type.
1747 *
1748 * @param[out] os Output stream
1749 * @param[in] norm_type Type to output
1750 *
1751 * @return Modified output stream.
1752 */
John Richardson25f23682017-11-27 14:35:09 +00001753inline ::std::ostream &operator<<(::std::ostream &os, const HOGNormType &norm_type)
1754{
1755 switch(norm_type)
1756 {
1757 case HOGNormType::L1_NORM:
1758 os << "L1_NORM";
1759 break;
1760 case HOGNormType::L2_NORM:
1761 os << "L2_NORM";
1762 break;
1763 case HOGNormType::L2HYS_NORM:
1764 os << "L2HYS_NORM";
1765 break;
1766 default:
1767 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1768 }
1769
1770 return os;
1771}
1772
Alex Gildayc357c472018-03-21 13:54:09 +00001773/** Formatted output of the HOGNormType type.
1774 *
1775 * @param[in] type Type to output
1776 *
1777 * @return Formatted string.
1778 */
John Richardson25f23682017-11-27 14:35:09 +00001779inline std::string to_string(const HOGNormType &type)
1780{
1781 std::stringstream str;
1782 str << type;
1783 return str.str();
1784}
1785
Alex Gildayc357c472018-03-21 13:54:09 +00001786/** Formatted output of the Size2D type.
1787 *
1788 * @param[out] os Output stream
1789 * @param[in] size Type to output
1790 *
1791 * @return Modified output stream.
1792 */
John Richardson25f23682017-11-27 14:35:09 +00001793inline ::std::ostream &operator<<(::std::ostream &os, const Size2D &size)
1794{
1795 os << size.width << "x" << size.height;
1796
1797 return os;
1798}
1799
Alex Gildayc357c472018-03-21 13:54:09 +00001800/** Formatted output of the Size2D type.
1801 *
1802 * @param[in] type Type to output
1803 *
1804 * @return Formatted string.
1805 */
John Richardson25f23682017-11-27 14:35:09 +00001806inline std::string to_string(const Size2D &type)
1807{
1808 std::stringstream str;
1809 str << type;
1810 return str.str();
1811}
1812
Alex Gildayc357c472018-03-21 13:54:09 +00001813/** Formatted output of the HOGInfo type.
1814 *
1815 * @param[out] os Output stream
1816 * @param[in] hog_info Type to output
1817 *
1818 * @return Modified output stream.
1819 */
John Richardson25f23682017-11-27 14:35:09 +00001820inline ::std::ostream &operator<<(::std::ostream &os, const HOGInfo &hog_info)
1821{
1822 os << "{CellSize=" << hog_info.cell_size() << ","
1823 << "BlockSize=" << hog_info.block_size() << ","
1824 << "DetectionWindowSize=" << hog_info.detection_window_size() << ","
1825 << "BlockStride=" << hog_info.block_stride() << ","
1826 << "NumBins=" << hog_info.num_bins() << ","
1827 << "NormType=" << hog_info.normalization_type() << ","
1828 << "L2HystThreshold=" << hog_info.l2_hyst_threshold() << ","
1829 << "PhaseType=" << hog_info.phase_type() << "}";
1830
1831 return os;
1832}
1833
Alex Gildayc357c472018-03-21 13:54:09 +00001834/** Formatted output of the HOGInfo type.
1835 *
1836 * @param[in] type Type to output
1837 *
1838 * @return Formatted string.
1839 */
John Richardson25f23682017-11-27 14:35:09 +00001840inline std::string to_string(const HOGInfo &type)
1841{
1842 std::stringstream str;
1843 str << type;
1844 return str.str();
1845}
1846
Alex Gildayc357c472018-03-21 13:54:09 +00001847/** Formatted output of the ConvolutionMethod type.
1848 *
1849 * @param[out] os Output stream
1850 * @param[in] conv_method Type to output
1851 *
1852 * @return Modified output stream.
1853 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001854inline ::std::ostream &operator<<(::std::ostream &os, const ConvolutionMethod &conv_method)
1855{
1856 switch(conv_method)
1857 {
1858 case ConvolutionMethod::GEMM:
1859 os << "GEMM";
1860 break;
1861 case ConvolutionMethod::DIRECT:
1862 os << "DIRECT";
1863 break;
1864 case ConvolutionMethod::WINOGRAD:
1865 os << "WINOGRAD";
1866 break;
1867 default:
1868 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1869 }
1870
1871 return os;
1872}
1873
Alex Gildayc357c472018-03-21 13:54:09 +00001874/** Formatted output of the ConvolutionMethod type.
1875 *
1876 * @param[in] conv_method Type to output
1877 *
1878 * @return Formatted string.
1879 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001880inline std::string to_string(const ConvolutionMethod &conv_method)
1881{
1882 std::stringstream str;
1883 str << conv_method;
1884 return str.str();
1885}
1886
Alex Gildayc357c472018-03-21 13:54:09 +00001887/** Formatted output of the GPUTarget type.
1888 *
1889 * @param[out] os Output stream
1890 * @param[in] gpu_target Type to output
1891 *
1892 * @return Modified output stream.
1893 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001894inline ::std::ostream &operator<<(::std::ostream &os, const GPUTarget &gpu_target)
1895{
1896 switch(gpu_target)
1897 {
1898 case GPUTarget::GPU_ARCH_MASK:
1899 os << "GPU_ARCH_MASK";
1900 break;
1901 case GPUTarget::MIDGARD:
1902 os << "MIDGARD";
1903 break;
1904 case GPUTarget::BIFROST:
1905 os << "BIFROST";
1906 break;
1907 case GPUTarget::T600:
1908 os << "T600";
1909 break;
1910 case GPUTarget::T700:
1911 os << "T700";
1912 break;
1913 case GPUTarget::T800:
1914 os << "T800";
1915 break;
Michalis Spyroua9676112018-02-22 18:07:43 +00001916 case GPUTarget::G71:
1917 os << "G71";
1918 break;
1919 case GPUTarget::G72:
1920 os << "G72";
1921 break;
1922 case GPUTarget::G51:
1923 os << "G51";
1924 break;
1925 case GPUTarget::G51BIG:
1926 os << "G51BIG";
1927 break;
1928 case GPUTarget::G51LIT:
1929 os << "G51LIT";
1930 break;
Georgios Pinitasb03f7c52018-07-12 10:49:53 +01001931 case GPUTarget::G76:
1932 os << "G76";
Michalis Spyroua9676112018-02-22 18:07:43 +00001933 break;
1934 case GPUTarget::TTRX:
1935 os << "TTRX";
1936 break;
1937 case GPUTarget::TBOX:
1938 os << "TBOX";
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001939 break;
1940 default:
1941 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1942 }
1943
1944 return os;
1945}
1946
Alex Gildayc357c472018-03-21 13:54:09 +00001947/** Formatted output of the GPUTarget type.
1948 *
1949 * @param[in] gpu_target Type to output
1950 *
1951 * @return Formatted string.
1952 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001953inline std::string to_string(const GPUTarget &gpu_target)
1954{
1955 std::stringstream str;
1956 str << gpu_target;
1957 return str.str();
1958}
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00001959
John Richardson8de92612018-02-22 14:09:31 +00001960/** Formatted output of the DetectionWindow type.
1961 *
1962 * @param[out] os Output stream
1963 * @param[in] detection_window Type to output
1964 *
1965 * @return Modified output stream.
1966 */
John Richardson684cb0f2018-01-09 11:17:00 +00001967inline ::std::ostream &operator<<(::std::ostream &os, const DetectionWindow &detection_window)
1968{
1969 os << "{x=" << detection_window.x << ","
1970 << "y=" << detection_window.y << ","
1971 << "width=" << detection_window.width << ","
1972 << "height=" << detection_window.height << ","
1973 << "idx_class=" << detection_window.idx_class << ","
1974 << "score=" << detection_window.score << "}";
1975
1976 return os;
1977}
1978
Isabella Gottardi05e56442018-11-16 11:26:52 +00001979/** Formatted output of the DetectionOutputLayerCodeType type.
1980 *
1981 * @param[out] os Output stream
1982 * @param[in] detection_code Type to output
1983 *
1984 * @return Modified output stream.
1985 */
1986inline ::std::ostream &operator<<(::std::ostream &os, const DetectionOutputLayerCodeType &detection_code)
1987{
1988 switch(detection_code)
1989 {
1990 case DetectionOutputLayerCodeType::CENTER_SIZE:
1991 os << "CENTER_SIZE";
1992 break;
1993 case DetectionOutputLayerCodeType::CORNER:
1994 os << "CORNER";
1995 break;
1996 case DetectionOutputLayerCodeType::CORNER_SIZE:
1997 os << "CORNER_SIZE";
1998 break;
1999 case DetectionOutputLayerCodeType::TF_CENTER:
2000 os << "TF_CENTER";
2001 break;
2002 default:
2003 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2004 }
2005
2006 return os;
2007}
2008/** Formatted output of the DetectionOutputLayerCodeType type.
2009 *
2010 * @param[in] detection_code Type to output
2011 *
2012 * @return Formatted string.
2013 */
2014inline std::string to_string(const DetectionOutputLayerCodeType &detection_code)
2015{
2016 std::stringstream str;
2017 str << detection_code;
2018 return str.str();
2019}
2020
2021/** Formatted output of the DetectionOutputLayerInfo type.
2022 *
2023 * @param[out] os Output stream
2024 * @param[in] detection_info Type to output
2025 *
2026 * @return Modified output stream.
2027 */
2028inline ::std::ostream &operator<<(::std::ostream &os, const DetectionOutputLayerInfo &detection_info)
2029{
2030 os << "{Classes=" << detection_info.num_classes() << ","
2031 << "ShareLocation=" << detection_info.share_location() << ","
2032 << "CodeType=" << detection_info.code_type() << ","
2033 << "VarianceEncodedInTarget=" << detection_info.variance_encoded_in_target() << ","
2034 << "KeepTopK=" << detection_info.keep_top_k() << ","
2035 << "NMSThreshold=" << detection_info.nms_threshold() << ","
2036 << "Eta=" << detection_info.eta() << ","
2037 << "BackgroundLabelId=" << detection_info.background_label_id() << ","
2038 << "ConfidenceThreshold=" << detection_info.confidence_threshold() << ","
2039 << "TopK=" << detection_info.top_k() << ","
2040 << "NumLocClasses=" << detection_info.num_loc_classes()
2041 << "}";
2042
2043 return os;
2044}
2045
2046/** Formatted output of the DetectionOutputLayerInfo type.
2047 *
2048 * @param[in] detection_info Type to output
2049 *
2050 * @return Formatted string.
2051 */
2052inline std::string to_string(const DetectionOutputLayerInfo &detection_info)
2053{
2054 std::stringstream str;
2055 str << detection_info;
2056 return str.str();
2057}
John Richardson8de92612018-02-22 14:09:31 +00002058/** Formatted output of the DetectionWindow type.
2059 *
2060 * @param[in] detection_window Type to output
2061 *
2062 * @return Formatted string.
2063 */
2064inline std::string to_string(const DetectionWindow &detection_window)
2065{
2066 std::stringstream str;
2067 str << detection_window;
2068 return str.str();
2069}
2070
2071/** Formatted output of the Termination type.
2072 *
2073 * @param[out] os Output stream
2074 * @param[in] termination Type to output
2075 *
2076 * @return Modified output stream.
2077 */
2078inline ::std::ostream &operator<<(::std::ostream &os, const Termination &termination)
2079{
2080 switch(termination)
2081 {
2082 case Termination::TERM_CRITERIA_EPSILON:
2083 os << "TERM_CRITERIA_EPSILON";
2084 break;
2085 case Termination::TERM_CRITERIA_ITERATIONS:
2086 os << "TERM_CRITERIA_ITERATIONS";
2087 break;
2088 case Termination::TERM_CRITERIA_BOTH:
2089 os << "TERM_CRITERIA_BOTH";
2090 break;
2091 default:
2092 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2093 }
2094
2095 return os;
2096}
2097
2098/** Formatted output of the Termination type.
2099 *
2100 * @param[in] termination Type to output
2101 *
2102 * @return Formatted string.
2103 */
2104inline std::string to_string(const Termination &termination)
2105{
2106 std::stringstream str;
2107 str << termination;
2108 return str.str();
2109}
2110
Anthony Barbier8914e322018-08-10 15:28:25 +01002111/** Formatted output of the CPUModel type.
2112 *
2113 * @param[out] os Output stream
2114 * @param[in] cpu_model Model to output
2115 *
2116 * @return Modified output stream.
2117 */
2118inline ::std::ostream &operator<<(::std::ostream &os, const CPUModel &cpu_model)
2119{
2120 switch(cpu_model)
2121 {
2122 case CPUModel::GENERIC:
2123 os << "GENERIC";
2124 break;
2125 case CPUModel::GENERIC_FP16:
2126 os << "GENERIC_FP16";
2127 break;
2128 case CPUModel::GENERIC_FP16_DOT:
2129 os << "GENERIC_FP16_DOT";
2130 break;
2131 case CPUModel::A53:
2132 os << "A53";
2133 break;
2134 case CPUModel::A55r0:
2135 os << "A55r0";
2136 break;
2137 case CPUModel::A55r1:
2138 os << "A55r1";
2139 break;
2140 default:
2141 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2142 }
2143
2144 return os;
2145}
2146
2147/** Formatted output of the CPUModel type.
2148 *
2149 * @param[in] cpu_model Model to output
2150 *
2151 * @return Formatted string.
2152 */
2153inline std::string to_string(const CPUModel &cpu_model)
2154{
2155 std::stringstream str;
2156 str << cpu_model;
2157 return str.str();
2158}
Anthony Barbier671a11e2018-07-06 15:11:36 +01002159/** Formatted output of a vector of objects.
2160 *
2161 * @param[out] os Output stream
2162 * @param[in] args Vector of objects to print
2163 *
2164 * @return Modified output stream.
2165 */
2166template <typename T>
2167inline ::std::ostream &operator<<(::std::ostream &os, const std::vector<T> &args)
2168{
2169 os << "[";
2170 bool first = true;
2171 for(auto &arg : args)
2172 {
2173 if(first)
2174 {
2175 first = false;
2176 }
2177 else
2178 {
2179 os << ", ";
2180 }
2181 os << arg;
2182 }
2183 os << "]";
2184 return os;
2185}
2186
Michalis Spyrou6c7c38e2018-08-29 16:28:11 +01002187/** Formatted output of @ref PriorBoxLayerInfo.
2188 *
2189 * @param[out] os Output stream.
2190 * @param[in] info Type to output.
2191 *
2192 * @return Modified output stream.
2193 */
2194inline ::std::ostream &operator<<(::std::ostream &os, const PriorBoxLayerInfo &info)
2195{
2196 os << "Clip:" << info.clip()
2197 << "Flip:" << info.flip()
2198 << "StepX:" << info.steps()[0]
2199 << "StepY:" << info.steps()[1]
2200 << "MinSizes:" << info.min_sizes()
2201 << "MaxSizes:" << info.max_sizes()
2202 << "ImgSizeX:" << info.img_size().x
2203 << "ImgSizeY:" << info.img_size().y
2204 << "Offset:" << info.offset()
2205 << "Variances:" << info.variances();
2206
2207 return os;
2208}
2209
Anthony Barbier671a11e2018-07-06 15:11:36 +01002210/** Formatted output of a vector of objects.
2211 *
2212 * @param[in] args Vector of objects to print
2213 *
2214 * @return String representing args.
2215 */
2216template <typename T>
2217std::string to_string(const std::vector<T> &args)
2218{
2219 std::stringstream str;
2220 str << args;
2221 return str.str();
2222}
2223
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00002224/** Formatted output of the WinogradInfo type. */
2225inline ::std::ostream &operator<<(::std::ostream &os, const WinogradInfo &info)
2226{
2227 os << "{OutputTileSize=" << info.output_tile_size << ","
2228 << "KernelSize=" << info.kernel_size << ","
2229 << "PadStride=" << info.convolution_info << ","
2230 << "OutputDataLayout=" << info.output_data_layout << "}";
2231
2232 return os;
2233}
2234
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00002235inline std::string to_string(const WinogradInfo &type)
2236{
2237 std::stringstream str;
2238 str << type;
2239 return str.str();
2240}
Anthony Barbier671a11e2018-07-06 15:11:36 +01002241
2242/** Fallback method: try to use std::to_string:
2243 *
2244 * @param[in] val Value to convert to string
2245 *
2246 * @return String representing val.
2247 */
2248template <typename T>
2249inline std::string to_string(const T &val)
2250{
2251 return support::cpp11::to_string(val);
2252}
2253
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +01002254/** Convert a CLTunerMode value to a string
2255 *
2256 * @param val CLTunerMode value to be converted
2257 *
2258 * @return String representing the corresponding CLTunerMode.
2259 */
2260inline std::string to_string(const CLTunerMode val)
2261{
2262 switch(val)
2263 {
2264 case CLTunerMode::EXHAUSTIVE:
2265 {
2266 return std::string("Exhaustive");
2267 }
2268 case CLTunerMode::NORMAL:
2269 {
2270 return std::string("Normal");
2271 }
2272 case CLTunerMode::RAPID:
2273 {
2274 return std::string("Rapid");
2275 }
2276 default:
2277 {
2278 ARM_COMPUTE_ERROR("Invalid tuner mode.");
2279 return std::string("UNDEFINED");
2280 }
2281 }
2282}
2283/** [Print CLTunerMode type] **/
2284/** Formatted output of the CLTunerMode type.
2285 *
2286 * @param[out] os Output stream.
2287 * @param[in] val CLTunerMode to output.
2288 *
2289 * @return Modified output stream.
2290 */
2291inline ::std::ostream &operator<<(::std::ostream &os, const CLTunerMode &val)
2292{
2293 os << to_string(val);
2294 return os;
2295}
2296
Anthony Barbier6ff3b192017-09-04 18:44:23 +01002297} // namespace arm_compute
Anthony Barbier4dbc0a92018-08-27 13:39:47 +01002298
2299#endif /* __ARM_COMPUTE_TYPE_PRINTER_H__ */