blob: 79ec367a52bc758c197f207ac8e340de57468c90 [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;
Georgios Pinitase8291ac2020-02-26 09:58:13 +0000668 case DataType::BFLOAT16:
669 os << "BFLOAT16";
670 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100671 case DataType::F16:
672 os << "F16";
673 break;
674 case DataType::F32:
675 os << "F32";
676 break;
677 case DataType::F64:
678 os << "F64";
679 break;
680 case DataType::SIZET:
681 os << "SIZET";
682 break;
683 default:
684 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
685 }
686
687 return os;
688}
689
Alex Gildayc357c472018-03-21 13:54:09 +0000690/** Formatted output of the DataType type.
691 *
692 * @param[in] data_type Type to output.
693 *
694 * @return Formatted string.
695 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100696inline std::string to_string(const arm_compute::DataType &data_type)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100697{
698 std::stringstream str;
699 str << data_type;
700 return str.str();
701}
702
Alex Gildayc357c472018-03-21 13:54:09 +0000703/** Formatted output of the Format type.
704 *
705 * @param[out] os Output stream.
706 * @param[in] format Type to output.
707 *
708 * @return Modified output stream.
709 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100710inline ::std::ostream &operator<<(::std::ostream &os, const Format &format)
711{
712 switch(format)
713 {
714 case Format::UNKNOWN:
715 os << "UNKNOWN";
716 break;
717 case Format::U8:
718 os << "U8";
719 break;
720 case Format::S16:
721 os << "S16";
722 break;
723 case Format::U16:
724 os << "U16";
725 break;
726 case Format::S32:
727 os << "S32";
728 break;
729 case Format::U32:
730 os << "U32";
731 break;
732 case Format::F16:
733 os << "F16";
734 break;
735 case Format::F32:
736 os << "F32";
737 break;
738 case Format::UV88:
739 os << "UV88";
740 break;
741 case Format::RGB888:
742 os << "RGB888";
743 break;
744 case Format::RGBA8888:
745 os << "RGBA8888";
746 break;
747 case Format::YUV444:
748 os << "YUV444";
749 break;
750 case Format::YUYV422:
751 os << "YUYV422";
752 break;
753 case Format::NV12:
754 os << "NV12";
755 break;
756 case Format::NV21:
757 os << "NV21";
758 break;
759 case Format::IYUV:
760 os << "IYUV";
761 break;
762 case Format::UYVY422:
763 os << "UYVY422";
764 break;
765 default:
766 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
767 }
768
769 return os;
770}
771
Alex Gildayc357c472018-03-21 13:54:09 +0000772/** Formatted output of the Format type.
773 *
774 * @param[in] format Type to output.
775 *
776 * @return Formatted string.
777 */
Moritz Pflanzer7655a672017-09-23 11:57:33 +0100778inline std::string to_string(const Format &format)
779{
780 std::stringstream str;
781 str << format;
782 return str.str();
783}
784
Alex Gildayc357c472018-03-21 13:54:09 +0000785/** Formatted output of the Channel type.
786 *
787 * @param[out] os Output stream.
788 * @param[in] channel Type to output.
789 *
790 * @return Modified output stream.
791 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100792inline ::std::ostream &operator<<(::std::ostream &os, const Channel &channel)
793{
794 switch(channel)
795 {
796 case Channel::UNKNOWN:
797 os << "UNKNOWN";
798 break;
799 case Channel::C0:
800 os << "C0";
801 break;
802 case Channel::C1:
803 os << "C1";
804 break;
805 case Channel::C2:
806 os << "C2";
807 break;
808 case Channel::C3:
809 os << "C3";
810 break;
811 case Channel::R:
812 os << "R";
813 break;
814 case Channel::G:
815 os << "G";
816 break;
817 case Channel::B:
818 os << "B";
819 break;
820 case Channel::A:
821 os << "A";
822 break;
823 case Channel::Y:
824 os << "Y";
825 break;
826 case Channel::U:
827 os << "U";
828 break;
829 case Channel::V:
830 os << "V";
831 break;
832 default:
833 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
834 }
835
836 return os;
837}
838
Alex Gildayc357c472018-03-21 13:54:09 +0000839/** Formatted output of the Channel type.
840 *
841 * @param[in] channel Type to output.
842 *
843 * @return Formatted string.
844 */
Ioan-Cristian Szabo9414f642017-10-27 17:35:40 +0100845inline std::string to_string(const Channel &channel)
846{
847 std::stringstream str;
848 str << channel;
849 return str.str();
850}
851
Alex Gildayc357c472018-03-21 13:54:09 +0000852/** Formatted output of the BorderMode type.
853 *
854 * @param[out] os Output stream.
855 * @param[in] mode Type to output.
856 *
857 * @return Modified output stream.
858 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100859inline ::std::ostream &operator<<(::std::ostream &os, const BorderMode &mode)
860{
861 switch(mode)
862 {
863 case BorderMode::UNDEFINED:
864 os << "UNDEFINED";
865 break;
866 case BorderMode::CONSTANT:
867 os << "CONSTANT";
868 break;
869 case BorderMode::REPLICATE:
870 os << "REPLICATE";
871 break;
872 default:
873 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
874 }
875
876 return os;
877}
878
Alex Gildayc357c472018-03-21 13:54:09 +0000879/** Formatted output of the BorderSize type.
880 *
881 * @param[out] os Output stream.
882 * @param[in] border Type to output.
883 *
884 * @return Modified output stream.
885 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100886inline ::std::ostream &operator<<(::std::ostream &os, const BorderSize &border)
887{
Moritz Pflanzerc87fbf82017-07-18 14:02:10 +0100888 os << border.top << ","
889 << border.right << ","
890 << border.bottom << ","
891 << border.left;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100892
893 return os;
894}
Anthony Barbier2a07e182017-08-04 18:20:27 +0100895
Giuseppe Rossinid7647d42018-07-17 18:13:13 +0100896/** Formatted output of the PaddingList type.
897 *
898 * @param[out] os Output stream.
899 * @param[in] padding Type to output.
900 *
901 * @return Modified output stream.
902 */
903inline ::std::ostream &operator<<(::std::ostream &os, const PaddingList &padding)
904{
905 os << "{";
906 for(auto const &p : padding)
907 {
908 os << "{" << p.first << "," << p.second << "}";
909 }
910 os << "}";
911 return os;
912}
913
giuros013175fcf2018-11-21 09:59:17 +0000914/** Formatted output of the Multiples type.
915 *
916 * @param[out] os Output stream.
917 * @param[in] multiples Type to output.
918 *
919 * @return Modified output stream.
920 */
921inline ::std::ostream &operator<<(::std::ostream &os, const Multiples &multiples)
922{
923 os << "(";
924 for(size_t i = 0; i < multiples.size() - 1; i++)
925 {
926 os << multiples[i] << ", ";
927 }
928 os << multiples.back() << ")";
929 return os;
930}
931
Alex Gildayc357c472018-03-21 13:54:09 +0000932/** Formatted output of the InterpolationPolicy type.
933 *
934 * @param[out] os Output stream.
935 * @param[in] policy Type to output.
936 *
937 * @return Modified output stream.
938 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100939inline ::std::ostream &operator<<(::std::ostream &os, const InterpolationPolicy &policy)
940{
941 switch(policy)
942 {
943 case InterpolationPolicy::NEAREST_NEIGHBOR:
944 os << "NEAREST_NEIGHBOR";
945 break;
946 case InterpolationPolicy::BILINEAR:
947 os << "BILINEAR";
948 break;
949 case InterpolationPolicy::AREA:
950 os << "AREA";
951 break;
952 default:
953 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
954 }
955
956 return os;
957}
958
Alex Gildayc357c472018-03-21 13:54:09 +0000959/** Formatted output of the SamplingPolicy type.
960 *
961 * @param[out] os Output stream.
962 * @param[in] policy Type to output.
963 *
964 * @return Modified output stream.
965 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700966inline ::std::ostream &operator<<(::std::ostream &os, const SamplingPolicy &policy)
967{
968 switch(policy)
969 {
970 case SamplingPolicy::CENTER:
971 os << "CENTER";
972 break;
973 case SamplingPolicy::TOP_LEFT:
974 os << "TOP_LEFT";
975 break;
976 default:
977 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
978 }
979
980 return os;
981}
982
Alex Gildayc357c472018-03-21 13:54:09 +0000983/** Formatted output of the TensorInfo type.
984 *
Anthony Barbier366628a2018-08-01 13:55:03 +0100985 * @param[out] os Output stream.
986 * @param[in] info Type to output.
987 *
988 * @return Modified output stream.
989 */
990inline ::std::ostream &operator<<(::std::ostream &os, const TensorInfo &info)
991{
992 os << "{Shape=" << info.tensor_shape() << ","
993 << "Type=" << info.data_type() << ","
994 << "Channels=" << info.num_channels() << "}";
995 return os;
996}
997/** Formatted output of the TensorInfo type.
998 *
Alex Gildayc357c472018-03-21 13:54:09 +0000999 * @param[in] info Type to output.
1000 *
1001 * @return Formatted string.
1002 */
Georgios Pinitas3faea252017-10-30 14:13:50 +00001003inline std::string to_string(const TensorInfo &info)
1004{
1005 std::stringstream str;
Anthony Barbier366628a2018-08-01 13:55:03 +01001006 str << info;
Georgios Pinitas3faea252017-10-30 14:13:50 +00001007 return str.str();
1008}
1009
Alex Gildayc357c472018-03-21 13:54:09 +00001010/** Formatted output of the Dimensions type.
1011 *
1012 * @param[in] dimensions Type to output.
1013 *
1014 * @return Formatted string.
1015 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001016template <typename T>
1017inline std::string to_string(const Dimensions<T> &dimensions)
1018{
1019 std::stringstream str;
1020 str << dimensions;
1021 return str.str();
1022}
1023
Alex Gildayc357c472018-03-21 13:54:09 +00001024/** Formatted output of the Strides type.
1025 *
1026 * @param[in] stride Type to output.
1027 *
1028 * @return Formatted string.
1029 */
John Richardsona36eae12017-09-26 16:55:59 +01001030inline std::string to_string(const Strides &stride)
1031{
1032 std::stringstream str;
1033 str << stride;
1034 return str.str();
1035}
1036
Alex Gildayc357c472018-03-21 13:54:09 +00001037/** Formatted output of the TensorShape type.
1038 *
1039 * @param[in] shape Type to output.
1040 *
1041 * @return Formatted string.
1042 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001043inline std::string to_string(const TensorShape &shape)
1044{
1045 std::stringstream str;
1046 str << shape;
1047 return str.str();
1048}
1049
Alex Gildayc357c472018-03-21 13:54:09 +00001050/** Formatted output of the Coordinates type.
1051 *
1052 * @param[in] coord Type to output.
1053 *
1054 * @return Formatted string.
1055 */
Abe Mbise925ca0f2017-10-02 19:16:33 +01001056inline std::string to_string(const Coordinates &coord)
1057{
1058 std::stringstream str;
1059 str << coord;
1060 return str.str();
1061}
1062
Anthony Barbierb940fd62018-06-04 14:14:32 +01001063/** Formatted output of the GEMMReshapeInfo type.
1064 *
1065 * @param[out] os Output stream.
1066 * @param[in] info Type to output.
1067 *
1068 * @return Modified output stream.
1069 */
1070inline ::std::ostream &operator<<(::std::ostream &os, const GEMMReshapeInfo &info)
1071{
1072 os << "{m=" << info.m() << ",";
1073 os << "n=" << info.n() << ",";
1074 os << "k=" << info.k() << ",";
1075 os << "mult_transpose1xW_width=" << info.mult_transpose1xW_width() << ",";
1076 os << "mult_interleave4x4_height=" << info.mult_interleave4x4_height();
1077 os << "}";
1078
1079 return os;
1080}
1081
1082/** Formatted output of the GEMMInfo type.
1083 *
1084 * @param[out] os Output stream.
1085 * @param[in] info Type to output.
1086 *
1087 * @return Modified output stream.
1088 */
1089inline ::std::ostream &operator<<(::std::ostream &os, const GEMMInfo &info)
1090{
1091 os << "{is_a_reshaped=" << info.is_a_reshaped() << ",";
1092 os << "is_b_reshaped=" << info.is_b_reshaped() << ",";
1093 os << "reshape_b_only_on_first_run=" << info.reshape_b_only_on_first_run() << ",";
Anthony Barbierb940fd62018-06-04 14:14:32 +01001094 os << "}";
1095
1096 return os;
1097}
1098
1099/** Formatted output of the Window::Dimension type.
1100 *
1101 * @param[out] os Output stream.
1102 * @param[in] dim Type to output.
1103 *
1104 * @return Modified output stream.
1105 */
1106inline ::std::ostream &operator<<(::std::ostream &os, const Window::Dimension &dim)
1107{
1108 os << "{start=" << dim.start() << ", end=" << dim.end() << ", step=" << dim.step() << "}";
1109
1110 return os;
1111}
1112/** Formatted output of the Window type.
1113 *
1114 * @param[out] os Output stream.
1115 * @param[in] win Type to output.
1116 *
1117 * @return Modified output stream.
1118 */
1119inline ::std::ostream &operator<<(::std::ostream &os, const Window &win)
1120{
1121 os << "{";
1122 for(unsigned int i = 0; i < Coordinates::num_max_dimensions; i++)
1123 {
1124 if(i > 0)
1125 {
1126 os << ", ";
1127 }
1128 os << win[i];
1129 }
1130 os << "}";
1131
1132 return os;
1133}
1134
1135/** Formatted output of the WeightsInfo type.
1136 *
1137 * @param[in] info Type to output.
1138 *
1139 * @return Formatted string.
1140 */
1141inline std::string to_string(const WeightsInfo &info)
1142{
1143 std::stringstream str;
1144 str << info;
1145 return str.str();
1146}
1147
1148/** Formatted output of the GEMMReshapeInfo type.
1149 *
1150 * @param[in] info Type to output.
1151 *
1152 * @return Formatted string.
1153 */
1154inline std::string to_string(const GEMMReshapeInfo &info)
1155{
1156 std::stringstream str;
1157 str << info;
1158 return str.str();
1159}
1160
1161/** Formatted output of the GEMMInfo type.
1162 *
1163 * @param[in] info Type to output.
1164 *
1165 * @return Formatted string.
1166 */
1167inline std::string to_string(const GEMMInfo &info)
1168{
1169 std::stringstream str;
1170 str << info;
1171 return str.str();
1172}
1173
1174/** Formatted output of the Window::Dimension type.
1175 *
1176 * @param[in] dim Type to output.
1177 *
1178 * @return Formatted string.
1179 */
1180inline std::string to_string(const Window::Dimension &dim)
1181{
1182 std::stringstream str;
1183 str << dim;
1184 return str.str();
1185}
1186/** Formatted output of the Window type.
1187 *
1188 * @param[in] win Type to output.
1189 *
1190 * @return Formatted string.
1191 */
1192inline std::string to_string(const Window &win)
1193{
1194 std::stringstream str;
1195 str << win;
1196 return str.str();
1197}
1198
Alex Gildayc357c472018-03-21 13:54:09 +00001199/** Formatted output of the Rectangle type.
1200 *
1201 * @param[out] os Output stream.
1202 * @param[in] rect Type to output.
1203 *
1204 * @return Modified output stream.
1205 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001206inline ::std::ostream &operator<<(::std::ostream &os, const Rectangle &rect)
1207{
1208 os << rect.width << "x" << rect.height;
1209 os << "+" << rect.x << "+" << rect.y;
1210
1211 return os;
1212}
1213
Usama Arif8cf8c112019-03-14 15:36:54 +00001214/** Formatted output of the PaddingMode type.
1215 *
1216 * @param[out] os Output stream.
1217 * @param[in] mode Type to output.
1218 *
1219 * @return Modified output stream.
1220 */
1221inline ::std::ostream &operator<<(::std::ostream &os, const PaddingMode &mode)
1222{
1223 switch(mode)
1224 {
1225 case PaddingMode::CONSTANT:
1226 os << "CONSTANT";
1227 break;
1228 case PaddingMode::REFLECT:
1229 os << "REFLECT";
1230 break;
1231 case PaddingMode::SYMMETRIC:
1232 os << "SYMMETRIC";
1233 break;
1234 default:
1235 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1236 }
1237
1238 return os;
1239}
1240
1241/** Formatted output of the PaddingMode type.
1242 *
1243 * @param[in] mode Type to output.
1244 *
1245 * @return Formatted string.
1246 */
1247inline std::string to_string(const PaddingMode &mode)
1248{
1249 std::stringstream str;
1250 str << mode;
1251 return str.str();
1252}
1253
Alex Gildayc357c472018-03-21 13:54:09 +00001254/** Formatted output of the PadStrideInfo type.
1255 *
1256 * @param[out] os Output stream.
1257 * @param[in] pad_stride_info Type to output.
1258 *
1259 * @return Modified output stream.
1260 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001261inline ::std::ostream &operator<<(::std::ostream &os, const PadStrideInfo &pad_stride_info)
1262{
1263 os << pad_stride_info.stride().first << "," << pad_stride_info.stride().second;
1264 os << ";";
Jaroslaw Rzepeckia1ed41f2017-10-13 11:13:58 +01001265 os << pad_stride_info.pad_left() << "," << pad_stride_info.pad_right() << ","
1266 << pad_stride_info.pad_top() << "," << pad_stride_info.pad_bottom();
Anthony Barbier2a07e182017-08-04 18:20:27 +01001267
1268 return os;
1269}
1270
Alex Gildayc357c472018-03-21 13:54:09 +00001271/** Formatted output of the PadStrideInfo type.
1272 *
1273 * @param[in] pad_stride_info Type to output.
1274 *
1275 * @return Formatted string.
1276 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001277inline std::string to_string(const PadStrideInfo &pad_stride_info)
1278{
1279 std::stringstream str;
1280 str << pad_stride_info;
1281 return str.str();
1282}
1283
Alex Gildayc357c472018-03-21 13:54:09 +00001284/** Formatted output of the BorderMode type.
1285 *
1286 * @param[in] mode Type to output.
1287 *
1288 * @return Formatted string.
1289 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001290inline std::string to_string(const BorderMode &mode)
1291{
1292 std::stringstream str;
1293 str << mode;
1294 return str.str();
1295}
1296
Alex Gildayc357c472018-03-21 13:54:09 +00001297/** Formatted output of the BorderSize type.
1298 *
1299 * @param[in] border Type to output.
1300 *
1301 * @return Formatted string.
1302 */
John Richardsonb482ce12017-09-18 12:44:01 +01001303inline std::string to_string(const BorderSize &border)
1304{
1305 std::stringstream str;
1306 str << border;
1307 return str.str();
1308}
1309
Giuseppe Rossinid7647d42018-07-17 18:13:13 +01001310/** Formatted output of the PaddingList type.
1311 *
1312 * @param[in] padding Type to output.
1313 *
1314 * @return Formatted string.
1315 */
1316inline std::string to_string(const PaddingList &padding)
1317{
1318 std::stringstream str;
1319 str << padding;
1320 return str.str();
1321}
1322
giuros013175fcf2018-11-21 09:59:17 +00001323/** Formatted output of the Multiples type.
1324 *
1325 * @param[in] multiples Type to output.
1326 *
1327 * @return Formatted string.
1328 */
1329inline std::string to_string(const Multiples &multiples)
1330{
1331 std::stringstream str;
1332 str << multiples;
1333 return str.str();
1334}
1335
Alex Gildayc357c472018-03-21 13:54:09 +00001336/** Formatted output of the InterpolationPolicy type.
1337 *
1338 * @param[in] policy Type to output.
1339 *
1340 * @return Formatted string.
1341 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001342inline std::string to_string(const InterpolationPolicy &policy)
1343{
1344 std::stringstream str;
1345 str << policy;
1346 return str.str();
1347}
1348
Alex Gildayc357c472018-03-21 13:54:09 +00001349/** Formatted output of the SamplingPolicy type.
1350 *
1351 * @param[in] policy Type to output.
1352 *
1353 * @return Formatted string.
1354 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +07001355inline std::string to_string(const SamplingPolicy &policy)
1356{
1357 std::stringstream str;
1358 str << policy;
1359 return str.str();
1360}
1361
Alex Gildayc357c472018-03-21 13:54:09 +00001362/** Formatted output of the ConvertPolicy type.
1363 *
1364 * @param[out] os Output stream.
1365 * @param[in] policy Type to output.
1366 *
1367 * @return Modified output stream.
1368 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001369inline ::std::ostream &operator<<(::std::ostream &os, const ConvertPolicy &policy)
1370{
1371 switch(policy)
1372 {
1373 case ConvertPolicy::WRAP:
1374 os << "WRAP";
1375 break;
1376 case ConvertPolicy::SATURATE:
1377 os << "SATURATE";
1378 break;
1379 default:
1380 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1381 }
1382
1383 return os;
1384}
1385
1386inline std::string to_string(const ConvertPolicy &policy)
1387{
1388 std::stringstream str;
1389 str << policy;
1390 return str.str();
1391}
1392
giuros01164a2722018-11-20 18:34:46 +00001393/** Formatted output of the ArithmeticOperation type.
1394 *
1395 * @param[out] os Output stream.
1396 * @param[in] op Operation to output.
1397 *
1398 * @return Modified output stream.
1399 */
1400inline ::std::ostream &operator<<(::std::ostream &os, const ArithmeticOperation &op)
1401{
1402 switch(op)
1403 {
1404 case ArithmeticOperation::ADD:
1405 os << "ADD";
1406 break;
1407 case ArithmeticOperation::SUB:
1408 os << "SUB";
1409 break;
1410 case ArithmeticOperation::DIV:
1411 os << "DIV";
1412 break;
1413 case ArithmeticOperation::MAX:
1414 os << "MAX";
1415 break;
1416 case ArithmeticOperation::MIN:
1417 os << "MIN";
1418 break;
1419 case ArithmeticOperation::SQUARED_DIFF:
1420 os << "SQUARED_DIFF";
1421 break;
Usama Arif52c54f62019-05-14 10:22:36 +01001422 case ArithmeticOperation::POWER:
1423 os << "POWER";
1424 break;
giuros01164a2722018-11-20 18:34:46 +00001425 default:
1426 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1427 }
1428
1429 return os;
1430}
1431
1432/** Formatted output of the Arithmetic Operation
1433 *
1434 * @param[in] op Type to output.
1435 *
1436 * @return Formatted string.
1437 */
1438inline std::string to_string(const ArithmeticOperation &op)
1439{
1440 std::stringstream str;
1441 str << op;
1442 return str.str();
1443}
1444
Alex Gildayc357c472018-03-21 13:54:09 +00001445/** Formatted output of the Reduction Operations.
1446 *
1447 * @param[out] os Output stream.
1448 * @param[in] op Type to output.
1449 *
1450 * @return Modified output stream.
1451 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001452inline ::std::ostream &operator<<(::std::ostream &os, const ReductionOperation &op)
1453{
1454 switch(op)
1455 {
Michalis Spyrou7e9391b2018-10-05 14:49:28 +01001456 case ReductionOperation::SUM:
1457 os << "SUM";
1458 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +01001459 case ReductionOperation::SUM_SQUARE:
1460 os << "SUM_SQUARE";
1461 break;
Michalis Spyrou7e9391b2018-10-05 14:49:28 +01001462 case ReductionOperation::MEAN_SUM:
1463 os << "MEAN_SUM";
1464 break;
Michalis Spyrou7930db42018-11-22 17:36:28 +00001465 case ReductionOperation::ARG_IDX_MAX:
1466 os << "ARG_IDX_MAX";
1467 break;
1468 case ReductionOperation::ARG_IDX_MIN:
1469 os << "ARG_IDX_MIN";
1470 break;
Manuel Bottinib412fab2018-12-10 17:40:23 +00001471 case ReductionOperation::PROD:
1472 os << "PROD";
1473 break;
Usama Arifa4a08ad2019-05-20 12:38:33 +01001474 case ReductionOperation::MIN:
1475 os << "MIN";
1476 break;
Usama Arif28f0dd92019-05-20 13:44:34 +01001477 case ReductionOperation::MAX:
1478 os << "MAX";
1479 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +01001480 default:
1481 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1482 }
1483
1484 return os;
1485}
1486
Alex Gildayc357c472018-03-21 13:54:09 +00001487/** Formatted output of the Reduction Operations.
1488 *
1489 * @param[in] op Type to output.
1490 *
1491 * @return Formatted string.
1492 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001493inline std::string to_string(const ReductionOperation &op)
1494{
1495 std::stringstream str;
1496 str << op;
1497 return str.str();
1498}
1499
Georgios Pinitas7900a9e2018-11-23 11:44:58 +00001500/** Formatted output of the Comparison Operations.
1501 *
1502 * @param[out] os Output stream.
1503 * @param[in] op Type to output.
1504 *
1505 * @return Modified output stream.
1506 */
1507inline ::std::ostream &operator<<(::std::ostream &os, const ComparisonOperation &op)
1508{
1509 switch(op)
1510 {
1511 case ComparisonOperation::Equal:
1512 os << "Equal";
1513 break;
1514 case ComparisonOperation::NotEqual:
1515 os << "NotEqual";
1516 break;
1517 case ComparisonOperation::Greater:
1518 os << "Greater";
1519 break;
1520 case ComparisonOperation::GreaterEqual:
1521 os << "GreaterEqual";
1522 break;
1523 case ComparisonOperation::Less:
1524 os << "Less";
1525 break;
1526 case ComparisonOperation::LessEqual:
1527 os << "LessEqual";
1528 break;
1529 default:
1530 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1531 }
1532
1533 return os;
1534}
1535
Michalis Spyroue9362622018-11-23 17:41:37 +00001536/** Formatted output of the Elementwise unary Operations.
1537 *
1538 * @param[out] os Output stream.
1539 * @param[in] op Type to output.
1540 *
1541 * @return Modified output stream.
1542 */
1543inline ::std::ostream &operator<<(::std::ostream &os, const ElementWiseUnary &op)
1544{
1545 switch(op)
1546 {
1547 case ElementWiseUnary::RSQRT:
1548 os << "RSQRT";
1549 break;
1550 case ElementWiseUnary::EXP:
1551 os << "EXP";
1552 break;
Usama Arifeb312ef2019-05-13 17:45:54 +01001553 case ElementWiseUnary::NEG:
1554 os << "NEG";
1555 break;
Usama Arifac33d7e2019-05-20 14:21:40 +01001556 case ElementWiseUnary::LOG:
1557 os << "LOG";
1558 break;
Usama Arif6a4d5422019-05-24 14:53:59 +01001559 case ElementWiseUnary::ROUND:
1560 os << "ROUND";
1561 break;
Michalis Spyroue9362622018-11-23 17:41:37 +00001562 default:
1563 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1564 }
1565
1566 return os;
1567}
1568
Georgios Pinitas7900a9e2018-11-23 11:44:58 +00001569/** Formatted output of the Comparison Operations.
1570 *
1571 * @param[in] op Type to output.
1572 *
1573 * @return Formatted string.
1574 */
1575inline std::string to_string(const ComparisonOperation &op)
1576{
1577 std::stringstream str;
1578 str << op;
1579 return str.str();
1580}
1581
Michalis Spyroue9362622018-11-23 17:41:37 +00001582/** Formatted output of the Elementwise unary Operations.
1583 *
1584 * @param[in] op Type to output.
1585 *
1586 * @return Formatted string.
1587 */
1588inline std::string to_string(const ElementWiseUnary &op)
1589{
1590 std::stringstream str;
1591 str << op;
1592 return str.str();
1593}
1594
Alex Gildayc357c472018-03-21 13:54:09 +00001595/** Formatted output of the Norm Type.
1596 *
1597 * @param[in] type Type to output.
1598 *
1599 * @return Formatted string.
1600 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001601inline std::string to_string(const NormType &type)
1602{
1603 std::stringstream str;
1604 str << type;
1605 return str.str();
1606}
1607
Alex Gildayc357c472018-03-21 13:54:09 +00001608/** Formatted output of the Pooling Type.
1609 *
1610 * @param[in] type Type to output.
1611 *
1612 * @return Formatted string.
1613 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001614inline std::string to_string(const PoolingType &type)
1615{
1616 std::stringstream str;
1617 str << type;
1618 return str.str();
1619}
1620
Alex Gildayc357c472018-03-21 13:54:09 +00001621/** Formatted output of the Pooling Layer Info.
1622 *
1623 * @param[in] info Type to output.
1624 *
1625 * @return Formatted string.
1626 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001627inline std::string to_string(const PoolingLayerInfo &info)
1628{
1629 std::stringstream str;
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +00001630 str << "{Type=" << info.pool_type << ","
Sang-Hoon Park11fedda2020-01-15 14:44:04 +00001631 << "DataLayout=" << info.data_layout << ","
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +00001632 << "IsGlobalPooling=" << info.is_global_pooling;
1633 if(!info.is_global_pooling)
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001634 {
1635 str << ","
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +00001636 << "PoolSize=" << info.pool_size.width << "," << info.pool_size.height << ","
1637 << "PadStride=" << info.pad_stride_info;
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001638 }
1639 str << "}";
Anthony Barbier2a07e182017-08-04 18:20:27 +01001640 return str.str();
1641}
1642
Michalis Spyrou6c7c38e2018-08-29 16:28:11 +01001643/** Formatted output of the PriorBoxLayerInfo.
1644 *
1645 * @param[in] info Type to output.
1646 *
1647 * @return Formatted string.
1648 */
1649inline std::string to_string(const PriorBoxLayerInfo &info)
1650{
1651 std::stringstream str;
1652 str << "{";
1653 str << "Clip:" << info.clip()
1654 << "Flip:" << info.flip()
1655 << "StepX:" << info.steps()[0]
1656 << "StepY:" << info.steps()[1]
1657 << "MinSizes:" << info.min_sizes().size()
1658 << "MaxSizes:" << info.max_sizes().size()
1659 << "ImgSizeX:" << info.img_size().x
1660 << "ImgSizeY:" << info.img_size().y
1661 << "Offset:" << info.offset()
1662 << "Variances:" << info.variances().size();
1663 str << "}";
1664 return str.str();
1665}
1666
Alex Gildayc357c472018-03-21 13:54:09 +00001667/** Formatted output of the KeyPoint type.
1668 *
1669 * @param[out] os Output stream
1670 * @param[in] point Type to output.
1671 *
1672 * @return Modified output stream.
1673 */
Moritz Pflanzer6c6597c2017-09-24 12:09:41 +01001674inline ::std::ostream &operator<<(::std::ostream &os, const KeyPoint &point)
1675{
1676 os << "{x=" << point.x << ","
1677 << "y=" << point.y << ","
1678 << "strength=" << point.strength << ","
1679 << "scale=" << point.scale << ","
1680 << "orientation=" << point.orientation << ","
1681 << "tracking_status=" << point.tracking_status << ","
1682 << "error=" << point.error << "}";
1683
1684 return os;
1685}
John Richardson63e50412017-10-13 20:51:42 +01001686
Alex Gildayc357c472018-03-21 13:54:09 +00001687/** Formatted output of the PhaseType type.
1688 *
1689 * @param[out] os Output stream
1690 * @param[in] phase_type Type to output.
1691 *
1692 * @return Modified output stream.
1693 */
John Richardson63e50412017-10-13 20:51:42 +01001694inline ::std::ostream &operator<<(::std::ostream &os, const PhaseType &phase_type)
1695{
1696 switch(phase_type)
1697 {
1698 case PhaseType::SIGNED:
1699 os << "SIGNED";
1700 break;
1701 case PhaseType::UNSIGNED:
1702 os << "UNSIGNED";
1703 break;
1704 default:
1705 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1706 }
1707
1708 return os;
1709}
1710
Alex Gildayc357c472018-03-21 13:54:09 +00001711/** Formatted output of the PhaseType type.
1712 *
1713 * @param[in] type Type to output.
1714 *
1715 * @return Formatted string.
1716 */
John Richardson63e50412017-10-13 20:51:42 +01001717inline std::string to_string(const arm_compute::PhaseType &type)
1718{
1719 std::stringstream str;
1720 str << type;
1721 return str.str();
1722}
John Richardson3c5f9492017-10-04 15:27:37 +01001723
Alex Gildayc357c472018-03-21 13:54:09 +00001724/** Formatted output of the MagnitudeType type.
1725 *
1726 * @param[out] os Output stream
1727 * @param[in] magnitude_type Type to output.
1728 *
1729 * @return Modified output stream.
1730 */
John Richardson3c5f9492017-10-04 15:27:37 +01001731inline ::std::ostream &operator<<(::std::ostream &os, const MagnitudeType &magnitude_type)
1732{
1733 switch(magnitude_type)
1734 {
1735 case MagnitudeType::L1NORM:
1736 os << "L1NORM";
1737 break;
1738 case MagnitudeType::L2NORM:
1739 os << "L2NORM";
1740 break;
1741 default:
1742 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1743 }
1744
1745 return os;
1746}
1747
Alex Gildayc357c472018-03-21 13:54:09 +00001748/** Formatted output of the MagnitudeType type.
1749 *
1750 * @param[in] type Type to output.
1751 *
1752 * @return Formatted string.
1753 */
John Richardson3c5f9492017-10-04 15:27:37 +01001754inline std::string to_string(const arm_compute::MagnitudeType &type)
1755{
1756 std::stringstream str;
1757 str << type;
1758 return str.str();
1759}
John Richardson1c529922017-11-01 10:57:48 +00001760
Alex Gildayc357c472018-03-21 13:54:09 +00001761/** Formatted output of the HOGNormType type.
1762 *
1763 * @param[out] os Output stream
1764 * @param[in] norm_type Type to output
1765 *
1766 * @return Modified output stream.
1767 */
John Richardson25f23682017-11-27 14:35:09 +00001768inline ::std::ostream &operator<<(::std::ostream &os, const HOGNormType &norm_type)
1769{
1770 switch(norm_type)
1771 {
1772 case HOGNormType::L1_NORM:
1773 os << "L1_NORM";
1774 break;
1775 case HOGNormType::L2_NORM:
1776 os << "L2_NORM";
1777 break;
1778 case HOGNormType::L2HYS_NORM:
1779 os << "L2HYS_NORM";
1780 break;
1781 default:
1782 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1783 }
1784
1785 return os;
1786}
1787
Alex Gildayc357c472018-03-21 13:54:09 +00001788/** Formatted output of the HOGNormType type.
1789 *
1790 * @param[in] type Type to output
1791 *
1792 * @return Formatted string.
1793 */
John Richardson25f23682017-11-27 14:35:09 +00001794inline std::string to_string(const HOGNormType &type)
1795{
1796 std::stringstream str;
1797 str << type;
1798 return str.str();
1799}
1800
Alex Gildayc357c472018-03-21 13:54:09 +00001801/** Formatted output of the Size2D type.
1802 *
1803 * @param[out] os Output stream
1804 * @param[in] size Type to output
1805 *
1806 * @return Modified output stream.
1807 */
John Richardson25f23682017-11-27 14:35:09 +00001808inline ::std::ostream &operator<<(::std::ostream &os, const Size2D &size)
1809{
1810 os << size.width << "x" << size.height;
1811
1812 return os;
1813}
1814
Alex Gildayc357c472018-03-21 13:54:09 +00001815/** Formatted output of the Size2D type.
1816 *
1817 * @param[in] type Type to output
1818 *
1819 * @return Formatted string.
1820 */
John Richardson25f23682017-11-27 14:35:09 +00001821inline std::string to_string(const Size2D &type)
1822{
1823 std::stringstream str;
1824 str << type;
1825 return str.str();
1826}
1827
Alex Gildayc357c472018-03-21 13:54:09 +00001828/** Formatted output of the HOGInfo type.
1829 *
1830 * @param[out] os Output stream
1831 * @param[in] hog_info Type to output
1832 *
1833 * @return Modified output stream.
1834 */
John Richardson25f23682017-11-27 14:35:09 +00001835inline ::std::ostream &operator<<(::std::ostream &os, const HOGInfo &hog_info)
1836{
1837 os << "{CellSize=" << hog_info.cell_size() << ","
1838 << "BlockSize=" << hog_info.block_size() << ","
1839 << "DetectionWindowSize=" << hog_info.detection_window_size() << ","
1840 << "BlockStride=" << hog_info.block_stride() << ","
1841 << "NumBins=" << hog_info.num_bins() << ","
1842 << "NormType=" << hog_info.normalization_type() << ","
1843 << "L2HystThreshold=" << hog_info.l2_hyst_threshold() << ","
1844 << "PhaseType=" << hog_info.phase_type() << "}";
1845
1846 return os;
1847}
1848
Alex Gildayc357c472018-03-21 13:54:09 +00001849/** Formatted output of the HOGInfo type.
1850 *
1851 * @param[in] type Type to output
1852 *
1853 * @return Formatted string.
1854 */
John Richardson25f23682017-11-27 14:35:09 +00001855inline std::string to_string(const HOGInfo &type)
1856{
1857 std::stringstream str;
1858 str << type;
1859 return str.str();
1860}
1861
Alex Gildayc357c472018-03-21 13:54:09 +00001862/** Formatted output of the ConvolutionMethod type.
1863 *
1864 * @param[out] os Output stream
1865 * @param[in] conv_method Type to output
1866 *
1867 * @return Modified output stream.
1868 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001869inline ::std::ostream &operator<<(::std::ostream &os, const ConvolutionMethod &conv_method)
1870{
1871 switch(conv_method)
1872 {
1873 case ConvolutionMethod::GEMM:
1874 os << "GEMM";
1875 break;
1876 case ConvolutionMethod::DIRECT:
1877 os << "DIRECT";
1878 break;
1879 case ConvolutionMethod::WINOGRAD:
1880 os << "WINOGRAD";
1881 break;
1882 default:
1883 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1884 }
1885
1886 return os;
1887}
1888
Alex Gildayc357c472018-03-21 13:54:09 +00001889/** Formatted output of the ConvolutionMethod type.
1890 *
1891 * @param[in] conv_method Type to output
1892 *
1893 * @return Formatted string.
1894 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001895inline std::string to_string(const ConvolutionMethod &conv_method)
1896{
1897 std::stringstream str;
1898 str << conv_method;
1899 return str.str();
1900}
1901
Alex Gildayc357c472018-03-21 13:54:09 +00001902/** Formatted output of the GPUTarget type.
1903 *
1904 * @param[out] os Output stream
1905 * @param[in] gpu_target Type to output
1906 *
1907 * @return Modified output stream.
1908 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001909inline ::std::ostream &operator<<(::std::ostream &os, const GPUTarget &gpu_target)
1910{
1911 switch(gpu_target)
1912 {
1913 case GPUTarget::GPU_ARCH_MASK:
1914 os << "GPU_ARCH_MASK";
1915 break;
1916 case GPUTarget::MIDGARD:
1917 os << "MIDGARD";
1918 break;
1919 case GPUTarget::BIFROST:
1920 os << "BIFROST";
1921 break;
Georgios Pinitasd5462ff2019-07-03 19:33:57 +01001922 case GPUTarget::VALHALL:
1923 os << "VALHALL";
1924 break;
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001925 case GPUTarget::T600:
1926 os << "T600";
1927 break;
1928 case GPUTarget::T700:
1929 os << "T700";
1930 break;
1931 case GPUTarget::T800:
1932 os << "T800";
1933 break;
Michalis Spyroua9676112018-02-22 18:07:43 +00001934 case GPUTarget::G71:
1935 os << "G71";
1936 break;
1937 case GPUTarget::G72:
1938 os << "G72";
1939 break;
1940 case GPUTarget::G51:
1941 os << "G51";
1942 break;
1943 case GPUTarget::G51BIG:
1944 os << "G51BIG";
1945 break;
1946 case GPUTarget::G51LIT:
1947 os << "G51LIT";
1948 break;
Georgios Pinitasb03f7c52018-07-12 10:49:53 +01001949 case GPUTarget::G76:
1950 os << "G76";
Michalis Spyroua9676112018-02-22 18:07:43 +00001951 break;
Georgios Pinitasd5462ff2019-07-03 19:33:57 +01001952 case GPUTarget::G77:
1953 os << "G77";
Michalis Spyroua9676112018-02-22 18:07:43 +00001954 break;
1955 case GPUTarget::TBOX:
1956 os << "TBOX";
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001957 break;
Georgios Pinitasd5462ff2019-07-03 19:33:57 +01001958 case GPUTarget::TODX:
1959 os << "TODX";
1960 break;
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001961 default:
1962 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1963 }
1964
1965 return os;
1966}
1967
Alex Gildayc357c472018-03-21 13:54:09 +00001968/** Formatted output of the GPUTarget type.
1969 *
1970 * @param[in] gpu_target Type to output
1971 *
1972 * @return Formatted string.
1973 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001974inline std::string to_string(const GPUTarget &gpu_target)
1975{
1976 std::stringstream str;
1977 str << gpu_target;
1978 return str.str();
1979}
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00001980
John Richardson8de92612018-02-22 14:09:31 +00001981/** Formatted output of the DetectionWindow type.
1982 *
1983 * @param[out] os Output stream
1984 * @param[in] detection_window Type to output
1985 *
1986 * @return Modified output stream.
1987 */
John Richardson684cb0f2018-01-09 11:17:00 +00001988inline ::std::ostream &operator<<(::std::ostream &os, const DetectionWindow &detection_window)
1989{
1990 os << "{x=" << detection_window.x << ","
1991 << "y=" << detection_window.y << ","
1992 << "width=" << detection_window.width << ","
1993 << "height=" << detection_window.height << ","
1994 << "idx_class=" << detection_window.idx_class << ","
1995 << "score=" << detection_window.score << "}";
1996
1997 return os;
1998}
1999
Isabella Gottardi05e56442018-11-16 11:26:52 +00002000/** Formatted output of the DetectionOutputLayerCodeType type.
2001 *
2002 * @param[out] os Output stream
2003 * @param[in] detection_code Type to output
2004 *
2005 * @return Modified output stream.
2006 */
2007inline ::std::ostream &operator<<(::std::ostream &os, const DetectionOutputLayerCodeType &detection_code)
2008{
2009 switch(detection_code)
2010 {
2011 case DetectionOutputLayerCodeType::CENTER_SIZE:
2012 os << "CENTER_SIZE";
2013 break;
2014 case DetectionOutputLayerCodeType::CORNER:
2015 os << "CORNER";
2016 break;
2017 case DetectionOutputLayerCodeType::CORNER_SIZE:
2018 os << "CORNER_SIZE";
2019 break;
2020 case DetectionOutputLayerCodeType::TF_CENTER:
2021 os << "TF_CENTER";
2022 break;
2023 default:
2024 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2025 }
2026
2027 return os;
2028}
2029/** Formatted output of the DetectionOutputLayerCodeType type.
2030 *
2031 * @param[in] detection_code Type to output
2032 *
2033 * @return Formatted string.
2034 */
2035inline std::string to_string(const DetectionOutputLayerCodeType &detection_code)
2036{
2037 std::stringstream str;
2038 str << detection_code;
2039 return str.str();
2040}
2041
2042/** Formatted output of the DetectionOutputLayerInfo type.
2043 *
2044 * @param[out] os Output stream
2045 * @param[in] detection_info Type to output
2046 *
2047 * @return Modified output stream.
2048 */
2049inline ::std::ostream &operator<<(::std::ostream &os, const DetectionOutputLayerInfo &detection_info)
2050{
2051 os << "{Classes=" << detection_info.num_classes() << ","
2052 << "ShareLocation=" << detection_info.share_location() << ","
2053 << "CodeType=" << detection_info.code_type() << ","
2054 << "VarianceEncodedInTarget=" << detection_info.variance_encoded_in_target() << ","
2055 << "KeepTopK=" << detection_info.keep_top_k() << ","
2056 << "NMSThreshold=" << detection_info.nms_threshold() << ","
2057 << "Eta=" << detection_info.eta() << ","
2058 << "BackgroundLabelId=" << detection_info.background_label_id() << ","
2059 << "ConfidenceThreshold=" << detection_info.confidence_threshold() << ","
2060 << "TopK=" << detection_info.top_k() << ","
2061 << "NumLocClasses=" << detection_info.num_loc_classes()
2062 << "}";
2063
2064 return os;
2065}
2066
2067/** Formatted output of the DetectionOutputLayerInfo type.
2068 *
2069 * @param[in] detection_info Type to output
2070 *
2071 * @return Formatted string.
2072 */
2073inline std::string to_string(const DetectionOutputLayerInfo &detection_info)
2074{
2075 std::stringstream str;
2076 str << detection_info;
2077 return str.str();
2078}
Isabella Gottardia7acb3c2019-01-08 13:48:44 +00002079/** Formatted output of the DetectionPostProcessLayerInfo type.
2080 *
2081 * @param[out] os Output stream
2082 * @param[in] detection_info Type to output
2083 *
2084 * @return Modified output stream.
2085 */
2086inline ::std::ostream &operator<<(::std::ostream &os, const DetectionPostProcessLayerInfo &detection_info)
2087{
2088 os << "{MaxDetections=" << detection_info.max_detections() << ","
2089 << "MaxClassesPerDetection=" << detection_info.max_classes_per_detection() << ","
2090 << "NmsScoreThreshold=" << detection_info.nms_score_threshold() << ","
2091 << "NmsIouThreshold=" << detection_info.iou_threshold() << ","
2092 << "NumClasses=" << detection_info.num_classes() << ","
2093 << "ScaleValue_y=" << detection_info.scale_value_y() << ","
2094 << "ScaleValue_x=" << detection_info.scale_value_x() << ","
2095 << "ScaleValue_h=" << detection_info.scale_value_h() << ","
2096 << "ScaleValue_w=" << detection_info.scale_value_w() << ","
2097 << "UseRegularNms=" << detection_info.use_regular_nms() << ","
2098 << "DetectionPerClass=" << detection_info.detection_per_class()
2099 << "}";
2100
2101 return os;
2102}
2103
2104/** Formatted output of the DetectionPostProcessLayerInfo type.
2105 *
2106 * @param[in] detection_info Type to output
2107 *
2108 * @return Formatted string.
2109 */
2110inline std::string to_string(const DetectionPostProcessLayerInfo &detection_info)
2111{
2112 std::stringstream str;
2113 str << detection_info;
2114 return str.str();
2115}
John Richardson8de92612018-02-22 14:09:31 +00002116/** Formatted output of the DetectionWindow type.
2117 *
2118 * @param[in] detection_window Type to output
2119 *
2120 * @return Formatted string.
2121 */
2122inline std::string to_string(const DetectionWindow &detection_window)
2123{
2124 std::stringstream str;
2125 str << detection_window;
2126 return str.str();
2127}
2128
2129/** Formatted output of the Termination type.
2130 *
2131 * @param[out] os Output stream
2132 * @param[in] termination Type to output
2133 *
2134 * @return Modified output stream.
2135 */
2136inline ::std::ostream &operator<<(::std::ostream &os, const Termination &termination)
2137{
2138 switch(termination)
2139 {
2140 case Termination::TERM_CRITERIA_EPSILON:
2141 os << "TERM_CRITERIA_EPSILON";
2142 break;
2143 case Termination::TERM_CRITERIA_ITERATIONS:
2144 os << "TERM_CRITERIA_ITERATIONS";
2145 break;
2146 case Termination::TERM_CRITERIA_BOTH:
2147 os << "TERM_CRITERIA_BOTH";
2148 break;
2149 default:
2150 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2151 }
2152
2153 return os;
2154}
2155
2156/** Formatted output of the Termination type.
2157 *
2158 * @param[in] termination Type to output
2159 *
2160 * @return Formatted string.
2161 */
2162inline std::string to_string(const Termination &termination)
2163{
2164 std::stringstream str;
2165 str << termination;
2166 return str.str();
2167}
2168
Anthony Barbier8914e322018-08-10 15:28:25 +01002169/** Formatted output of the CPUModel type.
2170 *
2171 * @param[out] os Output stream
2172 * @param[in] cpu_model Model to output
2173 *
2174 * @return Modified output stream.
2175 */
2176inline ::std::ostream &operator<<(::std::ostream &os, const CPUModel &cpu_model)
2177{
2178 switch(cpu_model)
2179 {
2180 case CPUModel::GENERIC:
2181 os << "GENERIC";
2182 break;
2183 case CPUModel::GENERIC_FP16:
2184 os << "GENERIC_FP16";
2185 break;
2186 case CPUModel::GENERIC_FP16_DOT:
2187 os << "GENERIC_FP16_DOT";
2188 break;
2189 case CPUModel::A53:
2190 os << "A53";
2191 break;
2192 case CPUModel::A55r0:
2193 os << "A55r0";
2194 break;
2195 case CPUModel::A55r1:
2196 os << "A55r1";
2197 break;
2198 default:
2199 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2200 }
2201
2202 return os;
2203}
2204
2205/** Formatted output of the CPUModel type.
2206 *
2207 * @param[in] cpu_model Model to output
2208 *
2209 * @return Formatted string.
2210 */
2211inline std::string to_string(const CPUModel &cpu_model)
2212{
2213 std::stringstream str;
2214 str << cpu_model;
2215 return str.str();
2216}
Anthony Barbier671a11e2018-07-06 15:11:36 +01002217/** Formatted output of a vector of objects.
2218 *
2219 * @param[out] os Output stream
2220 * @param[in] args Vector of objects to print
2221 *
2222 * @return Modified output stream.
2223 */
2224template <typename T>
2225inline ::std::ostream &operator<<(::std::ostream &os, const std::vector<T> &args)
2226{
2227 os << "[";
2228 bool first = true;
2229 for(auto &arg : args)
2230 {
2231 if(first)
2232 {
2233 first = false;
2234 }
2235 else
2236 {
2237 os << ", ";
2238 }
2239 os << arg;
2240 }
2241 os << "]";
2242 return os;
2243}
2244
Michalis Spyrou6c7c38e2018-08-29 16:28:11 +01002245/** Formatted output of @ref PriorBoxLayerInfo.
2246 *
2247 * @param[out] os Output stream.
2248 * @param[in] info Type to output.
2249 *
2250 * @return Modified output stream.
2251 */
2252inline ::std::ostream &operator<<(::std::ostream &os, const PriorBoxLayerInfo &info)
2253{
2254 os << "Clip:" << info.clip()
2255 << "Flip:" << info.flip()
2256 << "StepX:" << info.steps()[0]
2257 << "StepY:" << info.steps()[1]
2258 << "MinSizes:" << info.min_sizes()
2259 << "MaxSizes:" << info.max_sizes()
2260 << "ImgSizeX:" << info.img_size().x
2261 << "ImgSizeY:" << info.img_size().y
2262 << "Offset:" << info.offset()
2263 << "Variances:" << info.variances();
2264
2265 return os;
2266}
2267
Anthony Barbier671a11e2018-07-06 15:11:36 +01002268/** Formatted output of a vector of objects.
2269 *
2270 * @param[in] args Vector of objects to print
2271 *
2272 * @return String representing args.
2273 */
2274template <typename T>
2275std::string to_string(const std::vector<T> &args)
2276{
2277 std::stringstream str;
2278 str << args;
2279 return str.str();
2280}
2281
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00002282/** Formatted output of the WinogradInfo type. */
2283inline ::std::ostream &operator<<(::std::ostream &os, const WinogradInfo &info)
2284{
2285 os << "{OutputTileSize=" << info.output_tile_size << ","
2286 << "KernelSize=" << info.kernel_size << ","
2287 << "PadStride=" << info.convolution_info << ","
2288 << "OutputDataLayout=" << info.output_data_layout << "}";
2289
2290 return os;
2291}
2292
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00002293inline std::string to_string(const WinogradInfo &type)
2294{
2295 std::stringstream str;
2296 str << type;
2297 return str.str();
2298}
Anthony Barbier671a11e2018-07-06 15:11:36 +01002299
2300/** Fallback method: try to use std::to_string:
2301 *
2302 * @param[in] val Value to convert to string
2303 *
2304 * @return String representing val.
2305 */
2306template <typename T>
2307inline std::string to_string(const T &val)
2308{
2309 return support::cpp11::to_string(val);
2310}
2311
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +01002312/** Convert a CLTunerMode value to a string
2313 *
2314 * @param val CLTunerMode value to be converted
2315 *
2316 * @return String representing the corresponding CLTunerMode.
2317 */
2318inline std::string to_string(const CLTunerMode val)
2319{
2320 switch(val)
2321 {
2322 case CLTunerMode::EXHAUSTIVE:
2323 {
2324 return std::string("Exhaustive");
2325 }
2326 case CLTunerMode::NORMAL:
2327 {
2328 return std::string("Normal");
2329 }
2330 case CLTunerMode::RAPID:
2331 {
2332 return std::string("Rapid");
2333 }
2334 default:
2335 {
2336 ARM_COMPUTE_ERROR("Invalid tuner mode.");
2337 return std::string("UNDEFINED");
2338 }
2339 }
2340}
2341/** [Print CLTunerMode type] **/
2342/** Formatted output of the CLTunerMode type.
2343 *
2344 * @param[out] os Output stream.
2345 * @param[in] val CLTunerMode to output.
2346 *
2347 * @return Modified output stream.
2348 */
2349inline ::std::ostream &operator<<(::std::ostream &os, const CLTunerMode &val)
2350{
2351 os << to_string(val);
2352 return os;
2353}
2354
Anthony Barbier6ff3b192017-09-04 18:44:23 +01002355} // namespace arm_compute
Anthony Barbier4dbc0a92018-08-27 13:39:47 +01002356
2357#endif /* __ARM_COMPUTE_TYPE_PRINTER_H__ */