blob: 50eb4753d1c324487c79c8698cf72f97dc45804f [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001/*
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +00002 * Copyright (c) 2017-2020 ARM Limited.
Anthony Barbier6ff3b192017-09-04 18:44:23 +01003 *
4 * SPDX-License-Identifier: MIT
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
Anthony Barbier4dbc0a92018-08-27 13:39:47 +010024#ifndef __ARM_COMPUTE_TYPE_PRINTER_H__
25#define __ARM_COMPUTE_TYPE_PRINTER_H__
Anthony Barbier6ff3b192017-09-04 18:44:23 +010026
Anthony Barbier8914e322018-08-10 15:28:25 +010027#include "arm_compute/core/CPP/CPPTypes.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010028#include "arm_compute/core/Dimensions.h"
29#include "arm_compute/core/Error.h"
Michele Di Giorgiob8fc60f2018-04-25 11:58:07 +010030#include "arm_compute/core/GPUTarget.h"
John Richardson25f23682017-11-27 14:35:09 +000031#include "arm_compute/core/HOGInfo.h"
32#include "arm_compute/core/Size2D.h"
John Richardsona36eae12017-09-26 16:55:59 +010033#include "arm_compute/core/Strides.h"
Georgios Pinitas3faea252017-10-30 14:13:50 +000034#include "arm_compute/core/TensorInfo.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010035#include "arm_compute/core/Types.h"
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +010036#include "arm_compute/runtime/CL/CLTunerTypes.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010037
38#include <ostream>
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010039#include <sstream>
40#include <string>
Anthony Barbier6ff3b192017-09-04 18:44:23 +010041
42namespace arm_compute
43{
Anthony Barbierb940fd62018-06-04 14:14:32 +010044/** Formatted output if arg is not null
45 *
46 * @param[in] arg Object to print
47 *
48 * @return String representing arg.
49 */
50template <typename T>
51std::string to_string_if_not_null(T *arg)
52{
53 if(arg == nullptr)
54 {
55 return "nullptr";
56 }
57 else
58 {
59 return to_string(*arg);
60 }
61}
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;
Georgios Pinitasfb0fdcd2019-08-22 17:10:04 +0100382 case ActivationLayerInfo::ActivationFunction::ELU:
383 os << "ELU";
384 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100385 case ActivationLayerInfo::ActivationFunction::SQUARE:
386 os << "SQUARE";
387 break;
388 case ActivationLayerInfo::ActivationFunction::TANH:
389 os << "TANH";
390 break;
Usama Arif6a98a6e2019-05-10 17:07:27 +0100391 case ActivationLayerInfo::ActivationFunction::IDENTITY:
392 os << "IDENTITY";
393 break;
morgolock07df3d42020-02-27 11:46:28 +0000394 case ActivationLayerInfo::ActivationFunction::HARD_SWISH:
395 os << "HARD_SWISH";
396 break;
397
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100398 default:
399 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
400 }
401
402 return os;
403}
404
Alex Gildayc357c472018-03-21 13:54:09 +0000405/** Formatted output of the activation function info type.
406 *
407 * @param[in] info Type to output.
408 *
409 * @return Formatted string.
410 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100411inline std::string to_string(const arm_compute::ActivationLayerInfo &info)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100412{
413 std::stringstream str;
Isabella Gottardi3f217ec2018-02-12 14:59:19 +0000414 if(info.enabled())
415 {
416 str << info.activation();
417 }
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100418 return str.str();
419}
420
Alex Gildayc357c472018-03-21 13:54:09 +0000421/** Formatted output of the activation function type.
422 *
423 * @param[in] function Type to output.
424 *
425 * @return Formatted string.
426 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100427inline std::string to_string(const arm_compute::ActivationLayerInfo::ActivationFunction &function)
428{
429 std::stringstream str;
430 str << function;
431 return str.str();
432}
433
Alex Gildayc357c472018-03-21 13:54:09 +0000434/** Formatted output of the NormType type.
435 *
436 * @param[out] os Output stream.
437 * @param[in] norm_type Type to output.
438 *
439 * @return Modified output stream.
440 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100441inline ::std::ostream &operator<<(::std::ostream &os, const NormType &norm_type)
442{
443 switch(norm_type)
444 {
445 case NormType::CROSS_MAP:
446 os << "CROSS_MAP";
447 break;
448 case NormType::IN_MAP_1D:
449 os << "IN_MAP_1D";
450 break;
451 case NormType::IN_MAP_2D:
452 os << "IN_MAP_2D";
453 break;
454 default:
455 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
456 }
457
458 return os;
459}
460
Alex Gildayc357c472018-03-21 13:54:09 +0000461/** Formatted output of @ref NormalizationLayerInfo.
462 *
463 * @param[in] info Type to output.
464 *
465 * @return Formatted string.
466 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100467inline std::string to_string(const arm_compute::NormalizationLayerInfo &info)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100468{
469 std::stringstream str;
Michalis Spyroud466c2d2018-01-30 10:54:39 +0000470 str << info.type() << ":NormSize=" << info.norm_size();
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100471 return str.str();
472}
473
Alex Gildayc357c472018-03-21 13:54:09 +0000474/** Formatted output of @ref NormalizationLayerInfo.
475 *
476 * @param[out] os Output stream.
477 * @param[in] info Type to output.
478 *
479 * @return Modified output stream.
480 */
Georgios Pinitas6f669f02017-09-26 12:32:57 +0100481inline ::std::ostream &operator<<(::std::ostream &os, const NormalizationLayerInfo &info)
482{
Michalis Spyroud466c2d2018-01-30 10:54:39 +0000483 os << info.type() << ":NormSize=" << info.norm_size();
Georgios Pinitas6f669f02017-09-26 12:32:57 +0100484 return os;
485}
486
Alex Gildayc357c472018-03-21 13:54:09 +0000487/** Formatted output of the PoolingType type.
488 *
489 * @param[out] os Output stream.
490 * @param[in] pool_type Type to output.
491 *
492 * @return Modified output stream.
493 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100494inline ::std::ostream &operator<<(::std::ostream &os, const PoolingType &pool_type)
495{
496 switch(pool_type)
497 {
498 case PoolingType::AVG:
499 os << "AVG";
500 break;
501 case PoolingType::MAX:
502 os << "MAX";
503 break;
Georgios Pinitascdf51452017-08-31 14:21:36 +0100504 case PoolingType::L2:
505 os << "L2";
506 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100507 default:
508 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
509 }
510
511 return os;
512}
513
Alex Gildayc357c472018-03-21 13:54:09 +0000514/** Formatted output of @ref PoolingLayerInfo.
515 *
516 * @param[out] os Output stream.
517 * @param[in] info Type to output.
518 *
519 * @return Modified output stream.
520 */
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100521inline ::std::ostream &operator<<(::std::ostream &os, const PoolingLayerInfo &info)
522{
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +0000523 os << info.pool_type;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100524
525 return os;
526}
527
Alex Gildayc357c472018-03-21 13:54:09 +0000528/** Formatted output of @ref RoundingPolicy.
529 *
530 * @param[in] rounding_policy Type to output.
531 *
532 * @return Formatted string.
533 */
John Richardsondd715f22017-09-18 16:10:48 +0100534inline std::string to_string(const RoundingPolicy &rounding_policy)
535{
536 std::stringstream str;
537 str << rounding_policy;
538 return str.str();
539}
540
Vidhya Sudhan Loganathand646ae12018-11-19 15:18:20 +0000541/** [Print DataLayout type] **/
Alex Gildayc357c472018-03-21 13:54:09 +0000542/** Formatted output of the DataLayout type.
543 *
544 * @param[out] os Output stream.
545 * @param[in] data_layout Type to output.
546 *
547 * @return Modified output stream.
548 */
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000549inline ::std::ostream &operator<<(::std::ostream &os, const DataLayout &data_layout)
550{
551 switch(data_layout)
552 {
553 case DataLayout::UNKNOWN:
554 os << "UNKNOWN";
555 break;
556 case DataLayout::NHWC:
557 os << "NHWC";
558 break;
559 case DataLayout::NCHW:
560 os << "NCHW";
561 break;
562 default:
563 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
564 }
565
566 return os;
567}
568
Alex Gildayc357c472018-03-21 13:54:09 +0000569/** Formatted output of the DataLayout type.
570 *
571 * @param[in] data_layout Type to output.
572 *
573 * @return Formatted string.
574 */
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000575inline std::string to_string(const arm_compute::DataLayout &data_layout)
576{
577 std::stringstream str;
578 str << data_layout;
579 return str.str();
580}
Vidhya Sudhan Loganathand646ae12018-11-19 15:18:20 +0000581/** [Print DataLayout type] **/
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000582
Georgios Pinitase2220552018-07-20 13:23:44 +0100583/** Formatted output of the DataLayoutDimension type.
584 *
585 * @param[out] os Output stream.
586 * @param[in] data_layout_dim Data layout dimension to print.
587 *
588 * @return Modified output stream.
589 */
590inline ::std::ostream &operator<<(::std::ostream &os, const DataLayoutDimension &data_layout_dim)
591{
592 switch(data_layout_dim)
593 {
594 case DataLayoutDimension::WIDTH:
595 os << "WIDTH";
596 break;
597 case DataLayoutDimension::HEIGHT:
598 os << "HEIGHT";
599 break;
600 case DataLayoutDimension::CHANNEL:
601 os << "CHANNEL";
602 break;
603 case DataLayoutDimension::BATCHES:
604 os << "BATCHES";
605 break;
606 default:
607 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
608 }
609 return os;
610}
611
Alex Gildayc357c472018-03-21 13:54:09 +0000612/** Formatted output of the DataType type.
613 *
614 * @param[out] os Output stream.
615 * @param[in] data_type Type to output.
616 *
617 * @return Modified output stream.
618 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100619inline ::std::ostream &operator<<(::std::ostream &os, const DataType &data_type)
620{
621 switch(data_type)
622 {
623 case DataType::UNKNOWN:
624 os << "UNKNOWN";
625 break;
626 case DataType::U8:
627 os << "U8";
628 break;
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100629 case DataType::QSYMM8:
630 os << "QSYMM8";
631 break;
Chunosovd621bca2017-11-03 17:33:15 +0700632 case DataType::QASYMM8:
633 os << "QASYMM8";
634 break;
Georgios Pinitas448a81f2019-11-21 14:10:25 +0000635 case DataType::QASYMM8_SIGNED:
636 os << "QASYMM8_SIGNED";
637 break;
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100638 case DataType::QSYMM8_PER_CHANNEL:
639 os << "QSYMM8_PER_CHANNEL";
640 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100641 case DataType::S8:
642 os << "S8";
643 break;
644 case DataType::U16:
645 os << "U16";
646 break;
647 case DataType::S16:
648 os << "S16";
649 break;
Manuel Bottini3689fcd2019-06-14 17:18:12 +0100650 case DataType::QSYMM16:
651 os << "QSYMM16";
652 break;
Michele Di Giorgio35ea9a72019-08-23 12:02:06 +0100653 case DataType::QASYMM16:
654 os << "QASYMM16";
655 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100656 case DataType::U32:
657 os << "U32";
658 break;
659 case DataType::S32:
660 os << "S32";
661 break;
662 case DataType::U64:
663 os << "U64";
664 break;
665 case DataType::S64:
666 os << "S64";
667 break;
668 case DataType::F16:
669 os << "F16";
670 break;
671 case DataType::F32:
672 os << "F32";
673 break;
674 case DataType::F64:
675 os << "F64";
676 break;
677 case DataType::SIZET:
678 os << "SIZET";
679 break;
680 default:
681 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
682 }
683
684 return os;
685}
686
Alex Gildayc357c472018-03-21 13:54:09 +0000687/** Formatted output of the DataType type.
688 *
689 * @param[in] data_type Type to output.
690 *
691 * @return Formatted string.
692 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100693inline std::string to_string(const arm_compute::DataType &data_type)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100694{
695 std::stringstream str;
696 str << data_type;
697 return str.str();
698}
699
Alex Gildayc357c472018-03-21 13:54:09 +0000700/** Formatted output of the Format type.
701 *
702 * @param[out] os Output stream.
703 * @param[in] format Type to output.
704 *
705 * @return Modified output stream.
706 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100707inline ::std::ostream &operator<<(::std::ostream &os, const Format &format)
708{
709 switch(format)
710 {
711 case Format::UNKNOWN:
712 os << "UNKNOWN";
713 break;
714 case Format::U8:
715 os << "U8";
716 break;
717 case Format::S16:
718 os << "S16";
719 break;
720 case Format::U16:
721 os << "U16";
722 break;
723 case Format::S32:
724 os << "S32";
725 break;
726 case Format::U32:
727 os << "U32";
728 break;
729 case Format::F16:
730 os << "F16";
731 break;
732 case Format::F32:
733 os << "F32";
734 break;
735 case Format::UV88:
736 os << "UV88";
737 break;
738 case Format::RGB888:
739 os << "RGB888";
740 break;
741 case Format::RGBA8888:
742 os << "RGBA8888";
743 break;
744 case Format::YUV444:
745 os << "YUV444";
746 break;
747 case Format::YUYV422:
748 os << "YUYV422";
749 break;
750 case Format::NV12:
751 os << "NV12";
752 break;
753 case Format::NV21:
754 os << "NV21";
755 break;
756 case Format::IYUV:
757 os << "IYUV";
758 break;
759 case Format::UYVY422:
760 os << "UYVY422";
761 break;
762 default:
763 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
764 }
765
766 return os;
767}
768
Alex Gildayc357c472018-03-21 13:54:09 +0000769/** Formatted output of the Format type.
770 *
771 * @param[in] format Type to output.
772 *
773 * @return Formatted string.
774 */
Moritz Pflanzer7655a672017-09-23 11:57:33 +0100775inline std::string to_string(const Format &format)
776{
777 std::stringstream str;
778 str << format;
779 return str.str();
780}
781
Alex Gildayc357c472018-03-21 13:54:09 +0000782/** Formatted output of the Channel type.
783 *
784 * @param[out] os Output stream.
785 * @param[in] channel Type to output.
786 *
787 * @return Modified output stream.
788 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100789inline ::std::ostream &operator<<(::std::ostream &os, const Channel &channel)
790{
791 switch(channel)
792 {
793 case Channel::UNKNOWN:
794 os << "UNKNOWN";
795 break;
796 case Channel::C0:
797 os << "C0";
798 break;
799 case Channel::C1:
800 os << "C1";
801 break;
802 case Channel::C2:
803 os << "C2";
804 break;
805 case Channel::C3:
806 os << "C3";
807 break;
808 case Channel::R:
809 os << "R";
810 break;
811 case Channel::G:
812 os << "G";
813 break;
814 case Channel::B:
815 os << "B";
816 break;
817 case Channel::A:
818 os << "A";
819 break;
820 case Channel::Y:
821 os << "Y";
822 break;
823 case Channel::U:
824 os << "U";
825 break;
826 case Channel::V:
827 os << "V";
828 break;
829 default:
830 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
831 }
832
833 return os;
834}
835
Alex Gildayc357c472018-03-21 13:54:09 +0000836/** Formatted output of the Channel type.
837 *
838 * @param[in] channel Type to output.
839 *
840 * @return Formatted string.
841 */
Ioan-Cristian Szabo9414f642017-10-27 17:35:40 +0100842inline std::string to_string(const Channel &channel)
843{
844 std::stringstream str;
845 str << channel;
846 return str.str();
847}
848
Alex Gildayc357c472018-03-21 13:54:09 +0000849/** Formatted output of the BorderMode type.
850 *
851 * @param[out] os Output stream.
852 * @param[in] mode Type to output.
853 *
854 * @return Modified output stream.
855 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100856inline ::std::ostream &operator<<(::std::ostream &os, const BorderMode &mode)
857{
858 switch(mode)
859 {
860 case BorderMode::UNDEFINED:
861 os << "UNDEFINED";
862 break;
863 case BorderMode::CONSTANT:
864 os << "CONSTANT";
865 break;
866 case BorderMode::REPLICATE:
867 os << "REPLICATE";
868 break;
869 default:
870 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
871 }
872
873 return os;
874}
875
Alex Gildayc357c472018-03-21 13:54:09 +0000876/** Formatted output of the BorderSize type.
877 *
878 * @param[out] os Output stream.
879 * @param[in] border Type to output.
880 *
881 * @return Modified output stream.
882 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100883inline ::std::ostream &operator<<(::std::ostream &os, const BorderSize &border)
884{
Moritz Pflanzerc87fbf82017-07-18 14:02:10 +0100885 os << border.top << ","
886 << border.right << ","
887 << border.bottom << ","
888 << border.left;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100889
890 return os;
891}
Anthony Barbier2a07e182017-08-04 18:20:27 +0100892
Giuseppe Rossinid7647d42018-07-17 18:13:13 +0100893/** Formatted output of the PaddingList type.
894 *
895 * @param[out] os Output stream.
896 * @param[in] padding Type to output.
897 *
898 * @return Modified output stream.
899 */
900inline ::std::ostream &operator<<(::std::ostream &os, const PaddingList &padding)
901{
902 os << "{";
903 for(auto const &p : padding)
904 {
905 os << "{" << p.first << "," << p.second << "}";
906 }
907 os << "}";
908 return os;
909}
910
giuros013175fcf2018-11-21 09:59:17 +0000911/** Formatted output of the Multiples type.
912 *
913 * @param[out] os Output stream.
914 * @param[in] multiples Type to output.
915 *
916 * @return Modified output stream.
917 */
918inline ::std::ostream &operator<<(::std::ostream &os, const Multiples &multiples)
919{
920 os << "(";
921 for(size_t i = 0; i < multiples.size() - 1; i++)
922 {
923 os << multiples[i] << ", ";
924 }
925 os << multiples.back() << ")";
926 return os;
927}
928
Alex Gildayc357c472018-03-21 13:54:09 +0000929/** Formatted output of the InterpolationPolicy type.
930 *
931 * @param[out] os Output stream.
932 * @param[in] policy Type to output.
933 *
934 * @return Modified output stream.
935 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100936inline ::std::ostream &operator<<(::std::ostream &os, const InterpolationPolicy &policy)
937{
938 switch(policy)
939 {
940 case InterpolationPolicy::NEAREST_NEIGHBOR:
941 os << "NEAREST_NEIGHBOR";
942 break;
943 case InterpolationPolicy::BILINEAR:
944 os << "BILINEAR";
945 break;
946 case InterpolationPolicy::AREA:
947 os << "AREA";
948 break;
949 default:
950 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
951 }
952
953 return os;
954}
955
Alex Gildayc357c472018-03-21 13:54:09 +0000956/** Formatted output of the SamplingPolicy type.
957 *
958 * @param[out] os Output stream.
959 * @param[in] policy Type to output.
960 *
961 * @return Modified output stream.
962 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700963inline ::std::ostream &operator<<(::std::ostream &os, const SamplingPolicy &policy)
964{
965 switch(policy)
966 {
967 case SamplingPolicy::CENTER:
968 os << "CENTER";
969 break;
970 case SamplingPolicy::TOP_LEFT:
971 os << "TOP_LEFT";
972 break;
973 default:
974 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
975 }
976
977 return os;
978}
979
Alex Gildayc357c472018-03-21 13:54:09 +0000980/** Formatted output of the TensorInfo type.
981 *
Anthony Barbier366628a2018-08-01 13:55:03 +0100982 * @param[out] os Output stream.
983 * @param[in] info Type to output.
984 *
985 * @return Modified output stream.
986 */
987inline ::std::ostream &operator<<(::std::ostream &os, const TensorInfo &info)
988{
989 os << "{Shape=" << info.tensor_shape() << ","
990 << "Type=" << info.data_type() << ","
991 << "Channels=" << info.num_channels() << "}";
992 return os;
993}
994/** Formatted output of the TensorInfo type.
995 *
Alex Gildayc357c472018-03-21 13:54:09 +0000996 * @param[in] info Type to output.
997 *
998 * @return Formatted string.
999 */
Georgios Pinitas3faea252017-10-30 14:13:50 +00001000inline std::string to_string(const TensorInfo &info)
1001{
1002 std::stringstream str;
Anthony Barbier366628a2018-08-01 13:55:03 +01001003 str << info;
Georgios Pinitas3faea252017-10-30 14:13:50 +00001004 return str.str();
1005}
1006
Alex Gildayc357c472018-03-21 13:54:09 +00001007/** Formatted output of the Dimensions type.
1008 *
1009 * @param[in] dimensions Type to output.
1010 *
1011 * @return Formatted string.
1012 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001013template <typename T>
1014inline std::string to_string(const Dimensions<T> &dimensions)
1015{
1016 std::stringstream str;
1017 str << dimensions;
1018 return str.str();
1019}
1020
Alex Gildayc357c472018-03-21 13:54:09 +00001021/** Formatted output of the Strides type.
1022 *
1023 * @param[in] stride Type to output.
1024 *
1025 * @return Formatted string.
1026 */
John Richardsona36eae12017-09-26 16:55:59 +01001027inline std::string to_string(const Strides &stride)
1028{
1029 std::stringstream str;
1030 str << stride;
1031 return str.str();
1032}
1033
Alex Gildayc357c472018-03-21 13:54:09 +00001034/** Formatted output of the TensorShape type.
1035 *
1036 * @param[in] shape Type to output.
1037 *
1038 * @return Formatted string.
1039 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001040inline std::string to_string(const TensorShape &shape)
1041{
1042 std::stringstream str;
1043 str << shape;
1044 return str.str();
1045}
1046
Alex Gildayc357c472018-03-21 13:54:09 +00001047/** Formatted output of the Coordinates type.
1048 *
1049 * @param[in] coord Type to output.
1050 *
1051 * @return Formatted string.
1052 */
Abe Mbise925ca0f2017-10-02 19:16:33 +01001053inline std::string to_string(const Coordinates &coord)
1054{
1055 std::stringstream str;
1056 str << coord;
1057 return str.str();
1058}
1059
Anthony Barbierb940fd62018-06-04 14:14:32 +01001060/** Formatted output of the GEMMReshapeInfo type.
1061 *
1062 * @param[out] os Output stream.
1063 * @param[in] info Type to output.
1064 *
1065 * @return Modified output stream.
1066 */
1067inline ::std::ostream &operator<<(::std::ostream &os, const GEMMReshapeInfo &info)
1068{
1069 os << "{m=" << info.m() << ",";
1070 os << "n=" << info.n() << ",";
1071 os << "k=" << info.k() << ",";
1072 os << "mult_transpose1xW_width=" << info.mult_transpose1xW_width() << ",";
1073 os << "mult_interleave4x4_height=" << info.mult_interleave4x4_height();
1074 os << "}";
1075
1076 return os;
1077}
1078
1079/** Formatted output of the GEMMInfo type.
1080 *
1081 * @param[out] os Output stream.
1082 * @param[in] info Type to output.
1083 *
1084 * @return Modified output stream.
1085 */
1086inline ::std::ostream &operator<<(::std::ostream &os, const GEMMInfo &info)
1087{
1088 os << "{is_a_reshaped=" << info.is_a_reshaped() << ",";
1089 os << "is_b_reshaped=" << info.is_b_reshaped() << ",";
1090 os << "reshape_b_only_on_first_run=" << info.reshape_b_only_on_first_run() << ",";
Anthony Barbierb940fd62018-06-04 14:14:32 +01001091 os << "}";
1092
1093 return os;
1094}
1095
1096/** Formatted output of the Window::Dimension type.
1097 *
1098 * @param[out] os Output stream.
1099 * @param[in] dim Type to output.
1100 *
1101 * @return Modified output stream.
1102 */
1103inline ::std::ostream &operator<<(::std::ostream &os, const Window::Dimension &dim)
1104{
1105 os << "{start=" << dim.start() << ", end=" << dim.end() << ", step=" << dim.step() << "}";
1106
1107 return os;
1108}
1109/** Formatted output of the Window type.
1110 *
1111 * @param[out] os Output stream.
1112 * @param[in] win Type to output.
1113 *
1114 * @return Modified output stream.
1115 */
1116inline ::std::ostream &operator<<(::std::ostream &os, const Window &win)
1117{
1118 os << "{";
1119 for(unsigned int i = 0; i < Coordinates::num_max_dimensions; i++)
1120 {
1121 if(i > 0)
1122 {
1123 os << ", ";
1124 }
1125 os << win[i];
1126 }
1127 os << "}";
1128
1129 return os;
1130}
1131
1132/** Formatted output of the WeightsInfo type.
1133 *
1134 * @param[in] info Type to output.
1135 *
1136 * @return Formatted string.
1137 */
1138inline std::string to_string(const WeightsInfo &info)
1139{
1140 std::stringstream str;
1141 str << info;
1142 return str.str();
1143}
1144
1145/** Formatted output of the GEMMReshapeInfo type.
1146 *
1147 * @param[in] info Type to output.
1148 *
1149 * @return Formatted string.
1150 */
1151inline std::string to_string(const GEMMReshapeInfo &info)
1152{
1153 std::stringstream str;
1154 str << info;
1155 return str.str();
1156}
1157
1158/** Formatted output of the GEMMInfo type.
1159 *
1160 * @param[in] info Type to output.
1161 *
1162 * @return Formatted string.
1163 */
1164inline std::string to_string(const GEMMInfo &info)
1165{
1166 std::stringstream str;
1167 str << info;
1168 return str.str();
1169}
1170
1171/** Formatted output of the Window::Dimension type.
1172 *
1173 * @param[in] dim Type to output.
1174 *
1175 * @return Formatted string.
1176 */
1177inline std::string to_string(const Window::Dimension &dim)
1178{
1179 std::stringstream str;
1180 str << dim;
1181 return str.str();
1182}
1183/** Formatted output of the Window type.
1184 *
1185 * @param[in] win Type to output.
1186 *
1187 * @return Formatted string.
1188 */
1189inline std::string to_string(const Window &win)
1190{
1191 std::stringstream str;
1192 str << win;
1193 return str.str();
1194}
1195
Alex Gildayc357c472018-03-21 13:54:09 +00001196/** Formatted output of the Rectangle type.
1197 *
1198 * @param[out] os Output stream.
1199 * @param[in] rect Type to output.
1200 *
1201 * @return Modified output stream.
1202 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001203inline ::std::ostream &operator<<(::std::ostream &os, const Rectangle &rect)
1204{
1205 os << rect.width << "x" << rect.height;
1206 os << "+" << rect.x << "+" << rect.y;
1207
1208 return os;
1209}
1210
Usama Arif8cf8c112019-03-14 15:36:54 +00001211/** Formatted output of the PaddingMode type.
1212 *
1213 * @param[out] os Output stream.
1214 * @param[in] mode Type to output.
1215 *
1216 * @return Modified output stream.
1217 */
1218inline ::std::ostream &operator<<(::std::ostream &os, const PaddingMode &mode)
1219{
1220 switch(mode)
1221 {
1222 case PaddingMode::CONSTANT:
1223 os << "CONSTANT";
1224 break;
1225 case PaddingMode::REFLECT:
1226 os << "REFLECT";
1227 break;
1228 case PaddingMode::SYMMETRIC:
1229 os << "SYMMETRIC";
1230 break;
1231 default:
1232 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1233 }
1234
1235 return os;
1236}
1237
1238/** Formatted output of the PaddingMode type.
1239 *
1240 * @param[in] mode Type to output.
1241 *
1242 * @return Formatted string.
1243 */
1244inline std::string to_string(const PaddingMode &mode)
1245{
1246 std::stringstream str;
1247 str << mode;
1248 return str.str();
1249}
1250
Alex Gildayc357c472018-03-21 13:54:09 +00001251/** Formatted output of the PadStrideInfo type.
1252 *
1253 * @param[out] os Output stream.
1254 * @param[in] pad_stride_info Type to output.
1255 *
1256 * @return Modified output stream.
1257 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001258inline ::std::ostream &operator<<(::std::ostream &os, const PadStrideInfo &pad_stride_info)
1259{
1260 os << pad_stride_info.stride().first << "," << pad_stride_info.stride().second;
1261 os << ";";
Jaroslaw Rzepeckia1ed41f2017-10-13 11:13:58 +01001262 os << pad_stride_info.pad_left() << "," << pad_stride_info.pad_right() << ","
1263 << pad_stride_info.pad_top() << "," << pad_stride_info.pad_bottom();
Anthony Barbier2a07e182017-08-04 18:20:27 +01001264
1265 return os;
1266}
1267
Alex Gildayc357c472018-03-21 13:54:09 +00001268/** Formatted output of the PadStrideInfo type.
1269 *
1270 * @param[in] pad_stride_info Type to output.
1271 *
1272 * @return Formatted string.
1273 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001274inline std::string to_string(const PadStrideInfo &pad_stride_info)
1275{
1276 std::stringstream str;
1277 str << pad_stride_info;
1278 return str.str();
1279}
1280
Alex Gildayc357c472018-03-21 13:54:09 +00001281/** Formatted output of the BorderMode type.
1282 *
1283 * @param[in] mode Type to output.
1284 *
1285 * @return Formatted string.
1286 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001287inline std::string to_string(const BorderMode &mode)
1288{
1289 std::stringstream str;
1290 str << mode;
1291 return str.str();
1292}
1293
Alex Gildayc357c472018-03-21 13:54:09 +00001294/** Formatted output of the BorderSize type.
1295 *
1296 * @param[in] border Type to output.
1297 *
1298 * @return Formatted string.
1299 */
John Richardsonb482ce12017-09-18 12:44:01 +01001300inline std::string to_string(const BorderSize &border)
1301{
1302 std::stringstream str;
1303 str << border;
1304 return str.str();
1305}
1306
Giuseppe Rossinid7647d42018-07-17 18:13:13 +01001307/** Formatted output of the PaddingList type.
1308 *
1309 * @param[in] padding Type to output.
1310 *
1311 * @return Formatted string.
1312 */
1313inline std::string to_string(const PaddingList &padding)
1314{
1315 std::stringstream str;
1316 str << padding;
1317 return str.str();
1318}
1319
giuros013175fcf2018-11-21 09:59:17 +00001320/** Formatted output of the Multiples type.
1321 *
1322 * @param[in] multiples Type to output.
1323 *
1324 * @return Formatted string.
1325 */
1326inline std::string to_string(const Multiples &multiples)
1327{
1328 std::stringstream str;
1329 str << multiples;
1330 return str.str();
1331}
1332
Alex Gildayc357c472018-03-21 13:54:09 +00001333/** Formatted output of the InterpolationPolicy type.
1334 *
1335 * @param[in] policy Type to output.
1336 *
1337 * @return Formatted string.
1338 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001339inline std::string to_string(const InterpolationPolicy &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 SamplingPolicy type.
1347 *
1348 * @param[in] policy Type to output.
1349 *
1350 * @return Formatted string.
1351 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +07001352inline std::string to_string(const SamplingPolicy &policy)
1353{
1354 std::stringstream str;
1355 str << policy;
1356 return str.str();
1357}
1358
Alex Gildayc357c472018-03-21 13:54:09 +00001359/** Formatted output of the ConvertPolicy type.
1360 *
1361 * @param[out] os Output stream.
1362 * @param[in] policy Type to output.
1363 *
1364 * @return Modified output stream.
1365 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001366inline ::std::ostream &operator<<(::std::ostream &os, const ConvertPolicy &policy)
1367{
1368 switch(policy)
1369 {
1370 case ConvertPolicy::WRAP:
1371 os << "WRAP";
1372 break;
1373 case ConvertPolicy::SATURATE:
1374 os << "SATURATE";
1375 break;
1376 default:
1377 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1378 }
1379
1380 return os;
1381}
1382
1383inline std::string to_string(const ConvertPolicy &policy)
1384{
1385 std::stringstream str;
1386 str << policy;
1387 return str.str();
1388}
1389
giuros01164a2722018-11-20 18:34:46 +00001390/** Formatted output of the ArithmeticOperation type.
1391 *
1392 * @param[out] os Output stream.
1393 * @param[in] op Operation to output.
1394 *
1395 * @return Modified output stream.
1396 */
1397inline ::std::ostream &operator<<(::std::ostream &os, const ArithmeticOperation &op)
1398{
1399 switch(op)
1400 {
1401 case ArithmeticOperation::ADD:
1402 os << "ADD";
1403 break;
1404 case ArithmeticOperation::SUB:
1405 os << "SUB";
1406 break;
1407 case ArithmeticOperation::DIV:
1408 os << "DIV";
1409 break;
1410 case ArithmeticOperation::MAX:
1411 os << "MAX";
1412 break;
1413 case ArithmeticOperation::MIN:
1414 os << "MIN";
1415 break;
1416 case ArithmeticOperation::SQUARED_DIFF:
1417 os << "SQUARED_DIFF";
1418 break;
Usama Arif52c54f62019-05-14 10:22:36 +01001419 case ArithmeticOperation::POWER:
1420 os << "POWER";
1421 break;
giuros01164a2722018-11-20 18:34:46 +00001422 default:
1423 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1424 }
1425
1426 return os;
1427}
1428
1429/** Formatted output of the Arithmetic Operation
1430 *
1431 * @param[in] op Type to output.
1432 *
1433 * @return Formatted string.
1434 */
1435inline std::string to_string(const ArithmeticOperation &op)
1436{
1437 std::stringstream str;
1438 str << op;
1439 return str.str();
1440}
1441
Alex Gildayc357c472018-03-21 13:54:09 +00001442/** Formatted output of the Reduction Operations.
1443 *
1444 * @param[out] os Output stream.
1445 * @param[in] op Type to output.
1446 *
1447 * @return Modified output stream.
1448 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001449inline ::std::ostream &operator<<(::std::ostream &os, const ReductionOperation &op)
1450{
1451 switch(op)
1452 {
Michalis Spyrou7e9391b2018-10-05 14:49:28 +01001453 case ReductionOperation::SUM:
1454 os << "SUM";
1455 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +01001456 case ReductionOperation::SUM_SQUARE:
1457 os << "SUM_SQUARE";
1458 break;
Michalis Spyrou7e9391b2018-10-05 14:49:28 +01001459 case ReductionOperation::MEAN_SUM:
1460 os << "MEAN_SUM";
1461 break;
Michalis Spyrou7930db42018-11-22 17:36:28 +00001462 case ReductionOperation::ARG_IDX_MAX:
1463 os << "ARG_IDX_MAX";
1464 break;
1465 case ReductionOperation::ARG_IDX_MIN:
1466 os << "ARG_IDX_MIN";
1467 break;
Manuel Bottinib412fab2018-12-10 17:40:23 +00001468 case ReductionOperation::PROD:
1469 os << "PROD";
1470 break;
Usama Arifa4a08ad2019-05-20 12:38:33 +01001471 case ReductionOperation::MIN:
1472 os << "MIN";
1473 break;
Usama Arif28f0dd92019-05-20 13:44:34 +01001474 case ReductionOperation::MAX:
1475 os << "MAX";
1476 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +01001477 default:
1478 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1479 }
1480
1481 return os;
1482}
1483
Alex Gildayc357c472018-03-21 13:54:09 +00001484/** Formatted output of the Reduction Operations.
1485 *
1486 * @param[in] op Type to output.
1487 *
1488 * @return Formatted string.
1489 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001490inline std::string to_string(const ReductionOperation &op)
1491{
1492 std::stringstream str;
1493 str << op;
1494 return str.str();
1495}
1496
Georgios Pinitas7900a9e2018-11-23 11:44:58 +00001497/** Formatted output of the Comparison Operations.
1498 *
1499 * @param[out] os Output stream.
1500 * @param[in] op Type to output.
1501 *
1502 * @return Modified output stream.
1503 */
1504inline ::std::ostream &operator<<(::std::ostream &os, const ComparisonOperation &op)
1505{
1506 switch(op)
1507 {
1508 case ComparisonOperation::Equal:
1509 os << "Equal";
1510 break;
1511 case ComparisonOperation::NotEqual:
1512 os << "NotEqual";
1513 break;
1514 case ComparisonOperation::Greater:
1515 os << "Greater";
1516 break;
1517 case ComparisonOperation::GreaterEqual:
1518 os << "GreaterEqual";
1519 break;
1520 case ComparisonOperation::Less:
1521 os << "Less";
1522 break;
1523 case ComparisonOperation::LessEqual:
1524 os << "LessEqual";
1525 break;
1526 default:
1527 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1528 }
1529
1530 return os;
1531}
1532
Michalis Spyroue9362622018-11-23 17:41:37 +00001533/** Formatted output of the Elementwise unary Operations.
1534 *
1535 * @param[out] os Output stream.
1536 * @param[in] op Type to output.
1537 *
1538 * @return Modified output stream.
1539 */
1540inline ::std::ostream &operator<<(::std::ostream &os, const ElementWiseUnary &op)
1541{
1542 switch(op)
1543 {
1544 case ElementWiseUnary::RSQRT:
1545 os << "RSQRT";
1546 break;
1547 case ElementWiseUnary::EXP:
1548 os << "EXP";
1549 break;
Usama Arifeb312ef2019-05-13 17:45:54 +01001550 case ElementWiseUnary::NEG:
1551 os << "NEG";
1552 break;
Usama Arifac33d7e2019-05-20 14:21:40 +01001553 case ElementWiseUnary::LOG:
1554 os << "LOG";
1555 break;
Usama Arif6a4d5422019-05-24 14:53:59 +01001556 case ElementWiseUnary::ROUND:
1557 os << "ROUND";
1558 break;
Michalis Spyroue9362622018-11-23 17:41:37 +00001559 default:
1560 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1561 }
1562
1563 return os;
1564}
1565
Georgios Pinitas7900a9e2018-11-23 11:44:58 +00001566/** Formatted output of the Comparison Operations.
1567 *
1568 * @param[in] op Type to output.
1569 *
1570 * @return Formatted string.
1571 */
1572inline std::string to_string(const ComparisonOperation &op)
1573{
1574 std::stringstream str;
1575 str << op;
1576 return str.str();
1577}
1578
Michalis Spyroue9362622018-11-23 17:41:37 +00001579/** Formatted output of the Elementwise unary Operations.
1580 *
1581 * @param[in] op Type to output.
1582 *
1583 * @return Formatted string.
1584 */
1585inline std::string to_string(const ElementWiseUnary &op)
1586{
1587 std::stringstream str;
1588 str << op;
1589 return str.str();
1590}
1591
Alex Gildayc357c472018-03-21 13:54:09 +00001592/** Formatted output of the Norm 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 NormType &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 Type.
1606 *
1607 * @param[in] type Type to output.
1608 *
1609 * @return Formatted string.
1610 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001611inline std::string to_string(const PoolingType &type)
1612{
1613 std::stringstream str;
1614 str << type;
1615 return str.str();
1616}
1617
Alex Gildayc357c472018-03-21 13:54:09 +00001618/** Formatted output of the Pooling Layer Info.
1619 *
1620 * @param[in] info Type to output.
1621 *
1622 * @return Formatted string.
1623 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001624inline std::string to_string(const PoolingLayerInfo &info)
1625{
1626 std::stringstream str;
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +00001627 str << "{Type=" << info.pool_type << ","
Sang-Hoon Park11fedda2020-01-15 14:44:04 +00001628 << "DataLayout=" << info.data_layout << ","
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +00001629 << "IsGlobalPooling=" << info.is_global_pooling;
1630 if(!info.is_global_pooling)
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001631 {
1632 str << ","
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +00001633 << "PoolSize=" << info.pool_size.width << "," << info.pool_size.height << ","
1634 << "PadStride=" << info.pad_stride_info;
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001635 }
1636 str << "}";
Anthony Barbier2a07e182017-08-04 18:20:27 +01001637 return str.str();
1638}
1639
Michalis Spyrou6c7c38e2018-08-29 16:28:11 +01001640/** Formatted output of the PriorBoxLayerInfo.
1641 *
1642 * @param[in] info Type to output.
1643 *
1644 * @return Formatted string.
1645 */
1646inline std::string to_string(const PriorBoxLayerInfo &info)
1647{
1648 std::stringstream str;
1649 str << "{";
1650 str << "Clip:" << info.clip()
1651 << "Flip:" << info.flip()
1652 << "StepX:" << info.steps()[0]
1653 << "StepY:" << info.steps()[1]
1654 << "MinSizes:" << info.min_sizes().size()
1655 << "MaxSizes:" << info.max_sizes().size()
1656 << "ImgSizeX:" << info.img_size().x
1657 << "ImgSizeY:" << info.img_size().y
1658 << "Offset:" << info.offset()
1659 << "Variances:" << info.variances().size();
1660 str << "}";
1661 return str.str();
1662}
1663
Alex Gildayc357c472018-03-21 13:54:09 +00001664/** Formatted output of the KeyPoint type.
1665 *
1666 * @param[out] os Output stream
1667 * @param[in] point Type to output.
1668 *
1669 * @return Modified output stream.
1670 */
Moritz Pflanzer6c6597c2017-09-24 12:09:41 +01001671inline ::std::ostream &operator<<(::std::ostream &os, const KeyPoint &point)
1672{
1673 os << "{x=" << point.x << ","
1674 << "y=" << point.y << ","
1675 << "strength=" << point.strength << ","
1676 << "scale=" << point.scale << ","
1677 << "orientation=" << point.orientation << ","
1678 << "tracking_status=" << point.tracking_status << ","
1679 << "error=" << point.error << "}";
1680
1681 return os;
1682}
John Richardson63e50412017-10-13 20:51:42 +01001683
Alex Gildayc357c472018-03-21 13:54:09 +00001684/** Formatted output of the PhaseType type.
1685 *
1686 * @param[out] os Output stream
1687 * @param[in] phase_type Type to output.
1688 *
1689 * @return Modified output stream.
1690 */
John Richardson63e50412017-10-13 20:51:42 +01001691inline ::std::ostream &operator<<(::std::ostream &os, const PhaseType &phase_type)
1692{
1693 switch(phase_type)
1694 {
1695 case PhaseType::SIGNED:
1696 os << "SIGNED";
1697 break;
1698 case PhaseType::UNSIGNED:
1699 os << "UNSIGNED";
1700 break;
1701 default:
1702 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1703 }
1704
1705 return os;
1706}
1707
Alex Gildayc357c472018-03-21 13:54:09 +00001708/** Formatted output of the PhaseType type.
1709 *
1710 * @param[in] type Type to output.
1711 *
1712 * @return Formatted string.
1713 */
John Richardson63e50412017-10-13 20:51:42 +01001714inline std::string to_string(const arm_compute::PhaseType &type)
1715{
1716 std::stringstream str;
1717 str << type;
1718 return str.str();
1719}
John Richardson3c5f9492017-10-04 15:27:37 +01001720
Alex Gildayc357c472018-03-21 13:54:09 +00001721/** Formatted output of the MagnitudeType type.
1722 *
1723 * @param[out] os Output stream
1724 * @param[in] magnitude_type Type to output.
1725 *
1726 * @return Modified output stream.
1727 */
John Richardson3c5f9492017-10-04 15:27:37 +01001728inline ::std::ostream &operator<<(::std::ostream &os, const MagnitudeType &magnitude_type)
1729{
1730 switch(magnitude_type)
1731 {
1732 case MagnitudeType::L1NORM:
1733 os << "L1NORM";
1734 break;
1735 case MagnitudeType::L2NORM:
1736 os << "L2NORM";
1737 break;
1738 default:
1739 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1740 }
1741
1742 return os;
1743}
1744
Alex Gildayc357c472018-03-21 13:54:09 +00001745/** Formatted output of the MagnitudeType type.
1746 *
1747 * @param[in] type Type to output.
1748 *
1749 * @return Formatted string.
1750 */
John Richardson3c5f9492017-10-04 15:27:37 +01001751inline std::string to_string(const arm_compute::MagnitudeType &type)
1752{
1753 std::stringstream str;
1754 str << type;
1755 return str.str();
1756}
John Richardson1c529922017-11-01 10:57:48 +00001757
Alex Gildayc357c472018-03-21 13:54:09 +00001758/** Formatted output of the HOGNormType type.
1759 *
1760 * @param[out] os Output stream
1761 * @param[in] norm_type Type to output
1762 *
1763 * @return Modified output stream.
1764 */
John Richardson25f23682017-11-27 14:35:09 +00001765inline ::std::ostream &operator<<(::std::ostream &os, const HOGNormType &norm_type)
1766{
1767 switch(norm_type)
1768 {
1769 case HOGNormType::L1_NORM:
1770 os << "L1_NORM";
1771 break;
1772 case HOGNormType::L2_NORM:
1773 os << "L2_NORM";
1774 break;
1775 case HOGNormType::L2HYS_NORM:
1776 os << "L2HYS_NORM";
1777 break;
1778 default:
1779 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1780 }
1781
1782 return os;
1783}
1784
Alex Gildayc357c472018-03-21 13:54:09 +00001785/** Formatted output of the HOGNormType type.
1786 *
1787 * @param[in] type Type to output
1788 *
1789 * @return Formatted string.
1790 */
John Richardson25f23682017-11-27 14:35:09 +00001791inline std::string to_string(const HOGNormType &type)
1792{
1793 std::stringstream str;
1794 str << type;
1795 return str.str();
1796}
1797
Alex Gildayc357c472018-03-21 13:54:09 +00001798/** Formatted output of the Size2D type.
1799 *
1800 * @param[out] os Output stream
1801 * @param[in] size Type to output
1802 *
1803 * @return Modified output stream.
1804 */
John Richardson25f23682017-11-27 14:35:09 +00001805inline ::std::ostream &operator<<(::std::ostream &os, const Size2D &size)
1806{
1807 os << size.width << "x" << size.height;
1808
1809 return os;
1810}
1811
Alex Gildayc357c472018-03-21 13:54:09 +00001812/** Formatted output of the Size2D type.
1813 *
1814 * @param[in] type Type to output
1815 *
1816 * @return Formatted string.
1817 */
John Richardson25f23682017-11-27 14:35:09 +00001818inline std::string to_string(const Size2D &type)
1819{
1820 std::stringstream str;
1821 str << type;
1822 return str.str();
1823}
1824
Alex Gildayc357c472018-03-21 13:54:09 +00001825/** Formatted output of the HOGInfo type.
1826 *
1827 * @param[out] os Output stream
1828 * @param[in] hog_info Type to output
1829 *
1830 * @return Modified output stream.
1831 */
John Richardson25f23682017-11-27 14:35:09 +00001832inline ::std::ostream &operator<<(::std::ostream &os, const HOGInfo &hog_info)
1833{
1834 os << "{CellSize=" << hog_info.cell_size() << ","
1835 << "BlockSize=" << hog_info.block_size() << ","
1836 << "DetectionWindowSize=" << hog_info.detection_window_size() << ","
1837 << "BlockStride=" << hog_info.block_stride() << ","
1838 << "NumBins=" << hog_info.num_bins() << ","
1839 << "NormType=" << hog_info.normalization_type() << ","
1840 << "L2HystThreshold=" << hog_info.l2_hyst_threshold() << ","
1841 << "PhaseType=" << hog_info.phase_type() << "}";
1842
1843 return os;
1844}
1845
Alex Gildayc357c472018-03-21 13:54:09 +00001846/** Formatted output of the HOGInfo type.
1847 *
1848 * @param[in] type Type to output
1849 *
1850 * @return Formatted string.
1851 */
John Richardson25f23682017-11-27 14:35:09 +00001852inline std::string to_string(const HOGInfo &type)
1853{
1854 std::stringstream str;
1855 str << type;
1856 return str.str();
1857}
1858
Alex Gildayc357c472018-03-21 13:54:09 +00001859/** Formatted output of the ConvolutionMethod type.
1860 *
1861 * @param[out] os Output stream
1862 * @param[in] conv_method Type to output
1863 *
1864 * @return Modified output stream.
1865 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001866inline ::std::ostream &operator<<(::std::ostream &os, const ConvolutionMethod &conv_method)
1867{
1868 switch(conv_method)
1869 {
1870 case ConvolutionMethod::GEMM:
1871 os << "GEMM";
1872 break;
1873 case ConvolutionMethod::DIRECT:
1874 os << "DIRECT";
1875 break;
1876 case ConvolutionMethod::WINOGRAD:
1877 os << "WINOGRAD";
1878 break;
1879 default:
1880 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1881 }
1882
1883 return os;
1884}
1885
Alex Gildayc357c472018-03-21 13:54:09 +00001886/** Formatted output of the ConvolutionMethod type.
1887 *
1888 * @param[in] conv_method Type to output
1889 *
1890 * @return Formatted string.
1891 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001892inline std::string to_string(const ConvolutionMethod &conv_method)
1893{
1894 std::stringstream str;
1895 str << conv_method;
1896 return str.str();
1897}
1898
Alex Gildayc357c472018-03-21 13:54:09 +00001899/** Formatted output of the GPUTarget type.
1900 *
1901 * @param[out] os Output stream
1902 * @param[in] gpu_target Type to output
1903 *
1904 * @return Modified output stream.
1905 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001906inline ::std::ostream &operator<<(::std::ostream &os, const GPUTarget &gpu_target)
1907{
1908 switch(gpu_target)
1909 {
1910 case GPUTarget::GPU_ARCH_MASK:
1911 os << "GPU_ARCH_MASK";
1912 break;
1913 case GPUTarget::MIDGARD:
1914 os << "MIDGARD";
1915 break;
1916 case GPUTarget::BIFROST:
1917 os << "BIFROST";
1918 break;
Georgios Pinitasd5462ff2019-07-03 19:33:57 +01001919 case GPUTarget::VALHALL:
1920 os << "VALHALL";
1921 break;
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001922 case GPUTarget::T600:
1923 os << "T600";
1924 break;
1925 case GPUTarget::T700:
1926 os << "T700";
1927 break;
1928 case GPUTarget::T800:
1929 os << "T800";
1930 break;
Michalis Spyroua9676112018-02-22 18:07:43 +00001931 case GPUTarget::G71:
1932 os << "G71";
1933 break;
1934 case GPUTarget::G72:
1935 os << "G72";
1936 break;
1937 case GPUTarget::G51:
1938 os << "G51";
1939 break;
1940 case GPUTarget::G51BIG:
1941 os << "G51BIG";
1942 break;
1943 case GPUTarget::G51LIT:
1944 os << "G51LIT";
1945 break;
Georgios Pinitasb03f7c52018-07-12 10:49:53 +01001946 case GPUTarget::G76:
1947 os << "G76";
Michalis Spyroua9676112018-02-22 18:07:43 +00001948 break;
Georgios Pinitasd5462ff2019-07-03 19:33:57 +01001949 case GPUTarget::G77:
1950 os << "G77";
Michalis Spyroua9676112018-02-22 18:07:43 +00001951 break;
1952 case GPUTarget::TBOX:
1953 os << "TBOX";
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001954 break;
Georgios Pinitasd5462ff2019-07-03 19:33:57 +01001955 case GPUTarget::TODX:
1956 os << "TODX";
1957 break;
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001958 default:
1959 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1960 }
1961
1962 return os;
1963}
1964
Alex Gildayc357c472018-03-21 13:54:09 +00001965/** Formatted output of the GPUTarget type.
1966 *
1967 * @param[in] gpu_target Type to output
1968 *
1969 * @return Formatted string.
1970 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001971inline std::string to_string(const GPUTarget &gpu_target)
1972{
1973 std::stringstream str;
1974 str << gpu_target;
1975 return str.str();
1976}
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00001977
John Richardson8de92612018-02-22 14:09:31 +00001978/** Formatted output of the DetectionWindow type.
1979 *
1980 * @param[out] os Output stream
1981 * @param[in] detection_window Type to output
1982 *
1983 * @return Modified output stream.
1984 */
John Richardson684cb0f2018-01-09 11:17:00 +00001985inline ::std::ostream &operator<<(::std::ostream &os, const DetectionWindow &detection_window)
1986{
1987 os << "{x=" << detection_window.x << ","
1988 << "y=" << detection_window.y << ","
1989 << "width=" << detection_window.width << ","
1990 << "height=" << detection_window.height << ","
1991 << "idx_class=" << detection_window.idx_class << ","
1992 << "score=" << detection_window.score << "}";
1993
1994 return os;
1995}
1996
Isabella Gottardi05e56442018-11-16 11:26:52 +00001997/** Formatted output of the DetectionOutputLayerCodeType type.
1998 *
1999 * @param[out] os Output stream
2000 * @param[in] detection_code Type to output
2001 *
2002 * @return Modified output stream.
2003 */
2004inline ::std::ostream &operator<<(::std::ostream &os, const DetectionOutputLayerCodeType &detection_code)
2005{
2006 switch(detection_code)
2007 {
2008 case DetectionOutputLayerCodeType::CENTER_SIZE:
2009 os << "CENTER_SIZE";
2010 break;
2011 case DetectionOutputLayerCodeType::CORNER:
2012 os << "CORNER";
2013 break;
2014 case DetectionOutputLayerCodeType::CORNER_SIZE:
2015 os << "CORNER_SIZE";
2016 break;
2017 case DetectionOutputLayerCodeType::TF_CENTER:
2018 os << "TF_CENTER";
2019 break;
2020 default:
2021 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2022 }
2023
2024 return os;
2025}
2026/** Formatted output of the DetectionOutputLayerCodeType type.
2027 *
2028 * @param[in] detection_code Type to output
2029 *
2030 * @return Formatted string.
2031 */
2032inline std::string to_string(const DetectionOutputLayerCodeType &detection_code)
2033{
2034 std::stringstream str;
2035 str << detection_code;
2036 return str.str();
2037}
2038
2039/** Formatted output of the DetectionOutputLayerInfo type.
2040 *
2041 * @param[out] os Output stream
2042 * @param[in] detection_info Type to output
2043 *
2044 * @return Modified output stream.
2045 */
2046inline ::std::ostream &operator<<(::std::ostream &os, const DetectionOutputLayerInfo &detection_info)
2047{
2048 os << "{Classes=" << detection_info.num_classes() << ","
2049 << "ShareLocation=" << detection_info.share_location() << ","
2050 << "CodeType=" << detection_info.code_type() << ","
2051 << "VarianceEncodedInTarget=" << detection_info.variance_encoded_in_target() << ","
2052 << "KeepTopK=" << detection_info.keep_top_k() << ","
2053 << "NMSThreshold=" << detection_info.nms_threshold() << ","
2054 << "Eta=" << detection_info.eta() << ","
2055 << "BackgroundLabelId=" << detection_info.background_label_id() << ","
2056 << "ConfidenceThreshold=" << detection_info.confidence_threshold() << ","
2057 << "TopK=" << detection_info.top_k() << ","
2058 << "NumLocClasses=" << detection_info.num_loc_classes()
2059 << "}";
2060
2061 return os;
2062}
2063
2064/** Formatted output of the DetectionOutputLayerInfo type.
2065 *
2066 * @param[in] detection_info Type to output
2067 *
2068 * @return Formatted string.
2069 */
2070inline std::string to_string(const DetectionOutputLayerInfo &detection_info)
2071{
2072 std::stringstream str;
2073 str << detection_info;
2074 return str.str();
2075}
Isabella Gottardia7acb3c2019-01-08 13:48:44 +00002076/** Formatted output of the DetectionPostProcessLayerInfo type.
2077 *
2078 * @param[out] os Output stream
2079 * @param[in] detection_info Type to output
2080 *
2081 * @return Modified output stream.
2082 */
2083inline ::std::ostream &operator<<(::std::ostream &os, const DetectionPostProcessLayerInfo &detection_info)
2084{
2085 os << "{MaxDetections=" << detection_info.max_detections() << ","
2086 << "MaxClassesPerDetection=" << detection_info.max_classes_per_detection() << ","
2087 << "NmsScoreThreshold=" << detection_info.nms_score_threshold() << ","
2088 << "NmsIouThreshold=" << detection_info.iou_threshold() << ","
2089 << "NumClasses=" << detection_info.num_classes() << ","
2090 << "ScaleValue_y=" << detection_info.scale_value_y() << ","
2091 << "ScaleValue_x=" << detection_info.scale_value_x() << ","
2092 << "ScaleValue_h=" << detection_info.scale_value_h() << ","
2093 << "ScaleValue_w=" << detection_info.scale_value_w() << ","
2094 << "UseRegularNms=" << detection_info.use_regular_nms() << ","
2095 << "DetectionPerClass=" << detection_info.detection_per_class()
2096 << "}";
2097
2098 return os;
2099}
2100
2101/** Formatted output of the DetectionPostProcessLayerInfo type.
2102 *
2103 * @param[in] detection_info Type to output
2104 *
2105 * @return Formatted string.
2106 */
2107inline std::string to_string(const DetectionPostProcessLayerInfo &detection_info)
2108{
2109 std::stringstream str;
2110 str << detection_info;
2111 return str.str();
2112}
John Richardson8de92612018-02-22 14:09:31 +00002113/** Formatted output of the DetectionWindow type.
2114 *
2115 * @param[in] detection_window Type to output
2116 *
2117 * @return Formatted string.
2118 */
2119inline std::string to_string(const DetectionWindow &detection_window)
2120{
2121 std::stringstream str;
2122 str << detection_window;
2123 return str.str();
2124}
2125
2126/** Formatted output of the Termination type.
2127 *
2128 * @param[out] os Output stream
2129 * @param[in] termination Type to output
2130 *
2131 * @return Modified output stream.
2132 */
2133inline ::std::ostream &operator<<(::std::ostream &os, const Termination &termination)
2134{
2135 switch(termination)
2136 {
2137 case Termination::TERM_CRITERIA_EPSILON:
2138 os << "TERM_CRITERIA_EPSILON";
2139 break;
2140 case Termination::TERM_CRITERIA_ITERATIONS:
2141 os << "TERM_CRITERIA_ITERATIONS";
2142 break;
2143 case Termination::TERM_CRITERIA_BOTH:
2144 os << "TERM_CRITERIA_BOTH";
2145 break;
2146 default:
2147 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2148 }
2149
2150 return os;
2151}
2152
2153/** Formatted output of the Termination type.
2154 *
2155 * @param[in] termination Type to output
2156 *
2157 * @return Formatted string.
2158 */
2159inline std::string to_string(const Termination &termination)
2160{
2161 std::stringstream str;
2162 str << termination;
2163 return str.str();
2164}
2165
Anthony Barbier8914e322018-08-10 15:28:25 +01002166/** Formatted output of the CPUModel type.
2167 *
2168 * @param[out] os Output stream
2169 * @param[in] cpu_model Model to output
2170 *
2171 * @return Modified output stream.
2172 */
2173inline ::std::ostream &operator<<(::std::ostream &os, const CPUModel &cpu_model)
2174{
2175 switch(cpu_model)
2176 {
2177 case CPUModel::GENERIC:
2178 os << "GENERIC";
2179 break;
2180 case CPUModel::GENERIC_FP16:
2181 os << "GENERIC_FP16";
2182 break;
2183 case CPUModel::GENERIC_FP16_DOT:
2184 os << "GENERIC_FP16_DOT";
2185 break;
2186 case CPUModel::A53:
2187 os << "A53";
2188 break;
2189 case CPUModel::A55r0:
2190 os << "A55r0";
2191 break;
2192 case CPUModel::A55r1:
2193 os << "A55r1";
2194 break;
2195 default:
2196 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2197 }
2198
2199 return os;
2200}
2201
2202/** Formatted output of the CPUModel type.
2203 *
2204 * @param[in] cpu_model Model to output
2205 *
2206 * @return Formatted string.
2207 */
2208inline std::string to_string(const CPUModel &cpu_model)
2209{
2210 std::stringstream str;
2211 str << cpu_model;
2212 return str.str();
2213}
Anthony Barbier671a11e2018-07-06 15:11:36 +01002214/** Formatted output of a vector of objects.
2215 *
2216 * @param[out] os Output stream
2217 * @param[in] args Vector of objects to print
2218 *
2219 * @return Modified output stream.
2220 */
2221template <typename T>
2222inline ::std::ostream &operator<<(::std::ostream &os, const std::vector<T> &args)
2223{
2224 os << "[";
2225 bool first = true;
2226 for(auto &arg : args)
2227 {
2228 if(first)
2229 {
2230 first = false;
2231 }
2232 else
2233 {
2234 os << ", ";
2235 }
2236 os << arg;
2237 }
2238 os << "]";
2239 return os;
2240}
2241
Michalis Spyrou6c7c38e2018-08-29 16:28:11 +01002242/** Formatted output of @ref PriorBoxLayerInfo.
2243 *
2244 * @param[out] os Output stream.
2245 * @param[in] info Type to output.
2246 *
2247 * @return Modified output stream.
2248 */
2249inline ::std::ostream &operator<<(::std::ostream &os, const PriorBoxLayerInfo &info)
2250{
2251 os << "Clip:" << info.clip()
2252 << "Flip:" << info.flip()
2253 << "StepX:" << info.steps()[0]
2254 << "StepY:" << info.steps()[1]
2255 << "MinSizes:" << info.min_sizes()
2256 << "MaxSizes:" << info.max_sizes()
2257 << "ImgSizeX:" << info.img_size().x
2258 << "ImgSizeY:" << info.img_size().y
2259 << "Offset:" << info.offset()
2260 << "Variances:" << info.variances();
2261
2262 return os;
2263}
2264
Anthony Barbier671a11e2018-07-06 15:11:36 +01002265/** Formatted output of a vector of objects.
2266 *
2267 * @param[in] args Vector of objects to print
2268 *
2269 * @return String representing args.
2270 */
2271template <typename T>
2272std::string to_string(const std::vector<T> &args)
2273{
2274 std::stringstream str;
2275 str << args;
2276 return str.str();
2277}
2278
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00002279/** Formatted output of the WinogradInfo type. */
2280inline ::std::ostream &operator<<(::std::ostream &os, const WinogradInfo &info)
2281{
2282 os << "{OutputTileSize=" << info.output_tile_size << ","
2283 << "KernelSize=" << info.kernel_size << ","
2284 << "PadStride=" << info.convolution_info << ","
2285 << "OutputDataLayout=" << info.output_data_layout << "}";
2286
2287 return os;
2288}
2289
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00002290inline std::string to_string(const WinogradInfo &type)
2291{
2292 std::stringstream str;
2293 str << type;
2294 return str.str();
2295}
Anthony Barbier671a11e2018-07-06 15:11:36 +01002296
2297/** Fallback method: try to use std::to_string:
2298 *
2299 * @param[in] val Value to convert to string
2300 *
2301 * @return String representing val.
2302 */
2303template <typename T>
2304inline std::string to_string(const T &val)
2305{
2306 return support::cpp11::to_string(val);
2307}
2308
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +01002309/** Convert a CLTunerMode value to a string
2310 *
2311 * @param val CLTunerMode value to be converted
2312 *
2313 * @return String representing the corresponding CLTunerMode.
2314 */
2315inline std::string to_string(const CLTunerMode val)
2316{
2317 switch(val)
2318 {
2319 case CLTunerMode::EXHAUSTIVE:
2320 {
2321 return std::string("Exhaustive");
2322 }
2323 case CLTunerMode::NORMAL:
2324 {
2325 return std::string("Normal");
2326 }
2327 case CLTunerMode::RAPID:
2328 {
2329 return std::string("Rapid");
2330 }
2331 default:
2332 {
2333 ARM_COMPUTE_ERROR("Invalid tuner mode.");
2334 return std::string("UNDEFINED");
2335 }
2336 }
2337}
2338/** [Print CLTunerMode type] **/
2339/** Formatted output of the CLTunerMode type.
2340 *
2341 * @param[out] os Output stream.
2342 * @param[in] val CLTunerMode to output.
2343 *
2344 * @return Modified output stream.
2345 */
2346inline ::std::ostream &operator<<(::std::ostream &os, const CLTunerMode &val)
2347{
2348 os << to_string(val);
2349 return os;
2350}
2351
Anthony Barbier6ff3b192017-09-04 18:44:23 +01002352} // namespace arm_compute
Anthony Barbier4dbc0a92018-08-27 13:39:47 +01002353
2354#endif /* __ARM_COMPUTE_TYPE_PRINTER_H__ */