blob: 74dd0bbc3586b37659c03fdccac68035d75aa1d7 [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;
Michalis Spyroue9362622018-11-23 17:41:37 +00001534 default:
1535 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1536 }
1537
1538 return os;
1539}
1540
Georgios Pinitas7900a9e2018-11-23 11:44:58 +00001541/** Formatted output of the Comparison Operations.
1542 *
1543 * @param[in] op Type to output.
1544 *
1545 * @return Formatted string.
1546 */
1547inline std::string to_string(const ComparisonOperation &op)
1548{
1549 std::stringstream str;
1550 str << op;
1551 return str.str();
1552}
1553
Michalis Spyroue9362622018-11-23 17:41:37 +00001554/** Formatted output of the Elementwise unary Operations.
1555 *
1556 * @param[in] op Type to output.
1557 *
1558 * @return Formatted string.
1559 */
1560inline std::string to_string(const ElementWiseUnary &op)
1561{
1562 std::stringstream str;
1563 str << op;
1564 return str.str();
1565}
1566
Alex Gildayc357c472018-03-21 13:54:09 +00001567/** Formatted output of the Norm Type.
1568 *
1569 * @param[in] type Type to output.
1570 *
1571 * @return Formatted string.
1572 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001573inline std::string to_string(const NormType &type)
1574{
1575 std::stringstream str;
1576 str << type;
1577 return str.str();
1578}
1579
Alex Gildayc357c472018-03-21 13:54:09 +00001580/** Formatted output of the Pooling Type.
1581 *
1582 * @param[in] type Type to output.
1583 *
1584 * @return Formatted string.
1585 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001586inline std::string to_string(const PoolingType &type)
1587{
1588 std::stringstream str;
1589 str << type;
1590 return str.str();
1591}
1592
Alex Gildayc357c472018-03-21 13:54:09 +00001593/** Formatted output of the Pooling Layer Info.
1594 *
1595 * @param[in] info Type to output.
1596 *
1597 * @return Formatted string.
1598 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001599inline std::string to_string(const PoolingLayerInfo &info)
1600{
1601 std::stringstream str;
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001602 str << "{Type=" << info.pool_type() << ","
1603 << "IsGlobalPooling=" << info.is_global_pooling();
1604 if(!info.is_global_pooling())
1605 {
1606 str << ","
Isabella Gottardi6e464c32018-01-26 12:32:45 +00001607 << "PoolSize=" << info.pool_size().width << "," << info.pool_size().height << ","
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001608 << "PadStride=" << info.pad_stride_info();
1609 }
1610 str << "}";
Anthony Barbier2a07e182017-08-04 18:20:27 +01001611 return str.str();
1612}
1613
Michalis Spyrou6c7c38e2018-08-29 16:28:11 +01001614/** Formatted output of the PriorBoxLayerInfo.
1615 *
1616 * @param[in] info Type to output.
1617 *
1618 * @return Formatted string.
1619 */
1620inline std::string to_string(const PriorBoxLayerInfo &info)
1621{
1622 std::stringstream str;
1623 str << "{";
1624 str << "Clip:" << info.clip()
1625 << "Flip:" << info.flip()
1626 << "StepX:" << info.steps()[0]
1627 << "StepY:" << info.steps()[1]
1628 << "MinSizes:" << info.min_sizes().size()
1629 << "MaxSizes:" << info.max_sizes().size()
1630 << "ImgSizeX:" << info.img_size().x
1631 << "ImgSizeY:" << info.img_size().y
1632 << "Offset:" << info.offset()
1633 << "Variances:" << info.variances().size();
1634 str << "}";
1635 return str.str();
1636}
1637
Alex Gildayc357c472018-03-21 13:54:09 +00001638/** Formatted output of the KeyPoint type.
1639 *
1640 * @param[out] os Output stream
1641 * @param[in] point Type to output.
1642 *
1643 * @return Modified output stream.
1644 */
Moritz Pflanzer6c6597c2017-09-24 12:09:41 +01001645inline ::std::ostream &operator<<(::std::ostream &os, const KeyPoint &point)
1646{
1647 os << "{x=" << point.x << ","
1648 << "y=" << point.y << ","
1649 << "strength=" << point.strength << ","
1650 << "scale=" << point.scale << ","
1651 << "orientation=" << point.orientation << ","
1652 << "tracking_status=" << point.tracking_status << ","
1653 << "error=" << point.error << "}";
1654
1655 return os;
1656}
John Richardson63e50412017-10-13 20:51:42 +01001657
Alex Gildayc357c472018-03-21 13:54:09 +00001658/** Formatted output of the PhaseType type.
1659 *
1660 * @param[out] os Output stream
1661 * @param[in] phase_type Type to output.
1662 *
1663 * @return Modified output stream.
1664 */
John Richardson63e50412017-10-13 20:51:42 +01001665inline ::std::ostream &operator<<(::std::ostream &os, const PhaseType &phase_type)
1666{
1667 switch(phase_type)
1668 {
1669 case PhaseType::SIGNED:
1670 os << "SIGNED";
1671 break;
1672 case PhaseType::UNSIGNED:
1673 os << "UNSIGNED";
1674 break;
1675 default:
1676 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1677 }
1678
1679 return os;
1680}
1681
Alex Gildayc357c472018-03-21 13:54:09 +00001682/** Formatted output of the PhaseType type.
1683 *
1684 * @param[in] type Type to output.
1685 *
1686 * @return Formatted string.
1687 */
John Richardson63e50412017-10-13 20:51:42 +01001688inline std::string to_string(const arm_compute::PhaseType &type)
1689{
1690 std::stringstream str;
1691 str << type;
1692 return str.str();
1693}
John Richardson3c5f9492017-10-04 15:27:37 +01001694
Alex Gildayc357c472018-03-21 13:54:09 +00001695/** Formatted output of the MagnitudeType type.
1696 *
1697 * @param[out] os Output stream
1698 * @param[in] magnitude_type Type to output.
1699 *
1700 * @return Modified output stream.
1701 */
John Richardson3c5f9492017-10-04 15:27:37 +01001702inline ::std::ostream &operator<<(::std::ostream &os, const MagnitudeType &magnitude_type)
1703{
1704 switch(magnitude_type)
1705 {
1706 case MagnitudeType::L1NORM:
1707 os << "L1NORM";
1708 break;
1709 case MagnitudeType::L2NORM:
1710 os << "L2NORM";
1711 break;
1712 default:
1713 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1714 }
1715
1716 return os;
1717}
1718
Alex Gildayc357c472018-03-21 13:54:09 +00001719/** Formatted output of the MagnitudeType type.
1720 *
1721 * @param[in] type Type to output.
1722 *
1723 * @return Formatted string.
1724 */
John Richardson3c5f9492017-10-04 15:27:37 +01001725inline std::string to_string(const arm_compute::MagnitudeType &type)
1726{
1727 std::stringstream str;
1728 str << type;
1729 return str.str();
1730}
John Richardson1c529922017-11-01 10:57:48 +00001731
Alex Gildayc357c472018-03-21 13:54:09 +00001732/** Formatted output of the HOGNormType type.
1733 *
1734 * @param[out] os Output stream
1735 * @param[in] norm_type Type to output
1736 *
1737 * @return Modified output stream.
1738 */
John Richardson25f23682017-11-27 14:35:09 +00001739inline ::std::ostream &operator<<(::std::ostream &os, const HOGNormType &norm_type)
1740{
1741 switch(norm_type)
1742 {
1743 case HOGNormType::L1_NORM:
1744 os << "L1_NORM";
1745 break;
1746 case HOGNormType::L2_NORM:
1747 os << "L2_NORM";
1748 break;
1749 case HOGNormType::L2HYS_NORM:
1750 os << "L2HYS_NORM";
1751 break;
1752 default:
1753 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1754 }
1755
1756 return os;
1757}
1758
Alex Gildayc357c472018-03-21 13:54:09 +00001759/** Formatted output of the HOGNormType type.
1760 *
1761 * @param[in] type Type to output
1762 *
1763 * @return Formatted string.
1764 */
John Richardson25f23682017-11-27 14:35:09 +00001765inline std::string to_string(const HOGNormType &type)
1766{
1767 std::stringstream str;
1768 str << type;
1769 return str.str();
1770}
1771
Alex Gildayc357c472018-03-21 13:54:09 +00001772/** Formatted output of the Size2D type.
1773 *
1774 * @param[out] os Output stream
1775 * @param[in] size Type to output
1776 *
1777 * @return Modified output stream.
1778 */
John Richardson25f23682017-11-27 14:35:09 +00001779inline ::std::ostream &operator<<(::std::ostream &os, const Size2D &size)
1780{
1781 os << size.width << "x" << size.height;
1782
1783 return os;
1784}
1785
Alex Gildayc357c472018-03-21 13:54:09 +00001786/** Formatted output of the Size2D type.
1787 *
1788 * @param[in] type Type to output
1789 *
1790 * @return Formatted string.
1791 */
John Richardson25f23682017-11-27 14:35:09 +00001792inline std::string to_string(const Size2D &type)
1793{
1794 std::stringstream str;
1795 str << type;
1796 return str.str();
1797}
1798
Alex Gildayc357c472018-03-21 13:54:09 +00001799/** Formatted output of the HOGInfo type.
1800 *
1801 * @param[out] os Output stream
1802 * @param[in] hog_info Type to output
1803 *
1804 * @return Modified output stream.
1805 */
John Richardson25f23682017-11-27 14:35:09 +00001806inline ::std::ostream &operator<<(::std::ostream &os, const HOGInfo &hog_info)
1807{
1808 os << "{CellSize=" << hog_info.cell_size() << ","
1809 << "BlockSize=" << hog_info.block_size() << ","
1810 << "DetectionWindowSize=" << hog_info.detection_window_size() << ","
1811 << "BlockStride=" << hog_info.block_stride() << ","
1812 << "NumBins=" << hog_info.num_bins() << ","
1813 << "NormType=" << hog_info.normalization_type() << ","
1814 << "L2HystThreshold=" << hog_info.l2_hyst_threshold() << ","
1815 << "PhaseType=" << hog_info.phase_type() << "}";
1816
1817 return os;
1818}
1819
Alex Gildayc357c472018-03-21 13:54:09 +00001820/** Formatted output of the HOGInfo type.
1821 *
1822 * @param[in] type Type to output
1823 *
1824 * @return Formatted string.
1825 */
John Richardson25f23682017-11-27 14:35:09 +00001826inline std::string to_string(const HOGInfo &type)
1827{
1828 std::stringstream str;
1829 str << type;
1830 return str.str();
1831}
1832
Alex Gildayc357c472018-03-21 13:54:09 +00001833/** Formatted output of the ConvolutionMethod type.
1834 *
1835 * @param[out] os Output stream
1836 * @param[in] conv_method Type to output
1837 *
1838 * @return Modified output stream.
1839 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001840inline ::std::ostream &operator<<(::std::ostream &os, const ConvolutionMethod &conv_method)
1841{
1842 switch(conv_method)
1843 {
1844 case ConvolutionMethod::GEMM:
1845 os << "GEMM";
1846 break;
1847 case ConvolutionMethod::DIRECT:
1848 os << "DIRECT";
1849 break;
1850 case ConvolutionMethod::WINOGRAD:
1851 os << "WINOGRAD";
1852 break;
1853 default:
1854 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1855 }
1856
1857 return os;
1858}
1859
Alex Gildayc357c472018-03-21 13:54:09 +00001860/** Formatted output of the ConvolutionMethod type.
1861 *
1862 * @param[in] conv_method Type to output
1863 *
1864 * @return Formatted string.
1865 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001866inline std::string to_string(const ConvolutionMethod &conv_method)
1867{
1868 std::stringstream str;
1869 str << conv_method;
1870 return str.str();
1871}
1872
Alex Gildayc357c472018-03-21 13:54:09 +00001873/** Formatted output of the GPUTarget type.
1874 *
1875 * @param[out] os Output stream
1876 * @param[in] gpu_target Type to output
1877 *
1878 * @return Modified output stream.
1879 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001880inline ::std::ostream &operator<<(::std::ostream &os, const GPUTarget &gpu_target)
1881{
1882 switch(gpu_target)
1883 {
1884 case GPUTarget::GPU_ARCH_MASK:
1885 os << "GPU_ARCH_MASK";
1886 break;
1887 case GPUTarget::MIDGARD:
1888 os << "MIDGARD";
1889 break;
1890 case GPUTarget::BIFROST:
1891 os << "BIFROST";
1892 break;
1893 case GPUTarget::T600:
1894 os << "T600";
1895 break;
1896 case GPUTarget::T700:
1897 os << "T700";
1898 break;
1899 case GPUTarget::T800:
1900 os << "T800";
1901 break;
Michalis Spyroua9676112018-02-22 18:07:43 +00001902 case GPUTarget::G71:
1903 os << "G71";
1904 break;
1905 case GPUTarget::G72:
1906 os << "G72";
1907 break;
1908 case GPUTarget::G51:
1909 os << "G51";
1910 break;
1911 case GPUTarget::G51BIG:
1912 os << "G51BIG";
1913 break;
1914 case GPUTarget::G51LIT:
1915 os << "G51LIT";
1916 break;
Georgios Pinitasb03f7c52018-07-12 10:49:53 +01001917 case GPUTarget::G76:
1918 os << "G76";
Michalis Spyroua9676112018-02-22 18:07:43 +00001919 break;
1920 case GPUTarget::TTRX:
1921 os << "TTRX";
1922 break;
1923 case GPUTarget::TBOX:
1924 os << "TBOX";
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001925 break;
1926 default:
1927 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1928 }
1929
1930 return os;
1931}
1932
Alex Gildayc357c472018-03-21 13:54:09 +00001933/** Formatted output of the GPUTarget type.
1934 *
1935 * @param[in] gpu_target Type to output
1936 *
1937 * @return Formatted string.
1938 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001939inline std::string to_string(const GPUTarget &gpu_target)
1940{
1941 std::stringstream str;
1942 str << gpu_target;
1943 return str.str();
1944}
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00001945
John Richardson8de92612018-02-22 14:09:31 +00001946/** Formatted output of the DetectionWindow type.
1947 *
1948 * @param[out] os Output stream
1949 * @param[in] detection_window Type to output
1950 *
1951 * @return Modified output stream.
1952 */
John Richardson684cb0f2018-01-09 11:17:00 +00001953inline ::std::ostream &operator<<(::std::ostream &os, const DetectionWindow &detection_window)
1954{
1955 os << "{x=" << detection_window.x << ","
1956 << "y=" << detection_window.y << ","
1957 << "width=" << detection_window.width << ","
1958 << "height=" << detection_window.height << ","
1959 << "idx_class=" << detection_window.idx_class << ","
1960 << "score=" << detection_window.score << "}";
1961
1962 return os;
1963}
1964
Isabella Gottardi05e56442018-11-16 11:26:52 +00001965/** Formatted output of the DetectionOutputLayerCodeType type.
1966 *
1967 * @param[out] os Output stream
1968 * @param[in] detection_code Type to output
1969 *
1970 * @return Modified output stream.
1971 */
1972inline ::std::ostream &operator<<(::std::ostream &os, const DetectionOutputLayerCodeType &detection_code)
1973{
1974 switch(detection_code)
1975 {
1976 case DetectionOutputLayerCodeType::CENTER_SIZE:
1977 os << "CENTER_SIZE";
1978 break;
1979 case DetectionOutputLayerCodeType::CORNER:
1980 os << "CORNER";
1981 break;
1982 case DetectionOutputLayerCodeType::CORNER_SIZE:
1983 os << "CORNER_SIZE";
1984 break;
1985 case DetectionOutputLayerCodeType::TF_CENTER:
1986 os << "TF_CENTER";
1987 break;
1988 default:
1989 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1990 }
1991
1992 return os;
1993}
1994/** Formatted output of the DetectionOutputLayerCodeType type.
1995 *
1996 * @param[in] detection_code Type to output
1997 *
1998 * @return Formatted string.
1999 */
2000inline std::string to_string(const DetectionOutputLayerCodeType &detection_code)
2001{
2002 std::stringstream str;
2003 str << detection_code;
2004 return str.str();
2005}
2006
2007/** Formatted output of the DetectionOutputLayerInfo type.
2008 *
2009 * @param[out] os Output stream
2010 * @param[in] detection_info Type to output
2011 *
2012 * @return Modified output stream.
2013 */
2014inline ::std::ostream &operator<<(::std::ostream &os, const DetectionOutputLayerInfo &detection_info)
2015{
2016 os << "{Classes=" << detection_info.num_classes() << ","
2017 << "ShareLocation=" << detection_info.share_location() << ","
2018 << "CodeType=" << detection_info.code_type() << ","
2019 << "VarianceEncodedInTarget=" << detection_info.variance_encoded_in_target() << ","
2020 << "KeepTopK=" << detection_info.keep_top_k() << ","
2021 << "NMSThreshold=" << detection_info.nms_threshold() << ","
2022 << "Eta=" << detection_info.eta() << ","
2023 << "BackgroundLabelId=" << detection_info.background_label_id() << ","
2024 << "ConfidenceThreshold=" << detection_info.confidence_threshold() << ","
2025 << "TopK=" << detection_info.top_k() << ","
2026 << "NumLocClasses=" << detection_info.num_loc_classes()
2027 << "}";
2028
2029 return os;
2030}
2031
2032/** Formatted output of the DetectionOutputLayerInfo type.
2033 *
2034 * @param[in] detection_info Type to output
2035 *
2036 * @return Formatted string.
2037 */
2038inline std::string to_string(const DetectionOutputLayerInfo &detection_info)
2039{
2040 std::stringstream str;
2041 str << detection_info;
2042 return str.str();
2043}
John Richardson8de92612018-02-22 14:09:31 +00002044/** Formatted output of the DetectionWindow type.
2045 *
2046 * @param[in] detection_window Type to output
2047 *
2048 * @return Formatted string.
2049 */
2050inline std::string to_string(const DetectionWindow &detection_window)
2051{
2052 std::stringstream str;
2053 str << detection_window;
2054 return str.str();
2055}
2056
2057/** Formatted output of the Termination type.
2058 *
2059 * @param[out] os Output stream
2060 * @param[in] termination Type to output
2061 *
2062 * @return Modified output stream.
2063 */
2064inline ::std::ostream &operator<<(::std::ostream &os, const Termination &termination)
2065{
2066 switch(termination)
2067 {
2068 case Termination::TERM_CRITERIA_EPSILON:
2069 os << "TERM_CRITERIA_EPSILON";
2070 break;
2071 case Termination::TERM_CRITERIA_ITERATIONS:
2072 os << "TERM_CRITERIA_ITERATIONS";
2073 break;
2074 case Termination::TERM_CRITERIA_BOTH:
2075 os << "TERM_CRITERIA_BOTH";
2076 break;
2077 default:
2078 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2079 }
2080
2081 return os;
2082}
2083
2084/** Formatted output of the Termination type.
2085 *
2086 * @param[in] termination Type to output
2087 *
2088 * @return Formatted string.
2089 */
2090inline std::string to_string(const Termination &termination)
2091{
2092 std::stringstream str;
2093 str << termination;
2094 return str.str();
2095}
2096
Anthony Barbier8914e322018-08-10 15:28:25 +01002097/** Formatted output of the CPUModel type.
2098 *
2099 * @param[out] os Output stream
2100 * @param[in] cpu_model Model to output
2101 *
2102 * @return Modified output stream.
2103 */
2104inline ::std::ostream &operator<<(::std::ostream &os, const CPUModel &cpu_model)
2105{
2106 switch(cpu_model)
2107 {
2108 case CPUModel::GENERIC:
2109 os << "GENERIC";
2110 break;
2111 case CPUModel::GENERIC_FP16:
2112 os << "GENERIC_FP16";
2113 break;
2114 case CPUModel::GENERIC_FP16_DOT:
2115 os << "GENERIC_FP16_DOT";
2116 break;
2117 case CPUModel::A53:
2118 os << "A53";
2119 break;
2120 case CPUModel::A55r0:
2121 os << "A55r0";
2122 break;
2123 case CPUModel::A55r1:
2124 os << "A55r1";
2125 break;
2126 default:
2127 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2128 }
2129
2130 return os;
2131}
2132
2133/** Formatted output of the CPUModel type.
2134 *
2135 * @param[in] cpu_model Model to output
2136 *
2137 * @return Formatted string.
2138 */
2139inline std::string to_string(const CPUModel &cpu_model)
2140{
2141 std::stringstream str;
2142 str << cpu_model;
2143 return str.str();
2144}
Anthony Barbier671a11e2018-07-06 15:11:36 +01002145/** Formatted output of a vector of objects.
2146 *
2147 * @param[out] os Output stream
2148 * @param[in] args Vector of objects to print
2149 *
2150 * @return Modified output stream.
2151 */
2152template <typename T>
2153inline ::std::ostream &operator<<(::std::ostream &os, const std::vector<T> &args)
2154{
2155 os << "[";
2156 bool first = true;
2157 for(auto &arg : args)
2158 {
2159 if(first)
2160 {
2161 first = false;
2162 }
2163 else
2164 {
2165 os << ", ";
2166 }
2167 os << arg;
2168 }
2169 os << "]";
2170 return os;
2171}
2172
Michalis Spyrou6c7c38e2018-08-29 16:28:11 +01002173/** Formatted output of @ref PriorBoxLayerInfo.
2174 *
2175 * @param[out] os Output stream.
2176 * @param[in] info Type to output.
2177 *
2178 * @return Modified output stream.
2179 */
2180inline ::std::ostream &operator<<(::std::ostream &os, const PriorBoxLayerInfo &info)
2181{
2182 os << "Clip:" << info.clip()
2183 << "Flip:" << info.flip()
2184 << "StepX:" << info.steps()[0]
2185 << "StepY:" << info.steps()[1]
2186 << "MinSizes:" << info.min_sizes()
2187 << "MaxSizes:" << info.max_sizes()
2188 << "ImgSizeX:" << info.img_size().x
2189 << "ImgSizeY:" << info.img_size().y
2190 << "Offset:" << info.offset()
2191 << "Variances:" << info.variances();
2192
2193 return os;
2194}
2195
Anthony Barbier671a11e2018-07-06 15:11:36 +01002196/** Formatted output of a vector of objects.
2197 *
2198 * @param[in] args Vector of objects to print
2199 *
2200 * @return String representing args.
2201 */
2202template <typename T>
2203std::string to_string(const std::vector<T> &args)
2204{
2205 std::stringstream str;
2206 str << args;
2207 return str.str();
2208}
2209
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00002210/** Formatted output of the WinogradInfo type. */
2211inline ::std::ostream &operator<<(::std::ostream &os, const WinogradInfo &info)
2212{
2213 os << "{OutputTileSize=" << info.output_tile_size << ","
2214 << "KernelSize=" << info.kernel_size << ","
2215 << "PadStride=" << info.convolution_info << ","
2216 << "OutputDataLayout=" << info.output_data_layout << "}";
2217
2218 return os;
2219}
2220
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00002221inline std::string to_string(const WinogradInfo &type)
2222{
2223 std::stringstream str;
2224 str << type;
2225 return str.str();
2226}
Anthony Barbier671a11e2018-07-06 15:11:36 +01002227
2228/** Fallback method: try to use std::to_string:
2229 *
2230 * @param[in] val Value to convert to string
2231 *
2232 * @return String representing val.
2233 */
2234template <typename T>
2235inline std::string to_string(const T &val)
2236{
2237 return support::cpp11::to_string(val);
2238}
2239
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +01002240/** Convert a CLTunerMode value to a string
2241 *
2242 * @param val CLTunerMode value to be converted
2243 *
2244 * @return String representing the corresponding CLTunerMode.
2245 */
2246inline std::string to_string(const CLTunerMode val)
2247{
2248 switch(val)
2249 {
2250 case CLTunerMode::EXHAUSTIVE:
2251 {
2252 return std::string("Exhaustive");
2253 }
2254 case CLTunerMode::NORMAL:
2255 {
2256 return std::string("Normal");
2257 }
2258 case CLTunerMode::RAPID:
2259 {
2260 return std::string("Rapid");
2261 }
2262 default:
2263 {
2264 ARM_COMPUTE_ERROR("Invalid tuner mode.");
2265 return std::string("UNDEFINED");
2266 }
2267 }
2268}
2269/** [Print CLTunerMode type] **/
2270/** Formatted output of the CLTunerMode type.
2271 *
2272 * @param[out] os Output stream.
2273 * @param[in] val CLTunerMode to output.
2274 *
2275 * @return Modified output stream.
2276 */
2277inline ::std::ostream &operator<<(::std::ostream &os, const CLTunerMode &val)
2278{
2279 os << to_string(val);
2280 return os;
2281}
2282
Anthony Barbier6ff3b192017-09-04 18:44:23 +01002283} // namespace arm_compute
Anthony Barbier4dbc0a92018-08-27 13:39:47 +01002284
2285#endif /* __ARM_COMPUTE_TYPE_PRINTER_H__ */