blob: 25c8cd396dafbe6e94f42d72cb1d6a19896f3417 [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
Isabella Gottardif07d28d2018-02-06 14:52:43 +000027#include "arm_compute/core/CL/CLTypes.h"
Anthony Barbier8914e322018-08-10 15:28:25 +010028#include "arm_compute/core/CPP/CPPTypes.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010029#include "arm_compute/core/Dimensions.h"
30#include "arm_compute/core/Error.h"
Michele Di Giorgiob8fc60f2018-04-25 11:58:07 +010031#include "arm_compute/core/GPUTarget.h"
John Richardson25f23682017-11-27 14:35:09 +000032#include "arm_compute/core/HOGInfo.h"
33#include "arm_compute/core/Size2D.h"
John Richardsona36eae12017-09-26 16:55:59 +010034#include "arm_compute/core/Strides.h"
Georgios Pinitas3faea252017-10-30 14:13:50 +000035#include "arm_compute/core/TensorInfo.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010036#include "arm_compute/core/Types.h"
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +010037#include "arm_compute/runtime/CL/CLTunerTypes.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010038
39#include <ostream>
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010040#include <sstream>
41#include <string>
Anthony Barbier6ff3b192017-09-04 18:44:23 +010042
43namespace arm_compute
44{
Anthony Barbierb940fd62018-06-04 14:14:32 +010045/** Formatted output if arg is not null
46 *
47 * @param[in] arg Object to print
48 *
49 * @return String representing arg.
50 */
51template <typename T>
52std::string to_string_if_not_null(T *arg)
53{
54 if(arg == nullptr)
55 {
56 return "nullptr";
57 }
58 else
59 {
60 return to_string(*arg);
61 }
62}
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 *
319 * @param[out] os Output stream.
320 * @param[in] quantization_info Type to output.
321 *
322 * @return Modified output stream.
323 */
Chunosovd621bca2017-11-03 17:33:15 +0700324inline ::std::ostream &operator<<(::std::ostream &os, const QuantizationInfo &quantization_info)
325{
326 os << "Scale:" << quantization_info.scale << "~"
327 << "Offset:" << quantization_info.offset;
328 return os;
329}
330
Alex Gildayc357c472018-03-21 13:54:09 +0000331/** Formatted output of the QuantizationInfo type.
332 *
333 * @param[in] quantization_info Type to output.
334 *
335 * @return Formatted string.
336 */
Chunosovd621bca2017-11-03 17:33:15 +0700337inline std::string to_string(const QuantizationInfo &quantization_info)
338{
339 std::stringstream str;
340 str << quantization_info;
341 return str.str();
342}
343
Alex Gildayc357c472018-03-21 13:54:09 +0000344/** Formatted output of the activation function type.
345 *
346 * @param[out] os Output stream.
347 * @param[in] act_function Type to output.
348 *
349 * @return Modified output stream.
350 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100351inline ::std::ostream &operator<<(::std::ostream &os, const ActivationLayerInfo::ActivationFunction &act_function)
352{
353 switch(act_function)
354 {
355 case ActivationLayerInfo::ActivationFunction::ABS:
356 os << "ABS";
357 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100358 case ActivationLayerInfo::ActivationFunction::LINEAR:
359 os << "LINEAR";
360 break;
361 case ActivationLayerInfo::ActivationFunction::LOGISTIC:
362 os << "LOGISTIC";
363 break;
364 case ActivationLayerInfo::ActivationFunction::RELU:
365 os << "RELU";
366 break;
Georgios Pinitas579c0492017-07-12 16:12:12 +0100367 case ActivationLayerInfo::ActivationFunction::BOUNDED_RELU:
368 os << "BOUNDED_RELU";
369 break;
370 case ActivationLayerInfo::ActivationFunction::LEAKY_RELU:
371 os << "LEAKY_RELU";
372 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100373 case ActivationLayerInfo::ActivationFunction::SOFT_RELU:
374 os << "SOFT_RELU";
375 break;
376 case ActivationLayerInfo::ActivationFunction::SQRT:
377 os << "SQRT";
378 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100379 case ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU:
380 os << "LU_BOUNDED_RELU";
Kevin Petitd9f80712017-12-06 12:18:48 +0000381 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100382 case ActivationLayerInfo::ActivationFunction::SQUARE:
383 os << "SQUARE";
384 break;
385 case ActivationLayerInfo::ActivationFunction::TANH:
386 os << "TANH";
387 break;
Usama Arif6a98a6e2019-05-10 17:07:27 +0100388 case ActivationLayerInfo::ActivationFunction::IDENTITY:
389 os << "IDENTITY";
390 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100391 default:
392 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
393 }
394
395 return os;
396}
397
Alex Gildayc357c472018-03-21 13:54:09 +0000398/** Formatted output of the activation function info type.
399 *
400 * @param[in] info Type to output.
401 *
402 * @return Formatted string.
403 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100404inline std::string to_string(const arm_compute::ActivationLayerInfo &info)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100405{
406 std::stringstream str;
Isabella Gottardi3f217ec2018-02-12 14:59:19 +0000407 if(info.enabled())
408 {
409 str << info.activation();
410 }
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100411 return str.str();
412}
413
Alex Gildayc357c472018-03-21 13:54:09 +0000414/** Formatted output of the activation function type.
415 *
416 * @param[in] function Type to output.
417 *
418 * @return Formatted string.
419 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100420inline std::string to_string(const arm_compute::ActivationLayerInfo::ActivationFunction &function)
421{
422 std::stringstream str;
423 str << function;
424 return str.str();
425}
426
Alex Gildayc357c472018-03-21 13:54:09 +0000427/** Formatted output of the NormType type.
428 *
429 * @param[out] os Output stream.
430 * @param[in] norm_type Type to output.
431 *
432 * @return Modified output stream.
433 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100434inline ::std::ostream &operator<<(::std::ostream &os, const NormType &norm_type)
435{
436 switch(norm_type)
437 {
438 case NormType::CROSS_MAP:
439 os << "CROSS_MAP";
440 break;
441 case NormType::IN_MAP_1D:
442 os << "IN_MAP_1D";
443 break;
444 case NormType::IN_MAP_2D:
445 os << "IN_MAP_2D";
446 break;
447 default:
448 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
449 }
450
451 return os;
452}
453
Alex Gildayc357c472018-03-21 13:54:09 +0000454/** Formatted output of @ref NormalizationLayerInfo.
455 *
456 * @param[in] info Type to output.
457 *
458 * @return Formatted string.
459 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100460inline std::string to_string(const arm_compute::NormalizationLayerInfo &info)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100461{
462 std::stringstream str;
Michalis Spyroud466c2d2018-01-30 10:54:39 +0000463 str << info.type() << ":NormSize=" << info.norm_size();
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100464 return str.str();
465}
466
Alex Gildayc357c472018-03-21 13:54:09 +0000467/** Formatted output of @ref NormalizationLayerInfo.
468 *
469 * @param[out] os Output stream.
470 * @param[in] info Type to output.
471 *
472 * @return Modified output stream.
473 */
Georgios Pinitas6f669f02017-09-26 12:32:57 +0100474inline ::std::ostream &operator<<(::std::ostream &os, const NormalizationLayerInfo &info)
475{
Michalis Spyroud466c2d2018-01-30 10:54:39 +0000476 os << info.type() << ":NormSize=" << info.norm_size();
Georgios Pinitas6f669f02017-09-26 12:32:57 +0100477 return os;
478}
479
Alex Gildayc357c472018-03-21 13:54:09 +0000480/** Formatted output of the PoolingType type.
481 *
482 * @param[out] os Output stream.
483 * @param[in] pool_type Type to output.
484 *
485 * @return Modified output stream.
486 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100487inline ::std::ostream &operator<<(::std::ostream &os, const PoolingType &pool_type)
488{
489 switch(pool_type)
490 {
491 case PoolingType::AVG:
492 os << "AVG";
493 break;
494 case PoolingType::MAX:
495 os << "MAX";
496 break;
Georgios Pinitascdf51452017-08-31 14:21:36 +0100497 case PoolingType::L2:
498 os << "L2";
499 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100500 default:
501 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
502 }
503
504 return os;
505}
506
Alex Gildayc357c472018-03-21 13:54:09 +0000507/** Formatted output of @ref PoolingLayerInfo.
508 *
509 * @param[out] os Output stream.
510 * @param[in] info Type to output.
511 *
512 * @return Modified output stream.
513 */
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100514inline ::std::ostream &operator<<(::std::ostream &os, const PoolingLayerInfo &info)
515{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100516 os << info.pool_type();
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100517
518 return os;
519}
520
Alex Gildayc357c472018-03-21 13:54:09 +0000521/** Formatted output of @ref RoundingPolicy.
522 *
523 * @param[in] rounding_policy Type to output.
524 *
525 * @return Formatted string.
526 */
John Richardsondd715f22017-09-18 16:10:48 +0100527inline std::string to_string(const RoundingPolicy &rounding_policy)
528{
529 std::stringstream str;
530 str << rounding_policy;
531 return str.str();
532}
533
Vidhya Sudhan Loganathand646ae12018-11-19 15:18:20 +0000534/** [Print DataLayout type] **/
Alex Gildayc357c472018-03-21 13:54:09 +0000535/** Formatted output of the DataLayout type.
536 *
537 * @param[out] os Output stream.
538 * @param[in] data_layout Type to output.
539 *
540 * @return Modified output stream.
541 */
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000542inline ::std::ostream &operator<<(::std::ostream &os, const DataLayout &data_layout)
543{
544 switch(data_layout)
545 {
546 case DataLayout::UNKNOWN:
547 os << "UNKNOWN";
548 break;
549 case DataLayout::NHWC:
550 os << "NHWC";
551 break;
552 case DataLayout::NCHW:
553 os << "NCHW";
554 break;
555 default:
556 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
557 }
558
559 return os;
560}
561
Alex Gildayc357c472018-03-21 13:54:09 +0000562/** Formatted output of the DataLayout type.
563 *
564 * @param[in] data_layout Type to output.
565 *
566 * @return Formatted string.
567 */
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000568inline std::string to_string(const arm_compute::DataLayout &data_layout)
569{
570 std::stringstream str;
571 str << data_layout;
572 return str.str();
573}
Vidhya Sudhan Loganathand646ae12018-11-19 15:18:20 +0000574/** [Print DataLayout type] **/
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000575
Georgios Pinitase2220552018-07-20 13:23:44 +0100576/** Formatted output of the DataLayoutDimension type.
577 *
578 * @param[out] os Output stream.
579 * @param[in] data_layout_dim Data layout dimension to print.
580 *
581 * @return Modified output stream.
582 */
583inline ::std::ostream &operator<<(::std::ostream &os, const DataLayoutDimension &data_layout_dim)
584{
585 switch(data_layout_dim)
586 {
587 case DataLayoutDimension::WIDTH:
588 os << "WIDTH";
589 break;
590 case DataLayoutDimension::HEIGHT:
591 os << "HEIGHT";
592 break;
593 case DataLayoutDimension::CHANNEL:
594 os << "CHANNEL";
595 break;
596 case DataLayoutDimension::BATCHES:
597 os << "BATCHES";
598 break;
599 default:
600 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
601 }
602 return os;
603}
604
Alex Gildayc357c472018-03-21 13:54:09 +0000605/** Formatted output of the DataType type.
606 *
607 * @param[out] os Output stream.
608 * @param[in] data_type Type to output.
609 *
610 * @return Modified output stream.
611 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100612inline ::std::ostream &operator<<(::std::ostream &os, const DataType &data_type)
613{
614 switch(data_type)
615 {
616 case DataType::UNKNOWN:
617 os << "UNKNOWN";
618 break;
619 case DataType::U8:
620 os << "U8";
621 break;
Chunosovd621bca2017-11-03 17:33:15 +0700622 case DataType::QASYMM8:
623 os << "QASYMM8";
624 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100625 case DataType::S8:
626 os << "S8";
627 break;
628 case DataType::U16:
629 os << "U16";
630 break;
631 case DataType::S16:
632 os << "S16";
633 break;
634 case DataType::U32:
635 os << "U32";
636 break;
637 case DataType::S32:
638 os << "S32";
639 break;
640 case DataType::U64:
641 os << "U64";
642 break;
643 case DataType::S64:
644 os << "S64";
645 break;
646 case DataType::F16:
647 os << "F16";
648 break;
649 case DataType::F32:
650 os << "F32";
651 break;
652 case DataType::F64:
653 os << "F64";
654 break;
655 case DataType::SIZET:
656 os << "SIZET";
657 break;
658 default:
659 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
660 }
661
662 return os;
663}
664
Alex Gildayc357c472018-03-21 13:54:09 +0000665/** Formatted output of the DataType type.
666 *
667 * @param[in] data_type Type to output.
668 *
669 * @return Formatted string.
670 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100671inline std::string to_string(const arm_compute::DataType &data_type)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100672{
673 std::stringstream str;
674 str << data_type;
675 return str.str();
676}
677
Alex Gildayc357c472018-03-21 13:54:09 +0000678/** Formatted output of the Format type.
679 *
680 * @param[out] os Output stream.
681 * @param[in] format Type to output.
682 *
683 * @return Modified output stream.
684 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100685inline ::std::ostream &operator<<(::std::ostream &os, const Format &format)
686{
687 switch(format)
688 {
689 case Format::UNKNOWN:
690 os << "UNKNOWN";
691 break;
692 case Format::U8:
693 os << "U8";
694 break;
695 case Format::S16:
696 os << "S16";
697 break;
698 case Format::U16:
699 os << "U16";
700 break;
701 case Format::S32:
702 os << "S32";
703 break;
704 case Format::U32:
705 os << "U32";
706 break;
707 case Format::F16:
708 os << "F16";
709 break;
710 case Format::F32:
711 os << "F32";
712 break;
713 case Format::UV88:
714 os << "UV88";
715 break;
716 case Format::RGB888:
717 os << "RGB888";
718 break;
719 case Format::RGBA8888:
720 os << "RGBA8888";
721 break;
722 case Format::YUV444:
723 os << "YUV444";
724 break;
725 case Format::YUYV422:
726 os << "YUYV422";
727 break;
728 case Format::NV12:
729 os << "NV12";
730 break;
731 case Format::NV21:
732 os << "NV21";
733 break;
734 case Format::IYUV:
735 os << "IYUV";
736 break;
737 case Format::UYVY422:
738 os << "UYVY422";
739 break;
740 default:
741 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
742 }
743
744 return os;
745}
746
Alex Gildayc357c472018-03-21 13:54:09 +0000747/** Formatted output of the Format type.
748 *
749 * @param[in] format Type to output.
750 *
751 * @return Formatted string.
752 */
Moritz Pflanzer7655a672017-09-23 11:57:33 +0100753inline std::string to_string(const Format &format)
754{
755 std::stringstream str;
756 str << format;
757 return str.str();
758}
759
Alex Gildayc357c472018-03-21 13:54:09 +0000760/** Formatted output of the Channel type.
761 *
762 * @param[out] os Output stream.
763 * @param[in] channel Type to output.
764 *
765 * @return Modified output stream.
766 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100767inline ::std::ostream &operator<<(::std::ostream &os, const Channel &channel)
768{
769 switch(channel)
770 {
771 case Channel::UNKNOWN:
772 os << "UNKNOWN";
773 break;
774 case Channel::C0:
775 os << "C0";
776 break;
777 case Channel::C1:
778 os << "C1";
779 break;
780 case Channel::C2:
781 os << "C2";
782 break;
783 case Channel::C3:
784 os << "C3";
785 break;
786 case Channel::R:
787 os << "R";
788 break;
789 case Channel::G:
790 os << "G";
791 break;
792 case Channel::B:
793 os << "B";
794 break;
795 case Channel::A:
796 os << "A";
797 break;
798 case Channel::Y:
799 os << "Y";
800 break;
801 case Channel::U:
802 os << "U";
803 break;
804 case Channel::V:
805 os << "V";
806 break;
807 default:
808 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
809 }
810
811 return os;
812}
813
Alex Gildayc357c472018-03-21 13:54:09 +0000814/** Formatted output of the Channel type.
815 *
816 * @param[in] channel Type to output.
817 *
818 * @return Formatted string.
819 */
Ioan-Cristian Szabo9414f642017-10-27 17:35:40 +0100820inline std::string to_string(const Channel &channel)
821{
822 std::stringstream str;
823 str << channel;
824 return str.str();
825}
826
Alex Gildayc357c472018-03-21 13:54:09 +0000827/** Formatted output of the BorderMode type.
828 *
829 * @param[out] os Output stream.
830 * @param[in] mode Type to output.
831 *
832 * @return Modified output stream.
833 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100834inline ::std::ostream &operator<<(::std::ostream &os, const BorderMode &mode)
835{
836 switch(mode)
837 {
838 case BorderMode::UNDEFINED:
839 os << "UNDEFINED";
840 break;
841 case BorderMode::CONSTANT:
842 os << "CONSTANT";
843 break;
844 case BorderMode::REPLICATE:
845 os << "REPLICATE";
846 break;
847 default:
848 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
849 }
850
851 return os;
852}
853
Alex Gildayc357c472018-03-21 13:54:09 +0000854/** Formatted output of the BorderSize type.
855 *
856 * @param[out] os Output stream.
857 * @param[in] border Type to output.
858 *
859 * @return Modified output stream.
860 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100861inline ::std::ostream &operator<<(::std::ostream &os, const BorderSize &border)
862{
Moritz Pflanzerc87fbf82017-07-18 14:02:10 +0100863 os << border.top << ","
864 << border.right << ","
865 << border.bottom << ","
866 << border.left;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100867
868 return os;
869}
Anthony Barbier2a07e182017-08-04 18:20:27 +0100870
Giuseppe Rossinid7647d42018-07-17 18:13:13 +0100871/** Formatted output of the PaddingList type.
872 *
873 * @param[out] os Output stream.
874 * @param[in] padding Type to output.
875 *
876 * @return Modified output stream.
877 */
878inline ::std::ostream &operator<<(::std::ostream &os, const PaddingList &padding)
879{
880 os << "{";
881 for(auto const &p : padding)
882 {
883 os << "{" << p.first << "," << p.second << "}";
884 }
885 os << "}";
886 return os;
887}
888
giuros013175fcf2018-11-21 09:59:17 +0000889/** Formatted output of the Multiples type.
890 *
891 * @param[out] os Output stream.
892 * @param[in] multiples Type to output.
893 *
894 * @return Modified output stream.
895 */
896inline ::std::ostream &operator<<(::std::ostream &os, const Multiples &multiples)
897{
898 os << "(";
899 for(size_t i = 0; i < multiples.size() - 1; i++)
900 {
901 os << multiples[i] << ", ";
902 }
903 os << multiples.back() << ")";
904 return os;
905}
906
Alex Gildayc357c472018-03-21 13:54:09 +0000907/** Formatted output of the InterpolationPolicy type.
908 *
909 * @param[out] os Output stream.
910 * @param[in] policy Type to output.
911 *
912 * @return Modified output stream.
913 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100914inline ::std::ostream &operator<<(::std::ostream &os, const InterpolationPolicy &policy)
915{
916 switch(policy)
917 {
918 case InterpolationPolicy::NEAREST_NEIGHBOR:
919 os << "NEAREST_NEIGHBOR";
920 break;
921 case InterpolationPolicy::BILINEAR:
922 os << "BILINEAR";
923 break;
924 case InterpolationPolicy::AREA:
925 os << "AREA";
926 break;
927 default:
928 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
929 }
930
931 return os;
932}
933
Alex Gildayc357c472018-03-21 13:54:09 +0000934/** Formatted output of the SamplingPolicy type.
935 *
936 * @param[out] os Output stream.
937 * @param[in] policy Type to output.
938 *
939 * @return Modified output stream.
940 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700941inline ::std::ostream &operator<<(::std::ostream &os, const SamplingPolicy &policy)
942{
943 switch(policy)
944 {
945 case SamplingPolicy::CENTER:
946 os << "CENTER";
947 break;
948 case SamplingPolicy::TOP_LEFT:
949 os << "TOP_LEFT";
950 break;
951 default:
952 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
953 }
954
955 return os;
956}
957
Alex Gildayc357c472018-03-21 13:54:09 +0000958/** Formatted output of the TensorInfo type.
959 *
Anthony Barbier366628a2018-08-01 13:55:03 +0100960 * @param[out] os Output stream.
961 * @param[in] info Type to output.
962 *
963 * @return Modified output stream.
964 */
965inline ::std::ostream &operator<<(::std::ostream &os, const TensorInfo &info)
966{
967 os << "{Shape=" << info.tensor_shape() << ","
968 << "Type=" << info.data_type() << ","
969 << "Channels=" << info.num_channels() << "}";
970 return os;
971}
972/** Formatted output of the TensorInfo type.
973 *
Alex Gildayc357c472018-03-21 13:54:09 +0000974 * @param[in] info Type to output.
975 *
976 * @return Formatted string.
977 */
Georgios Pinitas3faea252017-10-30 14:13:50 +0000978inline std::string to_string(const TensorInfo &info)
979{
980 std::stringstream str;
Anthony Barbier366628a2018-08-01 13:55:03 +0100981 str << info;
Georgios Pinitas3faea252017-10-30 14:13:50 +0000982 return str.str();
983}
984
Alex Gildayc357c472018-03-21 13:54:09 +0000985/** Formatted output of the Dimensions type.
986 *
987 * @param[in] dimensions Type to output.
988 *
989 * @return Formatted string.
990 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100991template <typename T>
992inline std::string to_string(const Dimensions<T> &dimensions)
993{
994 std::stringstream str;
995 str << dimensions;
996 return str.str();
997}
998
Alex Gildayc357c472018-03-21 13:54:09 +0000999/** Formatted output of the Strides type.
1000 *
1001 * @param[in] stride Type to output.
1002 *
1003 * @return Formatted string.
1004 */
John Richardsona36eae12017-09-26 16:55:59 +01001005inline std::string to_string(const Strides &stride)
1006{
1007 std::stringstream str;
1008 str << stride;
1009 return str.str();
1010}
1011
Alex Gildayc357c472018-03-21 13:54:09 +00001012/** Formatted output of the TensorShape type.
1013 *
1014 * @param[in] shape Type to output.
1015 *
1016 * @return Formatted string.
1017 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001018inline std::string to_string(const TensorShape &shape)
1019{
1020 std::stringstream str;
1021 str << shape;
1022 return str.str();
1023}
1024
Alex Gildayc357c472018-03-21 13:54:09 +00001025/** Formatted output of the Coordinates type.
1026 *
1027 * @param[in] coord Type to output.
1028 *
1029 * @return Formatted string.
1030 */
Abe Mbise925ca0f2017-10-02 19:16:33 +01001031inline std::string to_string(const Coordinates &coord)
1032{
1033 std::stringstream str;
1034 str << coord;
1035 return str.str();
1036}
1037
Anthony Barbierb940fd62018-06-04 14:14:32 +01001038/** Formatted output of the GEMMReshapeInfo type.
1039 *
1040 * @param[out] os Output stream.
1041 * @param[in] info Type to output.
1042 *
1043 * @return Modified output stream.
1044 */
1045inline ::std::ostream &operator<<(::std::ostream &os, const GEMMReshapeInfo &info)
1046{
1047 os << "{m=" << info.m() << ",";
1048 os << "n=" << info.n() << ",";
1049 os << "k=" << info.k() << ",";
1050 os << "mult_transpose1xW_width=" << info.mult_transpose1xW_width() << ",";
1051 os << "mult_interleave4x4_height=" << info.mult_interleave4x4_height();
1052 os << "}";
1053
1054 return os;
1055}
1056
1057/** Formatted output of the GEMMInfo type.
1058 *
1059 * @param[out] os Output stream.
1060 * @param[in] info Type to output.
1061 *
1062 * @return Modified output stream.
1063 */
1064inline ::std::ostream &operator<<(::std::ostream &os, const GEMMInfo &info)
1065{
1066 os << "{is_a_reshaped=" << info.is_a_reshaped() << ",";
1067 os << "is_b_reshaped=" << info.is_b_reshaped() << ",";
1068 os << "reshape_b_only_on_first_run=" << info.reshape_b_only_on_first_run() << ",";
Anthony Barbierb940fd62018-06-04 14:14:32 +01001069 os << "}";
1070
1071 return os;
1072}
1073
1074/** Formatted output of the Window::Dimension type.
1075 *
1076 * @param[out] os Output stream.
1077 * @param[in] dim Type to output.
1078 *
1079 * @return Modified output stream.
1080 */
1081inline ::std::ostream &operator<<(::std::ostream &os, const Window::Dimension &dim)
1082{
1083 os << "{start=" << dim.start() << ", end=" << dim.end() << ", step=" << dim.step() << "}";
1084
1085 return os;
1086}
1087/** Formatted output of the Window type.
1088 *
1089 * @param[out] os Output stream.
1090 * @param[in] win Type to output.
1091 *
1092 * @return Modified output stream.
1093 */
1094inline ::std::ostream &operator<<(::std::ostream &os, const Window &win)
1095{
1096 os << "{";
1097 for(unsigned int i = 0; i < Coordinates::num_max_dimensions; i++)
1098 {
1099 if(i > 0)
1100 {
1101 os << ", ";
1102 }
1103 os << win[i];
1104 }
1105 os << "}";
1106
1107 return os;
1108}
1109
1110/** Formatted output of the WeightsInfo type.
1111 *
1112 * @param[in] info Type to output.
1113 *
1114 * @return Formatted string.
1115 */
1116inline std::string to_string(const WeightsInfo &info)
1117{
1118 std::stringstream str;
1119 str << info;
1120 return str.str();
1121}
1122
1123/** Formatted output of the GEMMReshapeInfo type.
1124 *
1125 * @param[in] info Type to output.
1126 *
1127 * @return Formatted string.
1128 */
1129inline std::string to_string(const GEMMReshapeInfo &info)
1130{
1131 std::stringstream str;
1132 str << info;
1133 return str.str();
1134}
1135
1136/** Formatted output of the GEMMInfo type.
1137 *
1138 * @param[in] info Type to output.
1139 *
1140 * @return Formatted string.
1141 */
1142inline std::string to_string(const GEMMInfo &info)
1143{
1144 std::stringstream str;
1145 str << info;
1146 return str.str();
1147}
1148
1149/** Formatted output of the Window::Dimension type.
1150 *
1151 * @param[in] dim Type to output.
1152 *
1153 * @return Formatted string.
1154 */
1155inline std::string to_string(const Window::Dimension &dim)
1156{
1157 std::stringstream str;
1158 str << dim;
1159 return str.str();
1160}
1161/** Formatted output of the Window type.
1162 *
1163 * @param[in] win Type to output.
1164 *
1165 * @return Formatted string.
1166 */
1167inline std::string to_string(const Window &win)
1168{
1169 std::stringstream str;
1170 str << win;
1171 return str.str();
1172}
1173
Alex Gildayc357c472018-03-21 13:54:09 +00001174/** Formatted output of the Rectangle type.
1175 *
1176 * @param[out] os Output stream.
1177 * @param[in] rect Type to output.
1178 *
1179 * @return Modified output stream.
1180 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001181inline ::std::ostream &operator<<(::std::ostream &os, const Rectangle &rect)
1182{
1183 os << rect.width << "x" << rect.height;
1184 os << "+" << rect.x << "+" << rect.y;
1185
1186 return os;
1187}
1188
Usama Arif8cf8c112019-03-14 15:36:54 +00001189/** Formatted output of the PaddingMode type.
1190 *
1191 * @param[out] os Output stream.
1192 * @param[in] mode Type to output.
1193 *
1194 * @return Modified output stream.
1195 */
1196inline ::std::ostream &operator<<(::std::ostream &os, const PaddingMode &mode)
1197{
1198 switch(mode)
1199 {
1200 case PaddingMode::CONSTANT:
1201 os << "CONSTANT";
1202 break;
1203 case PaddingMode::REFLECT:
1204 os << "REFLECT";
1205 break;
1206 case PaddingMode::SYMMETRIC:
1207 os << "SYMMETRIC";
1208 break;
1209 default:
1210 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1211 }
1212
1213 return os;
1214}
1215
1216/** Formatted output of the PaddingMode type.
1217 *
1218 * @param[in] mode Type to output.
1219 *
1220 * @return Formatted string.
1221 */
1222inline std::string to_string(const PaddingMode &mode)
1223{
1224 std::stringstream str;
1225 str << mode;
1226 return str.str();
1227}
1228
Alex Gildayc357c472018-03-21 13:54:09 +00001229/** Formatted output of the PadStrideInfo type.
1230 *
1231 * @param[out] os Output stream.
1232 * @param[in] pad_stride_info Type to output.
1233 *
1234 * @return Modified output stream.
1235 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001236inline ::std::ostream &operator<<(::std::ostream &os, const PadStrideInfo &pad_stride_info)
1237{
1238 os << pad_stride_info.stride().first << "," << pad_stride_info.stride().second;
1239 os << ";";
Jaroslaw Rzepeckia1ed41f2017-10-13 11:13:58 +01001240 os << pad_stride_info.pad_left() << "," << pad_stride_info.pad_right() << ","
1241 << pad_stride_info.pad_top() << "," << pad_stride_info.pad_bottom();
Anthony Barbier2a07e182017-08-04 18:20:27 +01001242
1243 return os;
1244}
1245
Alex Gildayc357c472018-03-21 13:54:09 +00001246/** Formatted output of the PadStrideInfo type.
1247 *
1248 * @param[in] pad_stride_info Type to output.
1249 *
1250 * @return Formatted string.
1251 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001252inline std::string to_string(const PadStrideInfo &pad_stride_info)
1253{
1254 std::stringstream str;
1255 str << pad_stride_info;
1256 return str.str();
1257}
1258
Alex Gildayc357c472018-03-21 13:54:09 +00001259/** Formatted output of the BorderMode type.
1260 *
1261 * @param[in] mode Type to output.
1262 *
1263 * @return Formatted string.
1264 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001265inline std::string to_string(const BorderMode &mode)
1266{
1267 std::stringstream str;
1268 str << mode;
1269 return str.str();
1270}
1271
Alex Gildayc357c472018-03-21 13:54:09 +00001272/** Formatted output of the BorderSize type.
1273 *
1274 * @param[in] border Type to output.
1275 *
1276 * @return Formatted string.
1277 */
John Richardsonb482ce12017-09-18 12:44:01 +01001278inline std::string to_string(const BorderSize &border)
1279{
1280 std::stringstream str;
1281 str << border;
1282 return str.str();
1283}
1284
Giuseppe Rossinid7647d42018-07-17 18:13:13 +01001285/** Formatted output of the PaddingList type.
1286 *
1287 * @param[in] padding Type to output.
1288 *
1289 * @return Formatted string.
1290 */
1291inline std::string to_string(const PaddingList &padding)
1292{
1293 std::stringstream str;
1294 str << padding;
1295 return str.str();
1296}
1297
giuros013175fcf2018-11-21 09:59:17 +00001298/** Formatted output of the Multiples type.
1299 *
1300 * @param[in] multiples Type to output.
1301 *
1302 * @return Formatted string.
1303 */
1304inline std::string to_string(const Multiples &multiples)
1305{
1306 std::stringstream str;
1307 str << multiples;
1308 return str.str();
1309}
1310
Alex Gildayc357c472018-03-21 13:54:09 +00001311/** Formatted output of the InterpolationPolicy type.
1312 *
1313 * @param[in] policy Type to output.
1314 *
1315 * @return Formatted string.
1316 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001317inline std::string to_string(const InterpolationPolicy &policy)
1318{
1319 std::stringstream str;
1320 str << policy;
1321 return str.str();
1322}
1323
Alex Gildayc357c472018-03-21 13:54:09 +00001324/** Formatted output of the SamplingPolicy type.
1325 *
1326 * @param[in] policy Type to output.
1327 *
1328 * @return Formatted string.
1329 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +07001330inline std::string to_string(const SamplingPolicy &policy)
1331{
1332 std::stringstream str;
1333 str << policy;
1334 return str.str();
1335}
1336
Alex Gildayc357c472018-03-21 13:54:09 +00001337/** Formatted output of the ConvertPolicy type.
1338 *
1339 * @param[out] os Output stream.
1340 * @param[in] policy Type to output.
1341 *
1342 * @return Modified output stream.
1343 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001344inline ::std::ostream &operator<<(::std::ostream &os, const ConvertPolicy &policy)
1345{
1346 switch(policy)
1347 {
1348 case ConvertPolicy::WRAP:
1349 os << "WRAP";
1350 break;
1351 case ConvertPolicy::SATURATE:
1352 os << "SATURATE";
1353 break;
1354 default:
1355 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1356 }
1357
1358 return os;
1359}
1360
1361inline std::string to_string(const ConvertPolicy &policy)
1362{
1363 std::stringstream str;
1364 str << policy;
1365 return str.str();
1366}
1367
giuros01164a2722018-11-20 18:34:46 +00001368/** Formatted output of the ArithmeticOperation type.
1369 *
1370 * @param[out] os Output stream.
1371 * @param[in] op Operation to output.
1372 *
1373 * @return Modified output stream.
1374 */
1375inline ::std::ostream &operator<<(::std::ostream &os, const ArithmeticOperation &op)
1376{
1377 switch(op)
1378 {
1379 case ArithmeticOperation::ADD:
1380 os << "ADD";
1381 break;
1382 case ArithmeticOperation::SUB:
1383 os << "SUB";
1384 break;
1385 case ArithmeticOperation::DIV:
1386 os << "DIV";
1387 break;
1388 case ArithmeticOperation::MAX:
1389 os << "MAX";
1390 break;
1391 case ArithmeticOperation::MIN:
1392 os << "MIN";
1393 break;
1394 case ArithmeticOperation::SQUARED_DIFF:
1395 os << "SQUARED_DIFF";
1396 break;
Usama Arif52c54f62019-05-14 10:22:36 +01001397 case ArithmeticOperation::POWER:
1398 os << "POWER";
1399 break;
giuros01164a2722018-11-20 18:34:46 +00001400 default:
1401 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1402 }
1403
1404 return os;
1405}
1406
1407/** Formatted output of the Arithmetic Operation
1408 *
1409 * @param[in] op Type to output.
1410 *
1411 * @return Formatted string.
1412 */
1413inline std::string to_string(const ArithmeticOperation &op)
1414{
1415 std::stringstream str;
1416 str << op;
1417 return str.str();
1418}
1419
Alex Gildayc357c472018-03-21 13:54:09 +00001420/** Formatted output of the Reduction Operations.
1421 *
1422 * @param[out] os Output stream.
1423 * @param[in] op Type to output.
1424 *
1425 * @return Modified output stream.
1426 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001427inline ::std::ostream &operator<<(::std::ostream &os, const ReductionOperation &op)
1428{
1429 switch(op)
1430 {
Michalis Spyrou7e9391b2018-10-05 14:49:28 +01001431 case ReductionOperation::SUM:
1432 os << "SUM";
1433 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +01001434 case ReductionOperation::SUM_SQUARE:
1435 os << "SUM_SQUARE";
1436 break;
Michalis Spyrou7e9391b2018-10-05 14:49:28 +01001437 case ReductionOperation::MEAN_SUM:
1438 os << "MEAN_SUM";
1439 break;
Michalis Spyrou7930db42018-11-22 17:36:28 +00001440 case ReductionOperation::ARG_IDX_MAX:
1441 os << "ARG_IDX_MAX";
1442 break;
1443 case ReductionOperation::ARG_IDX_MIN:
1444 os << "ARG_IDX_MIN";
1445 break;
Manuel Bottinib412fab2018-12-10 17:40:23 +00001446 case ReductionOperation::PROD:
1447 os << "PROD";
1448 break;
Usama Arifa4a08ad2019-05-20 12:38:33 +01001449 case ReductionOperation::MIN:
1450 os << "MIN";
1451 break;
Usama Arif28f0dd92019-05-20 13:44:34 +01001452 case ReductionOperation::MAX:
1453 os << "MAX";
1454 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +01001455 default:
1456 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1457 }
1458
1459 return os;
1460}
1461
Alex Gildayc357c472018-03-21 13:54:09 +00001462/** Formatted output of the Reduction Operations.
1463 *
1464 * @param[in] op Type to output.
1465 *
1466 * @return Formatted string.
1467 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001468inline std::string to_string(const ReductionOperation &op)
1469{
1470 std::stringstream str;
1471 str << op;
1472 return str.str();
1473}
1474
Georgios Pinitas7900a9e2018-11-23 11:44:58 +00001475/** Formatted output of the Comparison Operations.
1476 *
1477 * @param[out] os Output stream.
1478 * @param[in] op Type to output.
1479 *
1480 * @return Modified output stream.
1481 */
1482inline ::std::ostream &operator<<(::std::ostream &os, const ComparisonOperation &op)
1483{
1484 switch(op)
1485 {
1486 case ComparisonOperation::Equal:
1487 os << "Equal";
1488 break;
1489 case ComparisonOperation::NotEqual:
1490 os << "NotEqual";
1491 break;
1492 case ComparisonOperation::Greater:
1493 os << "Greater";
1494 break;
1495 case ComparisonOperation::GreaterEqual:
1496 os << "GreaterEqual";
1497 break;
1498 case ComparisonOperation::Less:
1499 os << "Less";
1500 break;
1501 case ComparisonOperation::LessEqual:
1502 os << "LessEqual";
1503 break;
1504 default:
1505 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1506 }
1507
1508 return os;
1509}
1510
Michalis Spyroue9362622018-11-23 17:41:37 +00001511/** Formatted output of the Elementwise unary Operations.
1512 *
1513 * @param[out] os Output stream.
1514 * @param[in] op Type to output.
1515 *
1516 * @return Modified output stream.
1517 */
1518inline ::std::ostream &operator<<(::std::ostream &os, const ElementWiseUnary &op)
1519{
1520 switch(op)
1521 {
1522 case ElementWiseUnary::RSQRT:
1523 os << "RSQRT";
1524 break;
1525 case ElementWiseUnary::EXP:
1526 os << "EXP";
1527 break;
Usama Arifeb312ef2019-05-13 17:45:54 +01001528 case ElementWiseUnary::NEG:
1529 os << "NEG";
1530 break;
Usama Arifac33d7e2019-05-20 14:21:40 +01001531 case ElementWiseUnary::LOG:
1532 os << "LOG";
1533 break;
Usama Arif6a4d5422019-05-24 14:53:59 +01001534 case ElementWiseUnary::ROUND:
1535 os << "ROUND";
1536 break;
Michalis Spyroue9362622018-11-23 17:41:37 +00001537 default:
1538 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1539 }
1540
1541 return os;
1542}
1543
Georgios Pinitas7900a9e2018-11-23 11:44:58 +00001544/** Formatted output of the Comparison Operations.
1545 *
1546 * @param[in] op Type to output.
1547 *
1548 * @return Formatted string.
1549 */
1550inline std::string to_string(const ComparisonOperation &op)
1551{
1552 std::stringstream str;
1553 str << op;
1554 return str.str();
1555}
1556
Michalis Spyroue9362622018-11-23 17:41:37 +00001557/** Formatted output of the Elementwise unary Operations.
1558 *
1559 * @param[in] op Type to output.
1560 *
1561 * @return Formatted string.
1562 */
1563inline std::string to_string(const ElementWiseUnary &op)
1564{
1565 std::stringstream str;
1566 str << op;
1567 return str.str();
1568}
1569
Alex Gildayc357c472018-03-21 13:54:09 +00001570/** Formatted output of the Norm Type.
1571 *
1572 * @param[in] type Type to output.
1573 *
1574 * @return Formatted string.
1575 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001576inline std::string to_string(const NormType &type)
1577{
1578 std::stringstream str;
1579 str << type;
1580 return str.str();
1581}
1582
Alex Gildayc357c472018-03-21 13:54:09 +00001583/** Formatted output of the Pooling Type.
1584 *
1585 * @param[in] type Type to output.
1586 *
1587 * @return Formatted string.
1588 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001589inline std::string to_string(const PoolingType &type)
1590{
1591 std::stringstream str;
1592 str << type;
1593 return str.str();
1594}
1595
Alex Gildayc357c472018-03-21 13:54:09 +00001596/** Formatted output of the Pooling Layer Info.
1597 *
1598 * @param[in] info Type to output.
1599 *
1600 * @return Formatted string.
1601 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001602inline std::string to_string(const PoolingLayerInfo &info)
1603{
1604 std::stringstream str;
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001605 str << "{Type=" << info.pool_type() << ","
1606 << "IsGlobalPooling=" << info.is_global_pooling();
1607 if(!info.is_global_pooling())
1608 {
1609 str << ","
Isabella Gottardi6e464c32018-01-26 12:32:45 +00001610 << "PoolSize=" << info.pool_size().width << "," << info.pool_size().height << ","
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001611 << "PadStride=" << info.pad_stride_info();
1612 }
1613 str << "}";
Anthony Barbier2a07e182017-08-04 18:20:27 +01001614 return str.str();
1615}
1616
Michalis Spyrou6c7c38e2018-08-29 16:28:11 +01001617/** Formatted output of the PriorBoxLayerInfo.
1618 *
1619 * @param[in] info Type to output.
1620 *
1621 * @return Formatted string.
1622 */
1623inline std::string to_string(const PriorBoxLayerInfo &info)
1624{
1625 std::stringstream str;
1626 str << "{";
1627 str << "Clip:" << info.clip()
1628 << "Flip:" << info.flip()
1629 << "StepX:" << info.steps()[0]
1630 << "StepY:" << info.steps()[1]
1631 << "MinSizes:" << info.min_sizes().size()
1632 << "MaxSizes:" << info.max_sizes().size()
1633 << "ImgSizeX:" << info.img_size().x
1634 << "ImgSizeY:" << info.img_size().y
1635 << "Offset:" << info.offset()
1636 << "Variances:" << info.variances().size();
1637 str << "}";
1638 return str.str();
1639}
1640
Alex Gildayc357c472018-03-21 13:54:09 +00001641/** Formatted output of the KeyPoint type.
1642 *
1643 * @param[out] os Output stream
1644 * @param[in] point Type to output.
1645 *
1646 * @return Modified output stream.
1647 */
Moritz Pflanzer6c6597c2017-09-24 12:09:41 +01001648inline ::std::ostream &operator<<(::std::ostream &os, const KeyPoint &point)
1649{
1650 os << "{x=" << point.x << ","
1651 << "y=" << point.y << ","
1652 << "strength=" << point.strength << ","
1653 << "scale=" << point.scale << ","
1654 << "orientation=" << point.orientation << ","
1655 << "tracking_status=" << point.tracking_status << ","
1656 << "error=" << point.error << "}";
1657
1658 return os;
1659}
John Richardson63e50412017-10-13 20:51:42 +01001660
Alex Gildayc357c472018-03-21 13:54:09 +00001661/** Formatted output of the PhaseType type.
1662 *
1663 * @param[out] os Output stream
1664 * @param[in] phase_type Type to output.
1665 *
1666 * @return Modified output stream.
1667 */
John Richardson63e50412017-10-13 20:51:42 +01001668inline ::std::ostream &operator<<(::std::ostream &os, const PhaseType &phase_type)
1669{
1670 switch(phase_type)
1671 {
1672 case PhaseType::SIGNED:
1673 os << "SIGNED";
1674 break;
1675 case PhaseType::UNSIGNED:
1676 os << "UNSIGNED";
1677 break;
1678 default:
1679 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1680 }
1681
1682 return os;
1683}
1684
Alex Gildayc357c472018-03-21 13:54:09 +00001685/** Formatted output of the PhaseType type.
1686 *
1687 * @param[in] type Type to output.
1688 *
1689 * @return Formatted string.
1690 */
John Richardson63e50412017-10-13 20:51:42 +01001691inline std::string to_string(const arm_compute::PhaseType &type)
1692{
1693 std::stringstream str;
1694 str << type;
1695 return str.str();
1696}
John Richardson3c5f9492017-10-04 15:27:37 +01001697
Alex Gildayc357c472018-03-21 13:54:09 +00001698/** Formatted output of the MagnitudeType type.
1699 *
1700 * @param[out] os Output stream
1701 * @param[in] magnitude_type Type to output.
1702 *
1703 * @return Modified output stream.
1704 */
John Richardson3c5f9492017-10-04 15:27:37 +01001705inline ::std::ostream &operator<<(::std::ostream &os, const MagnitudeType &magnitude_type)
1706{
1707 switch(magnitude_type)
1708 {
1709 case MagnitudeType::L1NORM:
1710 os << "L1NORM";
1711 break;
1712 case MagnitudeType::L2NORM:
1713 os << "L2NORM";
1714 break;
1715 default:
1716 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1717 }
1718
1719 return os;
1720}
1721
Alex Gildayc357c472018-03-21 13:54:09 +00001722/** Formatted output of the MagnitudeType type.
1723 *
1724 * @param[in] type Type to output.
1725 *
1726 * @return Formatted string.
1727 */
John Richardson3c5f9492017-10-04 15:27:37 +01001728inline std::string to_string(const arm_compute::MagnitudeType &type)
1729{
1730 std::stringstream str;
1731 str << type;
1732 return str.str();
1733}
John Richardson1c529922017-11-01 10:57:48 +00001734
Alex Gildayc357c472018-03-21 13:54:09 +00001735/** Formatted output of the HOGNormType type.
1736 *
1737 * @param[out] os Output stream
1738 * @param[in] norm_type Type to output
1739 *
1740 * @return Modified output stream.
1741 */
John Richardson25f23682017-11-27 14:35:09 +00001742inline ::std::ostream &operator<<(::std::ostream &os, const HOGNormType &norm_type)
1743{
1744 switch(norm_type)
1745 {
1746 case HOGNormType::L1_NORM:
1747 os << "L1_NORM";
1748 break;
1749 case HOGNormType::L2_NORM:
1750 os << "L2_NORM";
1751 break;
1752 case HOGNormType::L2HYS_NORM:
1753 os << "L2HYS_NORM";
1754 break;
1755 default:
1756 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1757 }
1758
1759 return os;
1760}
1761
Alex Gildayc357c472018-03-21 13:54:09 +00001762/** Formatted output of the HOGNormType type.
1763 *
1764 * @param[in] type Type to output
1765 *
1766 * @return Formatted string.
1767 */
John Richardson25f23682017-11-27 14:35:09 +00001768inline std::string to_string(const HOGNormType &type)
1769{
1770 std::stringstream str;
1771 str << type;
1772 return str.str();
1773}
1774
Alex Gildayc357c472018-03-21 13:54:09 +00001775/** Formatted output of the Size2D type.
1776 *
1777 * @param[out] os Output stream
1778 * @param[in] size Type to output
1779 *
1780 * @return Modified output stream.
1781 */
John Richardson25f23682017-11-27 14:35:09 +00001782inline ::std::ostream &operator<<(::std::ostream &os, const Size2D &size)
1783{
1784 os << size.width << "x" << size.height;
1785
1786 return os;
1787}
1788
Alex Gildayc357c472018-03-21 13:54:09 +00001789/** Formatted output of the Size2D type.
1790 *
1791 * @param[in] type Type to output
1792 *
1793 * @return Formatted string.
1794 */
John Richardson25f23682017-11-27 14:35:09 +00001795inline std::string to_string(const Size2D &type)
1796{
1797 std::stringstream str;
1798 str << type;
1799 return str.str();
1800}
1801
Alex Gildayc357c472018-03-21 13:54:09 +00001802/** Formatted output of the HOGInfo type.
1803 *
1804 * @param[out] os Output stream
1805 * @param[in] hog_info Type to output
1806 *
1807 * @return Modified output stream.
1808 */
John Richardson25f23682017-11-27 14:35:09 +00001809inline ::std::ostream &operator<<(::std::ostream &os, const HOGInfo &hog_info)
1810{
1811 os << "{CellSize=" << hog_info.cell_size() << ","
1812 << "BlockSize=" << hog_info.block_size() << ","
1813 << "DetectionWindowSize=" << hog_info.detection_window_size() << ","
1814 << "BlockStride=" << hog_info.block_stride() << ","
1815 << "NumBins=" << hog_info.num_bins() << ","
1816 << "NormType=" << hog_info.normalization_type() << ","
1817 << "L2HystThreshold=" << hog_info.l2_hyst_threshold() << ","
1818 << "PhaseType=" << hog_info.phase_type() << "}";
1819
1820 return os;
1821}
1822
Alex Gildayc357c472018-03-21 13:54:09 +00001823/** Formatted output of the HOGInfo type.
1824 *
1825 * @param[in] type Type to output
1826 *
1827 * @return Formatted string.
1828 */
John Richardson25f23682017-11-27 14:35:09 +00001829inline std::string to_string(const HOGInfo &type)
1830{
1831 std::stringstream str;
1832 str << type;
1833 return str.str();
1834}
1835
Alex Gildayc357c472018-03-21 13:54:09 +00001836/** Formatted output of the ConvolutionMethod type.
1837 *
1838 * @param[out] os Output stream
1839 * @param[in] conv_method Type to output
1840 *
1841 * @return Modified output stream.
1842 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001843inline ::std::ostream &operator<<(::std::ostream &os, const ConvolutionMethod &conv_method)
1844{
1845 switch(conv_method)
1846 {
1847 case ConvolutionMethod::GEMM:
1848 os << "GEMM";
1849 break;
1850 case ConvolutionMethod::DIRECT:
1851 os << "DIRECT";
1852 break;
1853 case ConvolutionMethod::WINOGRAD:
1854 os << "WINOGRAD";
1855 break;
1856 default:
1857 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1858 }
1859
1860 return os;
1861}
1862
Alex Gildayc357c472018-03-21 13:54:09 +00001863/** Formatted output of the ConvolutionMethod type.
1864 *
1865 * @param[in] conv_method Type to output
1866 *
1867 * @return Formatted string.
1868 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001869inline std::string to_string(const ConvolutionMethod &conv_method)
1870{
1871 std::stringstream str;
1872 str << conv_method;
1873 return str.str();
1874}
1875
Alex Gildayc357c472018-03-21 13:54:09 +00001876/** Formatted output of the GPUTarget type.
1877 *
1878 * @param[out] os Output stream
1879 * @param[in] gpu_target Type to output
1880 *
1881 * @return Modified output stream.
1882 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001883inline ::std::ostream &operator<<(::std::ostream &os, const GPUTarget &gpu_target)
1884{
1885 switch(gpu_target)
1886 {
1887 case GPUTarget::GPU_ARCH_MASK:
1888 os << "GPU_ARCH_MASK";
1889 break;
1890 case GPUTarget::MIDGARD:
1891 os << "MIDGARD";
1892 break;
1893 case GPUTarget::BIFROST:
1894 os << "BIFROST";
1895 break;
1896 case GPUTarget::T600:
1897 os << "T600";
1898 break;
1899 case GPUTarget::T700:
1900 os << "T700";
1901 break;
1902 case GPUTarget::T800:
1903 os << "T800";
1904 break;
Michalis Spyroua9676112018-02-22 18:07:43 +00001905 case GPUTarget::G71:
1906 os << "G71";
1907 break;
1908 case GPUTarget::G72:
1909 os << "G72";
1910 break;
1911 case GPUTarget::G51:
1912 os << "G51";
1913 break;
1914 case GPUTarget::G51BIG:
1915 os << "G51BIG";
1916 break;
1917 case GPUTarget::G51LIT:
1918 os << "G51LIT";
1919 break;
Georgios Pinitasb03f7c52018-07-12 10:49:53 +01001920 case GPUTarget::G76:
1921 os << "G76";
Michalis Spyroua9676112018-02-22 18:07:43 +00001922 break;
1923 case GPUTarget::TTRX:
1924 os << "TTRX";
1925 break;
1926 case GPUTarget::TBOX:
1927 os << "TBOX";
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001928 break;
1929 default:
1930 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1931 }
1932
1933 return os;
1934}
1935
Alex Gildayc357c472018-03-21 13:54:09 +00001936/** Formatted output of the GPUTarget type.
1937 *
1938 * @param[in] gpu_target Type to output
1939 *
1940 * @return Formatted string.
1941 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001942inline std::string to_string(const GPUTarget &gpu_target)
1943{
1944 std::stringstream str;
1945 str << gpu_target;
1946 return str.str();
1947}
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00001948
John Richardson8de92612018-02-22 14:09:31 +00001949/** Formatted output of the DetectionWindow type.
1950 *
1951 * @param[out] os Output stream
1952 * @param[in] detection_window Type to output
1953 *
1954 * @return Modified output stream.
1955 */
John Richardson684cb0f2018-01-09 11:17:00 +00001956inline ::std::ostream &operator<<(::std::ostream &os, const DetectionWindow &detection_window)
1957{
1958 os << "{x=" << detection_window.x << ","
1959 << "y=" << detection_window.y << ","
1960 << "width=" << detection_window.width << ","
1961 << "height=" << detection_window.height << ","
1962 << "idx_class=" << detection_window.idx_class << ","
1963 << "score=" << detection_window.score << "}";
1964
1965 return os;
1966}
1967
Isabella Gottardi05e56442018-11-16 11:26:52 +00001968/** Formatted output of the DetectionOutputLayerCodeType type.
1969 *
1970 * @param[out] os Output stream
1971 * @param[in] detection_code Type to output
1972 *
1973 * @return Modified output stream.
1974 */
1975inline ::std::ostream &operator<<(::std::ostream &os, const DetectionOutputLayerCodeType &detection_code)
1976{
1977 switch(detection_code)
1978 {
1979 case DetectionOutputLayerCodeType::CENTER_SIZE:
1980 os << "CENTER_SIZE";
1981 break;
1982 case DetectionOutputLayerCodeType::CORNER:
1983 os << "CORNER";
1984 break;
1985 case DetectionOutputLayerCodeType::CORNER_SIZE:
1986 os << "CORNER_SIZE";
1987 break;
1988 case DetectionOutputLayerCodeType::TF_CENTER:
1989 os << "TF_CENTER";
1990 break;
1991 default:
1992 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1993 }
1994
1995 return os;
1996}
1997/** Formatted output of the DetectionOutputLayerCodeType type.
1998 *
1999 * @param[in] detection_code Type to output
2000 *
2001 * @return Formatted string.
2002 */
2003inline std::string to_string(const DetectionOutputLayerCodeType &detection_code)
2004{
2005 std::stringstream str;
2006 str << detection_code;
2007 return str.str();
2008}
2009
2010/** Formatted output of the DetectionOutputLayerInfo type.
2011 *
2012 * @param[out] os Output stream
2013 * @param[in] detection_info Type to output
2014 *
2015 * @return Modified output stream.
2016 */
2017inline ::std::ostream &operator<<(::std::ostream &os, const DetectionOutputLayerInfo &detection_info)
2018{
2019 os << "{Classes=" << detection_info.num_classes() << ","
2020 << "ShareLocation=" << detection_info.share_location() << ","
2021 << "CodeType=" << detection_info.code_type() << ","
2022 << "VarianceEncodedInTarget=" << detection_info.variance_encoded_in_target() << ","
2023 << "KeepTopK=" << detection_info.keep_top_k() << ","
2024 << "NMSThreshold=" << detection_info.nms_threshold() << ","
2025 << "Eta=" << detection_info.eta() << ","
2026 << "BackgroundLabelId=" << detection_info.background_label_id() << ","
2027 << "ConfidenceThreshold=" << detection_info.confidence_threshold() << ","
2028 << "TopK=" << detection_info.top_k() << ","
2029 << "NumLocClasses=" << detection_info.num_loc_classes()
2030 << "}";
2031
2032 return os;
2033}
2034
2035/** Formatted output of the DetectionOutputLayerInfo type.
2036 *
2037 * @param[in] detection_info Type to output
2038 *
2039 * @return Formatted string.
2040 */
2041inline std::string to_string(const DetectionOutputLayerInfo &detection_info)
2042{
2043 std::stringstream str;
2044 str << detection_info;
2045 return str.str();
2046}
John Richardson8de92612018-02-22 14:09:31 +00002047/** Formatted output of the DetectionWindow type.
2048 *
2049 * @param[in] detection_window Type to output
2050 *
2051 * @return Formatted string.
2052 */
2053inline std::string to_string(const DetectionWindow &detection_window)
2054{
2055 std::stringstream str;
2056 str << detection_window;
2057 return str.str();
2058}
2059
2060/** Formatted output of the Termination type.
2061 *
2062 * @param[out] os Output stream
2063 * @param[in] termination Type to output
2064 *
2065 * @return Modified output stream.
2066 */
2067inline ::std::ostream &operator<<(::std::ostream &os, const Termination &termination)
2068{
2069 switch(termination)
2070 {
2071 case Termination::TERM_CRITERIA_EPSILON:
2072 os << "TERM_CRITERIA_EPSILON";
2073 break;
2074 case Termination::TERM_CRITERIA_ITERATIONS:
2075 os << "TERM_CRITERIA_ITERATIONS";
2076 break;
2077 case Termination::TERM_CRITERIA_BOTH:
2078 os << "TERM_CRITERIA_BOTH";
2079 break;
2080 default:
2081 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2082 }
2083
2084 return os;
2085}
2086
2087/** Formatted output of the Termination type.
2088 *
2089 * @param[in] termination Type to output
2090 *
2091 * @return Formatted string.
2092 */
2093inline std::string to_string(const Termination &termination)
2094{
2095 std::stringstream str;
2096 str << termination;
2097 return str.str();
2098}
2099
Anthony Barbier8914e322018-08-10 15:28:25 +01002100/** Formatted output of the CPUModel type.
2101 *
2102 * @param[out] os Output stream
2103 * @param[in] cpu_model Model to output
2104 *
2105 * @return Modified output stream.
2106 */
2107inline ::std::ostream &operator<<(::std::ostream &os, const CPUModel &cpu_model)
2108{
2109 switch(cpu_model)
2110 {
2111 case CPUModel::GENERIC:
2112 os << "GENERIC";
2113 break;
2114 case CPUModel::GENERIC_FP16:
2115 os << "GENERIC_FP16";
2116 break;
2117 case CPUModel::GENERIC_FP16_DOT:
2118 os << "GENERIC_FP16_DOT";
2119 break;
2120 case CPUModel::A53:
2121 os << "A53";
2122 break;
2123 case CPUModel::A55r0:
2124 os << "A55r0";
2125 break;
2126 case CPUModel::A55r1:
2127 os << "A55r1";
2128 break;
2129 default:
2130 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2131 }
2132
2133 return os;
2134}
2135
2136/** Formatted output of the CPUModel type.
2137 *
2138 * @param[in] cpu_model Model to output
2139 *
2140 * @return Formatted string.
2141 */
2142inline std::string to_string(const CPUModel &cpu_model)
2143{
2144 std::stringstream str;
2145 str << cpu_model;
2146 return str.str();
2147}
Anthony Barbier671a11e2018-07-06 15:11:36 +01002148/** Formatted output of a vector of objects.
2149 *
2150 * @param[out] os Output stream
2151 * @param[in] args Vector of objects to print
2152 *
2153 * @return Modified output stream.
2154 */
2155template <typename T>
2156inline ::std::ostream &operator<<(::std::ostream &os, const std::vector<T> &args)
2157{
2158 os << "[";
2159 bool first = true;
2160 for(auto &arg : args)
2161 {
2162 if(first)
2163 {
2164 first = false;
2165 }
2166 else
2167 {
2168 os << ", ";
2169 }
2170 os << arg;
2171 }
2172 os << "]";
2173 return os;
2174}
2175
Michalis Spyrou6c7c38e2018-08-29 16:28:11 +01002176/** Formatted output of @ref PriorBoxLayerInfo.
2177 *
2178 * @param[out] os Output stream.
2179 * @param[in] info Type to output.
2180 *
2181 * @return Modified output stream.
2182 */
2183inline ::std::ostream &operator<<(::std::ostream &os, const PriorBoxLayerInfo &info)
2184{
2185 os << "Clip:" << info.clip()
2186 << "Flip:" << info.flip()
2187 << "StepX:" << info.steps()[0]
2188 << "StepY:" << info.steps()[1]
2189 << "MinSizes:" << info.min_sizes()
2190 << "MaxSizes:" << info.max_sizes()
2191 << "ImgSizeX:" << info.img_size().x
2192 << "ImgSizeY:" << info.img_size().y
2193 << "Offset:" << info.offset()
2194 << "Variances:" << info.variances();
2195
2196 return os;
2197}
2198
Anthony Barbier671a11e2018-07-06 15:11:36 +01002199/** Formatted output of a vector of objects.
2200 *
2201 * @param[in] args Vector of objects to print
2202 *
2203 * @return String representing args.
2204 */
2205template <typename T>
2206std::string to_string(const std::vector<T> &args)
2207{
2208 std::stringstream str;
2209 str << args;
2210 return str.str();
2211}
2212
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00002213/** Formatted output of the WinogradInfo type. */
2214inline ::std::ostream &operator<<(::std::ostream &os, const WinogradInfo &info)
2215{
2216 os << "{OutputTileSize=" << info.output_tile_size << ","
2217 << "KernelSize=" << info.kernel_size << ","
2218 << "PadStride=" << info.convolution_info << ","
2219 << "OutputDataLayout=" << info.output_data_layout << "}";
2220
2221 return os;
2222}
2223
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00002224inline std::string to_string(const WinogradInfo &type)
2225{
2226 std::stringstream str;
2227 str << type;
2228 return str.str();
2229}
Anthony Barbier671a11e2018-07-06 15:11:36 +01002230
2231/** Fallback method: try to use std::to_string:
2232 *
2233 * @param[in] val Value to convert to string
2234 *
2235 * @return String representing val.
2236 */
2237template <typename T>
2238inline std::string to_string(const T &val)
2239{
2240 return support::cpp11::to_string(val);
2241}
2242
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +01002243/** Convert a CLTunerMode value to a string
2244 *
2245 * @param val CLTunerMode value to be converted
2246 *
2247 * @return String representing the corresponding CLTunerMode.
2248 */
2249inline std::string to_string(const CLTunerMode val)
2250{
2251 switch(val)
2252 {
2253 case CLTunerMode::EXHAUSTIVE:
2254 {
2255 return std::string("Exhaustive");
2256 }
2257 case CLTunerMode::NORMAL:
2258 {
2259 return std::string("Normal");
2260 }
2261 case CLTunerMode::RAPID:
2262 {
2263 return std::string("Rapid");
2264 }
2265 default:
2266 {
2267 ARM_COMPUTE_ERROR("Invalid tuner mode.");
2268 return std::string("UNDEFINED");
2269 }
2270 }
2271}
2272/** [Print CLTunerMode type] **/
2273/** Formatted output of the CLTunerMode type.
2274 *
2275 * @param[out] os Output stream.
2276 * @param[in] val CLTunerMode to output.
2277 *
2278 * @return Modified output stream.
2279 */
2280inline ::std::ostream &operator<<(::std::ostream &os, const CLTunerMode &val)
2281{
2282 os << to_string(val);
2283 return os;
2284}
2285
Anthony Barbier6ff3b192017-09-04 18:44:23 +01002286} // namespace arm_compute
Anthony Barbier4dbc0a92018-08-27 13:39:47 +01002287
2288#endif /* __ARM_COMPUTE_TYPE_PRINTER_H__ */