blob: b62bd69a8d93e9aafa5652c37c439205ff0a4d35 [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001/*
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +00002 * Copyright (c) 2017-2020 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}
Anthony Barbierb4670212018-05-18 16:55:39 +010062
Alex Gildayc357c472018-03-21 13:54:09 +000063/** Formatted output of the Dimensions type.
64 *
65 * @param[out] os Output stream.
66 * @param[in] dimensions Type to output.
67 *
68 * @return Modified output stream.
69 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +010070template <typename T>
71inline ::std::ostream &operator<<(::std::ostream &os, const Dimensions<T> &dimensions)
72{
Anthony Barbier6ff3b192017-09-04 18:44:23 +010073 if(dimensions.num_dimensions() > 0)
74 {
75 os << dimensions[0];
76
77 for(unsigned int d = 1; d < dimensions.num_dimensions(); ++d)
78 {
Moritz Pflanzerc87fbf82017-07-18 14:02:10 +010079 os << "x" << dimensions[d];
Anthony Barbier6ff3b192017-09-04 18:44:23 +010080 }
81 }
82
Anthony Barbier6ff3b192017-09-04 18:44:23 +010083 return os;
84}
85
Alex Gildayc357c472018-03-21 13:54:09 +000086/** Formatted output of the NonLinearFilterFunction type.
87 *
88 * @param[out] os Output stream.
89 * @param[in] function Type to output.
90 *
91 * @return Modified output stream.
92 */
Isabella Gottardi3b77e9d2017-06-22 11:05:41 +010093inline ::std::ostream &operator<<(::std::ostream &os, const NonLinearFilterFunction &function)
94{
95 switch(function)
96 {
97 case NonLinearFilterFunction::MAX:
98 os << "MAX";
99 break;
100 case NonLinearFilterFunction::MEDIAN:
101 os << "MEDIAN";
102 break;
103 case NonLinearFilterFunction::MIN:
104 os << "MIN";
105 break;
106 default:
107 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
108 }
109
110 return os;
111}
112
Alex Gildayc357c472018-03-21 13:54:09 +0000113/** Formatted output of the NonLinearFilterFunction type.
114 *
115 * @param[in] function Type to output.
116 *
117 * @return Formatted string.
118 */
John Richardson6f4d49f2017-09-07 11:21:10 +0100119inline std::string to_string(const NonLinearFilterFunction &function)
120{
121 std::stringstream str;
122 str << function;
123 return str.str();
124}
125
Alex Gildayc357c472018-03-21 13:54:09 +0000126/** Formatted output of the MatrixPattern type.
127 *
128 * @param[out] os Output stream.
129 * @param[in] pattern Type to output.
130 *
131 * @return Modified output stream.
132 */
Isabella Gottardi3b77e9d2017-06-22 11:05:41 +0100133inline ::std::ostream &operator<<(::std::ostream &os, const MatrixPattern &pattern)
134{
135 switch(pattern)
136 {
137 case MatrixPattern::BOX:
138 os << "BOX";
139 break;
140 case MatrixPattern::CROSS:
141 os << "CROSS";
142 break;
143 case MatrixPattern::DISK:
144 os << "DISK";
145 break;
146 case MatrixPattern::OTHER:
147 os << "OTHER";
148 break;
149 default:
150 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
151 }
152
153 return os;
154}
155
Alex Gildayc357c472018-03-21 13:54:09 +0000156/** Formatted output of the MatrixPattern type.
157 *
158 * @param[in] pattern Type to output.
159 *
160 * @return Formatted string.
161 */
John Richardson6f4d49f2017-09-07 11:21:10 +0100162inline std::string to_string(const MatrixPattern &pattern)
163{
164 std::stringstream str;
165 str << pattern;
166 return str.str();
167}
168
Alex Gildayc357c472018-03-21 13:54:09 +0000169/** Formatted output of the RoundingPolicy type.
170 *
171 * @param[out] os Output stream.
172 * @param[in] rounding_policy Type to output.
173 *
174 * @return Modified output stream.
175 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100176inline ::std::ostream &operator<<(::std::ostream &os, const RoundingPolicy &rounding_policy)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100177{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100178 switch(rounding_policy)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100179 {
Anthony Barbier2a07e182017-08-04 18:20:27 +0100180 case RoundingPolicy::TO_ZERO:
181 os << "TO_ZERO";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100182 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100183 case RoundingPolicy::TO_NEAREST_UP:
184 os << "TO_NEAREST_UP";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100185 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100186 case RoundingPolicy::TO_NEAREST_EVEN:
187 os << "TO_NEAREST_EVEN";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100188 break;
189 default:
190 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
191 }
192
193 return os;
194}
195
Alex Gildayc357c472018-03-21 13:54:09 +0000196/** Formatted output of the WeightsInfo type.
197 *
198 * @param[out] os Output stream.
199 * @param[in] weights_info Type to output.
200 *
201 * @return Modified output stream.
202 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100203inline ::std::ostream &operator<<(::std::ostream &os, const WeightsInfo &weights_info)
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100204{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100205 os << weights_info.are_reshaped() << ";";
206 os << weights_info.num_kernels() << ";" << weights_info.kernel_size().first << "," << weights_info.kernel_size().second;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100207
208 return os;
209}
210
Alex Gildayc357c472018-03-21 13:54:09 +0000211/** Formatted output of the ROIPoolingInfo type.
212 *
213 * @param[out] os Output stream.
214 * @param[in] pool_info Type to output.
215 *
216 * @return Modified output stream.
217 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100218inline ::std::ostream &operator<<(::std::ostream &os, const ROIPoolingLayerInfo &pool_info)
Sanghoon Lee70f82912017-08-24 14:21:24 +0100219{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100220 os << pool_info.pooled_width() << "x" << pool_info.pooled_height() << "~" << pool_info.spatial_scale();
Georgios Pinitasd9769582017-08-03 10:19:40 +0100221 return os;
222}
223
giuros0118870812018-09-13 09:31:40 +0100224/** Formatted output of the ROIPoolingInfo type.
225 *
226 * @param[in] pool_info Type to output.
227 *
228 * @return Formatted string.
229 */
230inline std::string to_string(const ROIPoolingLayerInfo &pool_info)
231{
232 std::stringstream str;
233 str << pool_info;
234 return str.str();
235}
236
giuros01c04a0e82018-10-03 12:44:35 +0100237/** Formatted output of the BoundingBoxTransformInfo type.
238 *
239 * @param[out] os Output stream.
240 * @param[in] bbox_info Type to output.
241 *
242 * @return Modified output stream.
243 */
244inline ::std::ostream &operator<<(::std::ostream &os, const BoundingBoxTransformInfo &bbox_info)
245{
246 auto weights = bbox_info.weights();
247 os << "(" << bbox_info.img_width() << "x" << bbox_info.img_height() << ")~" << bbox_info.scale() << "(weights = {" << weights[0] << ", " << weights[1] << ", " << weights[2] << ", " << weights[3] <<
248 "})";
249 return os;
250}
251
252/** Formatted output of the BoundingBoxTransformInfo type.
253 *
254 * @param[in] bbox_info Type to output.
255 *
256 * @return Formatted string.
257 */
258inline std::string to_string(const BoundingBoxTransformInfo &bbox_info)
259{
260 std::stringstream str;
261 str << bbox_info;
262 return str.str();
263}
264
Manuel Bottini5209be52019-02-13 16:34:56 +0000265/** Formatted output of the ComputeAnchorsInfo type.
266 *
267 * @param[out] os Output stream.
268 * @param[in] anchors_info Type to output.
269 *
270 * @return Modified output stream.
271 */
272inline ::std::ostream &operator<<(::std::ostream &os, const ComputeAnchorsInfo &anchors_info)
273{
274 os << "(" << anchors_info.feat_width() << "x" << anchors_info.feat_height() << ")~" << anchors_info.spatial_scale();
275 return os;
276}
277
278/** Formatted output of the ComputeAnchorsInfo type.
279 *
280 * @param[in] anchors_info Type to output.
281 *
282 * @return Formatted string.
283 */
284inline std::string to_string(const ComputeAnchorsInfo &anchors_info)
285{
286 std::stringstream str;
287 str << anchors_info;
288 return str.str();
289}
290
291/** Formatted output of the GenerateProposalsInfo type.
292 *
293 * @param[out] os Output stream.
294 * @param[in] proposals_info Type to output.
295 *
296 * @return Modified output stream.
297 */
298inline ::std::ostream &operator<<(::std::ostream &os, const GenerateProposalsInfo &proposals_info)
299{
300 os << "(" << proposals_info.im_width() << "x" << proposals_info.im_height() << ")~" << proposals_info.im_scale();
301 return os;
302}
303
304/** Formatted output of the GenerateProposalsInfo type.
305 *
306 * @param[in] proposals_info Type to output.
307 *
308 * @return Formatted string.
309 */
310inline std::string to_string(const GenerateProposalsInfo &proposals_info)
311{
312 std::stringstream str;
313 str << proposals_info;
314 return str.str();
315}
316
Alex Gildayc357c472018-03-21 13:54:09 +0000317/** Formatted output of the QuantizationInfo type.
318 *
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100319 * @param[out] os Output stream.
320 * @param[in] qinfo Type to output.
Alex Gildayc357c472018-03-21 13:54:09 +0000321 *
322 * @return Modified output stream.
323 */
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100324inline ::std::ostream &operator<<(::std::ostream &os, const QuantizationInfo &qinfo)
Chunosovd621bca2017-11-03 17:33:15 +0700325{
Georgios Pinitas3d13af82019-06-04 13:04:16 +0100326 const UniformQuantizationInfo uqinfo = qinfo.uniform();
327 os << "Scale:" << uqinfo.scale << "~";
328 os << "Offset:" << uqinfo.offset;
Chunosovd621bca2017-11-03 17:33:15 +0700329 return os;
330}
331
Alex Gildayc357c472018-03-21 13:54:09 +0000332/** Formatted output of the QuantizationInfo type.
333 *
334 * @param[in] quantization_info Type to output.
335 *
336 * @return Formatted string.
337 */
Chunosovd621bca2017-11-03 17:33:15 +0700338inline std::string to_string(const QuantizationInfo &quantization_info)
339{
340 std::stringstream str;
341 str << quantization_info;
342 return str.str();
343}
344
Alex Gildayc357c472018-03-21 13:54:09 +0000345/** Formatted output of the activation function type.
346 *
347 * @param[out] os Output stream.
348 * @param[in] act_function Type to output.
349 *
350 * @return Modified output stream.
351 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100352inline ::std::ostream &operator<<(::std::ostream &os, const ActivationLayerInfo::ActivationFunction &act_function)
353{
354 switch(act_function)
355 {
356 case ActivationLayerInfo::ActivationFunction::ABS:
357 os << "ABS";
358 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100359 case ActivationLayerInfo::ActivationFunction::LINEAR:
360 os << "LINEAR";
361 break;
362 case ActivationLayerInfo::ActivationFunction::LOGISTIC:
363 os << "LOGISTIC";
364 break;
365 case ActivationLayerInfo::ActivationFunction::RELU:
366 os << "RELU";
367 break;
Georgios Pinitas579c0492017-07-12 16:12:12 +0100368 case ActivationLayerInfo::ActivationFunction::BOUNDED_RELU:
369 os << "BOUNDED_RELU";
370 break;
371 case ActivationLayerInfo::ActivationFunction::LEAKY_RELU:
372 os << "LEAKY_RELU";
373 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100374 case ActivationLayerInfo::ActivationFunction::SOFT_RELU:
375 os << "SOFT_RELU";
376 break;
377 case ActivationLayerInfo::ActivationFunction::SQRT:
378 os << "SQRT";
379 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100380 case ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU:
381 os << "LU_BOUNDED_RELU";
Kevin Petitd9f80712017-12-06 12:18:48 +0000382 break;
Georgios Pinitasfb0fdcd2019-08-22 17:10:04 +0100383 case ActivationLayerInfo::ActivationFunction::ELU:
384 os << "ELU";
385 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100386 case ActivationLayerInfo::ActivationFunction::SQUARE:
387 os << "SQUARE";
388 break;
389 case ActivationLayerInfo::ActivationFunction::TANH:
390 os << "TANH";
391 break;
Usama Arif6a98a6e2019-05-10 17:07:27 +0100392 case ActivationLayerInfo::ActivationFunction::IDENTITY:
393 os << "IDENTITY";
394 break;
morgolock07df3d42020-02-27 11:46:28 +0000395 case ActivationLayerInfo::ActivationFunction::HARD_SWISH:
396 os << "HARD_SWISH";
397 break;
398
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100399 default:
400 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
401 }
402
403 return os;
404}
405
Alex Gildayc357c472018-03-21 13:54:09 +0000406/** Formatted output of the activation function info type.
407 *
408 * @param[in] info Type to output.
409 *
410 * @return Formatted string.
411 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100412inline std::string to_string(const arm_compute::ActivationLayerInfo &info)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100413{
414 std::stringstream str;
Isabella Gottardi3f217ec2018-02-12 14:59:19 +0000415 if(info.enabled())
416 {
417 str << info.activation();
418 }
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100419 return str.str();
420}
421
Alex Gildayc357c472018-03-21 13:54:09 +0000422/** Formatted output of the activation function type.
423 *
424 * @param[in] function Type to output.
425 *
426 * @return Formatted string.
427 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100428inline std::string to_string(const arm_compute::ActivationLayerInfo::ActivationFunction &function)
429{
430 std::stringstream str;
431 str << function;
432 return str.str();
433}
434
Alex Gildayc357c472018-03-21 13:54:09 +0000435/** Formatted output of the NormType type.
436 *
437 * @param[out] os Output stream.
438 * @param[in] norm_type Type to output.
439 *
440 * @return Modified output stream.
441 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100442inline ::std::ostream &operator<<(::std::ostream &os, const NormType &norm_type)
443{
444 switch(norm_type)
445 {
446 case NormType::CROSS_MAP:
447 os << "CROSS_MAP";
448 break;
449 case NormType::IN_MAP_1D:
450 os << "IN_MAP_1D";
451 break;
452 case NormType::IN_MAP_2D:
453 os << "IN_MAP_2D";
454 break;
455 default:
456 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
457 }
458
459 return os;
460}
461
Alex Gildayc357c472018-03-21 13:54:09 +0000462/** Formatted output of @ref NormalizationLayerInfo.
463 *
464 * @param[in] info Type to output.
465 *
466 * @return Formatted string.
467 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100468inline std::string to_string(const arm_compute::NormalizationLayerInfo &info)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100469{
470 std::stringstream str;
Michalis Spyroud466c2d2018-01-30 10:54:39 +0000471 str << info.type() << ":NormSize=" << info.norm_size();
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100472 return str.str();
473}
474
Alex Gildayc357c472018-03-21 13:54:09 +0000475/** Formatted output of @ref NormalizationLayerInfo.
476 *
477 * @param[out] os Output stream.
478 * @param[in] info Type to output.
479 *
480 * @return Modified output stream.
481 */
Georgios Pinitas6f669f02017-09-26 12:32:57 +0100482inline ::std::ostream &operator<<(::std::ostream &os, const NormalizationLayerInfo &info)
483{
Michalis Spyroud466c2d2018-01-30 10:54:39 +0000484 os << info.type() << ":NormSize=" << info.norm_size();
Georgios Pinitas6f669f02017-09-26 12:32:57 +0100485 return os;
486}
487
Alex Gildayc357c472018-03-21 13:54:09 +0000488/** Formatted output of the PoolingType type.
489 *
490 * @param[out] os Output stream.
491 * @param[in] pool_type Type to output.
492 *
493 * @return Modified output stream.
494 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100495inline ::std::ostream &operator<<(::std::ostream &os, const PoolingType &pool_type)
496{
497 switch(pool_type)
498 {
499 case PoolingType::AVG:
500 os << "AVG";
501 break;
502 case PoolingType::MAX:
503 os << "MAX";
504 break;
Georgios Pinitascdf51452017-08-31 14:21:36 +0100505 case PoolingType::L2:
506 os << "L2";
507 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100508 default:
509 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
510 }
511
512 return os;
513}
514
Alex Gildayc357c472018-03-21 13:54:09 +0000515/** Formatted output of @ref PoolingLayerInfo.
516 *
517 * @param[out] os Output stream.
518 * @param[in] info Type to output.
519 *
520 * @return Modified output stream.
521 */
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100522inline ::std::ostream &operator<<(::std::ostream &os, const PoolingLayerInfo &info)
523{
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +0000524 os << info.pool_type;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100525
526 return os;
527}
528
Alex Gildayc357c472018-03-21 13:54:09 +0000529/** Formatted output of @ref RoundingPolicy.
530 *
531 * @param[in] rounding_policy Type to output.
532 *
533 * @return Formatted string.
534 */
John Richardsondd715f22017-09-18 16:10:48 +0100535inline std::string to_string(const RoundingPolicy &rounding_policy)
536{
537 std::stringstream str;
538 str << rounding_policy;
539 return str.str();
540}
541
Vidhya Sudhan Loganathand646ae12018-11-19 15:18:20 +0000542/** [Print DataLayout type] **/
Alex Gildayc357c472018-03-21 13:54:09 +0000543/** Formatted output of the DataLayout type.
544 *
545 * @param[out] os Output stream.
546 * @param[in] data_layout Type to output.
547 *
548 * @return Modified output stream.
549 */
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000550inline ::std::ostream &operator<<(::std::ostream &os, const DataLayout &data_layout)
551{
552 switch(data_layout)
553 {
554 case DataLayout::UNKNOWN:
555 os << "UNKNOWN";
556 break;
557 case DataLayout::NHWC:
558 os << "NHWC";
559 break;
560 case DataLayout::NCHW:
561 os << "NCHW";
562 break;
563 default:
564 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
565 }
566
567 return os;
568}
569
Alex Gildayc357c472018-03-21 13:54:09 +0000570/** Formatted output of the DataLayout type.
571 *
572 * @param[in] data_layout Type to output.
573 *
574 * @return Formatted string.
575 */
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000576inline std::string to_string(const arm_compute::DataLayout &data_layout)
577{
578 std::stringstream str;
579 str << data_layout;
580 return str.str();
581}
Vidhya Sudhan Loganathand646ae12018-11-19 15:18:20 +0000582/** [Print DataLayout type] **/
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000583
Georgios Pinitase2220552018-07-20 13:23:44 +0100584/** Formatted output of the DataLayoutDimension type.
585 *
586 * @param[out] os Output stream.
587 * @param[in] data_layout_dim Data layout dimension to print.
588 *
589 * @return Modified output stream.
590 */
591inline ::std::ostream &operator<<(::std::ostream &os, const DataLayoutDimension &data_layout_dim)
592{
593 switch(data_layout_dim)
594 {
595 case DataLayoutDimension::WIDTH:
596 os << "WIDTH";
597 break;
598 case DataLayoutDimension::HEIGHT:
599 os << "HEIGHT";
600 break;
601 case DataLayoutDimension::CHANNEL:
602 os << "CHANNEL";
603 break;
604 case DataLayoutDimension::BATCHES:
605 os << "BATCHES";
606 break;
607 default:
608 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
609 }
610 return os;
611}
612
Alex Gildayc357c472018-03-21 13:54:09 +0000613/** Formatted output of the DataType type.
614 *
615 * @param[out] os Output stream.
616 * @param[in] data_type Type to output.
617 *
618 * @return Modified output stream.
619 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100620inline ::std::ostream &operator<<(::std::ostream &os, const DataType &data_type)
621{
622 switch(data_type)
623 {
624 case DataType::UNKNOWN:
625 os << "UNKNOWN";
626 break;
627 case DataType::U8:
628 os << "U8";
629 break;
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100630 case DataType::QSYMM8:
631 os << "QSYMM8";
632 break;
Chunosovd621bca2017-11-03 17:33:15 +0700633 case DataType::QASYMM8:
634 os << "QASYMM8";
635 break;
Georgios Pinitas448a81f2019-11-21 14:10:25 +0000636 case DataType::QASYMM8_SIGNED:
637 os << "QASYMM8_SIGNED";
638 break;
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100639 case DataType::QSYMM8_PER_CHANNEL:
640 os << "QSYMM8_PER_CHANNEL";
641 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100642 case DataType::S8:
643 os << "S8";
644 break;
645 case DataType::U16:
646 os << "U16";
647 break;
648 case DataType::S16:
649 os << "S16";
650 break;
Manuel Bottini3689fcd2019-06-14 17:18:12 +0100651 case DataType::QSYMM16:
652 os << "QSYMM16";
653 break;
Michele Di Giorgio35ea9a72019-08-23 12:02:06 +0100654 case DataType::QASYMM16:
655 os << "QASYMM16";
656 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100657 case DataType::U32:
658 os << "U32";
659 break;
660 case DataType::S32:
661 os << "S32";
662 break;
663 case DataType::U64:
664 os << "U64";
665 break;
666 case DataType::S64:
667 os << "S64";
668 break;
Georgios Pinitase8291ac2020-02-26 09:58:13 +0000669 case DataType::BFLOAT16:
670 os << "BFLOAT16";
671 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100672 case DataType::F16:
673 os << "F16";
674 break;
675 case DataType::F32:
676 os << "F32";
677 break;
678 case DataType::F64:
679 os << "F64";
680 break;
681 case DataType::SIZET:
682 os << "SIZET";
683 break;
684 default:
685 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
686 }
687
688 return os;
689}
690
Alex Gildayc357c472018-03-21 13:54:09 +0000691/** Formatted output of the DataType type.
692 *
693 * @param[in] data_type Type to output.
694 *
695 * @return Formatted string.
696 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100697inline std::string to_string(const arm_compute::DataType &data_type)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100698{
699 std::stringstream str;
700 str << data_type;
701 return str.str();
702}
703
Alex Gildayc357c472018-03-21 13:54:09 +0000704/** Formatted output of the Format type.
705 *
706 * @param[out] os Output stream.
707 * @param[in] format Type to output.
708 *
709 * @return Modified output stream.
710 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100711inline ::std::ostream &operator<<(::std::ostream &os, const Format &format)
712{
713 switch(format)
714 {
715 case Format::UNKNOWN:
716 os << "UNKNOWN";
717 break;
718 case Format::U8:
719 os << "U8";
720 break;
721 case Format::S16:
722 os << "S16";
723 break;
724 case Format::U16:
725 os << "U16";
726 break;
727 case Format::S32:
728 os << "S32";
729 break;
730 case Format::U32:
731 os << "U32";
732 break;
733 case Format::F16:
734 os << "F16";
735 break;
736 case Format::F32:
737 os << "F32";
738 break;
739 case Format::UV88:
740 os << "UV88";
741 break;
742 case Format::RGB888:
743 os << "RGB888";
744 break;
745 case Format::RGBA8888:
746 os << "RGBA8888";
747 break;
748 case Format::YUV444:
749 os << "YUV444";
750 break;
751 case Format::YUYV422:
752 os << "YUYV422";
753 break;
754 case Format::NV12:
755 os << "NV12";
756 break;
757 case Format::NV21:
758 os << "NV21";
759 break;
760 case Format::IYUV:
761 os << "IYUV";
762 break;
763 case Format::UYVY422:
764 os << "UYVY422";
765 break;
766 default:
767 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
768 }
769
770 return os;
771}
772
Alex Gildayc357c472018-03-21 13:54:09 +0000773/** Formatted output of the Format type.
774 *
775 * @param[in] format Type to output.
776 *
777 * @return Formatted string.
778 */
Moritz Pflanzer7655a672017-09-23 11:57:33 +0100779inline std::string to_string(const Format &format)
780{
781 std::stringstream str;
782 str << format;
783 return str.str();
784}
785
Alex Gildayc357c472018-03-21 13:54:09 +0000786/** Formatted output of the Channel type.
787 *
788 * @param[out] os Output stream.
789 * @param[in] channel Type to output.
790 *
791 * @return Modified output stream.
792 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100793inline ::std::ostream &operator<<(::std::ostream &os, const Channel &channel)
794{
795 switch(channel)
796 {
797 case Channel::UNKNOWN:
798 os << "UNKNOWN";
799 break;
800 case Channel::C0:
801 os << "C0";
802 break;
803 case Channel::C1:
804 os << "C1";
805 break;
806 case Channel::C2:
807 os << "C2";
808 break;
809 case Channel::C3:
810 os << "C3";
811 break;
812 case Channel::R:
813 os << "R";
814 break;
815 case Channel::G:
816 os << "G";
817 break;
818 case Channel::B:
819 os << "B";
820 break;
821 case Channel::A:
822 os << "A";
823 break;
824 case Channel::Y:
825 os << "Y";
826 break;
827 case Channel::U:
828 os << "U";
829 break;
830 case Channel::V:
831 os << "V";
832 break;
833 default:
834 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
835 }
836
837 return os;
838}
839
Alex Gildayc357c472018-03-21 13:54:09 +0000840/** Formatted output of the Channel type.
841 *
842 * @param[in] channel Type to output.
843 *
844 * @return Formatted string.
845 */
Ioan-Cristian Szabo9414f642017-10-27 17:35:40 +0100846inline std::string to_string(const Channel &channel)
847{
848 std::stringstream str;
849 str << channel;
850 return str.str();
851}
852
Alex Gildayc357c472018-03-21 13:54:09 +0000853/** Formatted output of the BorderMode type.
854 *
855 * @param[out] os Output stream.
856 * @param[in] mode Type to output.
857 *
858 * @return Modified output stream.
859 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100860inline ::std::ostream &operator<<(::std::ostream &os, const BorderMode &mode)
861{
862 switch(mode)
863 {
864 case BorderMode::UNDEFINED:
865 os << "UNDEFINED";
866 break;
867 case BorderMode::CONSTANT:
868 os << "CONSTANT";
869 break;
870 case BorderMode::REPLICATE:
871 os << "REPLICATE";
872 break;
873 default:
874 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
875 }
876
877 return os;
878}
879
Alex Gildayc357c472018-03-21 13:54:09 +0000880/** Formatted output of the BorderSize type.
881 *
882 * @param[out] os Output stream.
883 * @param[in] border Type to output.
884 *
885 * @return Modified output stream.
886 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100887inline ::std::ostream &operator<<(::std::ostream &os, const BorderSize &border)
888{
Moritz Pflanzerc87fbf82017-07-18 14:02:10 +0100889 os << border.top << ","
890 << border.right << ","
891 << border.bottom << ","
892 << border.left;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100893
894 return os;
895}
Anthony Barbier2a07e182017-08-04 18:20:27 +0100896
Giuseppe Rossinid7647d42018-07-17 18:13:13 +0100897/** Formatted output of the PaddingList type.
898 *
899 * @param[out] os Output stream.
900 * @param[in] padding Type to output.
901 *
902 * @return Modified output stream.
903 */
904inline ::std::ostream &operator<<(::std::ostream &os, const PaddingList &padding)
905{
906 os << "{";
907 for(auto const &p : padding)
908 {
909 os << "{" << p.first << "," << p.second << "}";
910 }
911 os << "}";
912 return os;
913}
914
giuros013175fcf2018-11-21 09:59:17 +0000915/** Formatted output of the Multiples type.
916 *
917 * @param[out] os Output stream.
918 * @param[in] multiples Type to output.
919 *
920 * @return Modified output stream.
921 */
922inline ::std::ostream &operator<<(::std::ostream &os, const Multiples &multiples)
923{
924 os << "(";
925 for(size_t i = 0; i < multiples.size() - 1; i++)
926 {
927 os << multiples[i] << ", ";
928 }
929 os << multiples.back() << ")";
930 return os;
931}
932
Alex Gildayc357c472018-03-21 13:54:09 +0000933/** Formatted output of the InterpolationPolicy type.
934 *
935 * @param[out] os Output stream.
936 * @param[in] policy Type to output.
937 *
938 * @return Modified output stream.
939 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100940inline ::std::ostream &operator<<(::std::ostream &os, const InterpolationPolicy &policy)
941{
942 switch(policy)
943 {
944 case InterpolationPolicy::NEAREST_NEIGHBOR:
945 os << "NEAREST_NEIGHBOR";
946 break;
947 case InterpolationPolicy::BILINEAR:
948 os << "BILINEAR";
949 break;
950 case InterpolationPolicy::AREA:
951 os << "AREA";
952 break;
953 default:
954 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
955 }
956
957 return os;
958}
959
Alex Gildayc357c472018-03-21 13:54:09 +0000960/** Formatted output of the SamplingPolicy type.
961 *
962 * @param[out] os Output stream.
963 * @param[in] policy Type to output.
964 *
965 * @return Modified output stream.
966 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700967inline ::std::ostream &operator<<(::std::ostream &os, const SamplingPolicy &policy)
968{
969 switch(policy)
970 {
971 case SamplingPolicy::CENTER:
972 os << "CENTER";
973 break;
974 case SamplingPolicy::TOP_LEFT:
975 os << "TOP_LEFT";
976 break;
977 default:
978 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
979 }
980
981 return os;
982}
983
Alex Gildayc357c472018-03-21 13:54:09 +0000984/** Formatted output of the TensorInfo type.
985 *
Anthony Barbier366628a2018-08-01 13:55:03 +0100986 * @param[out] os Output stream.
987 * @param[in] info Type to output.
988 *
989 * @return Modified output stream.
990 */
991inline ::std::ostream &operator<<(::std::ostream &os, const TensorInfo &info)
992{
993 os << "{Shape=" << info.tensor_shape() << ","
994 << "Type=" << info.data_type() << ","
995 << "Channels=" << info.num_channels() << "}";
996 return os;
997}
998/** Formatted output of the TensorInfo type.
999 *
Alex Gildayc357c472018-03-21 13:54:09 +00001000 * @param[in] info Type to output.
1001 *
1002 * @return Formatted string.
1003 */
Georgios Pinitas3faea252017-10-30 14:13:50 +00001004inline std::string to_string(const TensorInfo &info)
1005{
1006 std::stringstream str;
Anthony Barbier366628a2018-08-01 13:55:03 +01001007 str << info;
Georgios Pinitas3faea252017-10-30 14:13:50 +00001008 return str.str();
1009}
1010
Alex Gildayc357c472018-03-21 13:54:09 +00001011/** Formatted output of the Dimensions type.
1012 *
1013 * @param[in] dimensions Type to output.
1014 *
1015 * @return Formatted string.
1016 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001017template <typename T>
1018inline std::string to_string(const Dimensions<T> &dimensions)
1019{
1020 std::stringstream str;
1021 str << dimensions;
1022 return str.str();
1023}
1024
Alex Gildayc357c472018-03-21 13:54:09 +00001025/** Formatted output of the Strides type.
1026 *
1027 * @param[in] stride Type to output.
1028 *
1029 * @return Formatted string.
1030 */
John Richardsona36eae12017-09-26 16:55:59 +01001031inline std::string to_string(const Strides &stride)
1032{
1033 std::stringstream str;
1034 str << stride;
1035 return str.str();
1036}
1037
Alex Gildayc357c472018-03-21 13:54:09 +00001038/** Formatted output of the TensorShape type.
1039 *
1040 * @param[in] shape Type to output.
1041 *
1042 * @return Formatted string.
1043 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001044inline std::string to_string(const TensorShape &shape)
1045{
1046 std::stringstream str;
1047 str << shape;
1048 return str.str();
1049}
1050
Alex Gildayc357c472018-03-21 13:54:09 +00001051/** Formatted output of the Coordinates type.
1052 *
1053 * @param[in] coord Type to output.
1054 *
1055 * @return Formatted string.
1056 */
Abe Mbise925ca0f2017-10-02 19:16:33 +01001057inline std::string to_string(const Coordinates &coord)
1058{
1059 std::stringstream str;
1060 str << coord;
1061 return str.str();
1062}
1063
Anthony Barbierb940fd62018-06-04 14:14:32 +01001064/** Formatted output of the GEMMReshapeInfo type.
1065 *
1066 * @param[out] os Output stream.
1067 * @param[in] info Type to output.
1068 *
1069 * @return Modified output stream.
1070 */
1071inline ::std::ostream &operator<<(::std::ostream &os, const GEMMReshapeInfo &info)
1072{
1073 os << "{m=" << info.m() << ",";
1074 os << "n=" << info.n() << ",";
1075 os << "k=" << info.k() << ",";
1076 os << "mult_transpose1xW_width=" << info.mult_transpose1xW_width() << ",";
1077 os << "mult_interleave4x4_height=" << info.mult_interleave4x4_height();
1078 os << "}";
1079
1080 return os;
1081}
1082
1083/** Formatted output of the GEMMInfo type.
1084 *
1085 * @param[out] os Output stream.
1086 * @param[in] info Type to output.
1087 *
1088 * @return Modified output stream.
1089 */
1090inline ::std::ostream &operator<<(::std::ostream &os, const GEMMInfo &info)
1091{
1092 os << "{is_a_reshaped=" << info.is_a_reshaped() << ",";
1093 os << "is_b_reshaped=" << info.is_b_reshaped() << ",";
1094 os << "reshape_b_only_on_first_run=" << info.reshape_b_only_on_first_run() << ",";
Anthony Barbierb4670212018-05-18 16:55:39 +01001095 os << "depth_output_gemm3d=" << info.depth_output_gemm3d() << ",";
1096 os << "reinterpret_input_as_3d=" << info.reinterpret_input_as_3d() << ",";
1097 os << "retain_internal_weights=" << info.retain_internal_weights() << ",";
1098 os << "fp_mixed_precision=" << info.fp_mixed_precision() << ",";
1099 os << "broadcast_bias=" << info.broadcast_bias() << ",";
1100 os << "pretranpose_B=" << info.pretranpose_B() << ",";
Anthony Barbierb940fd62018-06-04 14:14:32 +01001101
1102 return os;
1103}
1104
1105/** Formatted output of the Window::Dimension type.
1106 *
1107 * @param[out] os Output stream.
1108 * @param[in] dim Type to output.
1109 *
1110 * @return Modified output stream.
1111 */
1112inline ::std::ostream &operator<<(::std::ostream &os, const Window::Dimension &dim)
1113{
1114 os << "{start=" << dim.start() << ", end=" << dim.end() << ", step=" << dim.step() << "}";
1115
1116 return os;
1117}
1118/** Formatted output of the Window type.
1119 *
1120 * @param[out] os Output stream.
1121 * @param[in] win Type to output.
1122 *
1123 * @return Modified output stream.
1124 */
1125inline ::std::ostream &operator<<(::std::ostream &os, const Window &win)
1126{
1127 os << "{";
1128 for(unsigned int i = 0; i < Coordinates::num_max_dimensions; i++)
1129 {
1130 if(i > 0)
1131 {
1132 os << ", ";
1133 }
1134 os << win[i];
1135 }
1136 os << "}";
1137
1138 return os;
1139}
1140
1141/** Formatted output of the WeightsInfo type.
1142 *
1143 * @param[in] info Type to output.
1144 *
1145 * @return Formatted string.
1146 */
1147inline std::string to_string(const WeightsInfo &info)
1148{
1149 std::stringstream str;
1150 str << info;
1151 return str.str();
1152}
1153
1154/** Formatted output of the GEMMReshapeInfo type.
1155 *
1156 * @param[in] info Type to output.
1157 *
1158 * @return Formatted string.
1159 */
1160inline std::string to_string(const GEMMReshapeInfo &info)
1161{
1162 std::stringstream str;
1163 str << info;
1164 return str.str();
1165}
1166
1167/** Formatted output of the GEMMInfo type.
1168 *
1169 * @param[in] info Type to output.
1170 *
1171 * @return Formatted string.
1172 */
1173inline std::string to_string(const GEMMInfo &info)
1174{
1175 std::stringstream str;
1176 str << info;
1177 return str.str();
1178}
1179
1180/** Formatted output of the Window::Dimension type.
1181 *
1182 * @param[in] dim Type to output.
1183 *
1184 * @return Formatted string.
1185 */
1186inline std::string to_string(const Window::Dimension &dim)
1187{
1188 std::stringstream str;
1189 str << dim;
1190 return str.str();
1191}
1192/** Formatted output of the Window type.
1193 *
1194 * @param[in] win Type to output.
1195 *
1196 * @return Formatted string.
1197 */
1198inline std::string to_string(const Window &win)
1199{
1200 std::stringstream str;
1201 str << win;
1202 return str.str();
1203}
1204
Alex Gildayc357c472018-03-21 13:54:09 +00001205/** Formatted output of the Rectangle type.
1206 *
1207 * @param[out] os Output stream.
1208 * @param[in] rect Type to output.
1209 *
1210 * @return Modified output stream.
1211 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001212inline ::std::ostream &operator<<(::std::ostream &os, const Rectangle &rect)
1213{
1214 os << rect.width << "x" << rect.height;
1215 os << "+" << rect.x << "+" << rect.y;
1216
1217 return os;
1218}
1219
Usama Arif8cf8c112019-03-14 15:36:54 +00001220/** Formatted output of the PaddingMode type.
1221 *
1222 * @param[out] os Output stream.
1223 * @param[in] mode Type to output.
1224 *
1225 * @return Modified output stream.
1226 */
1227inline ::std::ostream &operator<<(::std::ostream &os, const PaddingMode &mode)
1228{
1229 switch(mode)
1230 {
1231 case PaddingMode::CONSTANT:
1232 os << "CONSTANT";
1233 break;
1234 case PaddingMode::REFLECT:
1235 os << "REFLECT";
1236 break;
1237 case PaddingMode::SYMMETRIC:
1238 os << "SYMMETRIC";
1239 break;
1240 default:
1241 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1242 }
1243
1244 return os;
1245}
1246
1247/** Formatted output of the PaddingMode type.
1248 *
1249 * @param[in] mode Type to output.
1250 *
1251 * @return Formatted string.
1252 */
1253inline std::string to_string(const PaddingMode &mode)
1254{
1255 std::stringstream str;
1256 str << mode;
1257 return str.str();
1258}
1259
Alex Gildayc357c472018-03-21 13:54:09 +00001260/** Formatted output of the PadStrideInfo type.
1261 *
1262 * @param[out] os Output stream.
1263 * @param[in] pad_stride_info Type to output.
1264 *
1265 * @return Modified output stream.
1266 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001267inline ::std::ostream &operator<<(::std::ostream &os, const PadStrideInfo &pad_stride_info)
1268{
1269 os << pad_stride_info.stride().first << "," << pad_stride_info.stride().second;
1270 os << ";";
Jaroslaw Rzepeckia1ed41f2017-10-13 11:13:58 +01001271 os << pad_stride_info.pad_left() << "," << pad_stride_info.pad_right() << ","
1272 << pad_stride_info.pad_top() << "," << pad_stride_info.pad_bottom();
Anthony Barbier2a07e182017-08-04 18:20:27 +01001273
1274 return os;
1275}
1276
Alex Gildayc357c472018-03-21 13:54:09 +00001277/** Formatted output of the PadStrideInfo type.
1278 *
1279 * @param[in] pad_stride_info Type to output.
1280 *
1281 * @return Formatted string.
1282 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001283inline std::string to_string(const PadStrideInfo &pad_stride_info)
1284{
1285 std::stringstream str;
1286 str << pad_stride_info;
1287 return str.str();
1288}
1289
Alex Gildayc357c472018-03-21 13:54:09 +00001290/** Formatted output of the BorderMode type.
1291 *
1292 * @param[in] mode Type to output.
1293 *
1294 * @return Formatted string.
1295 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001296inline std::string to_string(const BorderMode &mode)
1297{
1298 std::stringstream str;
1299 str << mode;
1300 return str.str();
1301}
1302
Alex Gildayc357c472018-03-21 13:54:09 +00001303/** Formatted output of the BorderSize type.
1304 *
1305 * @param[in] border Type to output.
1306 *
1307 * @return Formatted string.
1308 */
John Richardsonb482ce12017-09-18 12:44:01 +01001309inline std::string to_string(const BorderSize &border)
1310{
1311 std::stringstream str;
1312 str << border;
1313 return str.str();
1314}
1315
Giuseppe Rossinid7647d42018-07-17 18:13:13 +01001316/** Formatted output of the PaddingList type.
1317 *
1318 * @param[in] padding Type to output.
1319 *
1320 * @return Formatted string.
1321 */
1322inline std::string to_string(const PaddingList &padding)
1323{
1324 std::stringstream str;
1325 str << padding;
1326 return str.str();
1327}
1328
giuros013175fcf2018-11-21 09:59:17 +00001329/** Formatted output of the Multiples type.
1330 *
1331 * @param[in] multiples Type to output.
1332 *
1333 * @return Formatted string.
1334 */
1335inline std::string to_string(const Multiples &multiples)
1336{
1337 std::stringstream str;
1338 str << multiples;
1339 return str.str();
1340}
1341
Alex Gildayc357c472018-03-21 13:54:09 +00001342/** Formatted output of the InterpolationPolicy type.
1343 *
1344 * @param[in] policy Type to output.
1345 *
1346 * @return Formatted string.
1347 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001348inline std::string to_string(const InterpolationPolicy &policy)
1349{
1350 std::stringstream str;
1351 str << policy;
1352 return str.str();
1353}
1354
Alex Gildayc357c472018-03-21 13:54:09 +00001355/** Formatted output of the SamplingPolicy type.
1356 *
1357 * @param[in] policy Type to output.
1358 *
1359 * @return Formatted string.
1360 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +07001361inline std::string to_string(const SamplingPolicy &policy)
1362{
1363 std::stringstream str;
1364 str << policy;
1365 return str.str();
1366}
1367
Alex Gildayc357c472018-03-21 13:54:09 +00001368/** Formatted output of the ConvertPolicy type.
1369 *
1370 * @param[out] os Output stream.
1371 * @param[in] policy Type to output.
1372 *
1373 * @return Modified output stream.
1374 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001375inline ::std::ostream &operator<<(::std::ostream &os, const ConvertPolicy &policy)
1376{
1377 switch(policy)
1378 {
1379 case ConvertPolicy::WRAP:
1380 os << "WRAP";
1381 break;
1382 case ConvertPolicy::SATURATE:
1383 os << "SATURATE";
1384 break;
1385 default:
1386 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1387 }
1388
1389 return os;
1390}
1391
1392inline std::string to_string(const ConvertPolicy &policy)
1393{
1394 std::stringstream str;
1395 str << policy;
1396 return str.str();
1397}
1398
giuros01164a2722018-11-20 18:34:46 +00001399/** Formatted output of the ArithmeticOperation type.
1400 *
1401 * @param[out] os Output stream.
1402 * @param[in] op Operation to output.
1403 *
1404 * @return Modified output stream.
1405 */
1406inline ::std::ostream &operator<<(::std::ostream &os, const ArithmeticOperation &op)
1407{
1408 switch(op)
1409 {
1410 case ArithmeticOperation::ADD:
1411 os << "ADD";
1412 break;
1413 case ArithmeticOperation::SUB:
1414 os << "SUB";
1415 break;
1416 case ArithmeticOperation::DIV:
1417 os << "DIV";
1418 break;
1419 case ArithmeticOperation::MAX:
1420 os << "MAX";
1421 break;
1422 case ArithmeticOperation::MIN:
1423 os << "MIN";
1424 break;
1425 case ArithmeticOperation::SQUARED_DIFF:
1426 os << "SQUARED_DIFF";
1427 break;
Usama Arif52c54f62019-05-14 10:22:36 +01001428 case ArithmeticOperation::POWER:
1429 os << "POWER";
1430 break;
giuros01164a2722018-11-20 18:34:46 +00001431 default:
1432 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1433 }
1434
1435 return os;
1436}
1437
1438/** Formatted output of the Arithmetic Operation
1439 *
1440 * @param[in] op Type to output.
1441 *
1442 * @return Formatted string.
1443 */
1444inline std::string to_string(const ArithmeticOperation &op)
1445{
1446 std::stringstream str;
1447 str << op;
1448 return str.str();
1449}
1450
Alex Gildayc357c472018-03-21 13:54:09 +00001451/** Formatted output of the Reduction Operations.
1452 *
1453 * @param[out] os Output stream.
1454 * @param[in] op Type to output.
1455 *
1456 * @return Modified output stream.
1457 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001458inline ::std::ostream &operator<<(::std::ostream &os, const ReductionOperation &op)
1459{
1460 switch(op)
1461 {
Michalis Spyrou7e9391b2018-10-05 14:49:28 +01001462 case ReductionOperation::SUM:
1463 os << "SUM";
1464 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +01001465 case ReductionOperation::SUM_SQUARE:
1466 os << "SUM_SQUARE";
1467 break;
Michalis Spyrou7e9391b2018-10-05 14:49:28 +01001468 case ReductionOperation::MEAN_SUM:
1469 os << "MEAN_SUM";
1470 break;
Michalis Spyrou7930db42018-11-22 17:36:28 +00001471 case ReductionOperation::ARG_IDX_MAX:
1472 os << "ARG_IDX_MAX";
1473 break;
1474 case ReductionOperation::ARG_IDX_MIN:
1475 os << "ARG_IDX_MIN";
1476 break;
Manuel Bottinib412fab2018-12-10 17:40:23 +00001477 case ReductionOperation::PROD:
1478 os << "PROD";
1479 break;
Usama Arifa4a08ad2019-05-20 12:38:33 +01001480 case ReductionOperation::MIN:
1481 os << "MIN";
1482 break;
Usama Arif28f0dd92019-05-20 13:44:34 +01001483 case ReductionOperation::MAX:
1484 os << "MAX";
1485 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +01001486 default:
1487 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1488 }
1489
1490 return os;
1491}
1492
Alex Gildayc357c472018-03-21 13:54:09 +00001493/** Formatted output of the Reduction Operations.
1494 *
1495 * @param[in] op Type to output.
1496 *
1497 * @return Formatted string.
1498 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001499inline std::string to_string(const ReductionOperation &op)
1500{
1501 std::stringstream str;
1502 str << op;
1503 return str.str();
1504}
1505
Georgios Pinitas7900a9e2018-11-23 11:44:58 +00001506/** Formatted output of the Comparison Operations.
1507 *
1508 * @param[out] os Output stream.
1509 * @param[in] op Type to output.
1510 *
1511 * @return Modified output stream.
1512 */
1513inline ::std::ostream &operator<<(::std::ostream &os, const ComparisonOperation &op)
1514{
1515 switch(op)
1516 {
1517 case ComparisonOperation::Equal:
1518 os << "Equal";
1519 break;
1520 case ComparisonOperation::NotEqual:
1521 os << "NotEqual";
1522 break;
1523 case ComparisonOperation::Greater:
1524 os << "Greater";
1525 break;
1526 case ComparisonOperation::GreaterEqual:
1527 os << "GreaterEqual";
1528 break;
1529 case ComparisonOperation::Less:
1530 os << "Less";
1531 break;
1532 case ComparisonOperation::LessEqual:
1533 os << "LessEqual";
1534 break;
1535 default:
1536 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1537 }
1538
1539 return os;
1540}
1541
Michalis Spyroue9362622018-11-23 17:41:37 +00001542/** Formatted output of the Elementwise unary Operations.
1543 *
1544 * @param[out] os Output stream.
1545 * @param[in] op Type to output.
1546 *
1547 * @return Modified output stream.
1548 */
1549inline ::std::ostream &operator<<(::std::ostream &os, const ElementWiseUnary &op)
1550{
1551 switch(op)
1552 {
1553 case ElementWiseUnary::RSQRT:
1554 os << "RSQRT";
1555 break;
1556 case ElementWiseUnary::EXP:
1557 os << "EXP";
1558 break;
Usama Arifeb312ef2019-05-13 17:45:54 +01001559 case ElementWiseUnary::NEG:
1560 os << "NEG";
1561 break;
Usama Arifac33d7e2019-05-20 14:21:40 +01001562 case ElementWiseUnary::LOG:
1563 os << "LOG";
1564 break;
Usama Arif6a4d5422019-05-24 14:53:59 +01001565 case ElementWiseUnary::ROUND:
1566 os << "ROUND";
1567 break;
Michalis Spyroue9362622018-11-23 17:41:37 +00001568 default:
1569 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1570 }
1571
1572 return os;
1573}
1574
Georgios Pinitas7900a9e2018-11-23 11:44:58 +00001575/** Formatted output of the Comparison Operations.
1576 *
1577 * @param[in] op Type to output.
1578 *
1579 * @return Formatted string.
1580 */
1581inline std::string to_string(const ComparisonOperation &op)
1582{
1583 std::stringstream str;
1584 str << op;
1585 return str.str();
1586}
1587
Michalis Spyroue9362622018-11-23 17:41:37 +00001588/** Formatted output of the Elementwise unary Operations.
1589 *
1590 * @param[in] op Type to output.
1591 *
1592 * @return Formatted string.
1593 */
1594inline std::string to_string(const ElementWiseUnary &op)
1595{
1596 std::stringstream str;
1597 str << op;
1598 return str.str();
1599}
1600
Alex Gildayc357c472018-03-21 13:54:09 +00001601/** Formatted output of the Norm Type.
1602 *
1603 * @param[in] type Type to output.
1604 *
1605 * @return Formatted string.
1606 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001607inline std::string to_string(const NormType &type)
1608{
1609 std::stringstream str;
1610 str << type;
1611 return str.str();
1612}
1613
Alex Gildayc357c472018-03-21 13:54:09 +00001614/** Formatted output of the Pooling Type.
1615 *
1616 * @param[in] type Type to output.
1617 *
1618 * @return Formatted string.
1619 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001620inline std::string to_string(const PoolingType &type)
1621{
1622 std::stringstream str;
1623 str << type;
1624 return str.str();
1625}
1626
Alex Gildayc357c472018-03-21 13:54:09 +00001627/** Formatted output of the Pooling Layer Info.
1628 *
1629 * @param[in] info Type to output.
1630 *
1631 * @return Formatted string.
1632 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001633inline std::string to_string(const PoolingLayerInfo &info)
1634{
1635 std::stringstream str;
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +00001636 str << "{Type=" << info.pool_type << ","
Sang-Hoon Park11fedda2020-01-15 14:44:04 +00001637 << "DataLayout=" << info.data_layout << ","
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +00001638 << "IsGlobalPooling=" << info.is_global_pooling;
1639 if(!info.is_global_pooling)
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001640 {
1641 str << ","
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +00001642 << "PoolSize=" << info.pool_size.width << "," << info.pool_size.height << ","
1643 << "PadStride=" << info.pad_stride_info;
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001644 }
1645 str << "}";
Anthony Barbier2a07e182017-08-04 18:20:27 +01001646 return str.str();
1647}
1648
Michalis Spyrou6c7c38e2018-08-29 16:28:11 +01001649/** Formatted output of the PriorBoxLayerInfo.
1650 *
1651 * @param[in] info Type to output.
1652 *
1653 * @return Formatted string.
1654 */
1655inline std::string to_string(const PriorBoxLayerInfo &info)
1656{
1657 std::stringstream str;
1658 str << "{";
1659 str << "Clip:" << info.clip()
1660 << "Flip:" << info.flip()
1661 << "StepX:" << info.steps()[0]
1662 << "StepY:" << info.steps()[1]
1663 << "MinSizes:" << info.min_sizes().size()
1664 << "MaxSizes:" << info.max_sizes().size()
1665 << "ImgSizeX:" << info.img_size().x
1666 << "ImgSizeY:" << info.img_size().y
1667 << "Offset:" << info.offset()
1668 << "Variances:" << info.variances().size();
1669 str << "}";
1670 return str.str();
1671}
1672
Alex Gildayc357c472018-03-21 13:54:09 +00001673/** Formatted output of the KeyPoint type.
1674 *
1675 * @param[out] os Output stream
1676 * @param[in] point Type to output.
1677 *
1678 * @return Modified output stream.
1679 */
Moritz Pflanzer6c6597c2017-09-24 12:09:41 +01001680inline ::std::ostream &operator<<(::std::ostream &os, const KeyPoint &point)
1681{
1682 os << "{x=" << point.x << ","
1683 << "y=" << point.y << ","
1684 << "strength=" << point.strength << ","
1685 << "scale=" << point.scale << ","
1686 << "orientation=" << point.orientation << ","
1687 << "tracking_status=" << point.tracking_status << ","
1688 << "error=" << point.error << "}";
1689
1690 return os;
1691}
John Richardson63e50412017-10-13 20:51:42 +01001692
Alex Gildayc357c472018-03-21 13:54:09 +00001693/** Formatted output of the PhaseType type.
1694 *
1695 * @param[out] os Output stream
1696 * @param[in] phase_type Type to output.
1697 *
1698 * @return Modified output stream.
1699 */
John Richardson63e50412017-10-13 20:51:42 +01001700inline ::std::ostream &operator<<(::std::ostream &os, const PhaseType &phase_type)
1701{
1702 switch(phase_type)
1703 {
1704 case PhaseType::SIGNED:
1705 os << "SIGNED";
1706 break;
1707 case PhaseType::UNSIGNED:
1708 os << "UNSIGNED";
1709 break;
1710 default:
1711 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1712 }
1713
1714 return os;
1715}
1716
Alex Gildayc357c472018-03-21 13:54:09 +00001717/** Formatted output of the PhaseType type.
1718 *
1719 * @param[in] type Type to output.
1720 *
1721 * @return Formatted string.
1722 */
John Richardson63e50412017-10-13 20:51:42 +01001723inline std::string to_string(const arm_compute::PhaseType &type)
1724{
1725 std::stringstream str;
1726 str << type;
1727 return str.str();
1728}
John Richardson3c5f9492017-10-04 15:27:37 +01001729
Alex Gildayc357c472018-03-21 13:54:09 +00001730/** Formatted output of the MagnitudeType type.
1731 *
1732 * @param[out] os Output stream
1733 * @param[in] magnitude_type Type to output.
1734 *
1735 * @return Modified output stream.
1736 */
John Richardson3c5f9492017-10-04 15:27:37 +01001737inline ::std::ostream &operator<<(::std::ostream &os, const MagnitudeType &magnitude_type)
1738{
1739 switch(magnitude_type)
1740 {
1741 case MagnitudeType::L1NORM:
1742 os << "L1NORM";
1743 break;
1744 case MagnitudeType::L2NORM:
1745 os << "L2NORM";
1746 break;
1747 default:
1748 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1749 }
1750
1751 return os;
1752}
1753
Alex Gildayc357c472018-03-21 13:54:09 +00001754/** Formatted output of the MagnitudeType type.
1755 *
1756 * @param[in] type Type to output.
1757 *
1758 * @return Formatted string.
1759 */
John Richardson3c5f9492017-10-04 15:27:37 +01001760inline std::string to_string(const arm_compute::MagnitudeType &type)
1761{
1762 std::stringstream str;
1763 str << type;
1764 return str.str();
1765}
John Richardson1c529922017-11-01 10:57:48 +00001766
Alex Gildayc357c472018-03-21 13:54:09 +00001767/** Formatted output of the HOGNormType type.
1768 *
1769 * @param[out] os Output stream
1770 * @param[in] norm_type Type to output
1771 *
1772 * @return Modified output stream.
1773 */
John Richardson25f23682017-11-27 14:35:09 +00001774inline ::std::ostream &operator<<(::std::ostream &os, const HOGNormType &norm_type)
1775{
1776 switch(norm_type)
1777 {
1778 case HOGNormType::L1_NORM:
1779 os << "L1_NORM";
1780 break;
1781 case HOGNormType::L2_NORM:
1782 os << "L2_NORM";
1783 break;
1784 case HOGNormType::L2HYS_NORM:
1785 os << "L2HYS_NORM";
1786 break;
1787 default:
1788 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1789 }
1790
1791 return os;
1792}
1793
Alex Gildayc357c472018-03-21 13:54:09 +00001794/** Formatted output of the HOGNormType type.
1795 *
1796 * @param[in] type Type to output
1797 *
1798 * @return Formatted string.
1799 */
John Richardson25f23682017-11-27 14:35:09 +00001800inline std::string to_string(const HOGNormType &type)
1801{
1802 std::stringstream str;
1803 str << type;
1804 return str.str();
1805}
1806
Alex Gildayc357c472018-03-21 13:54:09 +00001807/** Formatted output of the Size2D type.
1808 *
1809 * @param[out] os Output stream
1810 * @param[in] size Type to output
1811 *
1812 * @return Modified output stream.
1813 */
John Richardson25f23682017-11-27 14:35:09 +00001814inline ::std::ostream &operator<<(::std::ostream &os, const Size2D &size)
1815{
1816 os << size.width << "x" << size.height;
1817
1818 return os;
1819}
1820
Alex Gildayc357c472018-03-21 13:54:09 +00001821/** Formatted output of the Size2D type.
1822 *
1823 * @param[in] type Type to output
1824 *
1825 * @return Formatted string.
1826 */
John Richardson25f23682017-11-27 14:35:09 +00001827inline std::string to_string(const Size2D &type)
1828{
1829 std::stringstream str;
1830 str << type;
1831 return str.str();
1832}
1833
Alex Gildayc357c472018-03-21 13:54:09 +00001834/** Formatted output of the HOGInfo type.
1835 *
1836 * @param[out] os Output stream
1837 * @param[in] hog_info Type to output
1838 *
1839 * @return Modified output stream.
1840 */
John Richardson25f23682017-11-27 14:35:09 +00001841inline ::std::ostream &operator<<(::std::ostream &os, const HOGInfo &hog_info)
1842{
1843 os << "{CellSize=" << hog_info.cell_size() << ","
1844 << "BlockSize=" << hog_info.block_size() << ","
1845 << "DetectionWindowSize=" << hog_info.detection_window_size() << ","
1846 << "BlockStride=" << hog_info.block_stride() << ","
1847 << "NumBins=" << hog_info.num_bins() << ","
1848 << "NormType=" << hog_info.normalization_type() << ","
1849 << "L2HystThreshold=" << hog_info.l2_hyst_threshold() << ","
1850 << "PhaseType=" << hog_info.phase_type() << "}";
1851
1852 return os;
1853}
1854
Alex Gildayc357c472018-03-21 13:54:09 +00001855/** Formatted output of the HOGInfo type.
1856 *
1857 * @param[in] type Type to output
1858 *
1859 * @return Formatted string.
1860 */
John Richardson25f23682017-11-27 14:35:09 +00001861inline std::string to_string(const HOGInfo &type)
1862{
1863 std::stringstream str;
1864 str << type;
1865 return str.str();
1866}
1867
Alex Gildayc357c472018-03-21 13:54:09 +00001868/** Formatted output of the ConvolutionMethod type.
1869 *
1870 * @param[out] os Output stream
1871 * @param[in] conv_method Type to output
1872 *
1873 * @return Modified output stream.
1874 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001875inline ::std::ostream &operator<<(::std::ostream &os, const ConvolutionMethod &conv_method)
1876{
1877 switch(conv_method)
1878 {
1879 case ConvolutionMethod::GEMM:
1880 os << "GEMM";
1881 break;
1882 case ConvolutionMethod::DIRECT:
1883 os << "DIRECT";
1884 break;
1885 case ConvolutionMethod::WINOGRAD:
1886 os << "WINOGRAD";
1887 break;
1888 default:
1889 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1890 }
1891
1892 return os;
1893}
1894
Alex Gildayc357c472018-03-21 13:54:09 +00001895/** Formatted output of the ConvolutionMethod type.
1896 *
1897 * @param[in] conv_method Type to output
1898 *
1899 * @return Formatted string.
1900 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001901inline std::string to_string(const ConvolutionMethod &conv_method)
1902{
1903 std::stringstream str;
1904 str << conv_method;
1905 return str.str();
1906}
1907
Alex Gildayc357c472018-03-21 13:54:09 +00001908/** Formatted output of the GPUTarget type.
1909 *
1910 * @param[out] os Output stream
1911 * @param[in] gpu_target Type to output
1912 *
1913 * @return Modified output stream.
1914 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001915inline ::std::ostream &operator<<(::std::ostream &os, const GPUTarget &gpu_target)
1916{
1917 switch(gpu_target)
1918 {
1919 case GPUTarget::GPU_ARCH_MASK:
1920 os << "GPU_ARCH_MASK";
1921 break;
1922 case GPUTarget::MIDGARD:
1923 os << "MIDGARD";
1924 break;
1925 case GPUTarget::BIFROST:
1926 os << "BIFROST";
1927 break;
Georgios Pinitasd5462ff2019-07-03 19:33:57 +01001928 case GPUTarget::VALHALL:
1929 os << "VALHALL";
1930 break;
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001931 case GPUTarget::T600:
1932 os << "T600";
1933 break;
1934 case GPUTarget::T700:
1935 os << "T700";
1936 break;
1937 case GPUTarget::T800:
1938 os << "T800";
1939 break;
Michalis Spyroua9676112018-02-22 18:07:43 +00001940 case GPUTarget::G71:
1941 os << "G71";
1942 break;
1943 case GPUTarget::G72:
1944 os << "G72";
1945 break;
1946 case GPUTarget::G51:
1947 os << "G51";
1948 break;
1949 case GPUTarget::G51BIG:
1950 os << "G51BIG";
1951 break;
1952 case GPUTarget::G51LIT:
1953 os << "G51LIT";
1954 break;
Georgios Pinitasb03f7c52018-07-12 10:49:53 +01001955 case GPUTarget::G76:
1956 os << "G76";
Michalis Spyroua9676112018-02-22 18:07:43 +00001957 break;
Georgios Pinitasd5462ff2019-07-03 19:33:57 +01001958 case GPUTarget::G77:
1959 os << "G77";
Michalis Spyroua9676112018-02-22 18:07:43 +00001960 break;
1961 case GPUTarget::TBOX:
1962 os << "TBOX";
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001963 break;
Georgios Pinitasd5462ff2019-07-03 19:33:57 +01001964 case GPUTarget::TODX:
1965 os << "TODX";
1966 break;
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001967 default:
1968 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1969 }
1970
1971 return os;
1972}
1973
Alex Gildayc357c472018-03-21 13:54:09 +00001974/** Formatted output of the GPUTarget type.
1975 *
1976 * @param[in] gpu_target Type to output
1977 *
1978 * @return Formatted string.
1979 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001980inline std::string to_string(const GPUTarget &gpu_target)
1981{
1982 std::stringstream str;
1983 str << gpu_target;
1984 return str.str();
1985}
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00001986
John Richardson8de92612018-02-22 14:09:31 +00001987/** Formatted output of the DetectionWindow type.
1988 *
1989 * @param[out] os Output stream
1990 * @param[in] detection_window Type to output
1991 *
1992 * @return Modified output stream.
1993 */
John Richardson684cb0f2018-01-09 11:17:00 +00001994inline ::std::ostream &operator<<(::std::ostream &os, const DetectionWindow &detection_window)
1995{
1996 os << "{x=" << detection_window.x << ","
1997 << "y=" << detection_window.y << ","
1998 << "width=" << detection_window.width << ","
1999 << "height=" << detection_window.height << ","
2000 << "idx_class=" << detection_window.idx_class << ","
2001 << "score=" << detection_window.score << "}";
2002
2003 return os;
2004}
2005
Isabella Gottardi05e56442018-11-16 11:26:52 +00002006/** Formatted output of the DetectionOutputLayerCodeType type.
2007 *
2008 * @param[out] os Output stream
2009 * @param[in] detection_code Type to output
2010 *
2011 * @return Modified output stream.
2012 */
2013inline ::std::ostream &operator<<(::std::ostream &os, const DetectionOutputLayerCodeType &detection_code)
2014{
2015 switch(detection_code)
2016 {
2017 case DetectionOutputLayerCodeType::CENTER_SIZE:
2018 os << "CENTER_SIZE";
2019 break;
2020 case DetectionOutputLayerCodeType::CORNER:
2021 os << "CORNER";
2022 break;
2023 case DetectionOutputLayerCodeType::CORNER_SIZE:
2024 os << "CORNER_SIZE";
2025 break;
2026 case DetectionOutputLayerCodeType::TF_CENTER:
2027 os << "TF_CENTER";
2028 break;
2029 default:
2030 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2031 }
2032
2033 return os;
2034}
2035/** Formatted output of the DetectionOutputLayerCodeType type.
2036 *
2037 * @param[in] detection_code Type to output
2038 *
2039 * @return Formatted string.
2040 */
2041inline std::string to_string(const DetectionOutputLayerCodeType &detection_code)
2042{
2043 std::stringstream str;
2044 str << detection_code;
2045 return str.str();
2046}
2047
2048/** Formatted output of the DetectionOutputLayerInfo type.
2049 *
2050 * @param[out] os Output stream
2051 * @param[in] detection_info Type to output
2052 *
2053 * @return Modified output stream.
2054 */
2055inline ::std::ostream &operator<<(::std::ostream &os, const DetectionOutputLayerInfo &detection_info)
2056{
2057 os << "{Classes=" << detection_info.num_classes() << ","
2058 << "ShareLocation=" << detection_info.share_location() << ","
2059 << "CodeType=" << detection_info.code_type() << ","
2060 << "VarianceEncodedInTarget=" << detection_info.variance_encoded_in_target() << ","
2061 << "KeepTopK=" << detection_info.keep_top_k() << ","
2062 << "NMSThreshold=" << detection_info.nms_threshold() << ","
2063 << "Eta=" << detection_info.eta() << ","
2064 << "BackgroundLabelId=" << detection_info.background_label_id() << ","
2065 << "ConfidenceThreshold=" << detection_info.confidence_threshold() << ","
2066 << "TopK=" << detection_info.top_k() << ","
2067 << "NumLocClasses=" << detection_info.num_loc_classes()
2068 << "}";
2069
2070 return os;
2071}
2072
2073/** Formatted output of the DetectionOutputLayerInfo type.
2074 *
2075 * @param[in] detection_info Type to output
2076 *
2077 * @return Formatted string.
2078 */
2079inline std::string to_string(const DetectionOutputLayerInfo &detection_info)
2080{
2081 std::stringstream str;
2082 str << detection_info;
2083 return str.str();
2084}
Isabella Gottardia7acb3c2019-01-08 13:48:44 +00002085/** Formatted output of the DetectionPostProcessLayerInfo type.
2086 *
2087 * @param[out] os Output stream
2088 * @param[in] detection_info Type to output
2089 *
2090 * @return Modified output stream.
2091 */
2092inline ::std::ostream &operator<<(::std::ostream &os, const DetectionPostProcessLayerInfo &detection_info)
2093{
2094 os << "{MaxDetections=" << detection_info.max_detections() << ","
2095 << "MaxClassesPerDetection=" << detection_info.max_classes_per_detection() << ","
2096 << "NmsScoreThreshold=" << detection_info.nms_score_threshold() << ","
2097 << "NmsIouThreshold=" << detection_info.iou_threshold() << ","
2098 << "NumClasses=" << detection_info.num_classes() << ","
2099 << "ScaleValue_y=" << detection_info.scale_value_y() << ","
2100 << "ScaleValue_x=" << detection_info.scale_value_x() << ","
2101 << "ScaleValue_h=" << detection_info.scale_value_h() << ","
2102 << "ScaleValue_w=" << detection_info.scale_value_w() << ","
2103 << "UseRegularNms=" << detection_info.use_regular_nms() << ","
2104 << "DetectionPerClass=" << detection_info.detection_per_class()
2105 << "}";
2106
2107 return os;
2108}
2109
2110/** Formatted output of the DetectionPostProcessLayerInfo type.
2111 *
2112 * @param[in] detection_info Type to output
2113 *
2114 * @return Formatted string.
2115 */
2116inline std::string to_string(const DetectionPostProcessLayerInfo &detection_info)
2117{
2118 std::stringstream str;
2119 str << detection_info;
2120 return str.str();
2121}
John Richardson8de92612018-02-22 14:09:31 +00002122/** Formatted output of the DetectionWindow type.
2123 *
2124 * @param[in] detection_window Type to output
2125 *
2126 * @return Formatted string.
2127 */
2128inline std::string to_string(const DetectionWindow &detection_window)
2129{
2130 std::stringstream str;
2131 str << detection_window;
2132 return str.str();
2133}
2134
2135/** Formatted output of the Termination type.
2136 *
2137 * @param[out] os Output stream
2138 * @param[in] termination Type to output
2139 *
2140 * @return Modified output stream.
2141 */
2142inline ::std::ostream &operator<<(::std::ostream &os, const Termination &termination)
2143{
2144 switch(termination)
2145 {
2146 case Termination::TERM_CRITERIA_EPSILON:
2147 os << "TERM_CRITERIA_EPSILON";
2148 break;
2149 case Termination::TERM_CRITERIA_ITERATIONS:
2150 os << "TERM_CRITERIA_ITERATIONS";
2151 break;
2152 case Termination::TERM_CRITERIA_BOTH:
2153 os << "TERM_CRITERIA_BOTH";
2154 break;
2155 default:
2156 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2157 }
2158
2159 return os;
2160}
2161
2162/** Formatted output of the Termination type.
2163 *
2164 * @param[in] termination Type to output
2165 *
2166 * @return Formatted string.
2167 */
2168inline std::string to_string(const Termination &termination)
2169{
2170 std::stringstream str;
2171 str << termination;
2172 return str.str();
2173}
2174
Anthony Barbier8914e322018-08-10 15:28:25 +01002175/** Formatted output of the CPUModel type.
2176 *
2177 * @param[out] os Output stream
2178 * @param[in] cpu_model Model to output
2179 *
2180 * @return Modified output stream.
2181 */
2182inline ::std::ostream &operator<<(::std::ostream &os, const CPUModel &cpu_model)
2183{
2184 switch(cpu_model)
2185 {
2186 case CPUModel::GENERIC:
2187 os << "GENERIC";
2188 break;
2189 case CPUModel::GENERIC_FP16:
2190 os << "GENERIC_FP16";
2191 break;
2192 case CPUModel::GENERIC_FP16_DOT:
2193 os << "GENERIC_FP16_DOT";
2194 break;
2195 case CPUModel::A53:
2196 os << "A53";
2197 break;
2198 case CPUModel::A55r0:
2199 os << "A55r0";
2200 break;
2201 case CPUModel::A55r1:
2202 os << "A55r1";
2203 break;
2204 default:
2205 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2206 }
2207
2208 return os;
2209}
2210
2211/** Formatted output of the CPUModel type.
2212 *
2213 * @param[in] cpu_model Model to output
2214 *
2215 * @return Formatted string.
2216 */
2217inline std::string to_string(const CPUModel &cpu_model)
2218{
2219 std::stringstream str;
2220 str << cpu_model;
2221 return str.str();
2222}
Anthony Barbier671a11e2018-07-06 15:11:36 +01002223/** Formatted output of a vector of objects.
2224 *
2225 * @param[out] os Output stream
2226 * @param[in] args Vector of objects to print
2227 *
2228 * @return Modified output stream.
2229 */
2230template <typename T>
2231inline ::std::ostream &operator<<(::std::ostream &os, const std::vector<T> &args)
2232{
2233 os << "[";
2234 bool first = true;
2235 for(auto &arg : args)
2236 {
2237 if(first)
2238 {
2239 first = false;
2240 }
2241 else
2242 {
2243 os << ", ";
2244 }
2245 os << arg;
2246 }
2247 os << "]";
2248 return os;
2249}
2250
Michalis Spyrou6c7c38e2018-08-29 16:28:11 +01002251/** Formatted output of @ref PriorBoxLayerInfo.
2252 *
2253 * @param[out] os Output stream.
2254 * @param[in] info Type to output.
2255 *
2256 * @return Modified output stream.
2257 */
2258inline ::std::ostream &operator<<(::std::ostream &os, const PriorBoxLayerInfo &info)
2259{
2260 os << "Clip:" << info.clip()
2261 << "Flip:" << info.flip()
2262 << "StepX:" << info.steps()[0]
2263 << "StepY:" << info.steps()[1]
2264 << "MinSizes:" << info.min_sizes()
2265 << "MaxSizes:" << info.max_sizes()
2266 << "ImgSizeX:" << info.img_size().x
2267 << "ImgSizeY:" << info.img_size().y
2268 << "Offset:" << info.offset()
2269 << "Variances:" << info.variances();
2270
2271 return os;
2272}
2273
Anthony Barbier671a11e2018-07-06 15:11:36 +01002274/** Formatted output of a vector of objects.
2275 *
2276 * @param[in] args Vector of objects to print
2277 *
2278 * @return String representing args.
2279 */
2280template <typename T>
2281std::string to_string(const std::vector<T> &args)
2282{
2283 std::stringstream str;
2284 str << args;
2285 return str.str();
2286}
2287
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00002288/** Formatted output of the WinogradInfo type. */
2289inline ::std::ostream &operator<<(::std::ostream &os, const WinogradInfo &info)
2290{
2291 os << "{OutputTileSize=" << info.output_tile_size << ","
2292 << "KernelSize=" << info.kernel_size << ","
2293 << "PadStride=" << info.convolution_info << ","
2294 << "OutputDataLayout=" << info.output_data_layout << "}";
2295
2296 return os;
2297}
2298
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00002299inline std::string to_string(const WinogradInfo &type)
2300{
2301 std::stringstream str;
2302 str << type;
2303 return str.str();
2304}
Anthony Barbier671a11e2018-07-06 15:11:36 +01002305
2306/** Fallback method: try to use std::to_string:
2307 *
2308 * @param[in] val Value to convert to string
2309 *
2310 * @return String representing val.
2311 */
2312template <typename T>
2313inline std::string to_string(const T &val)
2314{
2315 return support::cpp11::to_string(val);
2316}
2317
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +01002318/** Convert a CLTunerMode value to a string
2319 *
2320 * @param val CLTunerMode value to be converted
2321 *
2322 * @return String representing the corresponding CLTunerMode.
2323 */
2324inline std::string to_string(const CLTunerMode val)
2325{
2326 switch(val)
2327 {
2328 case CLTunerMode::EXHAUSTIVE:
2329 {
2330 return std::string("Exhaustive");
2331 }
2332 case CLTunerMode::NORMAL:
2333 {
2334 return std::string("Normal");
2335 }
2336 case CLTunerMode::RAPID:
2337 {
2338 return std::string("Rapid");
2339 }
2340 default:
2341 {
2342 ARM_COMPUTE_ERROR("Invalid tuner mode.");
2343 return std::string("UNDEFINED");
2344 }
2345 }
2346}
2347/** [Print CLTunerMode type] **/
2348/** Formatted output of the CLTunerMode type.
2349 *
2350 * @param[out] os Output stream.
2351 * @param[in] val CLTunerMode to output.
2352 *
2353 * @return Modified output stream.
2354 */
2355inline ::std::ostream &operator<<(::std::ostream &os, const CLTunerMode &val)
2356{
2357 os << to_string(val);
2358 return os;
2359}
2360
Anthony Barbier6ff3b192017-09-04 18:44:23 +01002361} // namespace arm_compute
Anthony Barbier4dbc0a92018-08-27 13:39:47 +01002362
2363#endif /* __ARM_COMPUTE_TYPE_PRINTER_H__ */