blob: 6ba6f45f8c7e0a8ffd9b5e0a238678da4c916291 [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001/*
Manuel Bottinib412fab2018-12-10 17:40:23 +00002 * Copyright (c) 2017-2019 ARM Limited.
Anthony Barbier6ff3b192017-09-04 18:44:23 +01003 *
4 * SPDX-License-Identifier: MIT
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
Anthony Barbier4dbc0a92018-08-27 13:39:47 +010024#ifndef __ARM_COMPUTE_TYPE_PRINTER_H__
25#define __ARM_COMPUTE_TYPE_PRINTER_H__
Anthony Barbier6ff3b192017-09-04 18:44:23 +010026
Anthony Barbier8914e322018-08-10 15:28:25 +010027#include "arm_compute/core/CPP/CPPTypes.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010028#include "arm_compute/core/Dimensions.h"
29#include "arm_compute/core/Error.h"
Michele Di Giorgiob8fc60f2018-04-25 11:58:07 +010030#include "arm_compute/core/GPUTarget.h"
John Richardson25f23682017-11-27 14:35:09 +000031#include "arm_compute/core/HOGInfo.h"
32#include "arm_compute/core/Size2D.h"
John Richardsona36eae12017-09-26 16:55:59 +010033#include "arm_compute/core/Strides.h"
Georgios Pinitas3faea252017-10-30 14:13:50 +000034#include "arm_compute/core/TensorInfo.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010035#include "arm_compute/core/Types.h"
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +010036#include "arm_compute/runtime/CL/CLTunerTypes.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010037
38#include <ostream>
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010039#include <sstream>
40#include <string>
Anthony Barbier6ff3b192017-09-04 18:44:23 +010041
42namespace arm_compute
43{
Anthony Barbierb940fd62018-06-04 14:14:32 +010044/** Formatted output if arg is not null
45 *
46 * @param[in] arg Object to print
47 *
48 * @return String representing arg.
49 */
50template <typename T>
51std::string to_string_if_not_null(T *arg)
52{
53 if(arg == nullptr)
54 {
55 return "nullptr";
56 }
57 else
58 {
59 return to_string(*arg);
60 }
61}
Alex Gildayc357c472018-03-21 13:54:09 +000062/** Formatted output of the Dimensions type.
63 *
64 * @param[out] os Output stream.
65 * @param[in] dimensions Type to output.
66 *
67 * @return Modified output stream.
68 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +010069template <typename T>
70inline ::std::ostream &operator<<(::std::ostream &os, const Dimensions<T> &dimensions)
71{
Anthony Barbier6ff3b192017-09-04 18:44:23 +010072 if(dimensions.num_dimensions() > 0)
73 {
74 os << dimensions[0];
75
76 for(unsigned int d = 1; d < dimensions.num_dimensions(); ++d)
77 {
Moritz Pflanzerc87fbf82017-07-18 14:02:10 +010078 os << "x" << dimensions[d];
Anthony Barbier6ff3b192017-09-04 18:44:23 +010079 }
80 }
81
Anthony Barbier6ff3b192017-09-04 18:44:23 +010082 return os;
83}
84
Alex Gildayc357c472018-03-21 13:54:09 +000085/** Formatted output of the NonLinearFilterFunction type.
86 *
87 * @param[out] os Output stream.
88 * @param[in] function Type to output.
89 *
90 * @return Modified output stream.
91 */
Isabella Gottardi3b77e9d2017-06-22 11:05:41 +010092inline ::std::ostream &operator<<(::std::ostream &os, const NonLinearFilterFunction &function)
93{
94 switch(function)
95 {
96 case NonLinearFilterFunction::MAX:
97 os << "MAX";
98 break;
99 case NonLinearFilterFunction::MEDIAN:
100 os << "MEDIAN";
101 break;
102 case NonLinearFilterFunction::MIN:
103 os << "MIN";
104 break;
105 default:
106 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
107 }
108
109 return os;
110}
111
Alex Gildayc357c472018-03-21 13:54:09 +0000112/** Formatted output of the NonLinearFilterFunction type.
113 *
114 * @param[in] function Type to output.
115 *
116 * @return Formatted string.
117 */
John Richardson6f4d49f2017-09-07 11:21:10 +0100118inline std::string to_string(const NonLinearFilterFunction &function)
119{
120 std::stringstream str;
121 str << function;
122 return str.str();
123}
124
Alex Gildayc357c472018-03-21 13:54:09 +0000125/** Formatted output of the MatrixPattern type.
126 *
127 * @param[out] os Output stream.
128 * @param[in] pattern Type to output.
129 *
130 * @return Modified output stream.
131 */
Isabella Gottardi3b77e9d2017-06-22 11:05:41 +0100132inline ::std::ostream &operator<<(::std::ostream &os, const MatrixPattern &pattern)
133{
134 switch(pattern)
135 {
136 case MatrixPattern::BOX:
137 os << "BOX";
138 break;
139 case MatrixPattern::CROSS:
140 os << "CROSS";
141 break;
142 case MatrixPattern::DISK:
143 os << "DISK";
144 break;
145 case MatrixPattern::OTHER:
146 os << "OTHER";
147 break;
148 default:
149 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
150 }
151
152 return os;
153}
154
Alex Gildayc357c472018-03-21 13:54:09 +0000155/** Formatted output of the MatrixPattern type.
156 *
157 * @param[in] pattern Type to output.
158 *
159 * @return Formatted string.
160 */
John Richardson6f4d49f2017-09-07 11:21:10 +0100161inline std::string to_string(const MatrixPattern &pattern)
162{
163 std::stringstream str;
164 str << pattern;
165 return str.str();
166}
167
Alex Gildayc357c472018-03-21 13:54:09 +0000168/** Formatted output of the RoundingPolicy type.
169 *
170 * @param[out] os Output stream.
171 * @param[in] rounding_policy Type to output.
172 *
173 * @return Modified output stream.
174 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100175inline ::std::ostream &operator<<(::std::ostream &os, const RoundingPolicy &rounding_policy)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100176{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100177 switch(rounding_policy)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100178 {
Anthony Barbier2a07e182017-08-04 18:20:27 +0100179 case RoundingPolicy::TO_ZERO:
180 os << "TO_ZERO";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100181 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100182 case RoundingPolicy::TO_NEAREST_UP:
183 os << "TO_NEAREST_UP";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100184 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100185 case RoundingPolicy::TO_NEAREST_EVEN:
186 os << "TO_NEAREST_EVEN";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100187 break;
188 default:
189 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
190 }
191
192 return os;
193}
194
Alex Gildayc357c472018-03-21 13:54:09 +0000195/** Formatted output of the WeightsInfo type.
196 *
197 * @param[out] os Output stream.
198 * @param[in] weights_info Type to output.
199 *
200 * @return Modified output stream.
201 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100202inline ::std::ostream &operator<<(::std::ostream &os, const WeightsInfo &weights_info)
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100203{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100204 os << weights_info.are_reshaped() << ";";
205 os << weights_info.num_kernels() << ";" << weights_info.kernel_size().first << "," << weights_info.kernel_size().second;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100206
207 return os;
208}
209
Alex Gildayc357c472018-03-21 13:54:09 +0000210/** Formatted output of the ROIPoolingInfo type.
211 *
212 * @param[out] os Output stream.
213 * @param[in] pool_info Type to output.
214 *
215 * @return Modified output stream.
216 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100217inline ::std::ostream &operator<<(::std::ostream &os, const ROIPoolingLayerInfo &pool_info)
Sanghoon Lee70f82912017-08-24 14:21:24 +0100218{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100219 os << pool_info.pooled_width() << "x" << pool_info.pooled_height() << "~" << pool_info.spatial_scale();
Georgios Pinitasd9769582017-08-03 10:19:40 +0100220 return os;
221}
222
giuros0118870812018-09-13 09:31:40 +0100223/** Formatted output of the ROIPoolingInfo type.
224 *
225 * @param[in] pool_info Type to output.
226 *
227 * @return Formatted string.
228 */
229inline std::string to_string(const ROIPoolingLayerInfo &pool_info)
230{
231 std::stringstream str;
232 str << pool_info;
233 return str.str();
234}
235
giuros01c04a0e82018-10-03 12:44:35 +0100236/** Formatted output of the BoundingBoxTransformInfo type.
237 *
238 * @param[out] os Output stream.
239 * @param[in] bbox_info Type to output.
240 *
241 * @return Modified output stream.
242 */
243inline ::std::ostream &operator<<(::std::ostream &os, const BoundingBoxTransformInfo &bbox_info)
244{
245 auto weights = bbox_info.weights();
246 os << "(" << bbox_info.img_width() << "x" << bbox_info.img_height() << ")~" << bbox_info.scale() << "(weights = {" << weights[0] << ", " << weights[1] << ", " << weights[2] << ", " << weights[3] <<
247 "})";
248 return os;
249}
250
251/** Formatted output of the BoundingBoxTransformInfo type.
252 *
253 * @param[in] bbox_info Type to output.
254 *
255 * @return Formatted string.
256 */
257inline std::string to_string(const BoundingBoxTransformInfo &bbox_info)
258{
259 std::stringstream str;
260 str << bbox_info;
261 return str.str();
262}
263
Manuel Bottini5209be52019-02-13 16:34:56 +0000264/** Formatted output of the ComputeAnchorsInfo type.
265 *
266 * @param[out] os Output stream.
267 * @param[in] anchors_info Type to output.
268 *
269 * @return Modified output stream.
270 */
271inline ::std::ostream &operator<<(::std::ostream &os, const ComputeAnchorsInfo &anchors_info)
272{
273 os << "(" << anchors_info.feat_width() << "x" << anchors_info.feat_height() << ")~" << anchors_info.spatial_scale();
274 return os;
275}
276
277/** Formatted output of the ComputeAnchorsInfo type.
278 *
279 * @param[in] anchors_info Type to output.
280 *
281 * @return Formatted string.
282 */
283inline std::string to_string(const ComputeAnchorsInfo &anchors_info)
284{
285 std::stringstream str;
286 str << anchors_info;
287 return str.str();
288}
289
290/** Formatted output of the GenerateProposalsInfo type.
291 *
292 * @param[out] os Output stream.
293 * @param[in] proposals_info Type to output.
294 *
295 * @return Modified output stream.
296 */
297inline ::std::ostream &operator<<(::std::ostream &os, const GenerateProposalsInfo &proposals_info)
298{
299 os << "(" << proposals_info.im_width() << "x" << proposals_info.im_height() << ")~" << proposals_info.im_scale();
300 return os;
301}
302
303/** Formatted output of the GenerateProposalsInfo type.
304 *
305 * @param[in] proposals_info Type to output.
306 *
307 * @return Formatted string.
308 */
309inline std::string to_string(const GenerateProposalsInfo &proposals_info)
310{
311 std::stringstream str;
312 str << proposals_info;
313 return str.str();
314}
315
Alex Gildayc357c472018-03-21 13:54:09 +0000316/** Formatted output of the QuantizationInfo type.
317 *
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100318 * @param[out] os Output stream.
319 * @param[in] qinfo Type to output.
Alex Gildayc357c472018-03-21 13:54:09 +0000320 *
321 * @return Modified output stream.
322 */
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100323inline ::std::ostream &operator<<(::std::ostream &os, const QuantizationInfo &qinfo)
Chunosovd621bca2017-11-03 17:33:15 +0700324{
Georgios Pinitas3d13af82019-06-04 13:04:16 +0100325 const UniformQuantizationInfo uqinfo = qinfo.uniform();
326 os << "Scale:" << uqinfo.scale << "~";
327 os << "Offset:" << uqinfo.offset;
Chunosovd621bca2017-11-03 17:33:15 +0700328 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;
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100622 case DataType::QSYMM8:
623 os << "QSYMM8";
624 break;
Chunosovd621bca2017-11-03 17:33:15 +0700625 case DataType::QASYMM8:
626 os << "QASYMM8";
627 break;
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100628 case DataType::QSYMM8_PER_CHANNEL:
629 os << "QSYMM8_PER_CHANNEL";
630 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100631 case DataType::S8:
632 os << "S8";
633 break;
634 case DataType::U16:
635 os << "U16";
636 break;
637 case DataType::S16:
638 os << "S16";
639 break;
Manuel Bottini3689fcd2019-06-14 17:18:12 +0100640 case DataType::QSYMM16:
641 os << "QSYMM16";
642 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100643 case DataType::U32:
644 os << "U32";
645 break;
646 case DataType::S32:
647 os << "S32";
648 break;
649 case DataType::U64:
650 os << "U64";
651 break;
652 case DataType::S64:
653 os << "S64";
654 break;
655 case DataType::F16:
656 os << "F16";
657 break;
658 case DataType::F32:
659 os << "F32";
660 break;
661 case DataType::F64:
662 os << "F64";
663 break;
664 case DataType::SIZET:
665 os << "SIZET";
666 break;
667 default:
668 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
669 }
670
671 return os;
672}
673
Alex Gildayc357c472018-03-21 13:54:09 +0000674/** Formatted output of the DataType type.
675 *
676 * @param[in] data_type Type to output.
677 *
678 * @return Formatted string.
679 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100680inline std::string to_string(const arm_compute::DataType &data_type)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100681{
682 std::stringstream str;
683 str << data_type;
684 return str.str();
685}
686
Alex Gildayc357c472018-03-21 13:54:09 +0000687/** Formatted output of the Format type.
688 *
689 * @param[out] os Output stream.
690 * @param[in] format Type to output.
691 *
692 * @return Modified output stream.
693 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100694inline ::std::ostream &operator<<(::std::ostream &os, const Format &format)
695{
696 switch(format)
697 {
698 case Format::UNKNOWN:
699 os << "UNKNOWN";
700 break;
701 case Format::U8:
702 os << "U8";
703 break;
704 case Format::S16:
705 os << "S16";
706 break;
707 case Format::U16:
708 os << "U16";
709 break;
710 case Format::S32:
711 os << "S32";
712 break;
713 case Format::U32:
714 os << "U32";
715 break;
716 case Format::F16:
717 os << "F16";
718 break;
719 case Format::F32:
720 os << "F32";
721 break;
722 case Format::UV88:
723 os << "UV88";
724 break;
725 case Format::RGB888:
726 os << "RGB888";
727 break;
728 case Format::RGBA8888:
729 os << "RGBA8888";
730 break;
731 case Format::YUV444:
732 os << "YUV444";
733 break;
734 case Format::YUYV422:
735 os << "YUYV422";
736 break;
737 case Format::NV12:
738 os << "NV12";
739 break;
740 case Format::NV21:
741 os << "NV21";
742 break;
743 case Format::IYUV:
744 os << "IYUV";
745 break;
746 case Format::UYVY422:
747 os << "UYVY422";
748 break;
749 default:
750 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
751 }
752
753 return os;
754}
755
Alex Gildayc357c472018-03-21 13:54:09 +0000756/** Formatted output of the Format type.
757 *
758 * @param[in] format Type to output.
759 *
760 * @return Formatted string.
761 */
Moritz Pflanzer7655a672017-09-23 11:57:33 +0100762inline std::string to_string(const Format &format)
763{
764 std::stringstream str;
765 str << format;
766 return str.str();
767}
768
Alex Gildayc357c472018-03-21 13:54:09 +0000769/** Formatted output of the Channel type.
770 *
771 * @param[out] os Output stream.
772 * @param[in] channel Type to output.
773 *
774 * @return Modified output stream.
775 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100776inline ::std::ostream &operator<<(::std::ostream &os, const Channel &channel)
777{
778 switch(channel)
779 {
780 case Channel::UNKNOWN:
781 os << "UNKNOWN";
782 break;
783 case Channel::C0:
784 os << "C0";
785 break;
786 case Channel::C1:
787 os << "C1";
788 break;
789 case Channel::C2:
790 os << "C2";
791 break;
792 case Channel::C3:
793 os << "C3";
794 break;
795 case Channel::R:
796 os << "R";
797 break;
798 case Channel::G:
799 os << "G";
800 break;
801 case Channel::B:
802 os << "B";
803 break;
804 case Channel::A:
805 os << "A";
806 break;
807 case Channel::Y:
808 os << "Y";
809 break;
810 case Channel::U:
811 os << "U";
812 break;
813 case Channel::V:
814 os << "V";
815 break;
816 default:
817 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
818 }
819
820 return os;
821}
822
Alex Gildayc357c472018-03-21 13:54:09 +0000823/** Formatted output of the Channel type.
824 *
825 * @param[in] channel Type to output.
826 *
827 * @return Formatted string.
828 */
Ioan-Cristian Szabo9414f642017-10-27 17:35:40 +0100829inline std::string to_string(const Channel &channel)
830{
831 std::stringstream str;
832 str << channel;
833 return str.str();
834}
835
Alex Gildayc357c472018-03-21 13:54:09 +0000836/** Formatted output of the BorderMode type.
837 *
838 * @param[out] os Output stream.
839 * @param[in] mode Type to output.
840 *
841 * @return Modified output stream.
842 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100843inline ::std::ostream &operator<<(::std::ostream &os, const BorderMode &mode)
844{
845 switch(mode)
846 {
847 case BorderMode::UNDEFINED:
848 os << "UNDEFINED";
849 break;
850 case BorderMode::CONSTANT:
851 os << "CONSTANT";
852 break;
853 case BorderMode::REPLICATE:
854 os << "REPLICATE";
855 break;
856 default:
857 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
858 }
859
860 return os;
861}
862
Alex Gildayc357c472018-03-21 13:54:09 +0000863/** Formatted output of the BorderSize type.
864 *
865 * @param[out] os Output stream.
866 * @param[in] border Type to output.
867 *
868 * @return Modified output stream.
869 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100870inline ::std::ostream &operator<<(::std::ostream &os, const BorderSize &border)
871{
Moritz Pflanzerc87fbf82017-07-18 14:02:10 +0100872 os << border.top << ","
873 << border.right << ","
874 << border.bottom << ","
875 << border.left;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100876
877 return os;
878}
Anthony Barbier2a07e182017-08-04 18:20:27 +0100879
Giuseppe Rossinid7647d42018-07-17 18:13:13 +0100880/** Formatted output of the PaddingList type.
881 *
882 * @param[out] os Output stream.
883 * @param[in] padding Type to output.
884 *
885 * @return Modified output stream.
886 */
887inline ::std::ostream &operator<<(::std::ostream &os, const PaddingList &padding)
888{
889 os << "{";
890 for(auto const &p : padding)
891 {
892 os << "{" << p.first << "," << p.second << "}";
893 }
894 os << "}";
895 return os;
896}
897
giuros013175fcf2018-11-21 09:59:17 +0000898/** Formatted output of the Multiples type.
899 *
900 * @param[out] os Output stream.
901 * @param[in] multiples Type to output.
902 *
903 * @return Modified output stream.
904 */
905inline ::std::ostream &operator<<(::std::ostream &os, const Multiples &multiples)
906{
907 os << "(";
908 for(size_t i = 0; i < multiples.size() - 1; i++)
909 {
910 os << multiples[i] << ", ";
911 }
912 os << multiples.back() << ")";
913 return os;
914}
915
Alex Gildayc357c472018-03-21 13:54:09 +0000916/** Formatted output of the InterpolationPolicy type.
917 *
918 * @param[out] os Output stream.
919 * @param[in] policy Type to output.
920 *
921 * @return Modified output stream.
922 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100923inline ::std::ostream &operator<<(::std::ostream &os, const InterpolationPolicy &policy)
924{
925 switch(policy)
926 {
927 case InterpolationPolicy::NEAREST_NEIGHBOR:
928 os << "NEAREST_NEIGHBOR";
929 break;
930 case InterpolationPolicy::BILINEAR:
931 os << "BILINEAR";
932 break;
933 case InterpolationPolicy::AREA:
934 os << "AREA";
935 break;
936 default:
937 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
938 }
939
940 return os;
941}
942
Alex Gildayc357c472018-03-21 13:54:09 +0000943/** Formatted output of the SamplingPolicy type.
944 *
945 * @param[out] os Output stream.
946 * @param[in] policy Type to output.
947 *
948 * @return Modified output stream.
949 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700950inline ::std::ostream &operator<<(::std::ostream &os, const SamplingPolicy &policy)
951{
952 switch(policy)
953 {
954 case SamplingPolicy::CENTER:
955 os << "CENTER";
956 break;
957 case SamplingPolicy::TOP_LEFT:
958 os << "TOP_LEFT";
959 break;
960 default:
961 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
962 }
963
964 return os;
965}
966
Alex Gildayc357c472018-03-21 13:54:09 +0000967/** Formatted output of the TensorInfo type.
968 *
Anthony Barbier366628a2018-08-01 13:55:03 +0100969 * @param[out] os Output stream.
970 * @param[in] info Type to output.
971 *
972 * @return Modified output stream.
973 */
974inline ::std::ostream &operator<<(::std::ostream &os, const TensorInfo &info)
975{
976 os << "{Shape=" << info.tensor_shape() << ","
977 << "Type=" << info.data_type() << ","
978 << "Channels=" << info.num_channels() << "}";
979 return os;
980}
981/** Formatted output of the TensorInfo type.
982 *
Alex Gildayc357c472018-03-21 13:54:09 +0000983 * @param[in] info Type to output.
984 *
985 * @return Formatted string.
986 */
Georgios Pinitas3faea252017-10-30 14:13:50 +0000987inline std::string to_string(const TensorInfo &info)
988{
989 std::stringstream str;
Anthony Barbier366628a2018-08-01 13:55:03 +0100990 str << info;
Georgios Pinitas3faea252017-10-30 14:13:50 +0000991 return str.str();
992}
993
Alex Gildayc357c472018-03-21 13:54:09 +0000994/** Formatted output of the Dimensions type.
995 *
996 * @param[in] dimensions Type to output.
997 *
998 * @return Formatted string.
999 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001000template <typename T>
1001inline std::string to_string(const Dimensions<T> &dimensions)
1002{
1003 std::stringstream str;
1004 str << dimensions;
1005 return str.str();
1006}
1007
Alex Gildayc357c472018-03-21 13:54:09 +00001008/** Formatted output of the Strides type.
1009 *
1010 * @param[in] stride Type to output.
1011 *
1012 * @return Formatted string.
1013 */
John Richardsona36eae12017-09-26 16:55:59 +01001014inline std::string to_string(const Strides &stride)
1015{
1016 std::stringstream str;
1017 str << stride;
1018 return str.str();
1019}
1020
Alex Gildayc357c472018-03-21 13:54:09 +00001021/** Formatted output of the TensorShape type.
1022 *
1023 * @param[in] shape Type to output.
1024 *
1025 * @return Formatted string.
1026 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001027inline std::string to_string(const TensorShape &shape)
1028{
1029 std::stringstream str;
1030 str << shape;
1031 return str.str();
1032}
1033
Alex Gildayc357c472018-03-21 13:54:09 +00001034/** Formatted output of the Coordinates type.
1035 *
1036 * @param[in] coord Type to output.
1037 *
1038 * @return Formatted string.
1039 */
Abe Mbise925ca0f2017-10-02 19:16:33 +01001040inline std::string to_string(const Coordinates &coord)
1041{
1042 std::stringstream str;
1043 str << coord;
1044 return str.str();
1045}
1046
Anthony Barbierb940fd62018-06-04 14:14:32 +01001047/** Formatted output of the GEMMReshapeInfo type.
1048 *
1049 * @param[out] os Output stream.
1050 * @param[in] info Type to output.
1051 *
1052 * @return Modified output stream.
1053 */
1054inline ::std::ostream &operator<<(::std::ostream &os, const GEMMReshapeInfo &info)
1055{
1056 os << "{m=" << info.m() << ",";
1057 os << "n=" << info.n() << ",";
1058 os << "k=" << info.k() << ",";
1059 os << "mult_transpose1xW_width=" << info.mult_transpose1xW_width() << ",";
1060 os << "mult_interleave4x4_height=" << info.mult_interleave4x4_height();
1061 os << "}";
1062
1063 return os;
1064}
1065
1066/** Formatted output of the GEMMInfo type.
1067 *
1068 * @param[out] os Output stream.
1069 * @param[in] info Type to output.
1070 *
1071 * @return Modified output stream.
1072 */
1073inline ::std::ostream &operator<<(::std::ostream &os, const GEMMInfo &info)
1074{
1075 os << "{is_a_reshaped=" << info.is_a_reshaped() << ",";
1076 os << "is_b_reshaped=" << info.is_b_reshaped() << ",";
1077 os << "reshape_b_only_on_first_run=" << info.reshape_b_only_on_first_run() << ",";
Anthony Barbierb940fd62018-06-04 14:14:32 +01001078 os << "}";
1079
1080 return os;
1081}
1082
1083/** Formatted output of the Window::Dimension type.
1084 *
1085 * @param[out] os Output stream.
1086 * @param[in] dim Type to output.
1087 *
1088 * @return Modified output stream.
1089 */
1090inline ::std::ostream &operator<<(::std::ostream &os, const Window::Dimension &dim)
1091{
1092 os << "{start=" << dim.start() << ", end=" << dim.end() << ", step=" << dim.step() << "}";
1093
1094 return os;
1095}
1096/** Formatted output of the Window type.
1097 *
1098 * @param[out] os Output stream.
1099 * @param[in] win Type to output.
1100 *
1101 * @return Modified output stream.
1102 */
1103inline ::std::ostream &operator<<(::std::ostream &os, const Window &win)
1104{
1105 os << "{";
1106 for(unsigned int i = 0; i < Coordinates::num_max_dimensions; i++)
1107 {
1108 if(i > 0)
1109 {
1110 os << ", ";
1111 }
1112 os << win[i];
1113 }
1114 os << "}";
1115
1116 return os;
1117}
1118
1119/** Formatted output of the WeightsInfo type.
1120 *
1121 * @param[in] info Type to output.
1122 *
1123 * @return Formatted string.
1124 */
1125inline std::string to_string(const WeightsInfo &info)
1126{
1127 std::stringstream str;
1128 str << info;
1129 return str.str();
1130}
1131
1132/** Formatted output of the GEMMReshapeInfo type.
1133 *
1134 * @param[in] info Type to output.
1135 *
1136 * @return Formatted string.
1137 */
1138inline std::string to_string(const GEMMReshapeInfo &info)
1139{
1140 std::stringstream str;
1141 str << info;
1142 return str.str();
1143}
1144
1145/** Formatted output of the GEMMInfo type.
1146 *
1147 * @param[in] info Type to output.
1148 *
1149 * @return Formatted string.
1150 */
1151inline std::string to_string(const GEMMInfo &info)
1152{
1153 std::stringstream str;
1154 str << info;
1155 return str.str();
1156}
1157
1158/** Formatted output of the Window::Dimension type.
1159 *
1160 * @param[in] dim Type to output.
1161 *
1162 * @return Formatted string.
1163 */
1164inline std::string to_string(const Window::Dimension &dim)
1165{
1166 std::stringstream str;
1167 str << dim;
1168 return str.str();
1169}
1170/** Formatted output of the Window type.
1171 *
1172 * @param[in] win Type to output.
1173 *
1174 * @return Formatted string.
1175 */
1176inline std::string to_string(const Window &win)
1177{
1178 std::stringstream str;
1179 str << win;
1180 return str.str();
1181}
1182
Alex Gildayc357c472018-03-21 13:54:09 +00001183/** Formatted output of the Rectangle type.
1184 *
1185 * @param[out] os Output stream.
1186 * @param[in] rect Type to output.
1187 *
1188 * @return Modified output stream.
1189 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001190inline ::std::ostream &operator<<(::std::ostream &os, const Rectangle &rect)
1191{
1192 os << rect.width << "x" << rect.height;
1193 os << "+" << rect.x << "+" << rect.y;
1194
1195 return os;
1196}
1197
Usama Arif8cf8c112019-03-14 15:36:54 +00001198/** Formatted output of the PaddingMode type.
1199 *
1200 * @param[out] os Output stream.
1201 * @param[in] mode Type to output.
1202 *
1203 * @return Modified output stream.
1204 */
1205inline ::std::ostream &operator<<(::std::ostream &os, const PaddingMode &mode)
1206{
1207 switch(mode)
1208 {
1209 case PaddingMode::CONSTANT:
1210 os << "CONSTANT";
1211 break;
1212 case PaddingMode::REFLECT:
1213 os << "REFLECT";
1214 break;
1215 case PaddingMode::SYMMETRIC:
1216 os << "SYMMETRIC";
1217 break;
1218 default:
1219 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1220 }
1221
1222 return os;
1223}
1224
1225/** Formatted output of the PaddingMode type.
1226 *
1227 * @param[in] mode Type to output.
1228 *
1229 * @return Formatted string.
1230 */
1231inline std::string to_string(const PaddingMode &mode)
1232{
1233 std::stringstream str;
1234 str << mode;
1235 return str.str();
1236}
1237
Alex Gildayc357c472018-03-21 13:54:09 +00001238/** Formatted output of the PadStrideInfo type.
1239 *
1240 * @param[out] os Output stream.
1241 * @param[in] pad_stride_info Type to output.
1242 *
1243 * @return Modified output stream.
1244 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001245inline ::std::ostream &operator<<(::std::ostream &os, const PadStrideInfo &pad_stride_info)
1246{
1247 os << pad_stride_info.stride().first << "," << pad_stride_info.stride().second;
1248 os << ";";
Jaroslaw Rzepeckia1ed41f2017-10-13 11:13:58 +01001249 os << pad_stride_info.pad_left() << "," << pad_stride_info.pad_right() << ","
1250 << pad_stride_info.pad_top() << "," << pad_stride_info.pad_bottom();
Anthony Barbier2a07e182017-08-04 18:20:27 +01001251
1252 return os;
1253}
1254
Alex Gildayc357c472018-03-21 13:54:09 +00001255/** Formatted output of the PadStrideInfo type.
1256 *
1257 * @param[in] pad_stride_info Type to output.
1258 *
1259 * @return Formatted string.
1260 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001261inline std::string to_string(const PadStrideInfo &pad_stride_info)
1262{
1263 std::stringstream str;
1264 str << pad_stride_info;
1265 return str.str();
1266}
1267
Alex Gildayc357c472018-03-21 13:54:09 +00001268/** Formatted output of the BorderMode type.
1269 *
1270 * @param[in] mode Type to output.
1271 *
1272 * @return Formatted string.
1273 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001274inline std::string to_string(const BorderMode &mode)
1275{
1276 std::stringstream str;
1277 str << mode;
1278 return str.str();
1279}
1280
Alex Gildayc357c472018-03-21 13:54:09 +00001281/** Formatted output of the BorderSize type.
1282 *
1283 * @param[in] border Type to output.
1284 *
1285 * @return Formatted string.
1286 */
John Richardsonb482ce12017-09-18 12:44:01 +01001287inline std::string to_string(const BorderSize &border)
1288{
1289 std::stringstream str;
1290 str << border;
1291 return str.str();
1292}
1293
Giuseppe Rossinid7647d42018-07-17 18:13:13 +01001294/** Formatted output of the PaddingList type.
1295 *
1296 * @param[in] padding Type to output.
1297 *
1298 * @return Formatted string.
1299 */
1300inline std::string to_string(const PaddingList &padding)
1301{
1302 std::stringstream str;
1303 str << padding;
1304 return str.str();
1305}
1306
giuros013175fcf2018-11-21 09:59:17 +00001307/** Formatted output of the Multiples type.
1308 *
1309 * @param[in] multiples Type to output.
1310 *
1311 * @return Formatted string.
1312 */
1313inline std::string to_string(const Multiples &multiples)
1314{
1315 std::stringstream str;
1316 str << multiples;
1317 return str.str();
1318}
1319
Alex Gildayc357c472018-03-21 13:54:09 +00001320/** Formatted output of the InterpolationPolicy type.
1321 *
1322 * @param[in] policy Type to output.
1323 *
1324 * @return Formatted string.
1325 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001326inline std::string to_string(const InterpolationPolicy &policy)
1327{
1328 std::stringstream str;
1329 str << policy;
1330 return str.str();
1331}
1332
Alex Gildayc357c472018-03-21 13:54:09 +00001333/** Formatted output of the SamplingPolicy type.
1334 *
1335 * @param[in] policy Type to output.
1336 *
1337 * @return Formatted string.
1338 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +07001339inline std::string to_string(const SamplingPolicy &policy)
1340{
1341 std::stringstream str;
1342 str << policy;
1343 return str.str();
1344}
1345
Alex Gildayc357c472018-03-21 13:54:09 +00001346/** Formatted output of the ConvertPolicy type.
1347 *
1348 * @param[out] os Output stream.
1349 * @param[in] policy Type to output.
1350 *
1351 * @return Modified output stream.
1352 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001353inline ::std::ostream &operator<<(::std::ostream &os, const ConvertPolicy &policy)
1354{
1355 switch(policy)
1356 {
1357 case ConvertPolicy::WRAP:
1358 os << "WRAP";
1359 break;
1360 case ConvertPolicy::SATURATE:
1361 os << "SATURATE";
1362 break;
1363 default:
1364 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1365 }
1366
1367 return os;
1368}
1369
1370inline std::string to_string(const ConvertPolicy &policy)
1371{
1372 std::stringstream str;
1373 str << policy;
1374 return str.str();
1375}
1376
giuros01164a2722018-11-20 18:34:46 +00001377/** Formatted output of the ArithmeticOperation type.
1378 *
1379 * @param[out] os Output stream.
1380 * @param[in] op Operation to output.
1381 *
1382 * @return Modified output stream.
1383 */
1384inline ::std::ostream &operator<<(::std::ostream &os, const ArithmeticOperation &op)
1385{
1386 switch(op)
1387 {
1388 case ArithmeticOperation::ADD:
1389 os << "ADD";
1390 break;
1391 case ArithmeticOperation::SUB:
1392 os << "SUB";
1393 break;
1394 case ArithmeticOperation::DIV:
1395 os << "DIV";
1396 break;
1397 case ArithmeticOperation::MAX:
1398 os << "MAX";
1399 break;
1400 case ArithmeticOperation::MIN:
1401 os << "MIN";
1402 break;
1403 case ArithmeticOperation::SQUARED_DIFF:
1404 os << "SQUARED_DIFF";
1405 break;
Usama Arif52c54f62019-05-14 10:22:36 +01001406 case ArithmeticOperation::POWER:
1407 os << "POWER";
1408 break;
giuros01164a2722018-11-20 18:34:46 +00001409 default:
1410 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1411 }
1412
1413 return os;
1414}
1415
1416/** Formatted output of the Arithmetic Operation
1417 *
1418 * @param[in] op Type to output.
1419 *
1420 * @return Formatted string.
1421 */
1422inline std::string to_string(const ArithmeticOperation &op)
1423{
1424 std::stringstream str;
1425 str << op;
1426 return str.str();
1427}
1428
Alex Gildayc357c472018-03-21 13:54:09 +00001429/** Formatted output of the Reduction Operations.
1430 *
1431 * @param[out] os Output stream.
1432 * @param[in] op Type to output.
1433 *
1434 * @return Modified output stream.
1435 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001436inline ::std::ostream &operator<<(::std::ostream &os, const ReductionOperation &op)
1437{
1438 switch(op)
1439 {
Michalis Spyrou7e9391b2018-10-05 14:49:28 +01001440 case ReductionOperation::SUM:
1441 os << "SUM";
1442 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +01001443 case ReductionOperation::SUM_SQUARE:
1444 os << "SUM_SQUARE";
1445 break;
Michalis Spyrou7e9391b2018-10-05 14:49:28 +01001446 case ReductionOperation::MEAN_SUM:
1447 os << "MEAN_SUM";
1448 break;
Michalis Spyrou7930db42018-11-22 17:36:28 +00001449 case ReductionOperation::ARG_IDX_MAX:
1450 os << "ARG_IDX_MAX";
1451 break;
1452 case ReductionOperation::ARG_IDX_MIN:
1453 os << "ARG_IDX_MIN";
1454 break;
Manuel Bottinib412fab2018-12-10 17:40:23 +00001455 case ReductionOperation::PROD:
1456 os << "PROD";
1457 break;
Usama Arifa4a08ad2019-05-20 12:38:33 +01001458 case ReductionOperation::MIN:
1459 os << "MIN";
1460 break;
Usama Arif28f0dd92019-05-20 13:44:34 +01001461 case ReductionOperation::MAX:
1462 os << "MAX";
1463 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +01001464 default:
1465 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1466 }
1467
1468 return os;
1469}
1470
Alex Gildayc357c472018-03-21 13:54:09 +00001471/** Formatted output of the Reduction Operations.
1472 *
1473 * @param[in] op Type to output.
1474 *
1475 * @return Formatted string.
1476 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001477inline std::string to_string(const ReductionOperation &op)
1478{
1479 std::stringstream str;
1480 str << op;
1481 return str.str();
1482}
1483
Georgios Pinitas7900a9e2018-11-23 11:44:58 +00001484/** Formatted output of the Comparison Operations.
1485 *
1486 * @param[out] os Output stream.
1487 * @param[in] op Type to output.
1488 *
1489 * @return Modified output stream.
1490 */
1491inline ::std::ostream &operator<<(::std::ostream &os, const ComparisonOperation &op)
1492{
1493 switch(op)
1494 {
1495 case ComparisonOperation::Equal:
1496 os << "Equal";
1497 break;
1498 case ComparisonOperation::NotEqual:
1499 os << "NotEqual";
1500 break;
1501 case ComparisonOperation::Greater:
1502 os << "Greater";
1503 break;
1504 case ComparisonOperation::GreaterEqual:
1505 os << "GreaterEqual";
1506 break;
1507 case ComparisonOperation::Less:
1508 os << "Less";
1509 break;
1510 case ComparisonOperation::LessEqual:
1511 os << "LessEqual";
1512 break;
1513 default:
1514 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1515 }
1516
1517 return os;
1518}
1519
Michalis Spyroue9362622018-11-23 17:41:37 +00001520/** Formatted output of the Elementwise unary Operations.
1521 *
1522 * @param[out] os Output stream.
1523 * @param[in] op Type to output.
1524 *
1525 * @return Modified output stream.
1526 */
1527inline ::std::ostream &operator<<(::std::ostream &os, const ElementWiseUnary &op)
1528{
1529 switch(op)
1530 {
1531 case ElementWiseUnary::RSQRT:
1532 os << "RSQRT";
1533 break;
1534 case ElementWiseUnary::EXP:
1535 os << "EXP";
1536 break;
Usama Arifeb312ef2019-05-13 17:45:54 +01001537 case ElementWiseUnary::NEG:
1538 os << "NEG";
1539 break;
Usama Arifac33d7e2019-05-20 14:21:40 +01001540 case ElementWiseUnary::LOG:
1541 os << "LOG";
1542 break;
Usama Arif6a4d5422019-05-24 14:53:59 +01001543 case ElementWiseUnary::ROUND:
1544 os << "ROUND";
1545 break;
Michalis Spyroue9362622018-11-23 17:41:37 +00001546 default:
1547 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1548 }
1549
1550 return os;
1551}
1552
Georgios Pinitas7900a9e2018-11-23 11:44:58 +00001553/** Formatted output of the Comparison Operations.
1554 *
1555 * @param[in] op Type to output.
1556 *
1557 * @return Formatted string.
1558 */
1559inline std::string to_string(const ComparisonOperation &op)
1560{
1561 std::stringstream str;
1562 str << op;
1563 return str.str();
1564}
1565
Michalis Spyroue9362622018-11-23 17:41:37 +00001566/** Formatted output of the Elementwise unary Operations.
1567 *
1568 * @param[in] op Type to output.
1569 *
1570 * @return Formatted string.
1571 */
1572inline std::string to_string(const ElementWiseUnary &op)
1573{
1574 std::stringstream str;
1575 str << op;
1576 return str.str();
1577}
1578
Alex Gildayc357c472018-03-21 13:54:09 +00001579/** Formatted output of the Norm Type.
1580 *
1581 * @param[in] type Type to output.
1582 *
1583 * @return Formatted string.
1584 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001585inline std::string to_string(const NormType &type)
1586{
1587 std::stringstream str;
1588 str << type;
1589 return str.str();
1590}
1591
Alex Gildayc357c472018-03-21 13:54:09 +00001592/** Formatted output of the Pooling Type.
1593 *
1594 * @param[in] type Type to output.
1595 *
1596 * @return Formatted string.
1597 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001598inline std::string to_string(const PoolingType &type)
1599{
1600 std::stringstream str;
1601 str << type;
1602 return str.str();
1603}
1604
Alex Gildayc357c472018-03-21 13:54:09 +00001605/** Formatted output of the Pooling Layer Info.
1606 *
1607 * @param[in] info Type to output.
1608 *
1609 * @return Formatted string.
1610 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001611inline std::string to_string(const PoolingLayerInfo &info)
1612{
1613 std::stringstream str;
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001614 str << "{Type=" << info.pool_type() << ","
1615 << "IsGlobalPooling=" << info.is_global_pooling();
1616 if(!info.is_global_pooling())
1617 {
1618 str << ","
Isabella Gottardi6e464c32018-01-26 12:32:45 +00001619 << "PoolSize=" << info.pool_size().width << "," << info.pool_size().height << ","
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001620 << "PadStride=" << info.pad_stride_info();
1621 }
1622 str << "}";
Anthony Barbier2a07e182017-08-04 18:20:27 +01001623 return str.str();
1624}
1625
Michalis Spyrou6c7c38e2018-08-29 16:28:11 +01001626/** Formatted output of the PriorBoxLayerInfo.
1627 *
1628 * @param[in] info Type to output.
1629 *
1630 * @return Formatted string.
1631 */
1632inline std::string to_string(const PriorBoxLayerInfo &info)
1633{
1634 std::stringstream str;
1635 str << "{";
1636 str << "Clip:" << info.clip()
1637 << "Flip:" << info.flip()
1638 << "StepX:" << info.steps()[0]
1639 << "StepY:" << info.steps()[1]
1640 << "MinSizes:" << info.min_sizes().size()
1641 << "MaxSizes:" << info.max_sizes().size()
1642 << "ImgSizeX:" << info.img_size().x
1643 << "ImgSizeY:" << info.img_size().y
1644 << "Offset:" << info.offset()
1645 << "Variances:" << info.variances().size();
1646 str << "}";
1647 return str.str();
1648}
1649
Alex Gildayc357c472018-03-21 13:54:09 +00001650/** Formatted output of the KeyPoint type.
1651 *
1652 * @param[out] os Output stream
1653 * @param[in] point Type to output.
1654 *
1655 * @return Modified output stream.
1656 */
Moritz Pflanzer6c6597c2017-09-24 12:09:41 +01001657inline ::std::ostream &operator<<(::std::ostream &os, const KeyPoint &point)
1658{
1659 os << "{x=" << point.x << ","
1660 << "y=" << point.y << ","
1661 << "strength=" << point.strength << ","
1662 << "scale=" << point.scale << ","
1663 << "orientation=" << point.orientation << ","
1664 << "tracking_status=" << point.tracking_status << ","
1665 << "error=" << point.error << "}";
1666
1667 return os;
1668}
John Richardson63e50412017-10-13 20:51:42 +01001669
Alex Gildayc357c472018-03-21 13:54:09 +00001670/** Formatted output of the PhaseType type.
1671 *
1672 * @param[out] os Output stream
1673 * @param[in] phase_type Type to output.
1674 *
1675 * @return Modified output stream.
1676 */
John Richardson63e50412017-10-13 20:51:42 +01001677inline ::std::ostream &operator<<(::std::ostream &os, const PhaseType &phase_type)
1678{
1679 switch(phase_type)
1680 {
1681 case PhaseType::SIGNED:
1682 os << "SIGNED";
1683 break;
1684 case PhaseType::UNSIGNED:
1685 os << "UNSIGNED";
1686 break;
1687 default:
1688 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1689 }
1690
1691 return os;
1692}
1693
Alex Gildayc357c472018-03-21 13:54:09 +00001694/** Formatted output of the PhaseType type.
1695 *
1696 * @param[in] type Type to output.
1697 *
1698 * @return Formatted string.
1699 */
John Richardson63e50412017-10-13 20:51:42 +01001700inline std::string to_string(const arm_compute::PhaseType &type)
1701{
1702 std::stringstream str;
1703 str << type;
1704 return str.str();
1705}
John Richardson3c5f9492017-10-04 15:27:37 +01001706
Alex Gildayc357c472018-03-21 13:54:09 +00001707/** Formatted output of the MagnitudeType type.
1708 *
1709 * @param[out] os Output stream
1710 * @param[in] magnitude_type Type to output.
1711 *
1712 * @return Modified output stream.
1713 */
John Richardson3c5f9492017-10-04 15:27:37 +01001714inline ::std::ostream &operator<<(::std::ostream &os, const MagnitudeType &magnitude_type)
1715{
1716 switch(magnitude_type)
1717 {
1718 case MagnitudeType::L1NORM:
1719 os << "L1NORM";
1720 break;
1721 case MagnitudeType::L2NORM:
1722 os << "L2NORM";
1723 break;
1724 default:
1725 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1726 }
1727
1728 return os;
1729}
1730
Alex Gildayc357c472018-03-21 13:54:09 +00001731/** Formatted output of the MagnitudeType type.
1732 *
1733 * @param[in] type Type to output.
1734 *
1735 * @return Formatted string.
1736 */
John Richardson3c5f9492017-10-04 15:27:37 +01001737inline std::string to_string(const arm_compute::MagnitudeType &type)
1738{
1739 std::stringstream str;
1740 str << type;
1741 return str.str();
1742}
John Richardson1c529922017-11-01 10:57:48 +00001743
Alex Gildayc357c472018-03-21 13:54:09 +00001744/** Formatted output of the HOGNormType type.
1745 *
1746 * @param[out] os Output stream
1747 * @param[in] norm_type Type to output
1748 *
1749 * @return Modified output stream.
1750 */
John Richardson25f23682017-11-27 14:35:09 +00001751inline ::std::ostream &operator<<(::std::ostream &os, const HOGNormType &norm_type)
1752{
1753 switch(norm_type)
1754 {
1755 case HOGNormType::L1_NORM:
1756 os << "L1_NORM";
1757 break;
1758 case HOGNormType::L2_NORM:
1759 os << "L2_NORM";
1760 break;
1761 case HOGNormType::L2HYS_NORM:
1762 os << "L2HYS_NORM";
1763 break;
1764 default:
1765 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1766 }
1767
1768 return os;
1769}
1770
Alex Gildayc357c472018-03-21 13:54:09 +00001771/** Formatted output of the HOGNormType type.
1772 *
1773 * @param[in] type Type to output
1774 *
1775 * @return Formatted string.
1776 */
John Richardson25f23682017-11-27 14:35:09 +00001777inline std::string to_string(const HOGNormType &type)
1778{
1779 std::stringstream str;
1780 str << type;
1781 return str.str();
1782}
1783
Alex Gildayc357c472018-03-21 13:54:09 +00001784/** Formatted output of the Size2D type.
1785 *
1786 * @param[out] os Output stream
1787 * @param[in] size Type to output
1788 *
1789 * @return Modified output stream.
1790 */
John Richardson25f23682017-11-27 14:35:09 +00001791inline ::std::ostream &operator<<(::std::ostream &os, const Size2D &size)
1792{
1793 os << size.width << "x" << size.height;
1794
1795 return os;
1796}
1797
Alex Gildayc357c472018-03-21 13:54:09 +00001798/** Formatted output of the Size2D type.
1799 *
1800 * @param[in] type Type to output
1801 *
1802 * @return Formatted string.
1803 */
John Richardson25f23682017-11-27 14:35:09 +00001804inline std::string to_string(const Size2D &type)
1805{
1806 std::stringstream str;
1807 str << type;
1808 return str.str();
1809}
1810
Alex Gildayc357c472018-03-21 13:54:09 +00001811/** Formatted output of the HOGInfo type.
1812 *
1813 * @param[out] os Output stream
1814 * @param[in] hog_info Type to output
1815 *
1816 * @return Modified output stream.
1817 */
John Richardson25f23682017-11-27 14:35:09 +00001818inline ::std::ostream &operator<<(::std::ostream &os, const HOGInfo &hog_info)
1819{
1820 os << "{CellSize=" << hog_info.cell_size() << ","
1821 << "BlockSize=" << hog_info.block_size() << ","
1822 << "DetectionWindowSize=" << hog_info.detection_window_size() << ","
1823 << "BlockStride=" << hog_info.block_stride() << ","
1824 << "NumBins=" << hog_info.num_bins() << ","
1825 << "NormType=" << hog_info.normalization_type() << ","
1826 << "L2HystThreshold=" << hog_info.l2_hyst_threshold() << ","
1827 << "PhaseType=" << hog_info.phase_type() << "}";
1828
1829 return os;
1830}
1831
Alex Gildayc357c472018-03-21 13:54:09 +00001832/** Formatted output of the HOGInfo type.
1833 *
1834 * @param[in] type Type to output
1835 *
1836 * @return Formatted string.
1837 */
John Richardson25f23682017-11-27 14:35:09 +00001838inline std::string to_string(const HOGInfo &type)
1839{
1840 std::stringstream str;
1841 str << type;
1842 return str.str();
1843}
1844
Alex Gildayc357c472018-03-21 13:54:09 +00001845/** Formatted output of the ConvolutionMethod type.
1846 *
1847 * @param[out] os Output stream
1848 * @param[in] conv_method Type to output
1849 *
1850 * @return Modified output stream.
1851 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001852inline ::std::ostream &operator<<(::std::ostream &os, const ConvolutionMethod &conv_method)
1853{
1854 switch(conv_method)
1855 {
1856 case ConvolutionMethod::GEMM:
1857 os << "GEMM";
1858 break;
1859 case ConvolutionMethod::DIRECT:
1860 os << "DIRECT";
1861 break;
1862 case ConvolutionMethod::WINOGRAD:
1863 os << "WINOGRAD";
1864 break;
1865 default:
1866 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1867 }
1868
1869 return os;
1870}
1871
Alex Gildayc357c472018-03-21 13:54:09 +00001872/** Formatted output of the ConvolutionMethod type.
1873 *
1874 * @param[in] conv_method Type to output
1875 *
1876 * @return Formatted string.
1877 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001878inline std::string to_string(const ConvolutionMethod &conv_method)
1879{
1880 std::stringstream str;
1881 str << conv_method;
1882 return str.str();
1883}
1884
Alex Gildayc357c472018-03-21 13:54:09 +00001885/** Formatted output of the GPUTarget type.
1886 *
1887 * @param[out] os Output stream
1888 * @param[in] gpu_target Type to output
1889 *
1890 * @return Modified output stream.
1891 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001892inline ::std::ostream &operator<<(::std::ostream &os, const GPUTarget &gpu_target)
1893{
1894 switch(gpu_target)
1895 {
1896 case GPUTarget::GPU_ARCH_MASK:
1897 os << "GPU_ARCH_MASK";
1898 break;
1899 case GPUTarget::MIDGARD:
1900 os << "MIDGARD";
1901 break;
1902 case GPUTarget::BIFROST:
1903 os << "BIFROST";
1904 break;
Georgios Pinitasd5462ff2019-07-03 19:33:57 +01001905 case GPUTarget::VALHALL:
1906 os << "VALHALL";
1907 break;
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001908 case GPUTarget::T600:
1909 os << "T600";
1910 break;
1911 case GPUTarget::T700:
1912 os << "T700";
1913 break;
1914 case GPUTarget::T800:
1915 os << "T800";
1916 break;
Michalis Spyroua9676112018-02-22 18:07:43 +00001917 case GPUTarget::G71:
1918 os << "G71";
1919 break;
1920 case GPUTarget::G72:
1921 os << "G72";
1922 break;
1923 case GPUTarget::G51:
1924 os << "G51";
1925 break;
1926 case GPUTarget::G51BIG:
1927 os << "G51BIG";
1928 break;
1929 case GPUTarget::G51LIT:
1930 os << "G51LIT";
1931 break;
Georgios Pinitasb03f7c52018-07-12 10:49:53 +01001932 case GPUTarget::G76:
1933 os << "G76";
Michalis Spyroua9676112018-02-22 18:07:43 +00001934 break;
Georgios Pinitasd5462ff2019-07-03 19:33:57 +01001935 case GPUTarget::G77:
1936 os << "G77";
Michalis Spyroua9676112018-02-22 18:07:43 +00001937 break;
1938 case GPUTarget::TBOX:
1939 os << "TBOX";
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001940 break;
Georgios Pinitasd5462ff2019-07-03 19:33:57 +01001941 case GPUTarget::TODX:
1942 os << "TODX";
1943 break;
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001944 default:
1945 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1946 }
1947
1948 return os;
1949}
1950
Alex Gildayc357c472018-03-21 13:54:09 +00001951/** Formatted output of the GPUTarget type.
1952 *
1953 * @param[in] gpu_target Type to output
1954 *
1955 * @return Formatted string.
1956 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001957inline std::string to_string(const GPUTarget &gpu_target)
1958{
1959 std::stringstream str;
1960 str << gpu_target;
1961 return str.str();
1962}
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00001963
John Richardson8de92612018-02-22 14:09:31 +00001964/** Formatted output of the DetectionWindow type.
1965 *
1966 * @param[out] os Output stream
1967 * @param[in] detection_window Type to output
1968 *
1969 * @return Modified output stream.
1970 */
John Richardson684cb0f2018-01-09 11:17:00 +00001971inline ::std::ostream &operator<<(::std::ostream &os, const DetectionWindow &detection_window)
1972{
1973 os << "{x=" << detection_window.x << ","
1974 << "y=" << detection_window.y << ","
1975 << "width=" << detection_window.width << ","
1976 << "height=" << detection_window.height << ","
1977 << "idx_class=" << detection_window.idx_class << ","
1978 << "score=" << detection_window.score << "}";
1979
1980 return os;
1981}
1982
Isabella Gottardi05e56442018-11-16 11:26:52 +00001983/** Formatted output of the DetectionOutputLayerCodeType type.
1984 *
1985 * @param[out] os Output stream
1986 * @param[in] detection_code Type to output
1987 *
1988 * @return Modified output stream.
1989 */
1990inline ::std::ostream &operator<<(::std::ostream &os, const DetectionOutputLayerCodeType &detection_code)
1991{
1992 switch(detection_code)
1993 {
1994 case DetectionOutputLayerCodeType::CENTER_SIZE:
1995 os << "CENTER_SIZE";
1996 break;
1997 case DetectionOutputLayerCodeType::CORNER:
1998 os << "CORNER";
1999 break;
2000 case DetectionOutputLayerCodeType::CORNER_SIZE:
2001 os << "CORNER_SIZE";
2002 break;
2003 case DetectionOutputLayerCodeType::TF_CENTER:
2004 os << "TF_CENTER";
2005 break;
2006 default:
2007 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2008 }
2009
2010 return os;
2011}
2012/** Formatted output of the DetectionOutputLayerCodeType type.
2013 *
2014 * @param[in] detection_code Type to output
2015 *
2016 * @return Formatted string.
2017 */
2018inline std::string to_string(const DetectionOutputLayerCodeType &detection_code)
2019{
2020 std::stringstream str;
2021 str << detection_code;
2022 return str.str();
2023}
2024
2025/** Formatted output of the DetectionOutputLayerInfo type.
2026 *
2027 * @param[out] os Output stream
2028 * @param[in] detection_info Type to output
2029 *
2030 * @return Modified output stream.
2031 */
2032inline ::std::ostream &operator<<(::std::ostream &os, const DetectionOutputLayerInfo &detection_info)
2033{
2034 os << "{Classes=" << detection_info.num_classes() << ","
2035 << "ShareLocation=" << detection_info.share_location() << ","
2036 << "CodeType=" << detection_info.code_type() << ","
2037 << "VarianceEncodedInTarget=" << detection_info.variance_encoded_in_target() << ","
2038 << "KeepTopK=" << detection_info.keep_top_k() << ","
2039 << "NMSThreshold=" << detection_info.nms_threshold() << ","
2040 << "Eta=" << detection_info.eta() << ","
2041 << "BackgroundLabelId=" << detection_info.background_label_id() << ","
2042 << "ConfidenceThreshold=" << detection_info.confidence_threshold() << ","
2043 << "TopK=" << detection_info.top_k() << ","
2044 << "NumLocClasses=" << detection_info.num_loc_classes()
2045 << "}";
2046
2047 return os;
2048}
2049
2050/** Formatted output of the DetectionOutputLayerInfo type.
2051 *
2052 * @param[in] detection_info Type to output
2053 *
2054 * @return Formatted string.
2055 */
2056inline std::string to_string(const DetectionOutputLayerInfo &detection_info)
2057{
2058 std::stringstream str;
2059 str << detection_info;
2060 return str.str();
2061}
John Richardson8de92612018-02-22 14:09:31 +00002062/** Formatted output of the DetectionWindow type.
2063 *
2064 * @param[in] detection_window Type to output
2065 *
2066 * @return Formatted string.
2067 */
2068inline std::string to_string(const DetectionWindow &detection_window)
2069{
2070 std::stringstream str;
2071 str << detection_window;
2072 return str.str();
2073}
2074
2075/** Formatted output of the Termination type.
2076 *
2077 * @param[out] os Output stream
2078 * @param[in] termination Type to output
2079 *
2080 * @return Modified output stream.
2081 */
2082inline ::std::ostream &operator<<(::std::ostream &os, const Termination &termination)
2083{
2084 switch(termination)
2085 {
2086 case Termination::TERM_CRITERIA_EPSILON:
2087 os << "TERM_CRITERIA_EPSILON";
2088 break;
2089 case Termination::TERM_CRITERIA_ITERATIONS:
2090 os << "TERM_CRITERIA_ITERATIONS";
2091 break;
2092 case Termination::TERM_CRITERIA_BOTH:
2093 os << "TERM_CRITERIA_BOTH";
2094 break;
2095 default:
2096 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2097 }
2098
2099 return os;
2100}
2101
2102/** Formatted output of the Termination type.
2103 *
2104 * @param[in] termination Type to output
2105 *
2106 * @return Formatted string.
2107 */
2108inline std::string to_string(const Termination &termination)
2109{
2110 std::stringstream str;
2111 str << termination;
2112 return str.str();
2113}
2114
Anthony Barbier8914e322018-08-10 15:28:25 +01002115/** Formatted output of the CPUModel type.
2116 *
2117 * @param[out] os Output stream
2118 * @param[in] cpu_model Model to output
2119 *
2120 * @return Modified output stream.
2121 */
2122inline ::std::ostream &operator<<(::std::ostream &os, const CPUModel &cpu_model)
2123{
2124 switch(cpu_model)
2125 {
2126 case CPUModel::GENERIC:
2127 os << "GENERIC";
2128 break;
2129 case CPUModel::GENERIC_FP16:
2130 os << "GENERIC_FP16";
2131 break;
2132 case CPUModel::GENERIC_FP16_DOT:
2133 os << "GENERIC_FP16_DOT";
2134 break;
2135 case CPUModel::A53:
2136 os << "A53";
2137 break;
2138 case CPUModel::A55r0:
2139 os << "A55r0";
2140 break;
2141 case CPUModel::A55r1:
2142 os << "A55r1";
2143 break;
2144 default:
2145 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2146 }
2147
2148 return os;
2149}
2150
2151/** Formatted output of the CPUModel type.
2152 *
2153 * @param[in] cpu_model Model to output
2154 *
2155 * @return Formatted string.
2156 */
2157inline std::string to_string(const CPUModel &cpu_model)
2158{
2159 std::stringstream str;
2160 str << cpu_model;
2161 return str.str();
2162}
Anthony Barbier671a11e2018-07-06 15:11:36 +01002163/** Formatted output of a vector of objects.
2164 *
2165 * @param[out] os Output stream
2166 * @param[in] args Vector of objects to print
2167 *
2168 * @return Modified output stream.
2169 */
2170template <typename T>
2171inline ::std::ostream &operator<<(::std::ostream &os, const std::vector<T> &args)
2172{
2173 os << "[";
2174 bool first = true;
2175 for(auto &arg : args)
2176 {
2177 if(first)
2178 {
2179 first = false;
2180 }
2181 else
2182 {
2183 os << ", ";
2184 }
2185 os << arg;
2186 }
2187 os << "]";
2188 return os;
2189}
2190
Michalis Spyrou6c7c38e2018-08-29 16:28:11 +01002191/** Formatted output of @ref PriorBoxLayerInfo.
2192 *
2193 * @param[out] os Output stream.
2194 * @param[in] info Type to output.
2195 *
2196 * @return Modified output stream.
2197 */
2198inline ::std::ostream &operator<<(::std::ostream &os, const PriorBoxLayerInfo &info)
2199{
2200 os << "Clip:" << info.clip()
2201 << "Flip:" << info.flip()
2202 << "StepX:" << info.steps()[0]
2203 << "StepY:" << info.steps()[1]
2204 << "MinSizes:" << info.min_sizes()
2205 << "MaxSizes:" << info.max_sizes()
2206 << "ImgSizeX:" << info.img_size().x
2207 << "ImgSizeY:" << info.img_size().y
2208 << "Offset:" << info.offset()
2209 << "Variances:" << info.variances();
2210
2211 return os;
2212}
2213
Anthony Barbier671a11e2018-07-06 15:11:36 +01002214/** Formatted output of a vector of objects.
2215 *
2216 * @param[in] args Vector of objects to print
2217 *
2218 * @return String representing args.
2219 */
2220template <typename T>
2221std::string to_string(const std::vector<T> &args)
2222{
2223 std::stringstream str;
2224 str << args;
2225 return str.str();
2226}
2227
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00002228/** Formatted output of the WinogradInfo type. */
2229inline ::std::ostream &operator<<(::std::ostream &os, const WinogradInfo &info)
2230{
2231 os << "{OutputTileSize=" << info.output_tile_size << ","
2232 << "KernelSize=" << info.kernel_size << ","
2233 << "PadStride=" << info.convolution_info << ","
2234 << "OutputDataLayout=" << info.output_data_layout << "}";
2235
2236 return os;
2237}
2238
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00002239inline std::string to_string(const WinogradInfo &type)
2240{
2241 std::stringstream str;
2242 str << type;
2243 return str.str();
2244}
Anthony Barbier671a11e2018-07-06 15:11:36 +01002245
2246/** Fallback method: try to use std::to_string:
2247 *
2248 * @param[in] val Value to convert to string
2249 *
2250 * @return String representing val.
2251 */
2252template <typename T>
2253inline std::string to_string(const T &val)
2254{
2255 return support::cpp11::to_string(val);
2256}
2257
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +01002258/** Convert a CLTunerMode value to a string
2259 *
2260 * @param val CLTunerMode value to be converted
2261 *
2262 * @return String representing the corresponding CLTunerMode.
2263 */
2264inline std::string to_string(const CLTunerMode val)
2265{
2266 switch(val)
2267 {
2268 case CLTunerMode::EXHAUSTIVE:
2269 {
2270 return std::string("Exhaustive");
2271 }
2272 case CLTunerMode::NORMAL:
2273 {
2274 return std::string("Normal");
2275 }
2276 case CLTunerMode::RAPID:
2277 {
2278 return std::string("Rapid");
2279 }
2280 default:
2281 {
2282 ARM_COMPUTE_ERROR("Invalid tuner mode.");
2283 return std::string("UNDEFINED");
2284 }
2285 }
2286}
2287/** [Print CLTunerMode type] **/
2288/** Formatted output of the CLTunerMode type.
2289 *
2290 * @param[out] os Output stream.
2291 * @param[in] val CLTunerMode to output.
2292 *
2293 * @return Modified output stream.
2294 */
2295inline ::std::ostream &operator<<(::std::ostream &os, const CLTunerMode &val)
2296{
2297 os << to_string(val);
2298 return os;
2299}
2300
Anthony Barbier6ff3b192017-09-04 18:44:23 +01002301} // namespace arm_compute
Anthony Barbier4dbc0a92018-08-27 13:39:47 +01002302
2303#endif /* __ARM_COMPUTE_TYPE_PRINTER_H__ */