blob: 1f499dec7eb4f0ab5efe2ba48144cbfc1851068a [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"
Matthew Bentham758b5ba2020-03-05 23:37:48 +000037#include "support/StringSupport.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010038
39#include <ostream>
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010040#include <sstream>
41#include <string>
Anthony Barbier6ff3b192017-09-04 18:44:23 +010042
43namespace arm_compute
44{
Anthony Barbierb940fd62018-06-04 14:14:32 +010045/** Formatted output if arg is not null
46 *
47 * @param[in] arg Object to print
48 *
49 * @return String representing arg.
50 */
51template <typename T>
52std::string to_string_if_not_null(T *arg)
53{
54 if(arg == nullptr)
55 {
56 return "nullptr";
57 }
58 else
59 {
60 return to_string(*arg);
61 }
62}
Anthony Barbierb4670212018-05-18 16:55:39 +010063
Alex Gildayc357c472018-03-21 13:54:09 +000064/** Formatted output of the Dimensions type.
65 *
66 * @param[out] os Output stream.
67 * @param[in] dimensions Type to output.
68 *
69 * @return Modified output stream.
70 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +010071template <typename T>
72inline ::std::ostream &operator<<(::std::ostream &os, const Dimensions<T> &dimensions)
73{
Anthony Barbier6ff3b192017-09-04 18:44:23 +010074 if(dimensions.num_dimensions() > 0)
75 {
76 os << dimensions[0];
77
78 for(unsigned int d = 1; d < dimensions.num_dimensions(); ++d)
79 {
Moritz Pflanzerc87fbf82017-07-18 14:02:10 +010080 os << "x" << dimensions[d];
Anthony Barbier6ff3b192017-09-04 18:44:23 +010081 }
82 }
83
Anthony Barbier6ff3b192017-09-04 18:44:23 +010084 return os;
85}
86
Alex Gildayc357c472018-03-21 13:54:09 +000087/** Formatted output of the NonLinearFilterFunction type.
88 *
89 * @param[out] os Output stream.
90 * @param[in] function Type to output.
91 *
92 * @return Modified output stream.
93 */
Isabella Gottardi3b77e9d2017-06-22 11:05:41 +010094inline ::std::ostream &operator<<(::std::ostream &os, const NonLinearFilterFunction &function)
95{
96 switch(function)
97 {
98 case NonLinearFilterFunction::MAX:
99 os << "MAX";
100 break;
101 case NonLinearFilterFunction::MEDIAN:
102 os << "MEDIAN";
103 break;
104 case NonLinearFilterFunction::MIN:
105 os << "MIN";
106 break;
107 default:
108 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
109 }
110
111 return os;
112}
113
Alex Gildayc357c472018-03-21 13:54:09 +0000114/** Formatted output of the NonLinearFilterFunction type.
115 *
116 * @param[in] function Type to output.
117 *
118 * @return Formatted string.
119 */
John Richardson6f4d49f2017-09-07 11:21:10 +0100120inline std::string to_string(const NonLinearFilterFunction &function)
121{
122 std::stringstream str;
123 str << function;
124 return str.str();
125}
126
Alex Gildayc357c472018-03-21 13:54:09 +0000127/** Formatted output of the MatrixPattern type.
128 *
129 * @param[out] os Output stream.
130 * @param[in] pattern Type to output.
131 *
132 * @return Modified output stream.
133 */
Isabella Gottardi3b77e9d2017-06-22 11:05:41 +0100134inline ::std::ostream &operator<<(::std::ostream &os, const MatrixPattern &pattern)
135{
136 switch(pattern)
137 {
138 case MatrixPattern::BOX:
139 os << "BOX";
140 break;
141 case MatrixPattern::CROSS:
142 os << "CROSS";
143 break;
144 case MatrixPattern::DISK:
145 os << "DISK";
146 break;
147 case MatrixPattern::OTHER:
148 os << "OTHER";
149 break;
150 default:
151 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
152 }
153
154 return os;
155}
156
Alex Gildayc357c472018-03-21 13:54:09 +0000157/** Formatted output of the MatrixPattern type.
158 *
159 * @param[in] pattern Type to output.
160 *
161 * @return Formatted string.
162 */
John Richardson6f4d49f2017-09-07 11:21:10 +0100163inline std::string to_string(const MatrixPattern &pattern)
164{
165 std::stringstream str;
166 str << pattern;
167 return str.str();
168}
169
Alex Gildayc357c472018-03-21 13:54:09 +0000170/** Formatted output of the RoundingPolicy type.
171 *
172 * @param[out] os Output stream.
173 * @param[in] rounding_policy Type to output.
174 *
175 * @return Modified output stream.
176 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100177inline ::std::ostream &operator<<(::std::ostream &os, const RoundingPolicy &rounding_policy)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100178{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100179 switch(rounding_policy)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100180 {
Anthony Barbier2a07e182017-08-04 18:20:27 +0100181 case RoundingPolicy::TO_ZERO:
182 os << "TO_ZERO";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100183 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100184 case RoundingPolicy::TO_NEAREST_UP:
185 os << "TO_NEAREST_UP";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100186 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100187 case RoundingPolicy::TO_NEAREST_EVEN:
188 os << "TO_NEAREST_EVEN";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100189 break;
190 default:
191 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
192 }
193
194 return os;
195}
196
Alex Gildayc357c472018-03-21 13:54:09 +0000197/** Formatted output of the WeightsInfo type.
198 *
199 * @param[out] os Output stream.
200 * @param[in] weights_info Type to output.
201 *
202 * @return Modified output stream.
203 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100204inline ::std::ostream &operator<<(::std::ostream &os, const WeightsInfo &weights_info)
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100205{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100206 os << weights_info.are_reshaped() << ";";
207 os << weights_info.num_kernels() << ";" << weights_info.kernel_size().first << "," << weights_info.kernel_size().second;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100208
209 return os;
210}
211
Alex Gildayc357c472018-03-21 13:54:09 +0000212/** Formatted output of the ROIPoolingInfo type.
213 *
214 * @param[out] os Output stream.
215 * @param[in] pool_info Type to output.
216 *
217 * @return Modified output stream.
218 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100219inline ::std::ostream &operator<<(::std::ostream &os, const ROIPoolingLayerInfo &pool_info)
Sanghoon Lee70f82912017-08-24 14:21:24 +0100220{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100221 os << pool_info.pooled_width() << "x" << pool_info.pooled_height() << "~" << pool_info.spatial_scale();
Georgios Pinitasd9769582017-08-03 10:19:40 +0100222 return os;
223}
224
giuros0118870812018-09-13 09:31:40 +0100225/** Formatted output of the ROIPoolingInfo type.
226 *
227 * @param[in] pool_info Type to output.
228 *
229 * @return Formatted string.
230 */
231inline std::string to_string(const ROIPoolingLayerInfo &pool_info)
232{
233 std::stringstream str;
234 str << pool_info;
235 return str.str();
236}
237
giuros01c04a0e82018-10-03 12:44:35 +0100238/** Formatted output of the BoundingBoxTransformInfo type.
239 *
240 * @param[out] os Output stream.
241 * @param[in] bbox_info Type to output.
242 *
243 * @return Modified output stream.
244 */
245inline ::std::ostream &operator<<(::std::ostream &os, const BoundingBoxTransformInfo &bbox_info)
246{
247 auto weights = bbox_info.weights();
248 os << "(" << bbox_info.img_width() << "x" << bbox_info.img_height() << ")~" << bbox_info.scale() << "(weights = {" << weights[0] << ", " << weights[1] << ", " << weights[2] << ", " << weights[3] <<
249 "})";
250 return os;
251}
252
253/** Formatted output of the BoundingBoxTransformInfo type.
254 *
255 * @param[in] bbox_info Type to output.
256 *
257 * @return Formatted string.
258 */
259inline std::string to_string(const BoundingBoxTransformInfo &bbox_info)
260{
261 std::stringstream str;
262 str << bbox_info;
263 return str.str();
264}
265
Manuel Bottini5209be52019-02-13 16:34:56 +0000266/** Formatted output of the ComputeAnchorsInfo type.
267 *
268 * @param[out] os Output stream.
269 * @param[in] anchors_info Type to output.
270 *
271 * @return Modified output stream.
272 */
273inline ::std::ostream &operator<<(::std::ostream &os, const ComputeAnchorsInfo &anchors_info)
274{
275 os << "(" << anchors_info.feat_width() << "x" << anchors_info.feat_height() << ")~" << anchors_info.spatial_scale();
276 return os;
277}
278
279/** Formatted output of the ComputeAnchorsInfo type.
280 *
281 * @param[in] anchors_info Type to output.
282 *
283 * @return Formatted string.
284 */
285inline std::string to_string(const ComputeAnchorsInfo &anchors_info)
286{
287 std::stringstream str;
288 str << anchors_info;
289 return str.str();
290}
291
292/** Formatted output of the GenerateProposalsInfo type.
293 *
294 * @param[out] os Output stream.
295 * @param[in] proposals_info Type to output.
296 *
297 * @return Modified output stream.
298 */
299inline ::std::ostream &operator<<(::std::ostream &os, const GenerateProposalsInfo &proposals_info)
300{
301 os << "(" << proposals_info.im_width() << "x" << proposals_info.im_height() << ")~" << proposals_info.im_scale();
302 return os;
303}
304
305/** Formatted output of the GenerateProposalsInfo type.
306 *
307 * @param[in] proposals_info Type to output.
308 *
309 * @return Formatted string.
310 */
311inline std::string to_string(const GenerateProposalsInfo &proposals_info)
312{
313 std::stringstream str;
314 str << proposals_info;
315 return str.str();
316}
317
Alex Gildayc357c472018-03-21 13:54:09 +0000318/** Formatted output of the QuantizationInfo type.
319 *
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100320 * @param[out] os Output stream.
321 * @param[in] qinfo Type to output.
Alex Gildayc357c472018-03-21 13:54:09 +0000322 *
323 * @return Modified output stream.
324 */
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100325inline ::std::ostream &operator<<(::std::ostream &os, const QuantizationInfo &qinfo)
Chunosovd621bca2017-11-03 17:33:15 +0700326{
Georgios Pinitas3d13af82019-06-04 13:04:16 +0100327 const UniformQuantizationInfo uqinfo = qinfo.uniform();
328 os << "Scale:" << uqinfo.scale << "~";
329 os << "Offset:" << uqinfo.offset;
Chunosovd621bca2017-11-03 17:33:15 +0700330 return os;
331}
332
Alex Gildayc357c472018-03-21 13:54:09 +0000333/** Formatted output of the QuantizationInfo type.
334 *
335 * @param[in] quantization_info Type to output.
336 *
337 * @return Formatted string.
338 */
Chunosovd621bca2017-11-03 17:33:15 +0700339inline std::string to_string(const QuantizationInfo &quantization_info)
340{
341 std::stringstream str;
342 str << quantization_info;
343 return str.str();
344}
345
Alex Gildayc357c472018-03-21 13:54:09 +0000346/** Formatted output of the activation function type.
347 *
348 * @param[out] os Output stream.
349 * @param[in] act_function Type to output.
350 *
351 * @return Modified output stream.
352 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100353inline ::std::ostream &operator<<(::std::ostream &os, const ActivationLayerInfo::ActivationFunction &act_function)
354{
355 switch(act_function)
356 {
357 case ActivationLayerInfo::ActivationFunction::ABS:
358 os << "ABS";
359 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100360 case ActivationLayerInfo::ActivationFunction::LINEAR:
361 os << "LINEAR";
362 break;
363 case ActivationLayerInfo::ActivationFunction::LOGISTIC:
364 os << "LOGISTIC";
365 break;
366 case ActivationLayerInfo::ActivationFunction::RELU:
367 os << "RELU";
368 break;
Georgios Pinitas579c0492017-07-12 16:12:12 +0100369 case ActivationLayerInfo::ActivationFunction::BOUNDED_RELU:
370 os << "BOUNDED_RELU";
371 break;
372 case ActivationLayerInfo::ActivationFunction::LEAKY_RELU:
373 os << "LEAKY_RELU";
374 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100375 case ActivationLayerInfo::ActivationFunction::SOFT_RELU:
376 os << "SOFT_RELU";
377 break;
378 case ActivationLayerInfo::ActivationFunction::SQRT:
379 os << "SQRT";
380 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100381 case ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU:
382 os << "LU_BOUNDED_RELU";
Kevin Petitd9f80712017-12-06 12:18:48 +0000383 break;
Georgios Pinitasfb0fdcd2019-08-22 17:10:04 +0100384 case ActivationLayerInfo::ActivationFunction::ELU:
385 os << "ELU";
386 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100387 case ActivationLayerInfo::ActivationFunction::SQUARE:
388 os << "SQUARE";
389 break;
390 case ActivationLayerInfo::ActivationFunction::TANH:
391 os << "TANH";
392 break;
Usama Arif6a98a6e2019-05-10 17:07:27 +0100393 case ActivationLayerInfo::ActivationFunction::IDENTITY:
394 os << "IDENTITY";
395 break;
morgolock07df3d42020-02-27 11:46:28 +0000396 case ActivationLayerInfo::ActivationFunction::HARD_SWISH:
397 os << "HARD_SWISH";
398 break;
399
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100400 default:
401 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
402 }
403
404 return os;
405}
406
Alex Gildayc357c472018-03-21 13:54:09 +0000407/** Formatted output of the activation function info type.
408 *
409 * @param[in] info Type to output.
410 *
411 * @return Formatted string.
412 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100413inline std::string to_string(const arm_compute::ActivationLayerInfo &info)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100414{
415 std::stringstream str;
Isabella Gottardi3f217ec2018-02-12 14:59:19 +0000416 if(info.enabled())
417 {
418 str << info.activation();
419 }
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100420 return str.str();
421}
422
Alex Gildayc357c472018-03-21 13:54:09 +0000423/** Formatted output of the activation function type.
424 *
425 * @param[in] function Type to output.
426 *
427 * @return Formatted string.
428 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100429inline std::string to_string(const arm_compute::ActivationLayerInfo::ActivationFunction &function)
430{
431 std::stringstream str;
432 str << function;
433 return str.str();
434}
435
Alex Gildayc357c472018-03-21 13:54:09 +0000436/** Formatted output of the NormType type.
437 *
438 * @param[out] os Output stream.
439 * @param[in] norm_type Type to output.
440 *
441 * @return Modified output stream.
442 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100443inline ::std::ostream &operator<<(::std::ostream &os, const NormType &norm_type)
444{
445 switch(norm_type)
446 {
447 case NormType::CROSS_MAP:
448 os << "CROSS_MAP";
449 break;
450 case NormType::IN_MAP_1D:
451 os << "IN_MAP_1D";
452 break;
453 case NormType::IN_MAP_2D:
454 os << "IN_MAP_2D";
455 break;
456 default:
457 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
458 }
459
460 return os;
461}
462
Alex Gildayc357c472018-03-21 13:54:09 +0000463/** Formatted output of @ref NormalizationLayerInfo.
464 *
465 * @param[in] info Type to output.
466 *
467 * @return Formatted string.
468 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100469inline std::string to_string(const arm_compute::NormalizationLayerInfo &info)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100470{
471 std::stringstream str;
Michalis Spyroud466c2d2018-01-30 10:54:39 +0000472 str << info.type() << ":NormSize=" << info.norm_size();
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100473 return str.str();
474}
475
Alex Gildayc357c472018-03-21 13:54:09 +0000476/** Formatted output of @ref NormalizationLayerInfo.
477 *
478 * @param[out] os Output stream.
479 * @param[in] info Type to output.
480 *
481 * @return Modified output stream.
482 */
Georgios Pinitas6f669f02017-09-26 12:32:57 +0100483inline ::std::ostream &operator<<(::std::ostream &os, const NormalizationLayerInfo &info)
484{
Michalis Spyroud466c2d2018-01-30 10:54:39 +0000485 os << info.type() << ":NormSize=" << info.norm_size();
Georgios Pinitas6f669f02017-09-26 12:32:57 +0100486 return os;
487}
488
Alex Gildayc357c472018-03-21 13:54:09 +0000489/** Formatted output of the PoolingType type.
490 *
491 * @param[out] os Output stream.
492 * @param[in] pool_type Type to output.
493 *
494 * @return Modified output stream.
495 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100496inline ::std::ostream &operator<<(::std::ostream &os, const PoolingType &pool_type)
497{
498 switch(pool_type)
499 {
500 case PoolingType::AVG:
501 os << "AVG";
502 break;
503 case PoolingType::MAX:
504 os << "MAX";
505 break;
Georgios Pinitascdf51452017-08-31 14:21:36 +0100506 case PoolingType::L2:
507 os << "L2";
508 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100509 default:
510 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
511 }
512
513 return os;
514}
515
Alex Gildayc357c472018-03-21 13:54:09 +0000516/** Formatted output of @ref PoolingLayerInfo.
517 *
518 * @param[out] os Output stream.
519 * @param[in] info Type to output.
520 *
521 * @return Modified output stream.
522 */
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100523inline ::std::ostream &operator<<(::std::ostream &os, const PoolingLayerInfo &info)
524{
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +0000525 os << info.pool_type;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100526
527 return os;
528}
529
Alex Gildayc357c472018-03-21 13:54:09 +0000530/** Formatted output of @ref RoundingPolicy.
531 *
532 * @param[in] rounding_policy Type to output.
533 *
534 * @return Formatted string.
535 */
John Richardsondd715f22017-09-18 16:10:48 +0100536inline std::string to_string(const RoundingPolicy &rounding_policy)
537{
538 std::stringstream str;
539 str << rounding_policy;
540 return str.str();
541}
542
Vidhya Sudhan Loganathand646ae12018-11-19 15:18:20 +0000543/** [Print DataLayout type] **/
Alex Gildayc357c472018-03-21 13:54:09 +0000544/** Formatted output of the DataLayout type.
545 *
546 * @param[out] os Output stream.
547 * @param[in] data_layout Type to output.
548 *
549 * @return Modified output stream.
550 */
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000551inline ::std::ostream &operator<<(::std::ostream &os, const DataLayout &data_layout)
552{
553 switch(data_layout)
554 {
555 case DataLayout::UNKNOWN:
556 os << "UNKNOWN";
557 break;
558 case DataLayout::NHWC:
559 os << "NHWC";
560 break;
561 case DataLayout::NCHW:
562 os << "NCHW";
563 break;
564 default:
565 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
566 }
567
568 return os;
569}
570
Alex Gildayc357c472018-03-21 13:54:09 +0000571/** Formatted output of the DataLayout type.
572 *
573 * @param[in] data_layout Type to output.
574 *
575 * @return Formatted string.
576 */
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000577inline std::string to_string(const arm_compute::DataLayout &data_layout)
578{
579 std::stringstream str;
580 str << data_layout;
581 return str.str();
582}
Vidhya Sudhan Loganathand646ae12018-11-19 15:18:20 +0000583/** [Print DataLayout type] **/
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000584
Georgios Pinitase2220552018-07-20 13:23:44 +0100585/** Formatted output of the DataLayoutDimension type.
586 *
587 * @param[out] os Output stream.
588 * @param[in] data_layout_dim Data layout dimension to print.
589 *
590 * @return Modified output stream.
591 */
592inline ::std::ostream &operator<<(::std::ostream &os, const DataLayoutDimension &data_layout_dim)
593{
594 switch(data_layout_dim)
595 {
596 case DataLayoutDimension::WIDTH:
597 os << "WIDTH";
598 break;
599 case DataLayoutDimension::HEIGHT:
600 os << "HEIGHT";
601 break;
602 case DataLayoutDimension::CHANNEL:
603 os << "CHANNEL";
604 break;
605 case DataLayoutDimension::BATCHES:
606 os << "BATCHES";
607 break;
608 default:
609 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
610 }
611 return os;
612}
613
Alex Gildayc357c472018-03-21 13:54:09 +0000614/** Formatted output of the DataType type.
615 *
616 * @param[out] os Output stream.
617 * @param[in] data_type Type to output.
618 *
619 * @return Modified output stream.
620 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100621inline ::std::ostream &operator<<(::std::ostream &os, const DataType &data_type)
622{
623 switch(data_type)
624 {
625 case DataType::UNKNOWN:
626 os << "UNKNOWN";
627 break;
628 case DataType::U8:
629 os << "U8";
630 break;
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100631 case DataType::QSYMM8:
632 os << "QSYMM8";
633 break;
Chunosovd621bca2017-11-03 17:33:15 +0700634 case DataType::QASYMM8:
635 os << "QASYMM8";
636 break;
Georgios Pinitas448a81f2019-11-21 14:10:25 +0000637 case DataType::QASYMM8_SIGNED:
638 os << "QASYMM8_SIGNED";
639 break;
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100640 case DataType::QSYMM8_PER_CHANNEL:
641 os << "QSYMM8_PER_CHANNEL";
642 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100643 case DataType::S8:
644 os << "S8";
645 break;
646 case DataType::U16:
647 os << "U16";
648 break;
649 case DataType::S16:
650 os << "S16";
651 break;
Manuel Bottini3689fcd2019-06-14 17:18:12 +0100652 case DataType::QSYMM16:
653 os << "QSYMM16";
654 break;
Michele Di Giorgio35ea9a72019-08-23 12:02:06 +0100655 case DataType::QASYMM16:
656 os << "QASYMM16";
657 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100658 case DataType::U32:
659 os << "U32";
660 break;
661 case DataType::S32:
662 os << "S32";
663 break;
664 case DataType::U64:
665 os << "U64";
666 break;
667 case DataType::S64:
668 os << "S64";
669 break;
Georgios Pinitase8291ac2020-02-26 09:58:13 +0000670 case DataType::BFLOAT16:
671 os << "BFLOAT16";
672 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100673 case DataType::F16:
674 os << "F16";
675 break;
676 case DataType::F32:
677 os << "F32";
678 break;
679 case DataType::F64:
680 os << "F64";
681 break;
682 case DataType::SIZET:
683 os << "SIZET";
684 break;
685 default:
686 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
687 }
688
689 return os;
690}
691
Alex Gildayc357c472018-03-21 13:54:09 +0000692/** Formatted output of the DataType type.
693 *
694 * @param[in] data_type Type to output.
695 *
696 * @return Formatted string.
697 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100698inline std::string to_string(const arm_compute::DataType &data_type)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100699{
700 std::stringstream str;
701 str << data_type;
702 return str.str();
703}
704
Alex Gildayc357c472018-03-21 13:54:09 +0000705/** Formatted output of the Format type.
706 *
707 * @param[out] os Output stream.
708 * @param[in] format Type to output.
709 *
710 * @return Modified output stream.
711 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100712inline ::std::ostream &operator<<(::std::ostream &os, const Format &format)
713{
714 switch(format)
715 {
716 case Format::UNKNOWN:
717 os << "UNKNOWN";
718 break;
719 case Format::U8:
720 os << "U8";
721 break;
722 case Format::S16:
723 os << "S16";
724 break;
725 case Format::U16:
726 os << "U16";
727 break;
728 case Format::S32:
729 os << "S32";
730 break;
731 case Format::U32:
732 os << "U32";
733 break;
734 case Format::F16:
735 os << "F16";
736 break;
737 case Format::F32:
738 os << "F32";
739 break;
740 case Format::UV88:
741 os << "UV88";
742 break;
743 case Format::RGB888:
744 os << "RGB888";
745 break;
746 case Format::RGBA8888:
747 os << "RGBA8888";
748 break;
749 case Format::YUV444:
750 os << "YUV444";
751 break;
752 case Format::YUYV422:
753 os << "YUYV422";
754 break;
755 case Format::NV12:
756 os << "NV12";
757 break;
758 case Format::NV21:
759 os << "NV21";
760 break;
761 case Format::IYUV:
762 os << "IYUV";
763 break;
764 case Format::UYVY422:
765 os << "UYVY422";
766 break;
767 default:
768 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
769 }
770
771 return os;
772}
773
Alex Gildayc357c472018-03-21 13:54:09 +0000774/** Formatted output of the Format type.
775 *
776 * @param[in] format Type to output.
777 *
778 * @return Formatted string.
779 */
Moritz Pflanzer7655a672017-09-23 11:57:33 +0100780inline std::string to_string(const Format &format)
781{
782 std::stringstream str;
783 str << format;
784 return str.str();
785}
786
Alex Gildayc357c472018-03-21 13:54:09 +0000787/** Formatted output of the Channel type.
788 *
789 * @param[out] os Output stream.
790 * @param[in] channel Type to output.
791 *
792 * @return Modified output stream.
793 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100794inline ::std::ostream &operator<<(::std::ostream &os, const Channel &channel)
795{
796 switch(channel)
797 {
798 case Channel::UNKNOWN:
799 os << "UNKNOWN";
800 break;
801 case Channel::C0:
802 os << "C0";
803 break;
804 case Channel::C1:
805 os << "C1";
806 break;
807 case Channel::C2:
808 os << "C2";
809 break;
810 case Channel::C3:
811 os << "C3";
812 break;
813 case Channel::R:
814 os << "R";
815 break;
816 case Channel::G:
817 os << "G";
818 break;
819 case Channel::B:
820 os << "B";
821 break;
822 case Channel::A:
823 os << "A";
824 break;
825 case Channel::Y:
826 os << "Y";
827 break;
828 case Channel::U:
829 os << "U";
830 break;
831 case Channel::V:
832 os << "V";
833 break;
834 default:
835 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
836 }
837
838 return os;
839}
840
Alex Gildayc357c472018-03-21 13:54:09 +0000841/** Formatted output of the Channel type.
842 *
843 * @param[in] channel Type to output.
844 *
845 * @return Formatted string.
846 */
Ioan-Cristian Szabo9414f642017-10-27 17:35:40 +0100847inline std::string to_string(const Channel &channel)
848{
849 std::stringstream str;
850 str << channel;
851 return str.str();
852}
853
Alex Gildayc357c472018-03-21 13:54:09 +0000854/** Formatted output of the BorderMode type.
855 *
856 * @param[out] os Output stream.
857 * @param[in] mode Type to output.
858 *
859 * @return Modified output stream.
860 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100861inline ::std::ostream &operator<<(::std::ostream &os, const BorderMode &mode)
862{
863 switch(mode)
864 {
865 case BorderMode::UNDEFINED:
866 os << "UNDEFINED";
867 break;
868 case BorderMode::CONSTANT:
869 os << "CONSTANT";
870 break;
871 case BorderMode::REPLICATE:
872 os << "REPLICATE";
873 break;
874 default:
875 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
876 }
877
878 return os;
879}
880
Alex Gildayc357c472018-03-21 13:54:09 +0000881/** Formatted output of the BorderSize type.
882 *
883 * @param[out] os Output stream.
884 * @param[in] border Type to output.
885 *
886 * @return Modified output stream.
887 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100888inline ::std::ostream &operator<<(::std::ostream &os, const BorderSize &border)
889{
Moritz Pflanzerc87fbf82017-07-18 14:02:10 +0100890 os << border.top << ","
891 << border.right << ","
892 << border.bottom << ","
893 << border.left;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100894
895 return os;
896}
Anthony Barbier2a07e182017-08-04 18:20:27 +0100897
Giuseppe Rossinid7647d42018-07-17 18:13:13 +0100898/** Formatted output of the PaddingList type.
899 *
900 * @param[out] os Output stream.
901 * @param[in] padding Type to output.
902 *
903 * @return Modified output stream.
904 */
905inline ::std::ostream &operator<<(::std::ostream &os, const PaddingList &padding)
906{
907 os << "{";
908 for(auto const &p : padding)
909 {
910 os << "{" << p.first << "," << p.second << "}";
911 }
912 os << "}";
913 return os;
914}
915
giuros013175fcf2018-11-21 09:59:17 +0000916/** Formatted output of the Multiples type.
917 *
918 * @param[out] os Output stream.
919 * @param[in] multiples Type to output.
920 *
921 * @return Modified output stream.
922 */
923inline ::std::ostream &operator<<(::std::ostream &os, const Multiples &multiples)
924{
925 os << "(";
926 for(size_t i = 0; i < multiples.size() - 1; i++)
927 {
928 os << multiples[i] << ", ";
929 }
930 os << multiples.back() << ")";
931 return os;
932}
933
Alex Gildayc357c472018-03-21 13:54:09 +0000934/** Formatted output of the InterpolationPolicy type.
935 *
936 * @param[out] os Output stream.
937 * @param[in] policy Type to output.
938 *
939 * @return Modified output stream.
940 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100941inline ::std::ostream &operator<<(::std::ostream &os, const InterpolationPolicy &policy)
942{
943 switch(policy)
944 {
945 case InterpolationPolicy::NEAREST_NEIGHBOR:
946 os << "NEAREST_NEIGHBOR";
947 break;
948 case InterpolationPolicy::BILINEAR:
949 os << "BILINEAR";
950 break;
951 case InterpolationPolicy::AREA:
952 os << "AREA";
953 break;
954 default:
955 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
956 }
957
958 return os;
959}
960
Alex Gildayc357c472018-03-21 13:54:09 +0000961/** Formatted output of the SamplingPolicy type.
962 *
963 * @param[out] os Output stream.
964 * @param[in] policy Type to output.
965 *
966 * @return Modified output stream.
967 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700968inline ::std::ostream &operator<<(::std::ostream &os, const SamplingPolicy &policy)
969{
970 switch(policy)
971 {
972 case SamplingPolicy::CENTER:
973 os << "CENTER";
974 break;
975 case SamplingPolicy::TOP_LEFT:
976 os << "TOP_LEFT";
977 break;
978 default:
979 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
980 }
981
982 return os;
983}
984
Alex Gildayc357c472018-03-21 13:54:09 +0000985/** Formatted output of the TensorInfo type.
986 *
Anthony Barbier366628a2018-08-01 13:55:03 +0100987 * @param[out] os Output stream.
988 * @param[in] info Type to output.
989 *
990 * @return Modified output stream.
991 */
992inline ::std::ostream &operator<<(::std::ostream &os, const TensorInfo &info)
993{
994 os << "{Shape=" << info.tensor_shape() << ","
995 << "Type=" << info.data_type() << ","
996 << "Channels=" << info.num_channels() << "}";
997 return os;
998}
999/** Formatted output of the TensorInfo type.
1000 *
Alex Gildayc357c472018-03-21 13:54:09 +00001001 * @param[in] info Type to output.
1002 *
1003 * @return Formatted string.
1004 */
Georgios Pinitas3faea252017-10-30 14:13:50 +00001005inline std::string to_string(const TensorInfo &info)
1006{
1007 std::stringstream str;
Anthony Barbier366628a2018-08-01 13:55:03 +01001008 str << info;
Georgios Pinitas3faea252017-10-30 14:13:50 +00001009 return str.str();
1010}
1011
Alex Gildayc357c472018-03-21 13:54:09 +00001012/** Formatted output of the Dimensions type.
1013 *
1014 * @param[in] dimensions Type to output.
1015 *
1016 * @return Formatted string.
1017 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001018template <typename T>
1019inline std::string to_string(const Dimensions<T> &dimensions)
1020{
1021 std::stringstream str;
1022 str << dimensions;
1023 return str.str();
1024}
1025
Alex Gildayc357c472018-03-21 13:54:09 +00001026/** Formatted output of the Strides type.
1027 *
1028 * @param[in] stride Type to output.
1029 *
1030 * @return Formatted string.
1031 */
John Richardsona36eae12017-09-26 16:55:59 +01001032inline std::string to_string(const Strides &stride)
1033{
1034 std::stringstream str;
1035 str << stride;
1036 return str.str();
1037}
1038
Alex Gildayc357c472018-03-21 13:54:09 +00001039/** Formatted output of the TensorShape type.
1040 *
1041 * @param[in] shape Type to output.
1042 *
1043 * @return Formatted string.
1044 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001045inline std::string to_string(const TensorShape &shape)
1046{
1047 std::stringstream str;
1048 str << shape;
1049 return str.str();
1050}
1051
Alex Gildayc357c472018-03-21 13:54:09 +00001052/** Formatted output of the Coordinates type.
1053 *
1054 * @param[in] coord Type to output.
1055 *
1056 * @return Formatted string.
1057 */
Abe Mbise925ca0f2017-10-02 19:16:33 +01001058inline std::string to_string(const Coordinates &coord)
1059{
1060 std::stringstream str;
1061 str << coord;
1062 return str.str();
1063}
1064
Anthony Barbierb940fd62018-06-04 14:14:32 +01001065/** Formatted output of the GEMMReshapeInfo type.
1066 *
1067 * @param[out] os Output stream.
1068 * @param[in] info Type to output.
1069 *
1070 * @return Modified output stream.
1071 */
1072inline ::std::ostream &operator<<(::std::ostream &os, const GEMMReshapeInfo &info)
1073{
1074 os << "{m=" << info.m() << ",";
1075 os << "n=" << info.n() << ",";
1076 os << "k=" << info.k() << ",";
1077 os << "mult_transpose1xW_width=" << info.mult_transpose1xW_width() << ",";
1078 os << "mult_interleave4x4_height=" << info.mult_interleave4x4_height();
1079 os << "}";
1080
1081 return os;
1082}
1083
1084/** Formatted output of the GEMMInfo type.
1085 *
1086 * @param[out] os Output stream.
1087 * @param[in] info Type to output.
1088 *
1089 * @return Modified output stream.
1090 */
1091inline ::std::ostream &operator<<(::std::ostream &os, const GEMMInfo &info)
1092{
1093 os << "{is_a_reshaped=" << info.is_a_reshaped() << ",";
1094 os << "is_b_reshaped=" << info.is_b_reshaped() << ",";
1095 os << "reshape_b_only_on_first_run=" << info.reshape_b_only_on_first_run() << ",";
Anthony Barbierb4670212018-05-18 16:55:39 +01001096 os << "depth_output_gemm3d=" << info.depth_output_gemm3d() << ",";
1097 os << "reinterpret_input_as_3d=" << info.reinterpret_input_as_3d() << ",";
1098 os << "retain_internal_weights=" << info.retain_internal_weights() << ",";
1099 os << "fp_mixed_precision=" << info.fp_mixed_precision() << ",";
1100 os << "broadcast_bias=" << info.broadcast_bias() << ",";
1101 os << "pretranpose_B=" << info.pretranpose_B() << ",";
Anthony Barbierb940fd62018-06-04 14:14:32 +01001102
1103 return os;
1104}
1105
1106/** Formatted output of the Window::Dimension type.
1107 *
1108 * @param[out] os Output stream.
1109 * @param[in] dim Type to output.
1110 *
1111 * @return Modified output stream.
1112 */
1113inline ::std::ostream &operator<<(::std::ostream &os, const Window::Dimension &dim)
1114{
1115 os << "{start=" << dim.start() << ", end=" << dim.end() << ", step=" << dim.step() << "}";
1116
1117 return os;
1118}
1119/** Formatted output of the Window type.
1120 *
1121 * @param[out] os Output stream.
1122 * @param[in] win Type to output.
1123 *
1124 * @return Modified output stream.
1125 */
1126inline ::std::ostream &operator<<(::std::ostream &os, const Window &win)
1127{
1128 os << "{";
1129 for(unsigned int i = 0; i < Coordinates::num_max_dimensions; i++)
1130 {
1131 if(i > 0)
1132 {
1133 os << ", ";
1134 }
1135 os << win[i];
1136 }
1137 os << "}";
1138
1139 return os;
1140}
1141
1142/** Formatted output of the WeightsInfo type.
1143 *
1144 * @param[in] info Type to output.
1145 *
1146 * @return Formatted string.
1147 */
1148inline std::string to_string(const WeightsInfo &info)
1149{
1150 std::stringstream str;
1151 str << info;
1152 return str.str();
1153}
1154
1155/** Formatted output of the GEMMReshapeInfo type.
1156 *
1157 * @param[in] info Type to output.
1158 *
1159 * @return Formatted string.
1160 */
1161inline std::string to_string(const GEMMReshapeInfo &info)
1162{
1163 std::stringstream str;
1164 str << info;
1165 return str.str();
1166}
1167
1168/** Formatted output of the GEMMInfo type.
1169 *
1170 * @param[in] info Type to output.
1171 *
1172 * @return Formatted string.
1173 */
1174inline std::string to_string(const GEMMInfo &info)
1175{
1176 std::stringstream str;
1177 str << info;
1178 return str.str();
1179}
1180
1181/** Formatted output of the Window::Dimension type.
1182 *
1183 * @param[in] dim Type to output.
1184 *
1185 * @return Formatted string.
1186 */
1187inline std::string to_string(const Window::Dimension &dim)
1188{
1189 std::stringstream str;
1190 str << dim;
1191 return str.str();
1192}
1193/** Formatted output of the Window type.
1194 *
1195 * @param[in] win Type to output.
1196 *
1197 * @return Formatted string.
1198 */
1199inline std::string to_string(const Window &win)
1200{
1201 std::stringstream str;
1202 str << win;
1203 return str.str();
1204}
1205
Alex Gildayc357c472018-03-21 13:54:09 +00001206/** Formatted output of the Rectangle type.
1207 *
1208 * @param[out] os Output stream.
1209 * @param[in] rect Type to output.
1210 *
1211 * @return Modified output stream.
1212 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001213inline ::std::ostream &operator<<(::std::ostream &os, const Rectangle &rect)
1214{
1215 os << rect.width << "x" << rect.height;
1216 os << "+" << rect.x << "+" << rect.y;
1217
1218 return os;
1219}
1220
Usama Arif8cf8c112019-03-14 15:36:54 +00001221/** Formatted output of the PaddingMode type.
1222 *
1223 * @param[out] os Output stream.
1224 * @param[in] mode Type to output.
1225 *
1226 * @return Modified output stream.
1227 */
1228inline ::std::ostream &operator<<(::std::ostream &os, const PaddingMode &mode)
1229{
1230 switch(mode)
1231 {
1232 case PaddingMode::CONSTANT:
1233 os << "CONSTANT";
1234 break;
1235 case PaddingMode::REFLECT:
1236 os << "REFLECT";
1237 break;
1238 case PaddingMode::SYMMETRIC:
1239 os << "SYMMETRIC";
1240 break;
1241 default:
1242 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1243 }
1244
1245 return os;
1246}
1247
1248/** Formatted output of the PaddingMode type.
1249 *
1250 * @param[in] mode Type to output.
1251 *
1252 * @return Formatted string.
1253 */
1254inline std::string to_string(const PaddingMode &mode)
1255{
1256 std::stringstream str;
1257 str << mode;
1258 return str.str();
1259}
1260
Alex Gildayc357c472018-03-21 13:54:09 +00001261/** Formatted output of the PadStrideInfo type.
1262 *
1263 * @param[out] os Output stream.
1264 * @param[in] pad_stride_info Type to output.
1265 *
1266 * @return Modified output stream.
1267 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001268inline ::std::ostream &operator<<(::std::ostream &os, const PadStrideInfo &pad_stride_info)
1269{
1270 os << pad_stride_info.stride().first << "," << pad_stride_info.stride().second;
1271 os << ";";
Jaroslaw Rzepeckia1ed41f2017-10-13 11:13:58 +01001272 os << pad_stride_info.pad_left() << "," << pad_stride_info.pad_right() << ","
1273 << pad_stride_info.pad_top() << "," << pad_stride_info.pad_bottom();
Anthony Barbier2a07e182017-08-04 18:20:27 +01001274
1275 return os;
1276}
1277
Alex Gildayc357c472018-03-21 13:54:09 +00001278/** Formatted output of the PadStrideInfo type.
1279 *
1280 * @param[in] pad_stride_info Type to output.
1281 *
1282 * @return Formatted string.
1283 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001284inline std::string to_string(const PadStrideInfo &pad_stride_info)
1285{
1286 std::stringstream str;
1287 str << pad_stride_info;
1288 return str.str();
1289}
1290
Alex Gildayc357c472018-03-21 13:54:09 +00001291/** Formatted output of the BorderMode type.
1292 *
1293 * @param[in] mode Type to output.
1294 *
1295 * @return Formatted string.
1296 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001297inline std::string to_string(const BorderMode &mode)
1298{
1299 std::stringstream str;
1300 str << mode;
1301 return str.str();
1302}
1303
Alex Gildayc357c472018-03-21 13:54:09 +00001304/** Formatted output of the BorderSize type.
1305 *
1306 * @param[in] border Type to output.
1307 *
1308 * @return Formatted string.
1309 */
John Richardsonb482ce12017-09-18 12:44:01 +01001310inline std::string to_string(const BorderSize &border)
1311{
1312 std::stringstream str;
1313 str << border;
1314 return str.str();
1315}
1316
Giuseppe Rossinid7647d42018-07-17 18:13:13 +01001317/** Formatted output of the PaddingList type.
1318 *
1319 * @param[in] padding Type to output.
1320 *
1321 * @return Formatted string.
1322 */
1323inline std::string to_string(const PaddingList &padding)
1324{
1325 std::stringstream str;
1326 str << padding;
1327 return str.str();
1328}
1329
giuros013175fcf2018-11-21 09:59:17 +00001330/** Formatted output of the Multiples type.
1331 *
1332 * @param[in] multiples Type to output.
1333 *
1334 * @return Formatted string.
1335 */
1336inline std::string to_string(const Multiples &multiples)
1337{
1338 std::stringstream str;
1339 str << multiples;
1340 return str.str();
1341}
1342
Alex Gildayc357c472018-03-21 13:54:09 +00001343/** Formatted output of the InterpolationPolicy type.
1344 *
1345 * @param[in] policy Type to output.
1346 *
1347 * @return Formatted string.
1348 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001349inline std::string to_string(const InterpolationPolicy &policy)
1350{
1351 std::stringstream str;
1352 str << policy;
1353 return str.str();
1354}
1355
Alex Gildayc357c472018-03-21 13:54:09 +00001356/** Formatted output of the SamplingPolicy type.
1357 *
1358 * @param[in] policy Type to output.
1359 *
1360 * @return Formatted string.
1361 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +07001362inline std::string to_string(const SamplingPolicy &policy)
1363{
1364 std::stringstream str;
1365 str << policy;
1366 return str.str();
1367}
1368
Alex Gildayc357c472018-03-21 13:54:09 +00001369/** Formatted output of the ConvertPolicy type.
1370 *
1371 * @param[out] os Output stream.
1372 * @param[in] policy Type to output.
1373 *
1374 * @return Modified output stream.
1375 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001376inline ::std::ostream &operator<<(::std::ostream &os, const ConvertPolicy &policy)
1377{
1378 switch(policy)
1379 {
1380 case ConvertPolicy::WRAP:
1381 os << "WRAP";
1382 break;
1383 case ConvertPolicy::SATURATE:
1384 os << "SATURATE";
1385 break;
1386 default:
1387 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1388 }
1389
1390 return os;
1391}
1392
1393inline std::string to_string(const ConvertPolicy &policy)
1394{
1395 std::stringstream str;
1396 str << policy;
1397 return str.str();
1398}
1399
giuros01164a2722018-11-20 18:34:46 +00001400/** Formatted output of the ArithmeticOperation type.
1401 *
1402 * @param[out] os Output stream.
1403 * @param[in] op Operation to output.
1404 *
1405 * @return Modified output stream.
1406 */
1407inline ::std::ostream &operator<<(::std::ostream &os, const ArithmeticOperation &op)
1408{
1409 switch(op)
1410 {
1411 case ArithmeticOperation::ADD:
1412 os << "ADD";
1413 break;
1414 case ArithmeticOperation::SUB:
1415 os << "SUB";
1416 break;
1417 case ArithmeticOperation::DIV:
1418 os << "DIV";
1419 break;
1420 case ArithmeticOperation::MAX:
1421 os << "MAX";
1422 break;
1423 case ArithmeticOperation::MIN:
1424 os << "MIN";
1425 break;
1426 case ArithmeticOperation::SQUARED_DIFF:
1427 os << "SQUARED_DIFF";
1428 break;
Usama Arif52c54f62019-05-14 10:22:36 +01001429 case ArithmeticOperation::POWER:
1430 os << "POWER";
1431 break;
giuros01164a2722018-11-20 18:34:46 +00001432 default:
1433 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1434 }
1435
1436 return os;
1437}
1438
1439/** Formatted output of the Arithmetic Operation
1440 *
1441 * @param[in] op Type to output.
1442 *
1443 * @return Formatted string.
1444 */
1445inline std::string to_string(const ArithmeticOperation &op)
1446{
1447 std::stringstream str;
1448 str << op;
1449 return str.str();
1450}
1451
Alex Gildayc357c472018-03-21 13:54:09 +00001452/** Formatted output of the Reduction Operations.
1453 *
1454 * @param[out] os Output stream.
1455 * @param[in] op Type to output.
1456 *
1457 * @return Modified output stream.
1458 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001459inline ::std::ostream &operator<<(::std::ostream &os, const ReductionOperation &op)
1460{
1461 switch(op)
1462 {
Michalis Spyrou7e9391b2018-10-05 14:49:28 +01001463 case ReductionOperation::SUM:
1464 os << "SUM";
1465 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +01001466 case ReductionOperation::SUM_SQUARE:
1467 os << "SUM_SQUARE";
1468 break;
Michalis Spyrou7e9391b2018-10-05 14:49:28 +01001469 case ReductionOperation::MEAN_SUM:
1470 os << "MEAN_SUM";
1471 break;
Michalis Spyrou7930db42018-11-22 17:36:28 +00001472 case ReductionOperation::ARG_IDX_MAX:
1473 os << "ARG_IDX_MAX";
1474 break;
1475 case ReductionOperation::ARG_IDX_MIN:
1476 os << "ARG_IDX_MIN";
1477 break;
Manuel Bottinib412fab2018-12-10 17:40:23 +00001478 case ReductionOperation::PROD:
1479 os << "PROD";
1480 break;
Usama Arifa4a08ad2019-05-20 12:38:33 +01001481 case ReductionOperation::MIN:
1482 os << "MIN";
1483 break;
Usama Arif28f0dd92019-05-20 13:44:34 +01001484 case ReductionOperation::MAX:
1485 os << "MAX";
1486 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +01001487 default:
1488 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1489 }
1490
1491 return os;
1492}
1493
Alex Gildayc357c472018-03-21 13:54:09 +00001494/** Formatted output of the Reduction Operations.
1495 *
1496 * @param[in] op Type to output.
1497 *
1498 * @return Formatted string.
1499 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001500inline std::string to_string(const ReductionOperation &op)
1501{
1502 std::stringstream str;
1503 str << op;
1504 return str.str();
1505}
1506
Georgios Pinitas7900a9e2018-11-23 11:44:58 +00001507/** Formatted output of the Comparison Operations.
1508 *
1509 * @param[out] os Output stream.
1510 * @param[in] op Type to output.
1511 *
1512 * @return Modified output stream.
1513 */
1514inline ::std::ostream &operator<<(::std::ostream &os, const ComparisonOperation &op)
1515{
1516 switch(op)
1517 {
1518 case ComparisonOperation::Equal:
1519 os << "Equal";
1520 break;
1521 case ComparisonOperation::NotEqual:
1522 os << "NotEqual";
1523 break;
1524 case ComparisonOperation::Greater:
1525 os << "Greater";
1526 break;
1527 case ComparisonOperation::GreaterEqual:
1528 os << "GreaterEqual";
1529 break;
1530 case ComparisonOperation::Less:
1531 os << "Less";
1532 break;
1533 case ComparisonOperation::LessEqual:
1534 os << "LessEqual";
1535 break;
1536 default:
1537 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1538 }
1539
1540 return os;
1541}
1542
Michalis Spyroue9362622018-11-23 17:41:37 +00001543/** Formatted output of the Elementwise unary Operations.
1544 *
1545 * @param[out] os Output stream.
1546 * @param[in] op Type to output.
1547 *
1548 * @return Modified output stream.
1549 */
1550inline ::std::ostream &operator<<(::std::ostream &os, const ElementWiseUnary &op)
1551{
1552 switch(op)
1553 {
1554 case ElementWiseUnary::RSQRT:
1555 os << "RSQRT";
1556 break;
1557 case ElementWiseUnary::EXP:
1558 os << "EXP";
1559 break;
Usama Arifeb312ef2019-05-13 17:45:54 +01001560 case ElementWiseUnary::NEG:
1561 os << "NEG";
1562 break;
Usama Arifac33d7e2019-05-20 14:21:40 +01001563 case ElementWiseUnary::LOG:
1564 os << "LOG";
1565 break;
Usama Arif6a4d5422019-05-24 14:53:59 +01001566 case ElementWiseUnary::ROUND:
1567 os << "ROUND";
1568 break;
Michalis Spyroue9362622018-11-23 17:41:37 +00001569 default:
1570 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1571 }
1572
1573 return os;
1574}
1575
Georgios Pinitas7900a9e2018-11-23 11:44:58 +00001576/** Formatted output of the Comparison Operations.
1577 *
1578 * @param[in] op Type to output.
1579 *
1580 * @return Formatted string.
1581 */
1582inline std::string to_string(const ComparisonOperation &op)
1583{
1584 std::stringstream str;
1585 str << op;
1586 return str.str();
1587}
1588
Michalis Spyroue9362622018-11-23 17:41:37 +00001589/** Formatted output of the Elementwise unary Operations.
1590 *
1591 * @param[in] op Type to output.
1592 *
1593 * @return Formatted string.
1594 */
1595inline std::string to_string(const ElementWiseUnary &op)
1596{
1597 std::stringstream str;
1598 str << op;
1599 return str.str();
1600}
1601
Alex Gildayc357c472018-03-21 13:54:09 +00001602/** Formatted output of the Norm Type.
1603 *
1604 * @param[in] type Type to output.
1605 *
1606 * @return Formatted string.
1607 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001608inline std::string to_string(const NormType &type)
1609{
1610 std::stringstream str;
1611 str << type;
1612 return str.str();
1613}
1614
Alex Gildayc357c472018-03-21 13:54:09 +00001615/** Formatted output of the Pooling Type.
1616 *
1617 * @param[in] type Type to output.
1618 *
1619 * @return Formatted string.
1620 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001621inline std::string to_string(const PoolingType &type)
1622{
1623 std::stringstream str;
1624 str << type;
1625 return str.str();
1626}
1627
Alex Gildayc357c472018-03-21 13:54:09 +00001628/** Formatted output of the Pooling Layer Info.
1629 *
1630 * @param[in] info Type to output.
1631 *
1632 * @return Formatted string.
1633 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001634inline std::string to_string(const PoolingLayerInfo &info)
1635{
1636 std::stringstream str;
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +00001637 str << "{Type=" << info.pool_type << ","
Sang-Hoon Park11fedda2020-01-15 14:44:04 +00001638 << "DataLayout=" << info.data_layout << ","
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +00001639 << "IsGlobalPooling=" << info.is_global_pooling;
1640 if(!info.is_global_pooling)
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001641 {
1642 str << ","
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +00001643 << "PoolSize=" << info.pool_size.width << "," << info.pool_size.height << ","
1644 << "PadStride=" << info.pad_stride_info;
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001645 }
1646 str << "}";
Anthony Barbier2a07e182017-08-04 18:20:27 +01001647 return str.str();
1648}
1649
Michalis Spyrou6c7c38e2018-08-29 16:28:11 +01001650/** Formatted output of the PriorBoxLayerInfo.
1651 *
1652 * @param[in] info Type to output.
1653 *
1654 * @return Formatted string.
1655 */
1656inline std::string to_string(const PriorBoxLayerInfo &info)
1657{
1658 std::stringstream str;
1659 str << "{";
1660 str << "Clip:" << info.clip()
1661 << "Flip:" << info.flip()
1662 << "StepX:" << info.steps()[0]
1663 << "StepY:" << info.steps()[1]
1664 << "MinSizes:" << info.min_sizes().size()
1665 << "MaxSizes:" << info.max_sizes().size()
1666 << "ImgSizeX:" << info.img_size().x
1667 << "ImgSizeY:" << info.img_size().y
1668 << "Offset:" << info.offset()
1669 << "Variances:" << info.variances().size();
1670 str << "}";
1671 return str.str();
1672}
1673
Alex Gildayc357c472018-03-21 13:54:09 +00001674/** Formatted output of the KeyPoint type.
1675 *
1676 * @param[out] os Output stream
1677 * @param[in] point Type to output.
1678 *
1679 * @return Modified output stream.
1680 */
Moritz Pflanzer6c6597c2017-09-24 12:09:41 +01001681inline ::std::ostream &operator<<(::std::ostream &os, const KeyPoint &point)
1682{
1683 os << "{x=" << point.x << ","
1684 << "y=" << point.y << ","
1685 << "strength=" << point.strength << ","
1686 << "scale=" << point.scale << ","
1687 << "orientation=" << point.orientation << ","
1688 << "tracking_status=" << point.tracking_status << ","
1689 << "error=" << point.error << "}";
1690
1691 return os;
1692}
John Richardson63e50412017-10-13 20:51:42 +01001693
Alex Gildayc357c472018-03-21 13:54:09 +00001694/** Formatted output of the PhaseType type.
1695 *
1696 * @param[out] os Output stream
1697 * @param[in] phase_type Type to output.
1698 *
1699 * @return Modified output stream.
1700 */
John Richardson63e50412017-10-13 20:51:42 +01001701inline ::std::ostream &operator<<(::std::ostream &os, const PhaseType &phase_type)
1702{
1703 switch(phase_type)
1704 {
1705 case PhaseType::SIGNED:
1706 os << "SIGNED";
1707 break;
1708 case PhaseType::UNSIGNED:
1709 os << "UNSIGNED";
1710 break;
1711 default:
1712 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1713 }
1714
1715 return os;
1716}
1717
Alex Gildayc357c472018-03-21 13:54:09 +00001718/** Formatted output of the PhaseType type.
1719 *
1720 * @param[in] type Type to output.
1721 *
1722 * @return Formatted string.
1723 */
John Richardson63e50412017-10-13 20:51:42 +01001724inline std::string to_string(const arm_compute::PhaseType &type)
1725{
1726 std::stringstream str;
1727 str << type;
1728 return str.str();
1729}
John Richardson3c5f9492017-10-04 15:27:37 +01001730
Alex Gildayc357c472018-03-21 13:54:09 +00001731/** Formatted output of the MagnitudeType type.
1732 *
1733 * @param[out] os Output stream
1734 * @param[in] magnitude_type Type to output.
1735 *
1736 * @return Modified output stream.
1737 */
John Richardson3c5f9492017-10-04 15:27:37 +01001738inline ::std::ostream &operator<<(::std::ostream &os, const MagnitudeType &magnitude_type)
1739{
1740 switch(magnitude_type)
1741 {
1742 case MagnitudeType::L1NORM:
1743 os << "L1NORM";
1744 break;
1745 case MagnitudeType::L2NORM:
1746 os << "L2NORM";
1747 break;
1748 default:
1749 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1750 }
1751
1752 return os;
1753}
1754
Alex Gildayc357c472018-03-21 13:54:09 +00001755/** Formatted output of the MagnitudeType type.
1756 *
1757 * @param[in] type Type to output.
1758 *
1759 * @return Formatted string.
1760 */
John Richardson3c5f9492017-10-04 15:27:37 +01001761inline std::string to_string(const arm_compute::MagnitudeType &type)
1762{
1763 std::stringstream str;
1764 str << type;
1765 return str.str();
1766}
John Richardson1c529922017-11-01 10:57:48 +00001767
Alex Gildayc357c472018-03-21 13:54:09 +00001768/** Formatted output of the HOGNormType type.
1769 *
1770 * @param[out] os Output stream
1771 * @param[in] norm_type Type to output
1772 *
1773 * @return Modified output stream.
1774 */
John Richardson25f23682017-11-27 14:35:09 +00001775inline ::std::ostream &operator<<(::std::ostream &os, const HOGNormType &norm_type)
1776{
1777 switch(norm_type)
1778 {
1779 case HOGNormType::L1_NORM:
1780 os << "L1_NORM";
1781 break;
1782 case HOGNormType::L2_NORM:
1783 os << "L2_NORM";
1784 break;
1785 case HOGNormType::L2HYS_NORM:
1786 os << "L2HYS_NORM";
1787 break;
1788 default:
1789 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1790 }
1791
1792 return os;
1793}
1794
Alex Gildayc357c472018-03-21 13:54:09 +00001795/** Formatted output of the HOGNormType type.
1796 *
1797 * @param[in] type Type to output
1798 *
1799 * @return Formatted string.
1800 */
John Richardson25f23682017-11-27 14:35:09 +00001801inline std::string to_string(const HOGNormType &type)
1802{
1803 std::stringstream str;
1804 str << type;
1805 return str.str();
1806}
1807
Alex Gildayc357c472018-03-21 13:54:09 +00001808/** Formatted output of the Size2D type.
1809 *
1810 * @param[out] os Output stream
1811 * @param[in] size Type to output
1812 *
1813 * @return Modified output stream.
1814 */
John Richardson25f23682017-11-27 14:35:09 +00001815inline ::std::ostream &operator<<(::std::ostream &os, const Size2D &size)
1816{
1817 os << size.width << "x" << size.height;
1818
1819 return os;
1820}
1821
Alex Gildayc357c472018-03-21 13:54:09 +00001822/** Formatted output of the Size2D type.
1823 *
1824 * @param[in] type Type to output
1825 *
1826 * @return Formatted string.
1827 */
John Richardson25f23682017-11-27 14:35:09 +00001828inline std::string to_string(const Size2D &type)
1829{
1830 std::stringstream str;
1831 str << type;
1832 return str.str();
1833}
1834
Alex Gildayc357c472018-03-21 13:54:09 +00001835/** Formatted output of the HOGInfo type.
1836 *
1837 * @param[out] os Output stream
1838 * @param[in] hog_info Type to output
1839 *
1840 * @return Modified output stream.
1841 */
John Richardson25f23682017-11-27 14:35:09 +00001842inline ::std::ostream &operator<<(::std::ostream &os, const HOGInfo &hog_info)
1843{
1844 os << "{CellSize=" << hog_info.cell_size() << ","
1845 << "BlockSize=" << hog_info.block_size() << ","
1846 << "DetectionWindowSize=" << hog_info.detection_window_size() << ","
1847 << "BlockStride=" << hog_info.block_stride() << ","
1848 << "NumBins=" << hog_info.num_bins() << ","
1849 << "NormType=" << hog_info.normalization_type() << ","
1850 << "L2HystThreshold=" << hog_info.l2_hyst_threshold() << ","
1851 << "PhaseType=" << hog_info.phase_type() << "}";
1852
1853 return os;
1854}
1855
Alex Gildayc357c472018-03-21 13:54:09 +00001856/** Formatted output of the HOGInfo type.
1857 *
1858 * @param[in] type Type to output
1859 *
1860 * @return Formatted string.
1861 */
John Richardson25f23682017-11-27 14:35:09 +00001862inline std::string to_string(const HOGInfo &type)
1863{
1864 std::stringstream str;
1865 str << type;
1866 return str.str();
1867}
1868
Alex Gildayc357c472018-03-21 13:54:09 +00001869/** Formatted output of the ConvolutionMethod type.
1870 *
1871 * @param[out] os Output stream
1872 * @param[in] conv_method Type to output
1873 *
1874 * @return Modified output stream.
1875 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001876inline ::std::ostream &operator<<(::std::ostream &os, const ConvolutionMethod &conv_method)
1877{
1878 switch(conv_method)
1879 {
1880 case ConvolutionMethod::GEMM:
1881 os << "GEMM";
1882 break;
1883 case ConvolutionMethod::DIRECT:
1884 os << "DIRECT";
1885 break;
1886 case ConvolutionMethod::WINOGRAD:
1887 os << "WINOGRAD";
1888 break;
1889 default:
1890 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1891 }
1892
1893 return os;
1894}
1895
Alex Gildayc357c472018-03-21 13:54:09 +00001896/** Formatted output of the ConvolutionMethod type.
1897 *
1898 * @param[in] conv_method Type to output
1899 *
1900 * @return Formatted string.
1901 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001902inline std::string to_string(const ConvolutionMethod &conv_method)
1903{
1904 std::stringstream str;
1905 str << conv_method;
1906 return str.str();
1907}
1908
Alex Gildayc357c472018-03-21 13:54:09 +00001909/** Formatted output of the GPUTarget type.
1910 *
1911 * @param[out] os Output stream
1912 * @param[in] gpu_target Type to output
1913 *
1914 * @return Modified output stream.
1915 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001916inline ::std::ostream &operator<<(::std::ostream &os, const GPUTarget &gpu_target)
1917{
1918 switch(gpu_target)
1919 {
1920 case GPUTarget::GPU_ARCH_MASK:
1921 os << "GPU_ARCH_MASK";
1922 break;
1923 case GPUTarget::MIDGARD:
1924 os << "MIDGARD";
1925 break;
1926 case GPUTarget::BIFROST:
1927 os << "BIFROST";
1928 break;
Georgios Pinitasd5462ff2019-07-03 19:33:57 +01001929 case GPUTarget::VALHALL:
1930 os << "VALHALL";
1931 break;
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001932 case GPUTarget::T600:
1933 os << "T600";
1934 break;
1935 case GPUTarget::T700:
1936 os << "T700";
1937 break;
1938 case GPUTarget::T800:
1939 os << "T800";
1940 break;
Michalis Spyroua9676112018-02-22 18:07:43 +00001941 case GPUTarget::G71:
1942 os << "G71";
1943 break;
1944 case GPUTarget::G72:
1945 os << "G72";
1946 break;
1947 case GPUTarget::G51:
1948 os << "G51";
1949 break;
1950 case GPUTarget::G51BIG:
1951 os << "G51BIG";
1952 break;
1953 case GPUTarget::G51LIT:
1954 os << "G51LIT";
1955 break;
Georgios Pinitasb03f7c52018-07-12 10:49:53 +01001956 case GPUTarget::G76:
1957 os << "G76";
Michalis Spyroua9676112018-02-22 18:07:43 +00001958 break;
Georgios Pinitasd5462ff2019-07-03 19:33:57 +01001959 case GPUTarget::G77:
1960 os << "G77";
Michalis Spyroua9676112018-02-22 18:07:43 +00001961 break;
1962 case GPUTarget::TBOX:
1963 os << "TBOX";
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001964 break;
Georgios Pinitasd5462ff2019-07-03 19:33:57 +01001965 case GPUTarget::TODX:
1966 os << "TODX";
1967 break;
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001968 default:
1969 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1970 }
1971
1972 return os;
1973}
1974
Alex Gildayc357c472018-03-21 13:54:09 +00001975/** Formatted output of the GPUTarget type.
1976 *
1977 * @param[in] gpu_target Type to output
1978 *
1979 * @return Formatted string.
1980 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001981inline std::string to_string(const GPUTarget &gpu_target)
1982{
1983 std::stringstream str;
1984 str << gpu_target;
1985 return str.str();
1986}
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00001987
John Richardson8de92612018-02-22 14:09:31 +00001988/** Formatted output of the DetectionWindow type.
1989 *
1990 * @param[out] os Output stream
1991 * @param[in] detection_window Type to output
1992 *
1993 * @return Modified output stream.
1994 */
John Richardson684cb0f2018-01-09 11:17:00 +00001995inline ::std::ostream &operator<<(::std::ostream &os, const DetectionWindow &detection_window)
1996{
1997 os << "{x=" << detection_window.x << ","
1998 << "y=" << detection_window.y << ","
1999 << "width=" << detection_window.width << ","
2000 << "height=" << detection_window.height << ","
2001 << "idx_class=" << detection_window.idx_class << ","
2002 << "score=" << detection_window.score << "}";
2003
2004 return os;
2005}
2006
Isabella Gottardi05e56442018-11-16 11:26:52 +00002007/** Formatted output of the DetectionOutputLayerCodeType type.
2008 *
2009 * @param[out] os Output stream
2010 * @param[in] detection_code Type to output
2011 *
2012 * @return Modified output stream.
2013 */
2014inline ::std::ostream &operator<<(::std::ostream &os, const DetectionOutputLayerCodeType &detection_code)
2015{
2016 switch(detection_code)
2017 {
2018 case DetectionOutputLayerCodeType::CENTER_SIZE:
2019 os << "CENTER_SIZE";
2020 break;
2021 case DetectionOutputLayerCodeType::CORNER:
2022 os << "CORNER";
2023 break;
2024 case DetectionOutputLayerCodeType::CORNER_SIZE:
2025 os << "CORNER_SIZE";
2026 break;
2027 case DetectionOutputLayerCodeType::TF_CENTER:
2028 os << "TF_CENTER";
2029 break;
2030 default:
2031 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2032 }
2033
2034 return os;
2035}
2036/** Formatted output of the DetectionOutputLayerCodeType type.
2037 *
2038 * @param[in] detection_code Type to output
2039 *
2040 * @return Formatted string.
2041 */
2042inline std::string to_string(const DetectionOutputLayerCodeType &detection_code)
2043{
2044 std::stringstream str;
2045 str << detection_code;
2046 return str.str();
2047}
2048
2049/** Formatted output of the DetectionOutputLayerInfo type.
2050 *
2051 * @param[out] os Output stream
2052 * @param[in] detection_info Type to output
2053 *
2054 * @return Modified output stream.
2055 */
2056inline ::std::ostream &operator<<(::std::ostream &os, const DetectionOutputLayerInfo &detection_info)
2057{
2058 os << "{Classes=" << detection_info.num_classes() << ","
2059 << "ShareLocation=" << detection_info.share_location() << ","
2060 << "CodeType=" << detection_info.code_type() << ","
2061 << "VarianceEncodedInTarget=" << detection_info.variance_encoded_in_target() << ","
2062 << "KeepTopK=" << detection_info.keep_top_k() << ","
2063 << "NMSThreshold=" << detection_info.nms_threshold() << ","
2064 << "Eta=" << detection_info.eta() << ","
2065 << "BackgroundLabelId=" << detection_info.background_label_id() << ","
2066 << "ConfidenceThreshold=" << detection_info.confidence_threshold() << ","
2067 << "TopK=" << detection_info.top_k() << ","
2068 << "NumLocClasses=" << detection_info.num_loc_classes()
2069 << "}";
2070
2071 return os;
2072}
2073
2074/** Formatted output of the DetectionOutputLayerInfo type.
2075 *
2076 * @param[in] detection_info Type to output
2077 *
2078 * @return Formatted string.
2079 */
2080inline std::string to_string(const DetectionOutputLayerInfo &detection_info)
2081{
2082 std::stringstream str;
2083 str << detection_info;
2084 return str.str();
2085}
Isabella Gottardia7acb3c2019-01-08 13:48:44 +00002086/** Formatted output of the DetectionPostProcessLayerInfo type.
2087 *
2088 * @param[out] os Output stream
2089 * @param[in] detection_info Type to output
2090 *
2091 * @return Modified output stream.
2092 */
2093inline ::std::ostream &operator<<(::std::ostream &os, const DetectionPostProcessLayerInfo &detection_info)
2094{
2095 os << "{MaxDetections=" << detection_info.max_detections() << ","
2096 << "MaxClassesPerDetection=" << detection_info.max_classes_per_detection() << ","
2097 << "NmsScoreThreshold=" << detection_info.nms_score_threshold() << ","
2098 << "NmsIouThreshold=" << detection_info.iou_threshold() << ","
2099 << "NumClasses=" << detection_info.num_classes() << ","
2100 << "ScaleValue_y=" << detection_info.scale_value_y() << ","
2101 << "ScaleValue_x=" << detection_info.scale_value_x() << ","
2102 << "ScaleValue_h=" << detection_info.scale_value_h() << ","
2103 << "ScaleValue_w=" << detection_info.scale_value_w() << ","
2104 << "UseRegularNms=" << detection_info.use_regular_nms() << ","
2105 << "DetectionPerClass=" << detection_info.detection_per_class()
2106 << "}";
2107
2108 return os;
2109}
2110
2111/** Formatted output of the DetectionPostProcessLayerInfo type.
2112 *
2113 * @param[in] detection_info Type to output
2114 *
2115 * @return Formatted string.
2116 */
2117inline std::string to_string(const DetectionPostProcessLayerInfo &detection_info)
2118{
2119 std::stringstream str;
2120 str << detection_info;
2121 return str.str();
2122}
John Richardson8de92612018-02-22 14:09:31 +00002123/** Formatted output of the DetectionWindow type.
2124 *
2125 * @param[in] detection_window Type to output
2126 *
2127 * @return Formatted string.
2128 */
2129inline std::string to_string(const DetectionWindow &detection_window)
2130{
2131 std::stringstream str;
2132 str << detection_window;
2133 return str.str();
2134}
2135
2136/** Formatted output of the Termination type.
2137 *
2138 * @param[out] os Output stream
2139 * @param[in] termination Type to output
2140 *
2141 * @return Modified output stream.
2142 */
2143inline ::std::ostream &operator<<(::std::ostream &os, const Termination &termination)
2144{
2145 switch(termination)
2146 {
2147 case Termination::TERM_CRITERIA_EPSILON:
2148 os << "TERM_CRITERIA_EPSILON";
2149 break;
2150 case Termination::TERM_CRITERIA_ITERATIONS:
2151 os << "TERM_CRITERIA_ITERATIONS";
2152 break;
2153 case Termination::TERM_CRITERIA_BOTH:
2154 os << "TERM_CRITERIA_BOTH";
2155 break;
2156 default:
2157 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2158 }
2159
2160 return os;
2161}
2162
2163/** Formatted output of the Termination type.
2164 *
2165 * @param[in] termination Type to output
2166 *
2167 * @return Formatted string.
2168 */
2169inline std::string to_string(const Termination &termination)
2170{
2171 std::stringstream str;
2172 str << termination;
2173 return str.str();
2174}
2175
Anthony Barbier8914e322018-08-10 15:28:25 +01002176/** Formatted output of the CPUModel type.
2177 *
2178 * @param[out] os Output stream
2179 * @param[in] cpu_model Model to output
2180 *
2181 * @return Modified output stream.
2182 */
2183inline ::std::ostream &operator<<(::std::ostream &os, const CPUModel &cpu_model)
2184{
2185 switch(cpu_model)
2186 {
2187 case CPUModel::GENERIC:
2188 os << "GENERIC";
2189 break;
2190 case CPUModel::GENERIC_FP16:
2191 os << "GENERIC_FP16";
2192 break;
2193 case CPUModel::GENERIC_FP16_DOT:
2194 os << "GENERIC_FP16_DOT";
2195 break;
2196 case CPUModel::A53:
2197 os << "A53";
2198 break;
2199 case CPUModel::A55r0:
2200 os << "A55r0";
2201 break;
2202 case CPUModel::A55r1:
2203 os << "A55r1";
2204 break;
2205 default:
2206 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2207 }
2208
2209 return os;
2210}
2211
2212/** Formatted output of the CPUModel type.
2213 *
2214 * @param[in] cpu_model Model to output
2215 *
2216 * @return Formatted string.
2217 */
2218inline std::string to_string(const CPUModel &cpu_model)
2219{
2220 std::stringstream str;
2221 str << cpu_model;
2222 return str.str();
2223}
Anthony Barbier671a11e2018-07-06 15:11:36 +01002224/** Formatted output of a vector of objects.
2225 *
2226 * @param[out] os Output stream
2227 * @param[in] args Vector of objects to print
2228 *
2229 * @return Modified output stream.
2230 */
2231template <typename T>
2232inline ::std::ostream &operator<<(::std::ostream &os, const std::vector<T> &args)
2233{
2234 os << "[";
2235 bool first = true;
2236 for(auto &arg : args)
2237 {
2238 if(first)
2239 {
2240 first = false;
2241 }
2242 else
2243 {
2244 os << ", ";
2245 }
2246 os << arg;
2247 }
2248 os << "]";
2249 return os;
2250}
2251
Michalis Spyrou6c7c38e2018-08-29 16:28:11 +01002252/** Formatted output of @ref PriorBoxLayerInfo.
2253 *
2254 * @param[out] os Output stream.
2255 * @param[in] info Type to output.
2256 *
2257 * @return Modified output stream.
2258 */
2259inline ::std::ostream &operator<<(::std::ostream &os, const PriorBoxLayerInfo &info)
2260{
2261 os << "Clip:" << info.clip()
2262 << "Flip:" << info.flip()
2263 << "StepX:" << info.steps()[0]
2264 << "StepY:" << info.steps()[1]
2265 << "MinSizes:" << info.min_sizes()
2266 << "MaxSizes:" << info.max_sizes()
2267 << "ImgSizeX:" << info.img_size().x
2268 << "ImgSizeY:" << info.img_size().y
2269 << "Offset:" << info.offset()
2270 << "Variances:" << info.variances();
2271
2272 return os;
2273}
2274
Anthony Barbier671a11e2018-07-06 15:11:36 +01002275/** Formatted output of a vector of objects.
2276 *
2277 * @param[in] args Vector of objects to print
2278 *
2279 * @return String representing args.
2280 */
2281template <typename T>
2282std::string to_string(const std::vector<T> &args)
2283{
2284 std::stringstream str;
2285 str << args;
2286 return str.str();
2287}
2288
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00002289/** Formatted output of the WinogradInfo type. */
2290inline ::std::ostream &operator<<(::std::ostream &os, const WinogradInfo &info)
2291{
2292 os << "{OutputTileSize=" << info.output_tile_size << ","
2293 << "KernelSize=" << info.kernel_size << ","
2294 << "PadStride=" << info.convolution_info << ","
2295 << "OutputDataLayout=" << info.output_data_layout << "}";
2296
2297 return os;
2298}
2299
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00002300inline std::string to_string(const WinogradInfo &type)
2301{
2302 std::stringstream str;
2303 str << type;
2304 return str.str();
2305}
Anthony Barbier671a11e2018-07-06 15:11:36 +01002306
2307/** Fallback method: try to use std::to_string:
2308 *
2309 * @param[in] val Value to convert to string
2310 *
2311 * @return String representing val.
2312 */
2313template <typename T>
2314inline std::string to_string(const T &val)
2315{
2316 return support::cpp11::to_string(val);
2317}
2318
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +01002319/** Convert a CLTunerMode value to a string
2320 *
2321 * @param val CLTunerMode value to be converted
2322 *
2323 * @return String representing the corresponding CLTunerMode.
2324 */
2325inline std::string to_string(const CLTunerMode val)
2326{
2327 switch(val)
2328 {
2329 case CLTunerMode::EXHAUSTIVE:
2330 {
2331 return std::string("Exhaustive");
2332 }
2333 case CLTunerMode::NORMAL:
2334 {
2335 return std::string("Normal");
2336 }
2337 case CLTunerMode::RAPID:
2338 {
2339 return std::string("Rapid");
2340 }
2341 default:
2342 {
2343 ARM_COMPUTE_ERROR("Invalid tuner mode.");
2344 return std::string("UNDEFINED");
2345 }
2346 }
2347}
2348/** [Print CLTunerMode type] **/
2349/** Formatted output of the CLTunerMode type.
2350 *
2351 * @param[out] os Output stream.
2352 * @param[in] val CLTunerMode to output.
2353 *
2354 * @return Modified output stream.
2355 */
2356inline ::std::ostream &operator<<(::std::ostream &os, const CLTunerMode &val)
2357{
2358 os << to_string(val);
2359 return os;
2360}
2361
Anthony Barbier6ff3b192017-09-04 18:44:23 +01002362} // namespace arm_compute
Anthony Barbier4dbc0a92018-08-27 13:39:47 +01002363
2364#endif /* __ARM_COMPUTE_TYPE_PRINTER_H__ */