blob: 372d4e762917270bcc040e310914c163b7e59230 [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001/*
Michele Di Giorgiod9eaf612020-07-08 11:12:57 +01002 * 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"
morgolockaba2f912020-05-05 16:28:19 +010032#include "arm_compute/core/KernelDescriptors.h"
John Richardson25f23682017-11-27 14:35:09 +000033#include "arm_compute/core/Size2D.h"
John Richardsona36eae12017-09-26 16:55:59 +010034#include "arm_compute/core/Strides.h"
Georgios Pinitas3faea252017-10-30 14:13:50 +000035#include "arm_compute/core/TensorInfo.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010036#include "arm_compute/core/Types.h"
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +010037#include "arm_compute/runtime/CL/CLTunerTypes.h"
Matthew Bentham758b5ba2020-03-05 23:37:48 +000038#include "support/StringSupport.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010039
40#include <ostream>
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010041#include <sstream>
42#include <string>
Anthony Barbier6ff3b192017-09-04 18:44:23 +010043
44namespace arm_compute
45{
Anthony Barbierb940fd62018-06-04 14:14:32 +010046/** Formatted output if arg is not null
47 *
48 * @param[in] arg Object to print
49 *
50 * @return String representing arg.
51 */
52template <typename T>
53std::string to_string_if_not_null(T *arg)
54{
55 if(arg == nullptr)
56 {
57 return "nullptr";
58 }
59 else
60 {
61 return to_string(*arg);
62 }
63}
Anthony Barbierb4670212018-05-18 16:55:39 +010064
Alex Gildayc357c472018-03-21 13:54:09 +000065/** Formatted output of the Dimensions type.
66 *
67 * @param[out] os Output stream.
68 * @param[in] dimensions Type to output.
69 *
70 * @return Modified output stream.
71 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +010072template <typename T>
73inline ::std::ostream &operator<<(::std::ostream &os, const Dimensions<T> &dimensions)
74{
Anthony Barbier6ff3b192017-09-04 18:44:23 +010075 if(dimensions.num_dimensions() > 0)
76 {
77 os << dimensions[0];
78
79 for(unsigned int d = 1; d < dimensions.num_dimensions(); ++d)
80 {
Moritz Pflanzerc87fbf82017-07-18 14:02:10 +010081 os << "x" << dimensions[d];
Anthony Barbier6ff3b192017-09-04 18:44:23 +010082 }
83 }
84
Anthony Barbier6ff3b192017-09-04 18:44:23 +010085 return os;
86}
87
Alex Gildayc357c472018-03-21 13:54:09 +000088/** Formatted output of the NonLinearFilterFunction type.
89 *
90 * @param[out] os Output stream.
91 * @param[in] function Type to output.
92 *
93 * @return Modified output stream.
94 */
Isabella Gottardi3b77e9d2017-06-22 11:05:41 +010095inline ::std::ostream &operator<<(::std::ostream &os, const NonLinearFilterFunction &function)
96{
97 switch(function)
98 {
99 case NonLinearFilterFunction::MAX:
100 os << "MAX";
101 break;
102 case NonLinearFilterFunction::MEDIAN:
103 os << "MEDIAN";
104 break;
105 case NonLinearFilterFunction::MIN:
106 os << "MIN";
107 break;
108 default:
109 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
110 }
111
112 return os;
113}
114
Alex Gildayc357c472018-03-21 13:54:09 +0000115/** Formatted output of the NonLinearFilterFunction type.
116 *
117 * @param[in] function Type to output.
118 *
119 * @return Formatted string.
120 */
John Richardson6f4d49f2017-09-07 11:21:10 +0100121inline std::string to_string(const NonLinearFilterFunction &function)
122{
123 std::stringstream str;
124 str << function;
125 return str.str();
126}
127
Alex Gildayc357c472018-03-21 13:54:09 +0000128/** Formatted output of the MatrixPattern type.
129 *
130 * @param[out] os Output stream.
131 * @param[in] pattern Type to output.
132 *
133 * @return Modified output stream.
134 */
Isabella Gottardi3b77e9d2017-06-22 11:05:41 +0100135inline ::std::ostream &operator<<(::std::ostream &os, const MatrixPattern &pattern)
136{
137 switch(pattern)
138 {
139 case MatrixPattern::BOX:
140 os << "BOX";
141 break;
142 case MatrixPattern::CROSS:
143 os << "CROSS";
144 break;
145 case MatrixPattern::DISK:
146 os << "DISK";
147 break;
148 case MatrixPattern::OTHER:
149 os << "OTHER";
150 break;
151 default:
152 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
153 }
154
155 return os;
156}
157
Alex Gildayc357c472018-03-21 13:54:09 +0000158/** Formatted output of the MatrixPattern type.
159 *
160 * @param[in] pattern Type to output.
161 *
162 * @return Formatted string.
163 */
John Richardson6f4d49f2017-09-07 11:21:10 +0100164inline std::string to_string(const MatrixPattern &pattern)
165{
166 std::stringstream str;
167 str << pattern;
168 return str.str();
169}
170
Alex Gildayc357c472018-03-21 13:54:09 +0000171/** Formatted output of the RoundingPolicy type.
172 *
173 * @param[out] os Output stream.
174 * @param[in] rounding_policy Type to output.
175 *
176 * @return Modified output stream.
177 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100178inline ::std::ostream &operator<<(::std::ostream &os, const RoundingPolicy &rounding_policy)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100179{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100180 switch(rounding_policy)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100181 {
Anthony Barbier2a07e182017-08-04 18:20:27 +0100182 case RoundingPolicy::TO_ZERO:
183 os << "TO_ZERO";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100184 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100185 case RoundingPolicy::TO_NEAREST_UP:
186 os << "TO_NEAREST_UP";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100187 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100188 case RoundingPolicy::TO_NEAREST_EVEN:
189 os << "TO_NEAREST_EVEN";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100190 break;
191 default:
192 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
193 }
194
195 return os;
196}
197
Alex Gildayc357c472018-03-21 13:54:09 +0000198/** Formatted output of the WeightsInfo type.
199 *
200 * @param[out] os Output stream.
201 * @param[in] weights_info Type to output.
202 *
203 * @return Modified output stream.
204 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100205inline ::std::ostream &operator<<(::std::ostream &os, const WeightsInfo &weights_info)
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100206{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100207 os << weights_info.are_reshaped() << ";";
208 os << weights_info.num_kernels() << ";" << weights_info.kernel_size().first << "," << weights_info.kernel_size().second;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100209
210 return os;
211}
212
Alex Gildayc357c472018-03-21 13:54:09 +0000213/** Formatted output of the ROIPoolingInfo type.
214 *
215 * @param[out] os Output stream.
216 * @param[in] pool_info Type to output.
217 *
218 * @return Modified output stream.
219 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100220inline ::std::ostream &operator<<(::std::ostream &os, const ROIPoolingLayerInfo &pool_info)
Sanghoon Lee70f82912017-08-24 14:21:24 +0100221{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100222 os << pool_info.pooled_width() << "x" << pool_info.pooled_height() << "~" << pool_info.spatial_scale();
Georgios Pinitasd9769582017-08-03 10:19:40 +0100223 return os;
224}
225
giuros0118870812018-09-13 09:31:40 +0100226/** Formatted output of the ROIPoolingInfo type.
227 *
228 * @param[in] pool_info Type to output.
229 *
230 * @return Formatted string.
231 */
232inline std::string to_string(const ROIPoolingLayerInfo &pool_info)
233{
234 std::stringstream str;
235 str << pool_info;
236 return str.str();
237}
238
morgolockaba2f912020-05-05 16:28:19 +0100239/** Formatted output of the GEMMKernelInfo type.
240 *
241 * @param[out] os Output stream.
242 * @param[in] gemm_info Type to output.
243 *
244 * @return Modified output stream.
245 */
246inline ::std::ostream &operator<<(::std::ostream &os, const GEMMKernelInfo &gemm_info)
247{
248 os << "( m= " << gemm_info.m;
249 os << " n= " << gemm_info.n;
250 os << " k= " << gemm_info.k;
251 os << " depth_output_gemm3d= " << gemm_info.depth_output_gemm3d;
252 os << " reinterpret_input_as_3d= " << gemm_info.reinterpret_input_as_3d;
253 os << " broadcast_bias= " << gemm_info.broadcast_bias;
254 os << " fp_mixed_precision= " << gemm_info.fp_mixed_precision;
255 os << " mult_transpose1xW_width= " << gemm_info.mult_transpose1xW_width;
256 os << " mult_interleave4x4_height= " << gemm_info.mult_interleave4x4_height;
257 os << " a_offset = " << gemm_info.a_offset;
258 os << " b_offset = " << gemm_info.b_offset;
259 os << ")";
260 return os;
261}
262
263/** Formatted output of the GEMMLHSMatrixInfo type.
264 *
265 * @param[out] os Output stream.
266 * @param[in] gemm_info Type to output.
267 *
268 * @return Modified output stream.
269 */
270inline ::std::ostream &operator<<(::std::ostream &os, const GEMMLHSMatrixInfo &gemm_info)
271{
272 os << "( m0= " << (unsigned int)gemm_info.m0 << " k0= " << gemm_info.k0 << " v0= " << gemm_info.v0 << " trans= " << gemm_info.transpose << " inter= " << gemm_info.interleave << "})";
273 return os;
274}
275
276/** Formatted output of the GEMMRHSMatrixInfo type.
277 *
278 * @param[out] os Output stream.
279 * @param[in] gemm_info Type to output.
280 *
281 * @return Modified output stream.
282 */
283inline ::std::ostream &operator<<(::std::ostream &os, const GEMMRHSMatrixInfo &gemm_info)
284{
285 os << "( n0= " << (unsigned int)gemm_info.n0 << " k0= " << gemm_info.k0 << " h0= " << gemm_info.h0 << " trans= " << gemm_info.transpose << " inter= " << gemm_info.interleave << "})";
286 return os;
287}
288
289/** Formatted output of the GEMMRHSMatrixInfo type.
290 *
291 * @param[in] gemm_info GEMMRHSMatrixInfo to output.
292 *
293 * @return Formatted string.
294 */
295inline std::string to_string(const GEMMRHSMatrixInfo &gemm_info)
296{
297 std::stringstream str;
298 str << gemm_info;
299 return str.str();
300}
301
302/** Formatted output of the GEMMLHSMatrixInfo type.
303 *
304 * @param[in] gemm_info GEMMLHSMatrixInfo to output.
305 *
306 * @return Formatted string.
307 */
308inline std::string to_string(const GEMMLHSMatrixInfo &gemm_info)
309{
310 std::stringstream str;
311 str << gemm_info;
312 return str.str();
313}
314
315/** Formatted output of the GEMMKernelInfo type.
316 *
317 * @param[in] gemm_info GEMMKernelInfo Type to output.
318 *
319 * @return Formatted string.
320 */
321inline std::string to_string(const GEMMKernelInfo &gemm_info)
322{
323 std::stringstream str;
324 str << gemm_info;
325 return str.str();
326}
327
giuros01c04a0e82018-10-03 12:44:35 +0100328/** Formatted output of the BoundingBoxTransformInfo type.
329 *
330 * @param[out] os Output stream.
331 * @param[in] bbox_info Type to output.
332 *
333 * @return Modified output stream.
334 */
335inline ::std::ostream &operator<<(::std::ostream &os, const BoundingBoxTransformInfo &bbox_info)
336{
337 auto weights = bbox_info.weights();
338 os << "(" << bbox_info.img_width() << "x" << bbox_info.img_height() << ")~" << bbox_info.scale() << "(weights = {" << weights[0] << ", " << weights[1] << ", " << weights[2] << ", " << weights[3] <<
339 "})";
340 return os;
341}
342
343/** Formatted output of the BoundingBoxTransformInfo type.
344 *
345 * @param[in] bbox_info Type to output.
346 *
347 * @return Formatted string.
348 */
349inline std::string to_string(const BoundingBoxTransformInfo &bbox_info)
350{
351 std::stringstream str;
352 str << bbox_info;
353 return str.str();
354}
355
Manuel Bottini5209be52019-02-13 16:34:56 +0000356/** Formatted output of the ComputeAnchorsInfo type.
357 *
358 * @param[out] os Output stream.
359 * @param[in] anchors_info Type to output.
360 *
361 * @return Modified output stream.
362 */
363inline ::std::ostream &operator<<(::std::ostream &os, const ComputeAnchorsInfo &anchors_info)
364{
365 os << "(" << anchors_info.feat_width() << "x" << anchors_info.feat_height() << ")~" << anchors_info.spatial_scale();
366 return os;
367}
368
369/** Formatted output of the ComputeAnchorsInfo type.
370 *
371 * @param[in] anchors_info Type to output.
372 *
373 * @return Formatted string.
374 */
375inline std::string to_string(const ComputeAnchorsInfo &anchors_info)
376{
377 std::stringstream str;
378 str << anchors_info;
379 return str.str();
380}
381
382/** Formatted output of the GenerateProposalsInfo type.
383 *
384 * @param[out] os Output stream.
385 * @param[in] proposals_info Type to output.
386 *
387 * @return Modified output stream.
388 */
389inline ::std::ostream &operator<<(::std::ostream &os, const GenerateProposalsInfo &proposals_info)
390{
391 os << "(" << proposals_info.im_width() << "x" << proposals_info.im_height() << ")~" << proposals_info.im_scale();
392 return os;
393}
394
395/** Formatted output of the GenerateProposalsInfo type.
396 *
397 * @param[in] proposals_info Type to output.
398 *
399 * @return Formatted string.
400 */
401inline std::string to_string(const GenerateProposalsInfo &proposals_info)
402{
403 std::stringstream str;
404 str << proposals_info;
405 return str.str();
406}
407
Alex Gildayc357c472018-03-21 13:54:09 +0000408/** Formatted output of the QuantizationInfo type.
409 *
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100410 * @param[out] os Output stream.
411 * @param[in] qinfo Type to output.
Alex Gildayc357c472018-03-21 13:54:09 +0000412 *
413 * @return Modified output stream.
414 */
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100415inline ::std::ostream &operator<<(::std::ostream &os, const QuantizationInfo &qinfo)
Chunosovd621bca2017-11-03 17:33:15 +0700416{
Georgios Pinitas3d13af82019-06-04 13:04:16 +0100417 const UniformQuantizationInfo uqinfo = qinfo.uniform();
418 os << "Scale:" << uqinfo.scale << "~";
419 os << "Offset:" << uqinfo.offset;
Chunosovd621bca2017-11-03 17:33:15 +0700420 return os;
421}
422
Alex Gildayc357c472018-03-21 13:54:09 +0000423/** Formatted output of the QuantizationInfo type.
424 *
425 * @param[in] quantization_info Type to output.
426 *
427 * @return Formatted string.
428 */
Chunosovd621bca2017-11-03 17:33:15 +0700429inline std::string to_string(const QuantizationInfo &quantization_info)
430{
431 std::stringstream str;
432 str << quantization_info;
433 return str.str();
434}
435
Alex Gildayc357c472018-03-21 13:54:09 +0000436/** Formatted output of the activation function type.
437 *
438 * @param[out] os Output stream.
439 * @param[in] act_function 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 ActivationLayerInfo::ActivationFunction &act_function)
444{
445 switch(act_function)
446 {
447 case ActivationLayerInfo::ActivationFunction::ABS:
448 os << "ABS";
449 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100450 case ActivationLayerInfo::ActivationFunction::LINEAR:
451 os << "LINEAR";
452 break;
453 case ActivationLayerInfo::ActivationFunction::LOGISTIC:
454 os << "LOGISTIC";
455 break;
456 case ActivationLayerInfo::ActivationFunction::RELU:
457 os << "RELU";
458 break;
Georgios Pinitas579c0492017-07-12 16:12:12 +0100459 case ActivationLayerInfo::ActivationFunction::BOUNDED_RELU:
460 os << "BOUNDED_RELU";
461 break;
462 case ActivationLayerInfo::ActivationFunction::LEAKY_RELU:
463 os << "LEAKY_RELU";
464 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100465 case ActivationLayerInfo::ActivationFunction::SOFT_RELU:
466 os << "SOFT_RELU";
467 break;
468 case ActivationLayerInfo::ActivationFunction::SQRT:
469 os << "SQRT";
470 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100471 case ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU:
472 os << "LU_BOUNDED_RELU";
Kevin Petitd9f80712017-12-06 12:18:48 +0000473 break;
Georgios Pinitasfb0fdcd2019-08-22 17:10:04 +0100474 case ActivationLayerInfo::ActivationFunction::ELU:
475 os << "ELU";
476 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100477 case ActivationLayerInfo::ActivationFunction::SQUARE:
478 os << "SQUARE";
479 break;
480 case ActivationLayerInfo::ActivationFunction::TANH:
481 os << "TANH";
482 break;
Usama Arif6a98a6e2019-05-10 17:07:27 +0100483 case ActivationLayerInfo::ActivationFunction::IDENTITY:
484 os << "IDENTITY";
485 break;
morgolock07df3d42020-02-27 11:46:28 +0000486 case ActivationLayerInfo::ActivationFunction::HARD_SWISH:
487 os << "HARD_SWISH";
488 break;
489
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100490 default:
491 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
492 }
493
494 return os;
495}
496
Alex Gildayc357c472018-03-21 13:54:09 +0000497/** Formatted output of the activation function info type.
498 *
499 * @param[in] info Type to output.
500 *
501 * @return Formatted string.
502 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100503inline std::string to_string(const arm_compute::ActivationLayerInfo &info)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100504{
505 std::stringstream str;
Isabella Gottardi3f217ec2018-02-12 14:59:19 +0000506 if(info.enabled())
507 {
508 str << info.activation();
509 }
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100510 return str.str();
511}
512
Alex Gildayc357c472018-03-21 13:54:09 +0000513/** Formatted output of the activation function type.
514 *
515 * @param[in] function Type to output.
516 *
517 * @return Formatted string.
518 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100519inline std::string to_string(const arm_compute::ActivationLayerInfo::ActivationFunction &function)
520{
521 std::stringstream str;
522 str << function;
523 return str.str();
524}
525
Alex Gildayc357c472018-03-21 13:54:09 +0000526/** Formatted output of the NormType type.
527 *
528 * @param[out] os Output stream.
529 * @param[in] norm_type Type to output.
530 *
531 * @return Modified output stream.
532 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100533inline ::std::ostream &operator<<(::std::ostream &os, const NormType &norm_type)
534{
535 switch(norm_type)
536 {
537 case NormType::CROSS_MAP:
538 os << "CROSS_MAP";
539 break;
540 case NormType::IN_MAP_1D:
541 os << "IN_MAP_1D";
542 break;
543 case NormType::IN_MAP_2D:
544 os << "IN_MAP_2D";
545 break;
546 default:
547 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
548 }
549
550 return os;
551}
552
Alex Gildayc357c472018-03-21 13:54:09 +0000553/** Formatted output of @ref NormalizationLayerInfo.
554 *
555 * @param[in] info Type to output.
556 *
557 * @return Formatted string.
558 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100559inline std::string to_string(const arm_compute::NormalizationLayerInfo &info)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100560{
561 std::stringstream str;
Michalis Spyroud466c2d2018-01-30 10:54:39 +0000562 str << info.type() << ":NormSize=" << info.norm_size();
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100563 return str.str();
564}
565
Alex Gildayc357c472018-03-21 13:54:09 +0000566/** Formatted output of @ref NormalizationLayerInfo.
567 *
568 * @param[out] os Output stream.
569 * @param[in] info Type to output.
570 *
571 * @return Modified output stream.
572 */
Georgios Pinitas6f669f02017-09-26 12:32:57 +0100573inline ::std::ostream &operator<<(::std::ostream &os, const NormalizationLayerInfo &info)
574{
Michalis Spyroud466c2d2018-01-30 10:54:39 +0000575 os << info.type() << ":NormSize=" << info.norm_size();
Georgios Pinitas6f669f02017-09-26 12:32:57 +0100576 return os;
577}
578
Alex Gildayc357c472018-03-21 13:54:09 +0000579/** Formatted output of the PoolingType type.
580 *
581 * @param[out] os Output stream.
582 * @param[in] pool_type Type to output.
583 *
584 * @return Modified output stream.
585 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100586inline ::std::ostream &operator<<(::std::ostream &os, const PoolingType &pool_type)
587{
588 switch(pool_type)
589 {
590 case PoolingType::AVG:
591 os << "AVG";
592 break;
593 case PoolingType::MAX:
594 os << "MAX";
595 break;
Georgios Pinitascdf51452017-08-31 14:21:36 +0100596 case PoolingType::L2:
597 os << "L2";
598 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100599 default:
600 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
601 }
602
603 return os;
604}
605
Alex Gildayc357c472018-03-21 13:54:09 +0000606/** Formatted output of @ref PoolingLayerInfo.
607 *
608 * @param[out] os Output stream.
609 * @param[in] info Type to output.
610 *
611 * @return Modified output stream.
612 */
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100613inline ::std::ostream &operator<<(::std::ostream &os, const PoolingLayerInfo &info)
614{
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +0000615 os << info.pool_type;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100616
617 return os;
618}
619
Alex Gildayc357c472018-03-21 13:54:09 +0000620/** Formatted output of @ref RoundingPolicy.
621 *
622 * @param[in] rounding_policy Type to output.
623 *
624 * @return Formatted string.
625 */
John Richardsondd715f22017-09-18 16:10:48 +0100626inline std::string to_string(const RoundingPolicy &rounding_policy)
627{
628 std::stringstream str;
629 str << rounding_policy;
630 return str.str();
631}
632
Vidhya Sudhan Loganathand646ae12018-11-19 15:18:20 +0000633/** [Print DataLayout type] **/
Alex Gildayc357c472018-03-21 13:54:09 +0000634/** Formatted output of the DataLayout type.
635 *
636 * @param[out] os Output stream.
637 * @param[in] data_layout Type to output.
638 *
639 * @return Modified output stream.
640 */
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000641inline ::std::ostream &operator<<(::std::ostream &os, const DataLayout &data_layout)
642{
643 switch(data_layout)
644 {
645 case DataLayout::UNKNOWN:
646 os << "UNKNOWN";
647 break;
648 case DataLayout::NHWC:
649 os << "NHWC";
650 break;
651 case DataLayout::NCHW:
652 os << "NCHW";
653 break;
654 default:
655 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
656 }
657
658 return os;
659}
660
Alex Gildayc357c472018-03-21 13:54:09 +0000661/** Formatted output of the DataLayout type.
662 *
663 * @param[in] data_layout Type to output.
664 *
665 * @return Formatted string.
666 */
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000667inline std::string to_string(const arm_compute::DataLayout &data_layout)
668{
669 std::stringstream str;
670 str << data_layout;
671 return str.str();
672}
Vidhya Sudhan Loganathand646ae12018-11-19 15:18:20 +0000673/** [Print DataLayout type] **/
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000674
Georgios Pinitase2220552018-07-20 13:23:44 +0100675/** Formatted output of the DataLayoutDimension type.
676 *
677 * @param[out] os Output stream.
678 * @param[in] data_layout_dim Data layout dimension to print.
679 *
680 * @return Modified output stream.
681 */
682inline ::std::ostream &operator<<(::std::ostream &os, const DataLayoutDimension &data_layout_dim)
683{
684 switch(data_layout_dim)
685 {
686 case DataLayoutDimension::WIDTH:
687 os << "WIDTH";
688 break;
689 case DataLayoutDimension::HEIGHT:
690 os << "HEIGHT";
691 break;
692 case DataLayoutDimension::CHANNEL:
693 os << "CHANNEL";
694 break;
695 case DataLayoutDimension::BATCHES:
696 os << "BATCHES";
697 break;
698 default:
699 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
700 }
701 return os;
702}
703
Alex Gildayc357c472018-03-21 13:54:09 +0000704/** Formatted output of the DataType type.
705 *
706 * @param[out] os Output stream.
707 * @param[in] data_type Type to output.
708 *
709 * @return Modified output stream.
710 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100711inline ::std::ostream &operator<<(::std::ostream &os, const DataType &data_type)
712{
713 switch(data_type)
714 {
715 case DataType::UNKNOWN:
716 os << "UNKNOWN";
717 break;
718 case DataType::U8:
719 os << "U8";
720 break;
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100721 case DataType::QSYMM8:
722 os << "QSYMM8";
723 break;
Chunosovd621bca2017-11-03 17:33:15 +0700724 case DataType::QASYMM8:
725 os << "QASYMM8";
726 break;
Georgios Pinitas448a81f2019-11-21 14:10:25 +0000727 case DataType::QASYMM8_SIGNED:
728 os << "QASYMM8_SIGNED";
729 break;
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100730 case DataType::QSYMM8_PER_CHANNEL:
731 os << "QSYMM8_PER_CHANNEL";
732 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100733 case DataType::S8:
734 os << "S8";
735 break;
736 case DataType::U16:
737 os << "U16";
738 break;
739 case DataType::S16:
740 os << "S16";
741 break;
Manuel Bottini3689fcd2019-06-14 17:18:12 +0100742 case DataType::QSYMM16:
743 os << "QSYMM16";
744 break;
Michele Di Giorgio35ea9a72019-08-23 12:02:06 +0100745 case DataType::QASYMM16:
746 os << "QASYMM16";
747 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100748 case DataType::U32:
749 os << "U32";
750 break;
751 case DataType::S32:
752 os << "S32";
753 break;
754 case DataType::U64:
755 os << "U64";
756 break;
757 case DataType::S64:
758 os << "S64";
759 break;
Georgios Pinitase8291ac2020-02-26 09:58:13 +0000760 case DataType::BFLOAT16:
761 os << "BFLOAT16";
762 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100763 case DataType::F16:
764 os << "F16";
765 break;
766 case DataType::F32:
767 os << "F32";
768 break;
769 case DataType::F64:
770 os << "F64";
771 break;
772 case DataType::SIZET:
773 os << "SIZET";
774 break;
775 default:
776 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
777 }
778
779 return os;
780}
781
Alex Gildayc357c472018-03-21 13:54:09 +0000782/** Formatted output of the DataType type.
783 *
784 * @param[in] data_type Type to output.
785 *
786 * @return Formatted string.
787 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100788inline std::string to_string(const arm_compute::DataType &data_type)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100789{
790 std::stringstream str;
791 str << data_type;
792 return str.str();
793}
794
Alex Gildayc357c472018-03-21 13:54:09 +0000795/** Formatted output of the Format type.
796 *
797 * @param[out] os Output stream.
798 * @param[in] format Type to output.
799 *
800 * @return Modified output stream.
801 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100802inline ::std::ostream &operator<<(::std::ostream &os, const Format &format)
803{
804 switch(format)
805 {
806 case Format::UNKNOWN:
807 os << "UNKNOWN";
808 break;
809 case Format::U8:
810 os << "U8";
811 break;
812 case Format::S16:
813 os << "S16";
814 break;
815 case Format::U16:
816 os << "U16";
817 break;
818 case Format::S32:
819 os << "S32";
820 break;
821 case Format::U32:
822 os << "U32";
823 break;
824 case Format::F16:
825 os << "F16";
826 break;
827 case Format::F32:
828 os << "F32";
829 break;
830 case Format::UV88:
831 os << "UV88";
832 break;
833 case Format::RGB888:
834 os << "RGB888";
835 break;
836 case Format::RGBA8888:
837 os << "RGBA8888";
838 break;
839 case Format::YUV444:
840 os << "YUV444";
841 break;
842 case Format::YUYV422:
843 os << "YUYV422";
844 break;
845 case Format::NV12:
846 os << "NV12";
847 break;
848 case Format::NV21:
849 os << "NV21";
850 break;
851 case Format::IYUV:
852 os << "IYUV";
853 break;
854 case Format::UYVY422:
855 os << "UYVY422";
856 break;
857 default:
858 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
859 }
860
861 return os;
862}
863
Alex Gildayc357c472018-03-21 13:54:09 +0000864/** Formatted output of the Format type.
865 *
866 * @param[in] format Type to output.
867 *
868 * @return Formatted string.
869 */
Moritz Pflanzer7655a672017-09-23 11:57:33 +0100870inline std::string to_string(const Format &format)
871{
872 std::stringstream str;
873 str << format;
874 return str.str();
875}
876
Alex Gildayc357c472018-03-21 13:54:09 +0000877/** Formatted output of the Channel type.
878 *
879 * @param[out] os Output stream.
880 * @param[in] channel Type to output.
881 *
882 * @return Modified output stream.
883 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100884inline ::std::ostream &operator<<(::std::ostream &os, const Channel &channel)
885{
886 switch(channel)
887 {
888 case Channel::UNKNOWN:
889 os << "UNKNOWN";
890 break;
891 case Channel::C0:
892 os << "C0";
893 break;
894 case Channel::C1:
895 os << "C1";
896 break;
897 case Channel::C2:
898 os << "C2";
899 break;
900 case Channel::C3:
901 os << "C3";
902 break;
903 case Channel::R:
904 os << "R";
905 break;
906 case Channel::G:
907 os << "G";
908 break;
909 case Channel::B:
910 os << "B";
911 break;
912 case Channel::A:
913 os << "A";
914 break;
915 case Channel::Y:
916 os << "Y";
917 break;
918 case Channel::U:
919 os << "U";
920 break;
921 case Channel::V:
922 os << "V";
923 break;
924 default:
925 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
926 }
927
928 return os;
929}
930
Alex Gildayc357c472018-03-21 13:54:09 +0000931/** Formatted output of the Channel type.
932 *
933 * @param[in] channel Type to output.
934 *
935 * @return Formatted string.
936 */
Ioan-Cristian Szabo9414f642017-10-27 17:35:40 +0100937inline std::string to_string(const Channel &channel)
938{
939 std::stringstream str;
940 str << channel;
941 return str.str();
942}
943
Alex Gildayc357c472018-03-21 13:54:09 +0000944/** Formatted output of the BorderMode type.
945 *
946 * @param[out] os Output stream.
947 * @param[in] mode Type to output.
948 *
949 * @return Modified output stream.
950 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100951inline ::std::ostream &operator<<(::std::ostream &os, const BorderMode &mode)
952{
953 switch(mode)
954 {
955 case BorderMode::UNDEFINED:
956 os << "UNDEFINED";
957 break;
958 case BorderMode::CONSTANT:
959 os << "CONSTANT";
960 break;
961 case BorderMode::REPLICATE:
962 os << "REPLICATE";
963 break;
964 default:
965 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
966 }
967
968 return os;
969}
970
Alex Gildayc357c472018-03-21 13:54:09 +0000971/** Formatted output of the BorderSize type.
972 *
973 * @param[out] os Output stream.
974 * @param[in] border Type to output.
975 *
976 * @return Modified output stream.
977 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100978inline ::std::ostream &operator<<(::std::ostream &os, const BorderSize &border)
979{
Moritz Pflanzerc87fbf82017-07-18 14:02:10 +0100980 os << border.top << ","
981 << border.right << ","
982 << border.bottom << ","
983 << border.left;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100984
985 return os;
986}
Anthony Barbier2a07e182017-08-04 18:20:27 +0100987
Giuseppe Rossinid7647d42018-07-17 18:13:13 +0100988/** Formatted output of the PaddingList type.
989 *
990 * @param[out] os Output stream.
991 * @param[in] padding Type to output.
992 *
993 * @return Modified output stream.
994 */
995inline ::std::ostream &operator<<(::std::ostream &os, const PaddingList &padding)
996{
997 os << "{";
998 for(auto const &p : padding)
999 {
1000 os << "{" << p.first << "," << p.second << "}";
1001 }
1002 os << "}";
1003 return os;
1004}
1005
giuros013175fcf2018-11-21 09:59:17 +00001006/** Formatted output of the Multiples type.
1007 *
1008 * @param[out] os Output stream.
1009 * @param[in] multiples Type to output.
1010 *
1011 * @return Modified output stream.
1012 */
1013inline ::std::ostream &operator<<(::std::ostream &os, const Multiples &multiples)
1014{
1015 os << "(";
1016 for(size_t i = 0; i < multiples.size() - 1; i++)
1017 {
1018 os << multiples[i] << ", ";
1019 }
1020 os << multiples.back() << ")";
1021 return os;
1022}
1023
Alex Gildayc357c472018-03-21 13:54:09 +00001024/** Formatted output of the InterpolationPolicy type.
1025 *
1026 * @param[out] os Output stream.
1027 * @param[in] policy Type to output.
1028 *
1029 * @return Modified output stream.
1030 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001031inline ::std::ostream &operator<<(::std::ostream &os, const InterpolationPolicy &policy)
1032{
1033 switch(policy)
1034 {
1035 case InterpolationPolicy::NEAREST_NEIGHBOR:
1036 os << "NEAREST_NEIGHBOR";
1037 break;
1038 case InterpolationPolicy::BILINEAR:
1039 os << "BILINEAR";
1040 break;
1041 case InterpolationPolicy::AREA:
1042 os << "AREA";
1043 break;
1044 default:
1045 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1046 }
1047
1048 return os;
1049}
1050
Alex Gildayc357c472018-03-21 13:54:09 +00001051/** Formatted output of the SamplingPolicy type.
1052 *
1053 * @param[out] os Output stream.
1054 * @param[in] policy Type to output.
1055 *
1056 * @return Modified output stream.
1057 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +07001058inline ::std::ostream &operator<<(::std::ostream &os, const SamplingPolicy &policy)
1059{
1060 switch(policy)
1061 {
1062 case SamplingPolicy::CENTER:
1063 os << "CENTER";
1064 break;
1065 case SamplingPolicy::TOP_LEFT:
1066 os << "TOP_LEFT";
1067 break;
1068 default:
1069 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1070 }
1071
1072 return os;
1073}
1074
Alex Gildayc357c472018-03-21 13:54:09 +00001075/** Formatted output of the TensorInfo type.
1076 *
Anthony Barbier366628a2018-08-01 13:55:03 +01001077 * @param[out] os Output stream.
1078 * @param[in] info Type to output.
1079 *
1080 * @return Modified output stream.
1081 */
1082inline ::std::ostream &operator<<(::std::ostream &os, const TensorInfo &info)
1083{
1084 os << "{Shape=" << info.tensor_shape() << ","
1085 << "Type=" << info.data_type() << ","
1086 << "Channels=" << info.num_channels() << "}";
1087 return os;
1088}
1089/** Formatted output of the TensorInfo type.
1090 *
Alex Gildayc357c472018-03-21 13:54:09 +00001091 * @param[in] info Type to output.
1092 *
1093 * @return Formatted string.
1094 */
Georgios Pinitas3faea252017-10-30 14:13:50 +00001095inline std::string to_string(const TensorInfo &info)
1096{
1097 std::stringstream str;
Anthony Barbier366628a2018-08-01 13:55:03 +01001098 str << info;
Georgios Pinitas3faea252017-10-30 14:13:50 +00001099 return str.str();
1100}
1101
Alex Gildayc357c472018-03-21 13:54:09 +00001102/** Formatted output of the Dimensions type.
1103 *
1104 * @param[in] dimensions Type to output.
1105 *
1106 * @return Formatted string.
1107 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001108template <typename T>
1109inline std::string to_string(const Dimensions<T> &dimensions)
1110{
1111 std::stringstream str;
1112 str << dimensions;
1113 return str.str();
1114}
1115
Alex Gildayc357c472018-03-21 13:54:09 +00001116/** Formatted output of the Strides type.
1117 *
1118 * @param[in] stride Type to output.
1119 *
1120 * @return Formatted string.
1121 */
John Richardsona36eae12017-09-26 16:55:59 +01001122inline std::string to_string(const Strides &stride)
1123{
1124 std::stringstream str;
1125 str << stride;
1126 return str.str();
1127}
1128
Alex Gildayc357c472018-03-21 13:54:09 +00001129/** Formatted output of the TensorShape type.
1130 *
1131 * @param[in] shape Type to output.
1132 *
1133 * @return Formatted string.
1134 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001135inline std::string to_string(const TensorShape &shape)
1136{
1137 std::stringstream str;
1138 str << shape;
1139 return str.str();
1140}
1141
Alex Gildayc357c472018-03-21 13:54:09 +00001142/** Formatted output of the Coordinates type.
1143 *
1144 * @param[in] coord Type to output.
1145 *
1146 * @return Formatted string.
1147 */
Abe Mbise925ca0f2017-10-02 19:16:33 +01001148inline std::string to_string(const Coordinates &coord)
1149{
1150 std::stringstream str;
1151 str << coord;
1152 return str.str();
1153}
1154
Anthony Barbierb940fd62018-06-04 14:14:32 +01001155/** Formatted output of the GEMMReshapeInfo type.
1156 *
1157 * @param[out] os Output stream.
1158 * @param[in] info Type to output.
1159 *
1160 * @return Modified output stream.
1161 */
1162inline ::std::ostream &operator<<(::std::ostream &os, const GEMMReshapeInfo &info)
1163{
1164 os << "{m=" << info.m() << ",";
1165 os << "n=" << info.n() << ",";
1166 os << "k=" << info.k() << ",";
1167 os << "mult_transpose1xW_width=" << info.mult_transpose1xW_width() << ",";
1168 os << "mult_interleave4x4_height=" << info.mult_interleave4x4_height();
1169 os << "}";
1170
1171 return os;
1172}
1173
1174/** Formatted output of the GEMMInfo type.
1175 *
1176 * @param[out] os Output stream.
1177 * @param[in] info Type to output.
1178 *
1179 * @return Modified output stream.
1180 */
1181inline ::std::ostream &operator<<(::std::ostream &os, const GEMMInfo &info)
1182{
1183 os << "{is_a_reshaped=" << info.is_a_reshaped() << ",";
1184 os << "is_b_reshaped=" << info.is_b_reshaped() << ",";
1185 os << "reshape_b_only_on_first_run=" << info.reshape_b_only_on_first_run() << ",";
Anthony Barbierb4670212018-05-18 16:55:39 +01001186 os << "depth_output_gemm3d=" << info.depth_output_gemm3d() << ",";
1187 os << "reinterpret_input_as_3d=" << info.reinterpret_input_as_3d() << ",";
1188 os << "retain_internal_weights=" << info.retain_internal_weights() << ",";
1189 os << "fp_mixed_precision=" << info.fp_mixed_precision() << ",";
1190 os << "broadcast_bias=" << info.broadcast_bias() << ",";
1191 os << "pretranpose_B=" << info.pretranpose_B() << ",";
Anthony Barbierb940fd62018-06-04 14:14:32 +01001192
1193 return os;
1194}
1195
1196/** Formatted output of the Window::Dimension type.
1197 *
1198 * @param[out] os Output stream.
1199 * @param[in] dim Type to output.
1200 *
1201 * @return Modified output stream.
1202 */
1203inline ::std::ostream &operator<<(::std::ostream &os, const Window::Dimension &dim)
1204{
1205 os << "{start=" << dim.start() << ", end=" << dim.end() << ", step=" << dim.step() << "}";
1206
1207 return os;
1208}
1209/** Formatted output of the Window type.
1210 *
1211 * @param[out] os Output stream.
1212 * @param[in] win Type to output.
1213 *
1214 * @return Modified output stream.
1215 */
1216inline ::std::ostream &operator<<(::std::ostream &os, const Window &win)
1217{
1218 os << "{";
1219 for(unsigned int i = 0; i < Coordinates::num_max_dimensions; i++)
1220 {
1221 if(i > 0)
1222 {
1223 os << ", ";
1224 }
1225 os << win[i];
1226 }
1227 os << "}";
1228
1229 return os;
1230}
1231
1232/** Formatted output of the WeightsInfo type.
1233 *
1234 * @param[in] info Type to output.
1235 *
1236 * @return Formatted string.
1237 */
1238inline std::string to_string(const WeightsInfo &info)
1239{
1240 std::stringstream str;
1241 str << info;
1242 return str.str();
1243}
1244
1245/** Formatted output of the GEMMReshapeInfo type.
1246 *
1247 * @param[in] info Type to output.
1248 *
1249 * @return Formatted string.
1250 */
1251inline std::string to_string(const GEMMReshapeInfo &info)
1252{
1253 std::stringstream str;
1254 str << info;
1255 return str.str();
1256}
1257
1258/** Formatted output of the GEMMInfo type.
1259 *
1260 * @param[in] info Type to output.
1261 *
1262 * @return Formatted string.
1263 */
1264inline std::string to_string(const GEMMInfo &info)
1265{
1266 std::stringstream str;
1267 str << info;
1268 return str.str();
1269}
1270
1271/** Formatted output of the Window::Dimension type.
1272 *
1273 * @param[in] dim Type to output.
1274 *
1275 * @return Formatted string.
1276 */
1277inline std::string to_string(const Window::Dimension &dim)
1278{
1279 std::stringstream str;
1280 str << dim;
1281 return str.str();
1282}
1283/** Formatted output of the Window type.
1284 *
1285 * @param[in] win Type to output.
1286 *
1287 * @return Formatted string.
1288 */
1289inline std::string to_string(const Window &win)
1290{
1291 std::stringstream str;
1292 str << win;
1293 return str.str();
1294}
1295
Alex Gildayc357c472018-03-21 13:54:09 +00001296/** Formatted output of the Rectangle type.
1297 *
1298 * @param[out] os Output stream.
1299 * @param[in] rect Type to output.
1300 *
1301 * @return Modified output stream.
1302 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001303inline ::std::ostream &operator<<(::std::ostream &os, const Rectangle &rect)
1304{
1305 os << rect.width << "x" << rect.height;
1306 os << "+" << rect.x << "+" << rect.y;
1307
1308 return os;
1309}
1310
Usama Arif8cf8c112019-03-14 15:36:54 +00001311/** Formatted output of the PaddingMode type.
1312 *
1313 * @param[out] os Output stream.
1314 * @param[in] mode Type to output.
1315 *
1316 * @return Modified output stream.
1317 */
1318inline ::std::ostream &operator<<(::std::ostream &os, const PaddingMode &mode)
1319{
1320 switch(mode)
1321 {
1322 case PaddingMode::CONSTANT:
1323 os << "CONSTANT";
1324 break;
1325 case PaddingMode::REFLECT:
1326 os << "REFLECT";
1327 break;
1328 case PaddingMode::SYMMETRIC:
1329 os << "SYMMETRIC";
1330 break;
1331 default:
1332 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1333 }
1334
1335 return os;
1336}
1337
1338/** Formatted output of the PaddingMode type.
1339 *
1340 * @param[in] mode Type to output.
1341 *
1342 * @return Formatted string.
1343 */
1344inline std::string to_string(const PaddingMode &mode)
1345{
1346 std::stringstream str;
1347 str << mode;
1348 return str.str();
1349}
1350
Alex Gildayc357c472018-03-21 13:54:09 +00001351/** Formatted output of the PadStrideInfo type.
1352 *
1353 * @param[out] os Output stream.
1354 * @param[in] pad_stride_info Type to output.
1355 *
1356 * @return Modified output stream.
1357 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001358inline ::std::ostream &operator<<(::std::ostream &os, const PadStrideInfo &pad_stride_info)
1359{
1360 os << pad_stride_info.stride().first << "," << pad_stride_info.stride().second;
1361 os << ";";
Jaroslaw Rzepeckia1ed41f2017-10-13 11:13:58 +01001362 os << pad_stride_info.pad_left() << "," << pad_stride_info.pad_right() << ","
1363 << pad_stride_info.pad_top() << "," << pad_stride_info.pad_bottom();
Anthony Barbier2a07e182017-08-04 18:20:27 +01001364
1365 return os;
1366}
1367
Alex Gildayc357c472018-03-21 13:54:09 +00001368/** Formatted output of the PadStrideInfo type.
1369 *
1370 * @param[in] pad_stride_info Type to output.
1371 *
1372 * @return Formatted string.
1373 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001374inline std::string to_string(const PadStrideInfo &pad_stride_info)
1375{
1376 std::stringstream str;
1377 str << pad_stride_info;
1378 return str.str();
1379}
1380
Alex Gildayc357c472018-03-21 13:54:09 +00001381/** Formatted output of the BorderMode type.
1382 *
1383 * @param[in] mode Type to output.
1384 *
1385 * @return Formatted string.
1386 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001387inline std::string to_string(const BorderMode &mode)
1388{
1389 std::stringstream str;
1390 str << mode;
1391 return str.str();
1392}
1393
Alex Gildayc357c472018-03-21 13:54:09 +00001394/** Formatted output of the BorderSize type.
1395 *
1396 * @param[in] border Type to output.
1397 *
1398 * @return Formatted string.
1399 */
John Richardsonb482ce12017-09-18 12:44:01 +01001400inline std::string to_string(const BorderSize &border)
1401{
1402 std::stringstream str;
1403 str << border;
1404 return str.str();
1405}
1406
Giuseppe Rossinid7647d42018-07-17 18:13:13 +01001407/** Formatted output of the PaddingList type.
1408 *
1409 * @param[in] padding Type to output.
1410 *
1411 * @return Formatted string.
1412 */
1413inline std::string to_string(const PaddingList &padding)
1414{
1415 std::stringstream str;
1416 str << padding;
1417 return str.str();
1418}
1419
giuros013175fcf2018-11-21 09:59:17 +00001420/** Formatted output of the Multiples type.
1421 *
1422 * @param[in] multiples Type to output.
1423 *
1424 * @return Formatted string.
1425 */
1426inline std::string to_string(const Multiples &multiples)
1427{
1428 std::stringstream str;
1429 str << multiples;
1430 return str.str();
1431}
1432
Alex Gildayc357c472018-03-21 13:54:09 +00001433/** Formatted output of the InterpolationPolicy type.
1434 *
1435 * @param[in] policy Type to output.
1436 *
1437 * @return Formatted string.
1438 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001439inline std::string to_string(const InterpolationPolicy &policy)
1440{
1441 std::stringstream str;
1442 str << policy;
1443 return str.str();
1444}
1445
Alex Gildayc357c472018-03-21 13:54:09 +00001446/** Formatted output of the SamplingPolicy type.
1447 *
1448 * @param[in] policy Type to output.
1449 *
1450 * @return Formatted string.
1451 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +07001452inline std::string to_string(const SamplingPolicy &policy)
1453{
1454 std::stringstream str;
1455 str << policy;
1456 return str.str();
1457}
1458
Alex Gildayc357c472018-03-21 13:54:09 +00001459/** Formatted output of the ConvertPolicy type.
1460 *
1461 * @param[out] os Output stream.
1462 * @param[in] policy Type to output.
1463 *
1464 * @return Modified output stream.
1465 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001466inline ::std::ostream &operator<<(::std::ostream &os, const ConvertPolicy &policy)
1467{
1468 switch(policy)
1469 {
1470 case ConvertPolicy::WRAP:
1471 os << "WRAP";
1472 break;
1473 case ConvertPolicy::SATURATE:
1474 os << "SATURATE";
1475 break;
1476 default:
1477 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1478 }
1479
1480 return os;
1481}
1482
1483inline std::string to_string(const ConvertPolicy &policy)
1484{
1485 std::stringstream str;
1486 str << policy;
1487 return str.str();
1488}
1489
giuros01164a2722018-11-20 18:34:46 +00001490/** Formatted output of the ArithmeticOperation type.
1491 *
1492 * @param[out] os Output stream.
1493 * @param[in] op Operation to output.
1494 *
1495 * @return Modified output stream.
1496 */
1497inline ::std::ostream &operator<<(::std::ostream &os, const ArithmeticOperation &op)
1498{
1499 switch(op)
1500 {
1501 case ArithmeticOperation::ADD:
1502 os << "ADD";
1503 break;
1504 case ArithmeticOperation::SUB:
1505 os << "SUB";
1506 break;
1507 case ArithmeticOperation::DIV:
1508 os << "DIV";
1509 break;
1510 case ArithmeticOperation::MAX:
1511 os << "MAX";
1512 break;
1513 case ArithmeticOperation::MIN:
1514 os << "MIN";
1515 break;
1516 case ArithmeticOperation::SQUARED_DIFF:
1517 os << "SQUARED_DIFF";
1518 break;
Usama Arif52c54f62019-05-14 10:22:36 +01001519 case ArithmeticOperation::POWER:
1520 os << "POWER";
1521 break;
giuros01164a2722018-11-20 18:34:46 +00001522 default:
1523 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1524 }
1525
1526 return os;
1527}
1528
1529/** Formatted output of the Arithmetic Operation
1530 *
1531 * @param[in] op Type to output.
1532 *
1533 * @return Formatted string.
1534 */
1535inline std::string to_string(const ArithmeticOperation &op)
1536{
1537 std::stringstream str;
1538 str << op;
1539 return str.str();
1540}
1541
Alex Gildayc357c472018-03-21 13:54:09 +00001542/** Formatted output of the Reduction Operations.
1543 *
1544 * @param[out] os Output stream.
1545 * @param[in] op Type to output.
1546 *
1547 * @return Modified output stream.
1548 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001549inline ::std::ostream &operator<<(::std::ostream &os, const ReductionOperation &op)
1550{
1551 switch(op)
1552 {
Michalis Spyrou7e9391b2018-10-05 14:49:28 +01001553 case ReductionOperation::SUM:
1554 os << "SUM";
1555 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +01001556 case ReductionOperation::SUM_SQUARE:
1557 os << "SUM_SQUARE";
1558 break;
Michalis Spyrou7e9391b2018-10-05 14:49:28 +01001559 case ReductionOperation::MEAN_SUM:
1560 os << "MEAN_SUM";
1561 break;
Michalis Spyrou7930db42018-11-22 17:36:28 +00001562 case ReductionOperation::ARG_IDX_MAX:
1563 os << "ARG_IDX_MAX";
1564 break;
1565 case ReductionOperation::ARG_IDX_MIN:
1566 os << "ARG_IDX_MIN";
1567 break;
Manuel Bottinib412fab2018-12-10 17:40:23 +00001568 case ReductionOperation::PROD:
1569 os << "PROD";
1570 break;
Usama Arifa4a08ad2019-05-20 12:38:33 +01001571 case ReductionOperation::MIN:
1572 os << "MIN";
1573 break;
Usama Arif28f0dd92019-05-20 13:44:34 +01001574 case ReductionOperation::MAX:
1575 os << "MAX";
1576 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +01001577 default:
1578 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1579 }
1580
1581 return os;
1582}
1583
Alex Gildayc357c472018-03-21 13:54:09 +00001584/** Formatted output of the Reduction Operations.
1585 *
1586 * @param[in] op Type to output.
1587 *
1588 * @return Formatted string.
1589 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001590inline std::string to_string(const ReductionOperation &op)
1591{
1592 std::stringstream str;
1593 str << op;
1594 return str.str();
1595}
1596
Georgios Pinitas7900a9e2018-11-23 11:44:58 +00001597/** Formatted output of the Comparison Operations.
1598 *
1599 * @param[out] os Output stream.
1600 * @param[in] op Type to output.
1601 *
1602 * @return Modified output stream.
1603 */
1604inline ::std::ostream &operator<<(::std::ostream &os, const ComparisonOperation &op)
1605{
1606 switch(op)
1607 {
1608 case ComparisonOperation::Equal:
1609 os << "Equal";
1610 break;
1611 case ComparisonOperation::NotEqual:
1612 os << "NotEqual";
1613 break;
1614 case ComparisonOperation::Greater:
1615 os << "Greater";
1616 break;
1617 case ComparisonOperation::GreaterEqual:
1618 os << "GreaterEqual";
1619 break;
1620 case ComparisonOperation::Less:
1621 os << "Less";
1622 break;
1623 case ComparisonOperation::LessEqual:
1624 os << "LessEqual";
1625 break;
1626 default:
1627 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1628 }
1629
1630 return os;
1631}
1632
Michalis Spyroue9362622018-11-23 17:41:37 +00001633/** Formatted output of the Elementwise unary Operations.
1634 *
1635 * @param[out] os Output stream.
1636 * @param[in] op Type to output.
1637 *
1638 * @return Modified output stream.
1639 */
1640inline ::std::ostream &operator<<(::std::ostream &os, const ElementWiseUnary &op)
1641{
1642 switch(op)
1643 {
1644 case ElementWiseUnary::RSQRT:
1645 os << "RSQRT";
1646 break;
1647 case ElementWiseUnary::EXP:
1648 os << "EXP";
1649 break;
Usama Arifeb312ef2019-05-13 17:45:54 +01001650 case ElementWiseUnary::NEG:
1651 os << "NEG";
1652 break;
Usama Arifac33d7e2019-05-20 14:21:40 +01001653 case ElementWiseUnary::LOG:
1654 os << "LOG";
1655 break;
Usama Arif6a4d5422019-05-24 14:53:59 +01001656 case ElementWiseUnary::ROUND:
1657 os << "ROUND";
1658 break;
Michalis Spyroue9362622018-11-23 17:41:37 +00001659 default:
1660 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1661 }
1662
1663 return os;
1664}
1665
Georgios Pinitas7900a9e2018-11-23 11:44:58 +00001666/** Formatted output of the Comparison Operations.
1667 *
1668 * @param[in] op Type to output.
1669 *
1670 * @return Formatted string.
1671 */
1672inline std::string to_string(const ComparisonOperation &op)
1673{
1674 std::stringstream str;
1675 str << op;
1676 return str.str();
1677}
1678
Michalis Spyroue9362622018-11-23 17:41:37 +00001679/** Formatted output of the Elementwise unary Operations.
1680 *
1681 * @param[in] op Type to output.
1682 *
1683 * @return Formatted string.
1684 */
1685inline std::string to_string(const ElementWiseUnary &op)
1686{
1687 std::stringstream str;
1688 str << op;
1689 return str.str();
1690}
1691
Alex Gildayc357c472018-03-21 13:54:09 +00001692/** Formatted output of the Norm Type.
1693 *
1694 * @param[in] type Type to output.
1695 *
1696 * @return Formatted string.
1697 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001698inline std::string to_string(const NormType &type)
1699{
1700 std::stringstream str;
1701 str << type;
1702 return str.str();
1703}
1704
Alex Gildayc357c472018-03-21 13:54:09 +00001705/** Formatted output of the Pooling Type.
1706 *
1707 * @param[in] type Type to output.
1708 *
1709 * @return Formatted string.
1710 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001711inline std::string to_string(const PoolingType &type)
1712{
1713 std::stringstream str;
1714 str << type;
1715 return str.str();
1716}
1717
Alex Gildayc357c472018-03-21 13:54:09 +00001718/** Formatted output of the Pooling Layer Info.
1719 *
1720 * @param[in] info Type to output.
1721 *
1722 * @return Formatted string.
1723 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001724inline std::string to_string(const PoolingLayerInfo &info)
1725{
1726 std::stringstream str;
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +00001727 str << "{Type=" << info.pool_type << ","
Sang-Hoon Park11fedda2020-01-15 14:44:04 +00001728 << "DataLayout=" << info.data_layout << ","
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +00001729 << "IsGlobalPooling=" << info.is_global_pooling;
1730 if(!info.is_global_pooling)
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001731 {
1732 str << ","
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +00001733 << "PoolSize=" << info.pool_size.width << "," << info.pool_size.height << ","
1734 << "PadStride=" << info.pad_stride_info;
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001735 }
1736 str << "}";
Anthony Barbier2a07e182017-08-04 18:20:27 +01001737 return str.str();
1738}
1739
Michalis Spyrou6c7c38e2018-08-29 16:28:11 +01001740/** Formatted output of the PriorBoxLayerInfo.
1741 *
1742 * @param[in] info Type to output.
1743 *
1744 * @return Formatted string.
1745 */
1746inline std::string to_string(const PriorBoxLayerInfo &info)
1747{
1748 std::stringstream str;
1749 str << "{";
1750 str << "Clip:" << info.clip()
1751 << "Flip:" << info.flip()
1752 << "StepX:" << info.steps()[0]
1753 << "StepY:" << info.steps()[1]
1754 << "MinSizes:" << info.min_sizes().size()
1755 << "MaxSizes:" << info.max_sizes().size()
1756 << "ImgSizeX:" << info.img_size().x
1757 << "ImgSizeY:" << info.img_size().y
1758 << "Offset:" << info.offset()
1759 << "Variances:" << info.variances().size();
1760 str << "}";
1761 return str.str();
1762}
1763
Alex Gildayc357c472018-03-21 13:54:09 +00001764/** Formatted output of the KeyPoint type.
1765 *
1766 * @param[out] os Output stream
1767 * @param[in] point Type to output.
1768 *
1769 * @return Modified output stream.
1770 */
Moritz Pflanzer6c6597c2017-09-24 12:09:41 +01001771inline ::std::ostream &operator<<(::std::ostream &os, const KeyPoint &point)
1772{
1773 os << "{x=" << point.x << ","
1774 << "y=" << point.y << ","
1775 << "strength=" << point.strength << ","
1776 << "scale=" << point.scale << ","
1777 << "orientation=" << point.orientation << ","
1778 << "tracking_status=" << point.tracking_status << ","
1779 << "error=" << point.error << "}";
1780
1781 return os;
1782}
John Richardson63e50412017-10-13 20:51:42 +01001783
Alex Gildayc357c472018-03-21 13:54:09 +00001784/** Formatted output of the PhaseType type.
1785 *
1786 * @param[out] os Output stream
1787 * @param[in] phase_type Type to output.
1788 *
1789 * @return Modified output stream.
1790 */
John Richardson63e50412017-10-13 20:51:42 +01001791inline ::std::ostream &operator<<(::std::ostream &os, const PhaseType &phase_type)
1792{
1793 switch(phase_type)
1794 {
1795 case PhaseType::SIGNED:
1796 os << "SIGNED";
1797 break;
1798 case PhaseType::UNSIGNED:
1799 os << "UNSIGNED";
1800 break;
1801 default:
1802 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1803 }
1804
1805 return os;
1806}
1807
Alex Gildayc357c472018-03-21 13:54:09 +00001808/** Formatted output of the PhaseType type.
1809 *
1810 * @param[in] type Type to output.
1811 *
1812 * @return Formatted string.
1813 */
John Richardson63e50412017-10-13 20:51:42 +01001814inline std::string to_string(const arm_compute::PhaseType &type)
1815{
1816 std::stringstream str;
1817 str << type;
1818 return str.str();
1819}
John Richardson3c5f9492017-10-04 15:27:37 +01001820
Alex Gildayc357c472018-03-21 13:54:09 +00001821/** Formatted output of the MagnitudeType type.
1822 *
1823 * @param[out] os Output stream
1824 * @param[in] magnitude_type Type to output.
1825 *
1826 * @return Modified output stream.
1827 */
John Richardson3c5f9492017-10-04 15:27:37 +01001828inline ::std::ostream &operator<<(::std::ostream &os, const MagnitudeType &magnitude_type)
1829{
1830 switch(magnitude_type)
1831 {
1832 case MagnitudeType::L1NORM:
1833 os << "L1NORM";
1834 break;
1835 case MagnitudeType::L2NORM:
1836 os << "L2NORM";
1837 break;
1838 default:
1839 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1840 }
1841
1842 return os;
1843}
1844
Alex Gildayc357c472018-03-21 13:54:09 +00001845/** Formatted output of the MagnitudeType type.
1846 *
1847 * @param[in] type Type to output.
1848 *
1849 * @return Formatted string.
1850 */
John Richardson3c5f9492017-10-04 15:27:37 +01001851inline std::string to_string(const arm_compute::MagnitudeType &type)
1852{
1853 std::stringstream str;
1854 str << type;
1855 return str.str();
1856}
John Richardson1c529922017-11-01 10:57:48 +00001857
Alex Gildayc357c472018-03-21 13:54:09 +00001858/** Formatted output of the HOGNormType type.
1859 *
1860 * @param[out] os Output stream
1861 * @param[in] norm_type Type to output
1862 *
1863 * @return Modified output stream.
1864 */
John Richardson25f23682017-11-27 14:35:09 +00001865inline ::std::ostream &operator<<(::std::ostream &os, const HOGNormType &norm_type)
1866{
1867 switch(norm_type)
1868 {
1869 case HOGNormType::L1_NORM:
1870 os << "L1_NORM";
1871 break;
1872 case HOGNormType::L2_NORM:
1873 os << "L2_NORM";
1874 break;
1875 case HOGNormType::L2HYS_NORM:
1876 os << "L2HYS_NORM";
1877 break;
1878 default:
1879 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1880 }
1881
1882 return os;
1883}
1884
Alex Gildayc357c472018-03-21 13:54:09 +00001885/** Formatted output of the HOGNormType type.
1886 *
1887 * @param[in] type Type to output
1888 *
1889 * @return Formatted string.
1890 */
John Richardson25f23682017-11-27 14:35:09 +00001891inline std::string to_string(const HOGNormType &type)
1892{
1893 std::stringstream str;
1894 str << type;
1895 return str.str();
1896}
1897
Alex Gildayc357c472018-03-21 13:54:09 +00001898/** Formatted output of the Size2D type.
1899 *
1900 * @param[out] os Output stream
1901 * @param[in] size Type to output
1902 *
1903 * @return Modified output stream.
1904 */
John Richardson25f23682017-11-27 14:35:09 +00001905inline ::std::ostream &operator<<(::std::ostream &os, const Size2D &size)
1906{
1907 os << size.width << "x" << size.height;
1908
1909 return os;
1910}
1911
Alex Gildayc357c472018-03-21 13:54:09 +00001912/** Formatted output of the Size2D type.
1913 *
1914 * @param[in] type Type to output
1915 *
1916 * @return Formatted string.
1917 */
John Richardson25f23682017-11-27 14:35:09 +00001918inline std::string to_string(const Size2D &type)
1919{
1920 std::stringstream str;
1921 str << type;
1922 return str.str();
1923}
1924
Alex Gildayc357c472018-03-21 13:54:09 +00001925/** Formatted output of the HOGInfo type.
1926 *
1927 * @param[out] os Output stream
1928 * @param[in] hog_info Type to output
1929 *
1930 * @return Modified output stream.
1931 */
John Richardson25f23682017-11-27 14:35:09 +00001932inline ::std::ostream &operator<<(::std::ostream &os, const HOGInfo &hog_info)
1933{
1934 os << "{CellSize=" << hog_info.cell_size() << ","
1935 << "BlockSize=" << hog_info.block_size() << ","
1936 << "DetectionWindowSize=" << hog_info.detection_window_size() << ","
1937 << "BlockStride=" << hog_info.block_stride() << ","
1938 << "NumBins=" << hog_info.num_bins() << ","
1939 << "NormType=" << hog_info.normalization_type() << ","
1940 << "L2HystThreshold=" << hog_info.l2_hyst_threshold() << ","
1941 << "PhaseType=" << hog_info.phase_type() << "}";
1942
1943 return os;
1944}
1945
Alex Gildayc357c472018-03-21 13:54:09 +00001946/** Formatted output of the HOGInfo type.
1947 *
1948 * @param[in] type Type to output
1949 *
1950 * @return Formatted string.
1951 */
John Richardson25f23682017-11-27 14:35:09 +00001952inline std::string to_string(const HOGInfo &type)
1953{
1954 std::stringstream str;
1955 str << type;
1956 return str.str();
1957}
1958
Alex Gildayc357c472018-03-21 13:54:09 +00001959/** Formatted output of the ConvolutionMethod type.
1960 *
1961 * @param[out] os Output stream
1962 * @param[in] conv_method Type to output
1963 *
1964 * @return Modified output stream.
1965 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001966inline ::std::ostream &operator<<(::std::ostream &os, const ConvolutionMethod &conv_method)
1967{
1968 switch(conv_method)
1969 {
1970 case ConvolutionMethod::GEMM:
1971 os << "GEMM";
1972 break;
1973 case ConvolutionMethod::DIRECT:
1974 os << "DIRECT";
1975 break;
1976 case ConvolutionMethod::WINOGRAD:
1977 os << "WINOGRAD";
1978 break;
1979 default:
1980 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1981 }
1982
1983 return os;
1984}
1985
Alex Gildayc357c472018-03-21 13:54:09 +00001986/** Formatted output of the ConvolutionMethod type.
1987 *
1988 * @param[in] conv_method Type to output
1989 *
1990 * @return Formatted string.
1991 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001992inline std::string to_string(const ConvolutionMethod &conv_method)
1993{
1994 std::stringstream str;
1995 str << conv_method;
1996 return str.str();
1997}
1998
Alex Gildayc357c472018-03-21 13:54:09 +00001999/** Formatted output of the GPUTarget type.
2000 *
2001 * @param[out] os Output stream
2002 * @param[in] gpu_target Type to output
2003 *
2004 * @return Modified output stream.
2005 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002006inline ::std::ostream &operator<<(::std::ostream &os, const GPUTarget &gpu_target)
2007{
2008 switch(gpu_target)
2009 {
2010 case GPUTarget::GPU_ARCH_MASK:
2011 os << "GPU_ARCH_MASK";
2012 break;
2013 case GPUTarget::MIDGARD:
2014 os << "MIDGARD";
2015 break;
2016 case GPUTarget::BIFROST:
2017 os << "BIFROST";
2018 break;
Georgios Pinitasd5462ff2019-07-03 19:33:57 +01002019 case GPUTarget::VALHALL:
2020 os << "VALHALL";
2021 break;
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002022 case GPUTarget::T600:
2023 os << "T600";
2024 break;
2025 case GPUTarget::T700:
2026 os << "T700";
2027 break;
2028 case GPUTarget::T800:
2029 os << "T800";
2030 break;
Michalis Spyroua9676112018-02-22 18:07:43 +00002031 case GPUTarget::G71:
2032 os << "G71";
2033 break;
2034 case GPUTarget::G72:
2035 os << "G72";
2036 break;
2037 case GPUTarget::G51:
2038 os << "G51";
2039 break;
2040 case GPUTarget::G51BIG:
2041 os << "G51BIG";
2042 break;
2043 case GPUTarget::G51LIT:
2044 os << "G51LIT";
2045 break;
Georgios Pinitasb03f7c52018-07-12 10:49:53 +01002046 case GPUTarget::G76:
2047 os << "G76";
Michalis Spyroua9676112018-02-22 18:07:43 +00002048 break;
Georgios Pinitasd5462ff2019-07-03 19:33:57 +01002049 case GPUTarget::G77:
2050 os << "G77";
Michalis Spyroua9676112018-02-22 18:07:43 +00002051 break;
2052 case GPUTarget::TBOX:
2053 os << "TBOX";
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002054 break;
Georgios Pinitasd5462ff2019-07-03 19:33:57 +01002055 case GPUTarget::TODX:
2056 os << "TODX";
2057 break;
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002058 default:
2059 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2060 }
2061
2062 return os;
2063}
2064
Alex Gildayc357c472018-03-21 13:54:09 +00002065/** Formatted output of the GPUTarget type.
2066 *
2067 * @param[in] gpu_target Type to output
2068 *
2069 * @return Formatted string.
2070 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002071inline std::string to_string(const GPUTarget &gpu_target)
2072{
2073 std::stringstream str;
2074 str << gpu_target;
2075 return str.str();
2076}
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00002077
John Richardson8de92612018-02-22 14:09:31 +00002078/** Formatted output of the DetectionWindow type.
2079 *
2080 * @param[out] os Output stream
2081 * @param[in] detection_window Type to output
2082 *
2083 * @return Modified output stream.
2084 */
John Richardson684cb0f2018-01-09 11:17:00 +00002085inline ::std::ostream &operator<<(::std::ostream &os, const DetectionWindow &detection_window)
2086{
2087 os << "{x=" << detection_window.x << ","
2088 << "y=" << detection_window.y << ","
2089 << "width=" << detection_window.width << ","
2090 << "height=" << detection_window.height << ","
2091 << "idx_class=" << detection_window.idx_class << ","
2092 << "score=" << detection_window.score << "}";
2093
2094 return os;
2095}
2096
Isabella Gottardi05e56442018-11-16 11:26:52 +00002097/** Formatted output of the DetectionOutputLayerCodeType type.
2098 *
2099 * @param[out] os Output stream
2100 * @param[in] detection_code Type to output
2101 *
2102 * @return Modified output stream.
2103 */
2104inline ::std::ostream &operator<<(::std::ostream &os, const DetectionOutputLayerCodeType &detection_code)
2105{
2106 switch(detection_code)
2107 {
2108 case DetectionOutputLayerCodeType::CENTER_SIZE:
2109 os << "CENTER_SIZE";
2110 break;
2111 case DetectionOutputLayerCodeType::CORNER:
2112 os << "CORNER";
2113 break;
2114 case DetectionOutputLayerCodeType::CORNER_SIZE:
2115 os << "CORNER_SIZE";
2116 break;
2117 case DetectionOutputLayerCodeType::TF_CENTER:
2118 os << "TF_CENTER";
2119 break;
2120 default:
2121 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2122 }
2123
2124 return os;
2125}
2126/** Formatted output of the DetectionOutputLayerCodeType type.
2127 *
2128 * @param[in] detection_code Type to output
2129 *
2130 * @return Formatted string.
2131 */
2132inline std::string to_string(const DetectionOutputLayerCodeType &detection_code)
2133{
2134 std::stringstream str;
2135 str << detection_code;
2136 return str.str();
2137}
2138
2139/** Formatted output of the DetectionOutputLayerInfo type.
2140 *
2141 * @param[out] os Output stream
2142 * @param[in] detection_info Type to output
2143 *
2144 * @return Modified output stream.
2145 */
2146inline ::std::ostream &operator<<(::std::ostream &os, const DetectionOutputLayerInfo &detection_info)
2147{
2148 os << "{Classes=" << detection_info.num_classes() << ","
2149 << "ShareLocation=" << detection_info.share_location() << ","
2150 << "CodeType=" << detection_info.code_type() << ","
2151 << "VarianceEncodedInTarget=" << detection_info.variance_encoded_in_target() << ","
2152 << "KeepTopK=" << detection_info.keep_top_k() << ","
2153 << "NMSThreshold=" << detection_info.nms_threshold() << ","
2154 << "Eta=" << detection_info.eta() << ","
2155 << "BackgroundLabelId=" << detection_info.background_label_id() << ","
2156 << "ConfidenceThreshold=" << detection_info.confidence_threshold() << ","
2157 << "TopK=" << detection_info.top_k() << ","
2158 << "NumLocClasses=" << detection_info.num_loc_classes()
2159 << "}";
2160
2161 return os;
2162}
2163
2164/** Formatted output of the DetectionOutputLayerInfo type.
2165 *
2166 * @param[in] detection_info Type to output
2167 *
2168 * @return Formatted string.
2169 */
2170inline std::string to_string(const DetectionOutputLayerInfo &detection_info)
2171{
2172 std::stringstream str;
2173 str << detection_info;
2174 return str.str();
2175}
Isabella Gottardia7acb3c2019-01-08 13:48:44 +00002176/** Formatted output of the DetectionPostProcessLayerInfo type.
2177 *
2178 * @param[out] os Output stream
2179 * @param[in] detection_info Type to output
2180 *
2181 * @return Modified output stream.
2182 */
2183inline ::std::ostream &operator<<(::std::ostream &os, const DetectionPostProcessLayerInfo &detection_info)
2184{
2185 os << "{MaxDetections=" << detection_info.max_detections() << ","
2186 << "MaxClassesPerDetection=" << detection_info.max_classes_per_detection() << ","
2187 << "NmsScoreThreshold=" << detection_info.nms_score_threshold() << ","
2188 << "NmsIouThreshold=" << detection_info.iou_threshold() << ","
2189 << "NumClasses=" << detection_info.num_classes() << ","
2190 << "ScaleValue_y=" << detection_info.scale_value_y() << ","
2191 << "ScaleValue_x=" << detection_info.scale_value_x() << ","
2192 << "ScaleValue_h=" << detection_info.scale_value_h() << ","
2193 << "ScaleValue_w=" << detection_info.scale_value_w() << ","
2194 << "UseRegularNms=" << detection_info.use_regular_nms() << ","
2195 << "DetectionPerClass=" << detection_info.detection_per_class()
2196 << "}";
2197
2198 return os;
2199}
2200
2201/** Formatted output of the DetectionPostProcessLayerInfo type.
2202 *
2203 * @param[in] detection_info Type to output
2204 *
2205 * @return Formatted string.
2206 */
2207inline std::string to_string(const DetectionPostProcessLayerInfo &detection_info)
2208{
2209 std::stringstream str;
2210 str << detection_info;
2211 return str.str();
2212}
John Richardson8de92612018-02-22 14:09:31 +00002213/** Formatted output of the DetectionWindow type.
2214 *
2215 * @param[in] detection_window Type to output
2216 *
2217 * @return Formatted string.
2218 */
2219inline std::string to_string(const DetectionWindow &detection_window)
2220{
2221 std::stringstream str;
2222 str << detection_window;
2223 return str.str();
2224}
2225
2226/** Formatted output of the Termination type.
2227 *
2228 * @param[out] os Output stream
2229 * @param[in] termination Type to output
2230 *
2231 * @return Modified output stream.
2232 */
2233inline ::std::ostream &operator<<(::std::ostream &os, const Termination &termination)
2234{
2235 switch(termination)
2236 {
2237 case Termination::TERM_CRITERIA_EPSILON:
2238 os << "TERM_CRITERIA_EPSILON";
2239 break;
2240 case Termination::TERM_CRITERIA_ITERATIONS:
2241 os << "TERM_CRITERIA_ITERATIONS";
2242 break;
2243 case Termination::TERM_CRITERIA_BOTH:
2244 os << "TERM_CRITERIA_BOTH";
2245 break;
2246 default:
2247 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2248 }
2249
2250 return os;
2251}
2252
2253/** Formatted output of the Termination type.
2254 *
2255 * @param[in] termination Type to output
2256 *
2257 * @return Formatted string.
2258 */
2259inline std::string to_string(const Termination &termination)
2260{
2261 std::stringstream str;
2262 str << termination;
2263 return str.str();
2264}
2265
Anthony Barbier8914e322018-08-10 15:28:25 +01002266/** Formatted output of the CPUModel type.
2267 *
2268 * @param[out] os Output stream
2269 * @param[in] cpu_model Model to output
2270 *
2271 * @return Modified output stream.
2272 */
2273inline ::std::ostream &operator<<(::std::ostream &os, const CPUModel &cpu_model)
2274{
2275 switch(cpu_model)
2276 {
2277 case CPUModel::GENERIC:
2278 os << "GENERIC";
2279 break;
2280 case CPUModel::GENERIC_FP16:
2281 os << "GENERIC_FP16";
2282 break;
2283 case CPUModel::GENERIC_FP16_DOT:
2284 os << "GENERIC_FP16_DOT";
2285 break;
2286 case CPUModel::A53:
2287 os << "A53";
2288 break;
2289 case CPUModel::A55r0:
2290 os << "A55r0";
2291 break;
2292 case CPUModel::A55r1:
2293 os << "A55r1";
2294 break;
David Mansell318c9f42020-07-08 13:28:45 +01002295 case CPUModel::A73:
2296 os << "A73";
2297 break;
2298 case CPUModel::X1:
2299 os << "X1";
2300 break;
Anthony Barbier8914e322018-08-10 15:28:25 +01002301 default:
2302 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2303 }
2304
2305 return os;
2306}
2307
2308/** Formatted output of the CPUModel type.
2309 *
2310 * @param[in] cpu_model Model to output
2311 *
2312 * @return Formatted string.
2313 */
2314inline std::string to_string(const CPUModel &cpu_model)
2315{
2316 std::stringstream str;
2317 str << cpu_model;
2318 return str.str();
2319}
Anthony Barbier671a11e2018-07-06 15:11:36 +01002320/** Formatted output of a vector of objects.
2321 *
2322 * @param[out] os Output stream
2323 * @param[in] args Vector of objects to print
2324 *
2325 * @return Modified output stream.
2326 */
2327template <typename T>
2328inline ::std::ostream &operator<<(::std::ostream &os, const std::vector<T> &args)
2329{
2330 os << "[";
2331 bool first = true;
2332 for(auto &arg : args)
2333 {
2334 if(first)
2335 {
2336 first = false;
2337 }
2338 else
2339 {
2340 os << ", ";
2341 }
2342 os << arg;
2343 }
2344 os << "]";
2345 return os;
2346}
2347
Michalis Spyrou6c7c38e2018-08-29 16:28:11 +01002348/** Formatted output of @ref PriorBoxLayerInfo.
2349 *
2350 * @param[out] os Output stream.
2351 * @param[in] info Type to output.
2352 *
2353 * @return Modified output stream.
2354 */
2355inline ::std::ostream &operator<<(::std::ostream &os, const PriorBoxLayerInfo &info)
2356{
2357 os << "Clip:" << info.clip()
2358 << "Flip:" << info.flip()
2359 << "StepX:" << info.steps()[0]
2360 << "StepY:" << info.steps()[1]
2361 << "MinSizes:" << info.min_sizes()
2362 << "MaxSizes:" << info.max_sizes()
2363 << "ImgSizeX:" << info.img_size().x
2364 << "ImgSizeY:" << info.img_size().y
2365 << "Offset:" << info.offset()
2366 << "Variances:" << info.variances();
2367
2368 return os;
2369}
2370
Anthony Barbier671a11e2018-07-06 15:11:36 +01002371/** Formatted output of a vector of objects.
2372 *
2373 * @param[in] args Vector of objects to print
2374 *
2375 * @return String representing args.
2376 */
2377template <typename T>
2378std::string to_string(const std::vector<T> &args)
2379{
2380 std::stringstream str;
2381 str << args;
2382 return str.str();
2383}
2384
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00002385/** Formatted output of the WinogradInfo type. */
2386inline ::std::ostream &operator<<(::std::ostream &os, const WinogradInfo &info)
2387{
2388 os << "{OutputTileSize=" << info.output_tile_size << ","
2389 << "KernelSize=" << info.kernel_size << ","
2390 << "PadStride=" << info.convolution_info << ","
2391 << "OutputDataLayout=" << info.output_data_layout << "}";
2392
2393 return os;
2394}
2395
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00002396inline std::string to_string(const WinogradInfo &type)
2397{
2398 std::stringstream str;
2399 str << type;
2400 return str.str();
2401}
Anthony Barbier671a11e2018-07-06 15:11:36 +01002402
2403/** Fallback method: try to use std::to_string:
2404 *
2405 * @param[in] val Value to convert to string
2406 *
2407 * @return String representing val.
2408 */
2409template <typename T>
2410inline std::string to_string(const T &val)
2411{
2412 return support::cpp11::to_string(val);
2413}
2414
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +01002415/** Convert a CLTunerMode value to a string
2416 *
2417 * @param val CLTunerMode value to be converted
2418 *
2419 * @return String representing the corresponding CLTunerMode.
2420 */
2421inline std::string to_string(const CLTunerMode val)
2422{
2423 switch(val)
2424 {
2425 case CLTunerMode::EXHAUSTIVE:
2426 {
2427 return std::string("Exhaustive");
2428 }
2429 case CLTunerMode::NORMAL:
2430 {
2431 return std::string("Normal");
2432 }
2433 case CLTunerMode::RAPID:
2434 {
2435 return std::string("Rapid");
2436 }
2437 default:
2438 {
2439 ARM_COMPUTE_ERROR("Invalid tuner mode.");
2440 return std::string("UNDEFINED");
2441 }
2442 }
2443}
2444/** [Print CLTunerMode type] **/
2445/** Formatted output of the CLTunerMode type.
2446 *
2447 * @param[out] os Output stream.
2448 * @param[in] val CLTunerMode to output.
2449 *
2450 * @return Modified output stream.
2451 */
2452inline ::std::ostream &operator<<(::std::ostream &os, const CLTunerMode &val)
2453{
2454 os << to_string(val);
2455 return os;
2456}
2457
Anthony Barbier6ff3b192017-09-04 18:44:23 +01002458} // namespace arm_compute
Anthony Barbier4dbc0a92018-08-27 13:39:47 +01002459
2460#endif /* __ARM_COMPUTE_TYPE_PRINTER_H__ */