blob: 53a8902dd4fae04ee0c3a5de96f1ee7548f0d04b [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001/*
SiCong Lidb4a6c12021-02-05 09:30:57 +00002 * Copyright (c) 2017-2021 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"
SiCong Lidb4a6c12021-02-05 09:30:57 +000038#include "arm_compute/runtime/CL/CLTypes.h"
Matthew Bentham758b5ba2020-03-05 23:37:48 +000039#include "support/StringSupport.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010040
41#include <ostream>
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010042#include <sstream>
43#include <string>
Anthony Barbier6ff3b192017-09-04 18:44:23 +010044
45namespace arm_compute
46{
Anthony Barbierb940fd62018-06-04 14:14:32 +010047/** Formatted output if arg is not null
48 *
49 * @param[in] arg Object to print
50 *
51 * @return String representing arg.
52 */
53template <typename T>
54std::string to_string_if_not_null(T *arg)
55{
56 if(arg == nullptr)
57 {
58 return "nullptr";
59 }
60 else
61 {
62 return to_string(*arg);
63 }
64}
Anthony Barbierb4670212018-05-18 16:55:39 +010065
Alex Gildayc357c472018-03-21 13:54:09 +000066/** Formatted output of the Dimensions type.
67 *
68 * @param[out] os Output stream.
69 * @param[in] dimensions Type to output.
70 *
71 * @return Modified output stream.
72 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +010073template <typename T>
74inline ::std::ostream &operator<<(::std::ostream &os, const Dimensions<T> &dimensions)
75{
Anthony Barbier6ff3b192017-09-04 18:44:23 +010076 if(dimensions.num_dimensions() > 0)
77 {
78 os << dimensions[0];
79
80 for(unsigned int d = 1; d < dimensions.num_dimensions(); ++d)
81 {
Moritz Pflanzerc87fbf82017-07-18 14:02:10 +010082 os << "x" << dimensions[d];
Anthony Barbier6ff3b192017-09-04 18:44:23 +010083 }
84 }
85
Anthony Barbier6ff3b192017-09-04 18:44:23 +010086 return os;
87}
88
Alex Gildayc357c472018-03-21 13:54:09 +000089/** Formatted output of the NonLinearFilterFunction type.
90 *
91 * @param[out] os Output stream.
92 * @param[in] function Type to output.
93 *
94 * @return Modified output stream.
95 */
Isabella Gottardi3b77e9d2017-06-22 11:05:41 +010096inline ::std::ostream &operator<<(::std::ostream &os, const NonLinearFilterFunction &function)
97{
98 switch(function)
99 {
100 case NonLinearFilterFunction::MAX:
101 os << "MAX";
102 break;
103 case NonLinearFilterFunction::MEDIAN:
104 os << "MEDIAN";
105 break;
106 case NonLinearFilterFunction::MIN:
107 os << "MIN";
108 break;
109 default:
110 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
111 }
112
113 return os;
114}
115
Alex Gildayc357c472018-03-21 13:54:09 +0000116/** Formatted output of the NonLinearFilterFunction type.
117 *
118 * @param[in] function Type to output.
119 *
120 * @return Formatted string.
121 */
John Richardson6f4d49f2017-09-07 11:21:10 +0100122inline std::string to_string(const NonLinearFilterFunction &function)
123{
124 std::stringstream str;
125 str << function;
126 return str.str();
127}
128
Alex Gildayc357c472018-03-21 13:54:09 +0000129/** Formatted output of the MatrixPattern type.
130 *
131 * @param[out] os Output stream.
132 * @param[in] pattern Type to output.
133 *
134 * @return Modified output stream.
135 */
Isabella Gottardi3b77e9d2017-06-22 11:05:41 +0100136inline ::std::ostream &operator<<(::std::ostream &os, const MatrixPattern &pattern)
137{
138 switch(pattern)
139 {
140 case MatrixPattern::BOX:
141 os << "BOX";
142 break;
143 case MatrixPattern::CROSS:
144 os << "CROSS";
145 break;
146 case MatrixPattern::DISK:
147 os << "DISK";
148 break;
149 case MatrixPattern::OTHER:
150 os << "OTHER";
151 break;
152 default:
153 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
154 }
155
156 return os;
157}
158
Alex Gildayc357c472018-03-21 13:54:09 +0000159/** Formatted output of the MatrixPattern type.
160 *
161 * @param[in] pattern Type to output.
162 *
163 * @return Formatted string.
164 */
John Richardson6f4d49f2017-09-07 11:21:10 +0100165inline std::string to_string(const MatrixPattern &pattern)
166{
167 std::stringstream str;
168 str << pattern;
169 return str.str();
170}
171
Alex Gildayc357c472018-03-21 13:54:09 +0000172/** Formatted output of the RoundingPolicy type.
173 *
174 * @param[out] os Output stream.
175 * @param[in] rounding_policy Type to output.
176 *
177 * @return Modified output stream.
178 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100179inline ::std::ostream &operator<<(::std::ostream &os, const RoundingPolicy &rounding_policy)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100180{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100181 switch(rounding_policy)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100182 {
Anthony Barbier2a07e182017-08-04 18:20:27 +0100183 case RoundingPolicy::TO_ZERO:
184 os << "TO_ZERO";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100185 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100186 case RoundingPolicy::TO_NEAREST_UP:
187 os << "TO_NEAREST_UP";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100188 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100189 case RoundingPolicy::TO_NEAREST_EVEN:
190 os << "TO_NEAREST_EVEN";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100191 break;
192 default:
193 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
194 }
195
196 return os;
197}
198
Alex Gildayc357c472018-03-21 13:54:09 +0000199/** Formatted output of the WeightsInfo type.
200 *
201 * @param[out] os Output stream.
202 * @param[in] weights_info Type to output.
203 *
204 * @return Modified output stream.
205 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100206inline ::std::ostream &operator<<(::std::ostream &os, const WeightsInfo &weights_info)
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100207{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100208 os << weights_info.are_reshaped() << ";";
209 os << weights_info.num_kernels() << ";" << weights_info.kernel_size().first << "," << weights_info.kernel_size().second;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100210
211 return os;
212}
213
Alex Gildayc357c472018-03-21 13:54:09 +0000214/** Formatted output of the ROIPoolingInfo type.
215 *
216 * @param[out] os Output stream.
217 * @param[in] pool_info Type to output.
218 *
219 * @return Modified output stream.
220 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100221inline ::std::ostream &operator<<(::std::ostream &os, const ROIPoolingLayerInfo &pool_info)
Sanghoon Lee70f82912017-08-24 14:21:24 +0100222{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100223 os << pool_info.pooled_width() << "x" << pool_info.pooled_height() << "~" << pool_info.spatial_scale();
Georgios Pinitasd9769582017-08-03 10:19:40 +0100224 return os;
225}
226
giuros0118870812018-09-13 09:31:40 +0100227/** Formatted output of the ROIPoolingInfo type.
228 *
229 * @param[in] pool_info Type to output.
230 *
231 * @return Formatted string.
232 */
233inline std::string to_string(const ROIPoolingLayerInfo &pool_info)
234{
235 std::stringstream str;
236 str << pool_info;
237 return str.str();
238}
239
morgolockaba2f912020-05-05 16:28:19 +0100240/** Formatted output of the GEMMKernelInfo type.
241 *
242 * @param[out] os Output stream.
243 * @param[in] gemm_info Type to output.
244 *
245 * @return Modified output stream.
246 */
247inline ::std::ostream &operator<<(::std::ostream &os, const GEMMKernelInfo &gemm_info)
248{
249 os << "( m= " << gemm_info.m;
250 os << " n= " << gemm_info.n;
251 os << " k= " << gemm_info.k;
252 os << " depth_output_gemm3d= " << gemm_info.depth_output_gemm3d;
253 os << " reinterpret_input_as_3d= " << gemm_info.reinterpret_input_as_3d;
254 os << " broadcast_bias= " << gemm_info.broadcast_bias;
255 os << " fp_mixed_precision= " << gemm_info.fp_mixed_precision;
256 os << " mult_transpose1xW_width= " << gemm_info.mult_transpose1xW_width;
257 os << " mult_interleave4x4_height= " << gemm_info.mult_interleave4x4_height;
258 os << " a_offset = " << gemm_info.a_offset;
259 os << " b_offset = " << gemm_info.b_offset;
260 os << ")";
261 return os;
262}
263
264/** Formatted output of the GEMMLHSMatrixInfo type.
265 *
266 * @param[out] os Output stream.
267 * @param[in] gemm_info Type to output.
268 *
269 * @return Modified output stream.
270 */
271inline ::std::ostream &operator<<(::std::ostream &os, const GEMMLHSMatrixInfo &gemm_info)
272{
273 os << "( m0= " << (unsigned int)gemm_info.m0 << " k0= " << gemm_info.k0 << " v0= " << gemm_info.v0 << " trans= " << gemm_info.transpose << " inter= " << gemm_info.interleave << "})";
274 return os;
275}
276
277/** Formatted output of the GEMMRHSMatrixInfo type.
278 *
279 * @param[out] os Output stream.
280 * @param[in] gemm_info Type to output.
281 *
282 * @return Modified output stream.
283 */
284inline ::std::ostream &operator<<(::std::ostream &os, const GEMMRHSMatrixInfo &gemm_info)
285{
SiCong Lidb4a6c12021-02-05 09:30:57 +0000286 os << "( n0= " << (unsigned int)gemm_info.n0 << " k0= " << gemm_info.k0 << " h0= " << gemm_info.h0 << " trans= " << gemm_info.transpose << " inter= " << gemm_info.interleave << " exp_img=" <<
287 gemm_info.export_to_cl_image << "})";
morgolockaba2f912020-05-05 16:28:19 +0100288 return os;
289}
290
291/** Formatted output of the GEMMRHSMatrixInfo type.
292 *
293 * @param[in] gemm_info GEMMRHSMatrixInfo to output.
294 *
295 * @return Formatted string.
296 */
297inline std::string to_string(const GEMMRHSMatrixInfo &gemm_info)
298{
299 std::stringstream str;
300 str << gemm_info;
301 return str.str();
302}
303
304/** Formatted output of the GEMMLHSMatrixInfo type.
305 *
306 * @param[in] gemm_info GEMMLHSMatrixInfo to output.
307 *
308 * @return Formatted string.
309 */
310inline std::string to_string(const GEMMLHSMatrixInfo &gemm_info)
311{
312 std::stringstream str;
313 str << gemm_info;
314 return str.str();
315}
316
317/** Formatted output of the GEMMKernelInfo type.
318 *
319 * @param[in] gemm_info GEMMKernelInfo Type to output.
320 *
321 * @return Formatted string.
322 */
323inline std::string to_string(const GEMMKernelInfo &gemm_info)
324{
325 std::stringstream str;
326 str << gemm_info;
327 return str.str();
328}
329
giuros01c04a0e82018-10-03 12:44:35 +0100330/** Formatted output of the BoundingBoxTransformInfo type.
331 *
332 * @param[out] os Output stream.
333 * @param[in] bbox_info Type to output.
334 *
335 * @return Modified output stream.
336 */
337inline ::std::ostream &operator<<(::std::ostream &os, const BoundingBoxTransformInfo &bbox_info)
338{
339 auto weights = bbox_info.weights();
340 os << "(" << bbox_info.img_width() << "x" << bbox_info.img_height() << ")~" << bbox_info.scale() << "(weights = {" << weights[0] << ", " << weights[1] << ", " << weights[2] << ", " << weights[3] <<
341 "})";
342 return os;
343}
344
345/** Formatted output of the BoundingBoxTransformInfo type.
346 *
347 * @param[in] bbox_info Type to output.
348 *
349 * @return Formatted string.
350 */
351inline std::string to_string(const BoundingBoxTransformInfo &bbox_info)
352{
353 std::stringstream str;
354 str << bbox_info;
355 return str.str();
356}
357
Manuel Bottini5209be52019-02-13 16:34:56 +0000358/** Formatted output of the ComputeAnchorsInfo type.
359 *
360 * @param[out] os Output stream.
361 * @param[in] anchors_info Type to output.
362 *
363 * @return Modified output stream.
364 */
365inline ::std::ostream &operator<<(::std::ostream &os, const ComputeAnchorsInfo &anchors_info)
366{
367 os << "(" << anchors_info.feat_width() << "x" << anchors_info.feat_height() << ")~" << anchors_info.spatial_scale();
368 return os;
369}
370
371/** Formatted output of the ComputeAnchorsInfo type.
372 *
373 * @param[in] anchors_info Type to output.
374 *
375 * @return Formatted string.
376 */
377inline std::string to_string(const ComputeAnchorsInfo &anchors_info)
378{
379 std::stringstream str;
380 str << anchors_info;
381 return str.str();
382}
383
384/** Formatted output of the GenerateProposalsInfo type.
385 *
386 * @param[out] os Output stream.
387 * @param[in] proposals_info Type to output.
388 *
389 * @return Modified output stream.
390 */
391inline ::std::ostream &operator<<(::std::ostream &os, const GenerateProposalsInfo &proposals_info)
392{
393 os << "(" << proposals_info.im_width() << "x" << proposals_info.im_height() << ")~" << proposals_info.im_scale();
394 return os;
395}
396
397/** Formatted output of the GenerateProposalsInfo type.
398 *
399 * @param[in] proposals_info Type to output.
400 *
401 * @return Formatted string.
402 */
403inline std::string to_string(const GenerateProposalsInfo &proposals_info)
404{
405 std::stringstream str;
406 str << proposals_info;
407 return str.str();
408}
409
Alex Gildayc357c472018-03-21 13:54:09 +0000410/** Formatted output of the QuantizationInfo type.
411 *
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100412 * @param[out] os Output stream.
413 * @param[in] qinfo Type to output.
Alex Gildayc357c472018-03-21 13:54:09 +0000414 *
415 * @return Modified output stream.
416 */
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100417inline ::std::ostream &operator<<(::std::ostream &os, const QuantizationInfo &qinfo)
Chunosovd621bca2017-11-03 17:33:15 +0700418{
Georgios Pinitas3d13af82019-06-04 13:04:16 +0100419 const UniformQuantizationInfo uqinfo = qinfo.uniform();
420 os << "Scale:" << uqinfo.scale << "~";
421 os << "Offset:" << uqinfo.offset;
Chunosovd621bca2017-11-03 17:33:15 +0700422 return os;
423}
424
Alex Gildayc357c472018-03-21 13:54:09 +0000425/** Formatted output of the QuantizationInfo type.
426 *
427 * @param[in] quantization_info Type to output.
428 *
429 * @return Formatted string.
430 */
Chunosovd621bca2017-11-03 17:33:15 +0700431inline std::string to_string(const QuantizationInfo &quantization_info)
432{
433 std::stringstream str;
434 str << quantization_info;
435 return str.str();
436}
437
Alex Gildayc357c472018-03-21 13:54:09 +0000438/** Formatted output of the activation function type.
439 *
440 * @param[out] os Output stream.
441 * @param[in] act_function Type to output.
442 *
443 * @return Modified output stream.
444 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100445inline ::std::ostream &operator<<(::std::ostream &os, const ActivationLayerInfo::ActivationFunction &act_function)
446{
447 switch(act_function)
448 {
449 case ActivationLayerInfo::ActivationFunction::ABS:
450 os << "ABS";
451 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100452 case ActivationLayerInfo::ActivationFunction::LINEAR:
453 os << "LINEAR";
454 break;
455 case ActivationLayerInfo::ActivationFunction::LOGISTIC:
456 os << "LOGISTIC";
457 break;
458 case ActivationLayerInfo::ActivationFunction::RELU:
459 os << "RELU";
460 break;
Georgios Pinitas579c0492017-07-12 16:12:12 +0100461 case ActivationLayerInfo::ActivationFunction::BOUNDED_RELU:
462 os << "BOUNDED_RELU";
463 break;
464 case ActivationLayerInfo::ActivationFunction::LEAKY_RELU:
465 os << "LEAKY_RELU";
466 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100467 case ActivationLayerInfo::ActivationFunction::SOFT_RELU:
468 os << "SOFT_RELU";
469 break;
470 case ActivationLayerInfo::ActivationFunction::SQRT:
471 os << "SQRT";
472 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100473 case ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU:
474 os << "LU_BOUNDED_RELU";
Kevin Petitd9f80712017-12-06 12:18:48 +0000475 break;
Georgios Pinitasfb0fdcd2019-08-22 17:10:04 +0100476 case ActivationLayerInfo::ActivationFunction::ELU:
477 os << "ELU";
478 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100479 case ActivationLayerInfo::ActivationFunction::SQUARE:
480 os << "SQUARE";
481 break;
482 case ActivationLayerInfo::ActivationFunction::TANH:
483 os << "TANH";
484 break;
Usama Arif6a98a6e2019-05-10 17:07:27 +0100485 case ActivationLayerInfo::ActivationFunction::IDENTITY:
486 os << "IDENTITY";
487 break;
morgolock07df3d42020-02-27 11:46:28 +0000488 case ActivationLayerInfo::ActivationFunction::HARD_SWISH:
489 os << "HARD_SWISH";
490 break;
491
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100492 default:
493 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
494 }
495
496 return os;
497}
498
Alex Gildayc357c472018-03-21 13:54:09 +0000499/** Formatted output of the activation function info type.
500 *
501 * @param[in] info Type to output.
502 *
503 * @return Formatted string.
504 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100505inline std::string to_string(const arm_compute::ActivationLayerInfo &info)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100506{
507 std::stringstream str;
Isabella Gottardi3f217ec2018-02-12 14:59:19 +0000508 if(info.enabled())
509 {
510 str << info.activation();
511 }
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100512 return str.str();
513}
514
Alex Gildayc357c472018-03-21 13:54:09 +0000515/** Formatted output of the activation function type.
516 *
517 * @param[in] function Type to output.
518 *
519 * @return Formatted string.
520 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100521inline std::string to_string(const arm_compute::ActivationLayerInfo::ActivationFunction &function)
522{
523 std::stringstream str;
524 str << function;
525 return str.str();
526}
527
Alex Gildayc357c472018-03-21 13:54:09 +0000528/** Formatted output of the NormType type.
529 *
530 * @param[out] os Output stream.
531 * @param[in] norm_type Type to output.
532 *
533 * @return Modified output stream.
534 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100535inline ::std::ostream &operator<<(::std::ostream &os, const NormType &norm_type)
536{
537 switch(norm_type)
538 {
539 case NormType::CROSS_MAP:
540 os << "CROSS_MAP";
541 break;
542 case NormType::IN_MAP_1D:
543 os << "IN_MAP_1D";
544 break;
545 case NormType::IN_MAP_2D:
546 os << "IN_MAP_2D";
547 break;
548 default:
549 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
550 }
551
552 return os;
553}
554
Alex Gildayc357c472018-03-21 13:54:09 +0000555/** Formatted output of @ref NormalizationLayerInfo.
556 *
557 * @param[in] info Type to output.
558 *
559 * @return Formatted string.
560 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100561inline std::string to_string(const arm_compute::NormalizationLayerInfo &info)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100562{
563 std::stringstream str;
Michalis Spyroud466c2d2018-01-30 10:54:39 +0000564 str << info.type() << ":NormSize=" << info.norm_size();
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100565 return str.str();
566}
567
Alex Gildayc357c472018-03-21 13:54:09 +0000568/** Formatted output of @ref NormalizationLayerInfo.
569 *
570 * @param[out] os Output stream.
571 * @param[in] info Type to output.
572 *
573 * @return Modified output stream.
574 */
Georgios Pinitas6f669f02017-09-26 12:32:57 +0100575inline ::std::ostream &operator<<(::std::ostream &os, const NormalizationLayerInfo &info)
576{
Michalis Spyroud466c2d2018-01-30 10:54:39 +0000577 os << info.type() << ":NormSize=" << info.norm_size();
Georgios Pinitas6f669f02017-09-26 12:32:57 +0100578 return os;
579}
580
Alex Gildayc357c472018-03-21 13:54:09 +0000581/** Formatted output of the PoolingType type.
582 *
583 * @param[out] os Output stream.
584 * @param[in] pool_type Type to output.
585 *
586 * @return Modified output stream.
587 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100588inline ::std::ostream &operator<<(::std::ostream &os, const PoolingType &pool_type)
589{
590 switch(pool_type)
591 {
592 case PoolingType::AVG:
593 os << "AVG";
594 break;
595 case PoolingType::MAX:
596 os << "MAX";
597 break;
Georgios Pinitascdf51452017-08-31 14:21:36 +0100598 case PoolingType::L2:
599 os << "L2";
600 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100601 default:
602 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
603 }
604
605 return os;
606}
607
Alex Gildayc357c472018-03-21 13:54:09 +0000608/** Formatted output of @ref PoolingLayerInfo.
609 *
610 * @param[out] os Output stream.
611 * @param[in] info Type to output.
612 *
613 * @return Modified output stream.
614 */
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100615inline ::std::ostream &operator<<(::std::ostream &os, const PoolingLayerInfo &info)
616{
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +0000617 os << info.pool_type;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100618
619 return os;
620}
621
Alex Gildayc357c472018-03-21 13:54:09 +0000622/** Formatted output of @ref RoundingPolicy.
623 *
624 * @param[in] rounding_policy Type to output.
625 *
626 * @return Formatted string.
627 */
John Richardsondd715f22017-09-18 16:10:48 +0100628inline std::string to_string(const RoundingPolicy &rounding_policy)
629{
630 std::stringstream str;
631 str << rounding_policy;
632 return str.str();
633}
634
Vidhya Sudhan Loganathand646ae12018-11-19 15:18:20 +0000635/** [Print DataLayout type] **/
Alex Gildayc357c472018-03-21 13:54:09 +0000636/** Formatted output of the DataLayout type.
637 *
638 * @param[out] os Output stream.
639 * @param[in] data_layout Type to output.
640 *
641 * @return Modified output stream.
642 */
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000643inline ::std::ostream &operator<<(::std::ostream &os, const DataLayout &data_layout)
644{
645 switch(data_layout)
646 {
647 case DataLayout::UNKNOWN:
648 os << "UNKNOWN";
649 break;
650 case DataLayout::NHWC:
651 os << "NHWC";
652 break;
653 case DataLayout::NCHW:
654 os << "NCHW";
655 break;
656 default:
657 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
658 }
659
660 return os;
661}
662
Alex Gildayc357c472018-03-21 13:54:09 +0000663/** Formatted output of the DataLayout type.
664 *
665 * @param[in] data_layout Type to output.
666 *
667 * @return Formatted string.
668 */
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000669inline std::string to_string(const arm_compute::DataLayout &data_layout)
670{
671 std::stringstream str;
672 str << data_layout;
673 return str.str();
674}
Vidhya Sudhan Loganathand646ae12018-11-19 15:18:20 +0000675/** [Print DataLayout type] **/
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000676
Georgios Pinitase2220552018-07-20 13:23:44 +0100677/** Formatted output of the DataLayoutDimension type.
678 *
679 * @param[out] os Output stream.
680 * @param[in] data_layout_dim Data layout dimension to print.
681 *
682 * @return Modified output stream.
683 */
684inline ::std::ostream &operator<<(::std::ostream &os, const DataLayoutDimension &data_layout_dim)
685{
686 switch(data_layout_dim)
687 {
688 case DataLayoutDimension::WIDTH:
689 os << "WIDTH";
690 break;
691 case DataLayoutDimension::HEIGHT:
692 os << "HEIGHT";
693 break;
694 case DataLayoutDimension::CHANNEL:
695 os << "CHANNEL";
696 break;
697 case DataLayoutDimension::BATCHES:
698 os << "BATCHES";
699 break;
700 default:
701 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
702 }
703 return os;
704}
705
Alex Gildayc357c472018-03-21 13:54:09 +0000706/** Formatted output of the DataType type.
707 *
708 * @param[out] os Output stream.
709 * @param[in] data_type Type to output.
710 *
711 * @return Modified output stream.
712 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100713inline ::std::ostream &operator<<(::std::ostream &os, const DataType &data_type)
714{
715 switch(data_type)
716 {
717 case DataType::UNKNOWN:
718 os << "UNKNOWN";
719 break;
720 case DataType::U8:
721 os << "U8";
722 break;
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100723 case DataType::QSYMM8:
724 os << "QSYMM8";
725 break;
Chunosovd621bca2017-11-03 17:33:15 +0700726 case DataType::QASYMM8:
727 os << "QASYMM8";
728 break;
Georgios Pinitas448a81f2019-11-21 14:10:25 +0000729 case DataType::QASYMM8_SIGNED:
730 os << "QASYMM8_SIGNED";
731 break;
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100732 case DataType::QSYMM8_PER_CHANNEL:
733 os << "QSYMM8_PER_CHANNEL";
734 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100735 case DataType::S8:
736 os << "S8";
737 break;
738 case DataType::U16:
739 os << "U16";
740 break;
741 case DataType::S16:
742 os << "S16";
743 break;
Manuel Bottini3689fcd2019-06-14 17:18:12 +0100744 case DataType::QSYMM16:
745 os << "QSYMM16";
746 break;
Michele Di Giorgio35ea9a72019-08-23 12:02:06 +0100747 case DataType::QASYMM16:
748 os << "QASYMM16";
749 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100750 case DataType::U32:
751 os << "U32";
752 break;
753 case DataType::S32:
754 os << "S32";
755 break;
756 case DataType::U64:
757 os << "U64";
758 break;
759 case DataType::S64:
760 os << "S64";
761 break;
Georgios Pinitase8291ac2020-02-26 09:58:13 +0000762 case DataType::BFLOAT16:
763 os << "BFLOAT16";
764 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100765 case DataType::F16:
766 os << "F16";
767 break;
768 case DataType::F32:
769 os << "F32";
770 break;
771 case DataType::F64:
772 os << "F64";
773 break;
774 case DataType::SIZET:
775 os << "SIZET";
776 break;
777 default:
778 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
779 }
780
781 return os;
782}
783
Alex Gildayc357c472018-03-21 13:54:09 +0000784/** Formatted output of the DataType type.
785 *
786 * @param[in] data_type Type to output.
787 *
788 * @return Formatted string.
789 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100790inline std::string to_string(const arm_compute::DataType &data_type)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100791{
792 std::stringstream str;
793 str << data_type;
794 return str.str();
795}
796
Alex Gildayc357c472018-03-21 13:54:09 +0000797/** Formatted output of the Format type.
798 *
799 * @param[out] os Output stream.
800 * @param[in] format Type to output.
801 *
802 * @return Modified output stream.
803 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100804inline ::std::ostream &operator<<(::std::ostream &os, const Format &format)
805{
806 switch(format)
807 {
808 case Format::UNKNOWN:
809 os << "UNKNOWN";
810 break;
811 case Format::U8:
812 os << "U8";
813 break;
814 case Format::S16:
815 os << "S16";
816 break;
817 case Format::U16:
818 os << "U16";
819 break;
820 case Format::S32:
821 os << "S32";
822 break;
823 case Format::U32:
824 os << "U32";
825 break;
826 case Format::F16:
827 os << "F16";
828 break;
829 case Format::F32:
830 os << "F32";
831 break;
832 case Format::UV88:
833 os << "UV88";
834 break;
835 case Format::RGB888:
836 os << "RGB888";
837 break;
838 case Format::RGBA8888:
839 os << "RGBA8888";
840 break;
841 case Format::YUV444:
842 os << "YUV444";
843 break;
844 case Format::YUYV422:
845 os << "YUYV422";
846 break;
847 case Format::NV12:
848 os << "NV12";
849 break;
850 case Format::NV21:
851 os << "NV21";
852 break;
853 case Format::IYUV:
854 os << "IYUV";
855 break;
856 case Format::UYVY422:
857 os << "UYVY422";
858 break;
859 default:
860 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
861 }
862
863 return os;
864}
865
Alex Gildayc357c472018-03-21 13:54:09 +0000866/** Formatted output of the Format type.
867 *
868 * @param[in] format Type to output.
869 *
870 * @return Formatted string.
871 */
Moritz Pflanzer7655a672017-09-23 11:57:33 +0100872inline std::string to_string(const Format &format)
873{
874 std::stringstream str;
875 str << format;
876 return str.str();
877}
878
Alex Gildayc357c472018-03-21 13:54:09 +0000879/** Formatted output of the Channel type.
880 *
881 * @param[out] os Output stream.
882 * @param[in] channel Type to output.
883 *
884 * @return Modified output stream.
885 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100886inline ::std::ostream &operator<<(::std::ostream &os, const Channel &channel)
887{
888 switch(channel)
889 {
890 case Channel::UNKNOWN:
891 os << "UNKNOWN";
892 break;
893 case Channel::C0:
894 os << "C0";
895 break;
896 case Channel::C1:
897 os << "C1";
898 break;
899 case Channel::C2:
900 os << "C2";
901 break;
902 case Channel::C3:
903 os << "C3";
904 break;
905 case Channel::R:
906 os << "R";
907 break;
908 case Channel::G:
909 os << "G";
910 break;
911 case Channel::B:
912 os << "B";
913 break;
914 case Channel::A:
915 os << "A";
916 break;
917 case Channel::Y:
918 os << "Y";
919 break;
920 case Channel::U:
921 os << "U";
922 break;
923 case Channel::V:
924 os << "V";
925 break;
926 default:
927 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
928 }
929
930 return os;
931}
932
Alex Gildayc357c472018-03-21 13:54:09 +0000933/** Formatted output of the Channel type.
934 *
935 * @param[in] channel Type to output.
936 *
937 * @return Formatted string.
938 */
Ioan-Cristian Szabo9414f642017-10-27 17:35:40 +0100939inline std::string to_string(const Channel &channel)
940{
941 std::stringstream str;
942 str << channel;
943 return str.str();
944}
945
Alex Gildayc357c472018-03-21 13:54:09 +0000946/** Formatted output of the BorderMode type.
947 *
948 * @param[out] os Output stream.
949 * @param[in] mode Type to output.
950 *
951 * @return Modified output stream.
952 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100953inline ::std::ostream &operator<<(::std::ostream &os, const BorderMode &mode)
954{
955 switch(mode)
956 {
957 case BorderMode::UNDEFINED:
958 os << "UNDEFINED";
959 break;
960 case BorderMode::CONSTANT:
961 os << "CONSTANT";
962 break;
963 case BorderMode::REPLICATE:
964 os << "REPLICATE";
965 break;
966 default:
967 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
968 }
969
970 return os;
971}
972
Alex Gildayc357c472018-03-21 13:54:09 +0000973/** Formatted output of the BorderSize type.
974 *
975 * @param[out] os Output stream.
976 * @param[in] border Type to output.
977 *
978 * @return Modified output stream.
979 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100980inline ::std::ostream &operator<<(::std::ostream &os, const BorderSize &border)
981{
Moritz Pflanzerc87fbf82017-07-18 14:02:10 +0100982 os << border.top << ","
983 << border.right << ","
984 << border.bottom << ","
985 << border.left;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100986
987 return os;
988}
Anthony Barbier2a07e182017-08-04 18:20:27 +0100989
Giuseppe Rossinid7647d42018-07-17 18:13:13 +0100990/** Formatted output of the PaddingList type.
991 *
992 * @param[out] os Output stream.
993 * @param[in] padding Type to output.
994 *
995 * @return Modified output stream.
996 */
997inline ::std::ostream &operator<<(::std::ostream &os, const PaddingList &padding)
998{
999 os << "{";
1000 for(auto const &p : padding)
1001 {
1002 os << "{" << p.first << "," << p.second << "}";
1003 }
1004 os << "}";
1005 return os;
1006}
1007
giuros013175fcf2018-11-21 09:59:17 +00001008/** Formatted output of the Multiples type.
1009 *
1010 * @param[out] os Output stream.
1011 * @param[in] multiples Type to output.
1012 *
1013 * @return Modified output stream.
1014 */
1015inline ::std::ostream &operator<<(::std::ostream &os, const Multiples &multiples)
1016{
1017 os << "(";
1018 for(size_t i = 0; i < multiples.size() - 1; i++)
1019 {
1020 os << multiples[i] << ", ";
1021 }
1022 os << multiples.back() << ")";
1023 return os;
1024}
1025
Alex Gildayc357c472018-03-21 13:54:09 +00001026/** Formatted output of the InterpolationPolicy type.
1027 *
1028 * @param[out] os Output stream.
1029 * @param[in] policy Type to output.
1030 *
1031 * @return Modified output stream.
1032 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001033inline ::std::ostream &operator<<(::std::ostream &os, const InterpolationPolicy &policy)
1034{
1035 switch(policy)
1036 {
1037 case InterpolationPolicy::NEAREST_NEIGHBOR:
1038 os << "NEAREST_NEIGHBOR";
1039 break;
1040 case InterpolationPolicy::BILINEAR:
1041 os << "BILINEAR";
1042 break;
1043 case InterpolationPolicy::AREA:
1044 os << "AREA";
1045 break;
1046 default:
1047 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1048 }
1049
1050 return os;
1051}
1052
Alex Gildayc357c472018-03-21 13:54:09 +00001053/** Formatted output of the SamplingPolicy type.
1054 *
1055 * @param[out] os Output stream.
1056 * @param[in] policy Type to output.
1057 *
1058 * @return Modified output stream.
1059 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +07001060inline ::std::ostream &operator<<(::std::ostream &os, const SamplingPolicy &policy)
1061{
1062 switch(policy)
1063 {
1064 case SamplingPolicy::CENTER:
1065 os << "CENTER";
1066 break;
1067 case SamplingPolicy::TOP_LEFT:
1068 os << "TOP_LEFT";
1069 break;
1070 default:
1071 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1072 }
1073
1074 return os;
1075}
1076
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001077/** Formatted output of the ITensorInfo type.
1078 *
1079 * @param[out] os Output stream.
1080 * @param[in] info Tensor information.
1081 *
1082 * @return Modified output stream.
1083 */
1084inline ::std::ostream &operator<<(std::ostream &os, const ITensorInfo *info)
1085{
1086 const DataType data_type = info->data_type();
1087 const DataLayout data_layout = info->data_layout();
1088
1089 os << "Shape=" << info->tensor_shape() << ","
1090 << "DataLayout=" << string_from_data_layout(data_layout) << ","
1091 << "DataType=" << string_from_data_type(data_type) << ",";
1092
1093 if(is_data_type_quantized(data_type))
1094 {
1095 const QuantizationInfo qinfo = info->quantization_info();
1096 os << "QuantizationInfo=";
1097 if(is_data_type_quantized_per_channel(data_type))
1098 {
1099 os << "[";
1100 const auto scales = qinfo.scale();
1101 const auto offsets = qinfo.offset();
1102 os << "(" << scales[0] << ", " << offsets[0] << ")";
1103 for(size_t i = 1; i < scales.size(); ++i)
1104 {
1105 os << ",(" << scales[i] << ", " << offsets[i] << ")";
1106 }
1107 os << "]";
1108 }
1109 else
1110 {
1111 os << "(" << qinfo.uniform().scale << ", "
1112 << qinfo.uniform().offset << ")";
1113 }
1114 }
1115 return os;
1116}
1117
Alex Gildayc357c472018-03-21 13:54:09 +00001118/** Formatted output of the TensorInfo type.
1119 *
Anthony Barbier366628a2018-08-01 13:55:03 +01001120 * @param[out] os Output stream.
1121 * @param[in] info Type to output.
1122 *
1123 * @return Modified output stream.
1124 */
1125inline ::std::ostream &operator<<(::std::ostream &os, const TensorInfo &info)
1126{
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001127 os << &info;
1128 return os;
Anthony Barbier366628a2018-08-01 13:55:03 +01001129}
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001130
Anthony Barbier366628a2018-08-01 13:55:03 +01001131/** Formatted output of the TensorInfo type.
1132 *
Alex Gildayc357c472018-03-21 13:54:09 +00001133 * @param[in] info Type to output.
1134 *
1135 * @return Formatted string.
1136 */
Georgios Pinitas3faea252017-10-30 14:13:50 +00001137inline std::string to_string(const TensorInfo &info)
1138{
1139 std::stringstream str;
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001140 str << &info;
Georgios Pinitas3faea252017-10-30 14:13:50 +00001141 return str.str();
1142}
1143
Alex Gildayc357c472018-03-21 13:54:09 +00001144/** Formatted output of the Dimensions type.
1145 *
1146 * @param[in] dimensions Type to output.
1147 *
1148 * @return Formatted string.
1149 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001150template <typename T>
1151inline std::string to_string(const Dimensions<T> &dimensions)
1152{
1153 std::stringstream str;
1154 str << dimensions;
1155 return str.str();
1156}
1157
Alex Gildayc357c472018-03-21 13:54:09 +00001158/** Formatted output of the Strides type.
1159 *
1160 * @param[in] stride Type to output.
1161 *
1162 * @return Formatted string.
1163 */
John Richardsona36eae12017-09-26 16:55:59 +01001164inline std::string to_string(const Strides &stride)
1165{
1166 std::stringstream str;
1167 str << stride;
1168 return str.str();
1169}
1170
Alex Gildayc357c472018-03-21 13:54:09 +00001171/** Formatted output of the TensorShape type.
1172 *
1173 * @param[in] shape Type to output.
1174 *
1175 * @return Formatted string.
1176 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001177inline std::string to_string(const TensorShape &shape)
1178{
1179 std::stringstream str;
1180 str << shape;
1181 return str.str();
1182}
1183
Alex Gildayc357c472018-03-21 13:54:09 +00001184/** Formatted output of the Coordinates type.
1185 *
1186 * @param[in] coord Type to output.
1187 *
1188 * @return Formatted string.
1189 */
Abe Mbise925ca0f2017-10-02 19:16:33 +01001190inline std::string to_string(const Coordinates &coord)
1191{
1192 std::stringstream str;
1193 str << coord;
1194 return str.str();
1195}
1196
Anthony Barbierb940fd62018-06-04 14:14:32 +01001197/** Formatted output of the GEMMReshapeInfo type.
1198 *
1199 * @param[out] os Output stream.
1200 * @param[in] info Type to output.
1201 *
1202 * @return Modified output stream.
1203 */
1204inline ::std::ostream &operator<<(::std::ostream &os, const GEMMReshapeInfo &info)
1205{
1206 os << "{m=" << info.m() << ",";
1207 os << "n=" << info.n() << ",";
1208 os << "k=" << info.k() << ",";
1209 os << "mult_transpose1xW_width=" << info.mult_transpose1xW_width() << ",";
1210 os << "mult_interleave4x4_height=" << info.mult_interleave4x4_height();
1211 os << "}";
1212
1213 return os;
1214}
1215
1216/** Formatted output of the GEMMInfo type.
1217 *
1218 * @param[out] os Output stream.
1219 * @param[in] info Type to output.
1220 *
1221 * @return Modified output stream.
1222 */
1223inline ::std::ostream &operator<<(::std::ostream &os, const GEMMInfo &info)
1224{
1225 os << "{is_a_reshaped=" << info.is_a_reshaped() << ",";
1226 os << "is_b_reshaped=" << info.is_b_reshaped() << ",";
1227 os << "reshape_b_only_on_first_run=" << info.reshape_b_only_on_first_run() << ",";
Anthony Barbierb4670212018-05-18 16:55:39 +01001228 os << "depth_output_gemm3d=" << info.depth_output_gemm3d() << ",";
1229 os << "reinterpret_input_as_3d=" << info.reinterpret_input_as_3d() << ",";
1230 os << "retain_internal_weights=" << info.retain_internal_weights() << ",";
1231 os << "fp_mixed_precision=" << info.fp_mixed_precision() << ",";
1232 os << "broadcast_bias=" << info.broadcast_bias() << ",";
1233 os << "pretranpose_B=" << info.pretranpose_B() << ",";
Anthony Barbierb940fd62018-06-04 14:14:32 +01001234
1235 return os;
1236}
1237
1238/** Formatted output of the Window::Dimension type.
1239 *
1240 * @param[out] os Output stream.
1241 * @param[in] dim Type to output.
1242 *
1243 * @return Modified output stream.
1244 */
1245inline ::std::ostream &operator<<(::std::ostream &os, const Window::Dimension &dim)
1246{
1247 os << "{start=" << dim.start() << ", end=" << dim.end() << ", step=" << dim.step() << "}";
1248
1249 return os;
1250}
1251/** Formatted output of the Window type.
1252 *
1253 * @param[out] os Output stream.
1254 * @param[in] win Type to output.
1255 *
1256 * @return Modified output stream.
1257 */
1258inline ::std::ostream &operator<<(::std::ostream &os, const Window &win)
1259{
1260 os << "{";
1261 for(unsigned int i = 0; i < Coordinates::num_max_dimensions; i++)
1262 {
1263 if(i > 0)
1264 {
1265 os << ", ";
1266 }
1267 os << win[i];
1268 }
1269 os << "}";
1270
1271 return os;
1272}
1273
1274/** Formatted output of the WeightsInfo type.
1275 *
1276 * @param[in] info Type to output.
1277 *
1278 * @return Formatted string.
1279 */
1280inline std::string to_string(const WeightsInfo &info)
1281{
1282 std::stringstream str;
1283 str << info;
1284 return str.str();
1285}
1286
1287/** Formatted output of the GEMMReshapeInfo type.
1288 *
1289 * @param[in] info Type to output.
1290 *
1291 * @return Formatted string.
1292 */
1293inline std::string to_string(const GEMMReshapeInfo &info)
1294{
1295 std::stringstream str;
1296 str << info;
1297 return str.str();
1298}
1299
1300/** Formatted output of the GEMMInfo type.
1301 *
1302 * @param[in] info Type to output.
1303 *
1304 * @return Formatted string.
1305 */
1306inline std::string to_string(const GEMMInfo &info)
1307{
1308 std::stringstream str;
1309 str << info;
1310 return str.str();
1311}
1312
1313/** Formatted output of the Window::Dimension type.
1314 *
1315 * @param[in] dim Type to output.
1316 *
1317 * @return Formatted string.
1318 */
1319inline std::string to_string(const Window::Dimension &dim)
1320{
1321 std::stringstream str;
1322 str << dim;
1323 return str.str();
1324}
1325/** Formatted output of the Window type.
1326 *
1327 * @param[in] win Type to output.
1328 *
1329 * @return Formatted string.
1330 */
1331inline std::string to_string(const Window &win)
1332{
1333 std::stringstream str;
1334 str << win;
1335 return str.str();
1336}
1337
Alex Gildayc357c472018-03-21 13:54:09 +00001338/** Formatted output of the Rectangle type.
1339 *
1340 * @param[out] os Output stream.
1341 * @param[in] rect Type to output.
1342 *
1343 * @return Modified output stream.
1344 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001345inline ::std::ostream &operator<<(::std::ostream &os, const Rectangle &rect)
1346{
1347 os << rect.width << "x" << rect.height;
1348 os << "+" << rect.x << "+" << rect.y;
1349
1350 return os;
1351}
1352
Usama Arif8cf8c112019-03-14 15:36:54 +00001353/** Formatted output of the PaddingMode type.
1354 *
1355 * @param[out] os Output stream.
1356 * @param[in] mode Type to output.
1357 *
1358 * @return Modified output stream.
1359 */
1360inline ::std::ostream &operator<<(::std::ostream &os, const PaddingMode &mode)
1361{
1362 switch(mode)
1363 {
1364 case PaddingMode::CONSTANT:
1365 os << "CONSTANT";
1366 break;
1367 case PaddingMode::REFLECT:
1368 os << "REFLECT";
1369 break;
1370 case PaddingMode::SYMMETRIC:
1371 os << "SYMMETRIC";
1372 break;
1373 default:
1374 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1375 }
1376
1377 return os;
1378}
1379
1380/** Formatted output of the PaddingMode type.
1381 *
1382 * @param[in] mode Type to output.
1383 *
1384 * @return Formatted string.
1385 */
1386inline std::string to_string(const PaddingMode &mode)
1387{
1388 std::stringstream str;
1389 str << mode;
1390 return str.str();
1391}
1392
Alex Gildayc357c472018-03-21 13:54:09 +00001393/** Formatted output of the PadStrideInfo type.
1394 *
1395 * @param[out] os Output stream.
1396 * @param[in] pad_stride_info Type to output.
1397 *
1398 * @return Modified output stream.
1399 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001400inline ::std::ostream &operator<<(::std::ostream &os, const PadStrideInfo &pad_stride_info)
1401{
1402 os << pad_stride_info.stride().first << "," << pad_stride_info.stride().second;
1403 os << ";";
Jaroslaw Rzepeckia1ed41f2017-10-13 11:13:58 +01001404 os << pad_stride_info.pad_left() << "," << pad_stride_info.pad_right() << ","
1405 << pad_stride_info.pad_top() << "," << pad_stride_info.pad_bottom();
Anthony Barbier2a07e182017-08-04 18:20:27 +01001406
1407 return os;
1408}
1409
Alex Gildayc357c472018-03-21 13:54:09 +00001410/** Formatted output of the PadStrideInfo type.
1411 *
1412 * @param[in] pad_stride_info Type to output.
1413 *
1414 * @return Formatted string.
1415 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001416inline std::string to_string(const PadStrideInfo &pad_stride_info)
1417{
1418 std::stringstream str;
1419 str << pad_stride_info;
1420 return str.str();
1421}
1422
Alex Gildayc357c472018-03-21 13:54:09 +00001423/** Formatted output of the BorderMode type.
1424 *
1425 * @param[in] mode Type to output.
1426 *
1427 * @return Formatted string.
1428 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001429inline std::string to_string(const BorderMode &mode)
1430{
1431 std::stringstream str;
1432 str << mode;
1433 return str.str();
1434}
1435
Alex Gildayc357c472018-03-21 13:54:09 +00001436/** Formatted output of the BorderSize type.
1437 *
1438 * @param[in] border Type to output.
1439 *
1440 * @return Formatted string.
1441 */
John Richardsonb482ce12017-09-18 12:44:01 +01001442inline std::string to_string(const BorderSize &border)
1443{
1444 std::stringstream str;
1445 str << border;
1446 return str.str();
1447}
1448
Giuseppe Rossinid7647d42018-07-17 18:13:13 +01001449/** Formatted output of the PaddingList type.
1450 *
1451 * @param[in] padding Type to output.
1452 *
1453 * @return Formatted string.
1454 */
1455inline std::string to_string(const PaddingList &padding)
1456{
1457 std::stringstream str;
1458 str << padding;
1459 return str.str();
1460}
1461
giuros013175fcf2018-11-21 09:59:17 +00001462/** Formatted output of the Multiples type.
1463 *
1464 * @param[in] multiples Type to output.
1465 *
1466 * @return Formatted string.
1467 */
1468inline std::string to_string(const Multiples &multiples)
1469{
1470 std::stringstream str;
1471 str << multiples;
1472 return str.str();
1473}
1474
Alex Gildayc357c472018-03-21 13:54:09 +00001475/** Formatted output of the InterpolationPolicy type.
1476 *
1477 * @param[in] policy Type to output.
1478 *
1479 * @return Formatted string.
1480 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001481inline std::string to_string(const InterpolationPolicy &policy)
1482{
1483 std::stringstream str;
1484 str << policy;
1485 return str.str();
1486}
1487
Alex Gildayc357c472018-03-21 13:54:09 +00001488/** Formatted output of the SamplingPolicy type.
1489 *
1490 * @param[in] policy Type to output.
1491 *
1492 * @return Formatted string.
1493 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +07001494inline std::string to_string(const SamplingPolicy &policy)
1495{
1496 std::stringstream str;
1497 str << policy;
1498 return str.str();
1499}
1500
Alex Gildayc357c472018-03-21 13:54:09 +00001501/** Formatted output of the ConvertPolicy type.
1502 *
1503 * @param[out] os Output stream.
1504 * @param[in] policy Type to output.
1505 *
1506 * @return Modified output stream.
1507 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001508inline ::std::ostream &operator<<(::std::ostream &os, const ConvertPolicy &policy)
1509{
1510 switch(policy)
1511 {
1512 case ConvertPolicy::WRAP:
1513 os << "WRAP";
1514 break;
1515 case ConvertPolicy::SATURATE:
1516 os << "SATURATE";
1517 break;
1518 default:
1519 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1520 }
1521
1522 return os;
1523}
1524
1525inline std::string to_string(const ConvertPolicy &policy)
1526{
1527 std::stringstream str;
1528 str << policy;
1529 return str.str();
1530}
1531
giuros01164a2722018-11-20 18:34:46 +00001532/** Formatted output of the ArithmeticOperation type.
1533 *
1534 * @param[out] os Output stream.
1535 * @param[in] op Operation to output.
1536 *
1537 * @return Modified output stream.
1538 */
1539inline ::std::ostream &operator<<(::std::ostream &os, const ArithmeticOperation &op)
1540{
1541 switch(op)
1542 {
1543 case ArithmeticOperation::ADD:
1544 os << "ADD";
1545 break;
1546 case ArithmeticOperation::SUB:
1547 os << "SUB";
1548 break;
1549 case ArithmeticOperation::DIV:
1550 os << "DIV";
1551 break;
1552 case ArithmeticOperation::MAX:
1553 os << "MAX";
1554 break;
1555 case ArithmeticOperation::MIN:
1556 os << "MIN";
1557 break;
1558 case ArithmeticOperation::SQUARED_DIFF:
1559 os << "SQUARED_DIFF";
1560 break;
Usama Arif52c54f62019-05-14 10:22:36 +01001561 case ArithmeticOperation::POWER:
1562 os << "POWER";
1563 break;
giuros01164a2722018-11-20 18:34:46 +00001564 default:
1565 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1566 }
1567
1568 return os;
1569}
1570
1571/** Formatted output of the Arithmetic Operation
1572 *
1573 * @param[in] op Type to output.
1574 *
1575 * @return Formatted string.
1576 */
1577inline std::string to_string(const ArithmeticOperation &op)
1578{
1579 std::stringstream str;
1580 str << op;
1581 return str.str();
1582}
1583
Alex Gildayc357c472018-03-21 13:54:09 +00001584/** Formatted output of the Reduction Operations.
1585 *
1586 * @param[out] os Output stream.
1587 * @param[in] op Type to output.
1588 *
1589 * @return Modified output stream.
1590 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001591inline ::std::ostream &operator<<(::std::ostream &os, const ReductionOperation &op)
1592{
1593 switch(op)
1594 {
Michalis Spyrou7e9391b2018-10-05 14:49:28 +01001595 case ReductionOperation::SUM:
1596 os << "SUM";
1597 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +01001598 case ReductionOperation::SUM_SQUARE:
1599 os << "SUM_SQUARE";
1600 break;
Michalis Spyrou7e9391b2018-10-05 14:49:28 +01001601 case ReductionOperation::MEAN_SUM:
1602 os << "MEAN_SUM";
1603 break;
Michalis Spyrou7930db42018-11-22 17:36:28 +00001604 case ReductionOperation::ARG_IDX_MAX:
1605 os << "ARG_IDX_MAX";
1606 break;
1607 case ReductionOperation::ARG_IDX_MIN:
1608 os << "ARG_IDX_MIN";
1609 break;
Manuel Bottinib412fab2018-12-10 17:40:23 +00001610 case ReductionOperation::PROD:
1611 os << "PROD";
1612 break;
Usama Arifa4a08ad2019-05-20 12:38:33 +01001613 case ReductionOperation::MIN:
1614 os << "MIN";
1615 break;
Usama Arif28f0dd92019-05-20 13:44:34 +01001616 case ReductionOperation::MAX:
1617 os << "MAX";
1618 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +01001619 default:
1620 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1621 }
1622
1623 return os;
1624}
1625
Alex Gildayc357c472018-03-21 13:54:09 +00001626/** Formatted output of the Reduction Operations.
1627 *
1628 * @param[in] op Type to output.
1629 *
1630 * @return Formatted string.
1631 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001632inline std::string to_string(const ReductionOperation &op)
1633{
1634 std::stringstream str;
1635 str << op;
1636 return str.str();
1637}
1638
Georgios Pinitas7900a9e2018-11-23 11:44:58 +00001639/** Formatted output of the Comparison Operations.
1640 *
1641 * @param[out] os Output stream.
1642 * @param[in] op Type to output.
1643 *
1644 * @return Modified output stream.
1645 */
1646inline ::std::ostream &operator<<(::std::ostream &os, const ComparisonOperation &op)
1647{
1648 switch(op)
1649 {
1650 case ComparisonOperation::Equal:
1651 os << "Equal";
1652 break;
1653 case ComparisonOperation::NotEqual:
1654 os << "NotEqual";
1655 break;
1656 case ComparisonOperation::Greater:
1657 os << "Greater";
1658 break;
1659 case ComparisonOperation::GreaterEqual:
1660 os << "GreaterEqual";
1661 break;
1662 case ComparisonOperation::Less:
1663 os << "Less";
1664 break;
1665 case ComparisonOperation::LessEqual:
1666 os << "LessEqual";
1667 break;
1668 default:
1669 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1670 }
1671
1672 return os;
1673}
1674
Michalis Spyroue9362622018-11-23 17:41:37 +00001675/** Formatted output of the Elementwise unary Operations.
1676 *
1677 * @param[out] os Output stream.
1678 * @param[in] op Type to output.
1679 *
1680 * @return Modified output stream.
1681 */
1682inline ::std::ostream &operator<<(::std::ostream &os, const ElementWiseUnary &op)
1683{
1684 switch(op)
1685 {
1686 case ElementWiseUnary::RSQRT:
1687 os << "RSQRT";
1688 break;
1689 case ElementWiseUnary::EXP:
1690 os << "EXP";
1691 break;
Usama Arifeb312ef2019-05-13 17:45:54 +01001692 case ElementWiseUnary::NEG:
1693 os << "NEG";
1694 break;
Usama Arifac33d7e2019-05-20 14:21:40 +01001695 case ElementWiseUnary::LOG:
1696 os << "LOG";
1697 break;
Usama Arif6a4d5422019-05-24 14:53:59 +01001698 case ElementWiseUnary::ROUND:
1699 os << "ROUND";
1700 break;
Michalis Spyroue9362622018-11-23 17:41:37 +00001701 default:
1702 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1703 }
1704
1705 return os;
1706}
1707
Georgios Pinitas7900a9e2018-11-23 11:44:58 +00001708/** Formatted output of the Comparison Operations.
1709 *
1710 * @param[in] op Type to output.
1711 *
1712 * @return Formatted string.
1713 */
1714inline std::string to_string(const ComparisonOperation &op)
1715{
1716 std::stringstream str;
1717 str << op;
1718 return str.str();
1719}
1720
Michalis Spyroue9362622018-11-23 17:41:37 +00001721/** Formatted output of the Elementwise unary Operations.
1722 *
1723 * @param[in] op Type to output.
1724 *
1725 * @return Formatted string.
1726 */
1727inline std::string to_string(const ElementWiseUnary &op)
1728{
1729 std::stringstream str;
1730 str << op;
1731 return str.str();
1732}
1733
Alex Gildayc357c472018-03-21 13:54:09 +00001734/** Formatted output of the Norm Type.
1735 *
1736 * @param[in] type Type to output.
1737 *
1738 * @return Formatted string.
1739 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001740inline std::string to_string(const NormType &type)
1741{
1742 std::stringstream str;
1743 str << type;
1744 return str.str();
1745}
1746
Alex Gildayc357c472018-03-21 13:54:09 +00001747/** Formatted output of the Pooling Type.
1748 *
1749 * @param[in] type Type to output.
1750 *
1751 * @return Formatted string.
1752 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001753inline std::string to_string(const PoolingType &type)
1754{
1755 std::stringstream str;
1756 str << type;
1757 return str.str();
1758}
1759
Alex Gildayc357c472018-03-21 13:54:09 +00001760/** Formatted output of the Pooling Layer Info.
1761 *
1762 * @param[in] info Type to output.
1763 *
1764 * @return Formatted string.
1765 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001766inline std::string to_string(const PoolingLayerInfo &info)
1767{
1768 std::stringstream str;
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +00001769 str << "{Type=" << info.pool_type << ","
Sang-Hoon Park11fedda2020-01-15 14:44:04 +00001770 << "DataLayout=" << info.data_layout << ","
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +00001771 << "IsGlobalPooling=" << info.is_global_pooling;
1772 if(!info.is_global_pooling)
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001773 {
1774 str << ","
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +00001775 << "PoolSize=" << info.pool_size.width << "," << info.pool_size.height << ","
1776 << "PadStride=" << info.pad_stride_info;
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001777 }
1778 str << "}";
Anthony Barbier2a07e182017-08-04 18:20:27 +01001779 return str.str();
1780}
1781
Michalis Spyrou6c7c38e2018-08-29 16:28:11 +01001782/** Formatted output of the PriorBoxLayerInfo.
1783 *
1784 * @param[in] info Type to output.
1785 *
1786 * @return Formatted string.
1787 */
1788inline std::string to_string(const PriorBoxLayerInfo &info)
1789{
1790 std::stringstream str;
1791 str << "{";
1792 str << "Clip:" << info.clip()
1793 << "Flip:" << info.flip()
1794 << "StepX:" << info.steps()[0]
1795 << "StepY:" << info.steps()[1]
1796 << "MinSizes:" << info.min_sizes().size()
1797 << "MaxSizes:" << info.max_sizes().size()
1798 << "ImgSizeX:" << info.img_size().x
1799 << "ImgSizeY:" << info.img_size().y
1800 << "Offset:" << info.offset()
1801 << "Variances:" << info.variances().size();
1802 str << "}";
1803 return str.str();
1804}
1805
Alex Gildayc357c472018-03-21 13:54:09 +00001806/** Formatted output of the KeyPoint type.
1807 *
1808 * @param[out] os Output stream
1809 * @param[in] point Type to output.
1810 *
1811 * @return Modified output stream.
1812 */
Moritz Pflanzer6c6597c2017-09-24 12:09:41 +01001813inline ::std::ostream &operator<<(::std::ostream &os, const KeyPoint &point)
1814{
1815 os << "{x=" << point.x << ","
1816 << "y=" << point.y << ","
1817 << "strength=" << point.strength << ","
1818 << "scale=" << point.scale << ","
1819 << "orientation=" << point.orientation << ","
1820 << "tracking_status=" << point.tracking_status << ","
1821 << "error=" << point.error << "}";
1822
1823 return os;
1824}
John Richardson63e50412017-10-13 20:51:42 +01001825
Alex Gildayc357c472018-03-21 13:54:09 +00001826/** Formatted output of the PhaseType type.
1827 *
1828 * @param[out] os Output stream
1829 * @param[in] phase_type Type to output.
1830 *
1831 * @return Modified output stream.
1832 */
John Richardson63e50412017-10-13 20:51:42 +01001833inline ::std::ostream &operator<<(::std::ostream &os, const PhaseType &phase_type)
1834{
1835 switch(phase_type)
1836 {
1837 case PhaseType::SIGNED:
1838 os << "SIGNED";
1839 break;
1840 case PhaseType::UNSIGNED:
1841 os << "UNSIGNED";
1842 break;
1843 default:
1844 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1845 }
1846
1847 return os;
1848}
1849
Alex Gildayc357c472018-03-21 13:54:09 +00001850/** Formatted output of the PhaseType type.
1851 *
1852 * @param[in] type Type to output.
1853 *
1854 * @return Formatted string.
1855 */
John Richardson63e50412017-10-13 20:51:42 +01001856inline std::string to_string(const arm_compute::PhaseType &type)
1857{
1858 std::stringstream str;
1859 str << type;
1860 return str.str();
1861}
John Richardson3c5f9492017-10-04 15:27:37 +01001862
Alex Gildayc357c472018-03-21 13:54:09 +00001863/** Formatted output of the MagnitudeType type.
1864 *
1865 * @param[out] os Output stream
1866 * @param[in] magnitude_type Type to output.
1867 *
1868 * @return Modified output stream.
1869 */
John Richardson3c5f9492017-10-04 15:27:37 +01001870inline ::std::ostream &operator<<(::std::ostream &os, const MagnitudeType &magnitude_type)
1871{
1872 switch(magnitude_type)
1873 {
1874 case MagnitudeType::L1NORM:
1875 os << "L1NORM";
1876 break;
1877 case MagnitudeType::L2NORM:
1878 os << "L2NORM";
1879 break;
1880 default:
1881 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1882 }
1883
1884 return os;
1885}
1886
Alex Gildayc357c472018-03-21 13:54:09 +00001887/** Formatted output of the MagnitudeType type.
1888 *
1889 * @param[in] type Type to output.
1890 *
1891 * @return Formatted string.
1892 */
John Richardson3c5f9492017-10-04 15:27:37 +01001893inline std::string to_string(const arm_compute::MagnitudeType &type)
1894{
1895 std::stringstream str;
1896 str << type;
1897 return str.str();
1898}
John Richardson1c529922017-11-01 10:57:48 +00001899
Alex Gildayc357c472018-03-21 13:54:09 +00001900/** Formatted output of the HOGNormType type.
1901 *
1902 * @param[out] os Output stream
1903 * @param[in] norm_type Type to output
1904 *
1905 * @return Modified output stream.
1906 */
John Richardson25f23682017-11-27 14:35:09 +00001907inline ::std::ostream &operator<<(::std::ostream &os, const HOGNormType &norm_type)
1908{
1909 switch(norm_type)
1910 {
1911 case HOGNormType::L1_NORM:
1912 os << "L1_NORM";
1913 break;
1914 case HOGNormType::L2_NORM:
1915 os << "L2_NORM";
1916 break;
1917 case HOGNormType::L2HYS_NORM:
1918 os << "L2HYS_NORM";
1919 break;
1920 default:
1921 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1922 }
1923
1924 return os;
1925}
1926
Alex Gildayc357c472018-03-21 13:54:09 +00001927/** Formatted output of the HOGNormType type.
1928 *
1929 * @param[in] type Type to output
1930 *
1931 * @return Formatted string.
1932 */
John Richardson25f23682017-11-27 14:35:09 +00001933inline std::string to_string(const HOGNormType &type)
1934{
1935 std::stringstream str;
1936 str << type;
1937 return str.str();
1938}
1939
Alex Gildayc357c472018-03-21 13:54:09 +00001940/** Formatted output of the Size2D type.
1941 *
1942 * @param[out] os Output stream
1943 * @param[in] size Type to output
1944 *
1945 * @return Modified output stream.
1946 */
John Richardson25f23682017-11-27 14:35:09 +00001947inline ::std::ostream &operator<<(::std::ostream &os, const Size2D &size)
1948{
1949 os << size.width << "x" << size.height;
1950
1951 return os;
1952}
1953
Alex Gildayc357c472018-03-21 13:54:09 +00001954/** Formatted output of the Size2D type.
1955 *
1956 * @param[in] type Type to output
1957 *
1958 * @return Formatted string.
1959 */
John Richardson25f23682017-11-27 14:35:09 +00001960inline std::string to_string(const Size2D &type)
1961{
1962 std::stringstream str;
1963 str << type;
1964 return str.str();
1965}
1966
Alex Gildayc357c472018-03-21 13:54:09 +00001967/** Formatted output of the HOGInfo type.
1968 *
1969 * @param[out] os Output stream
1970 * @param[in] hog_info Type to output
1971 *
1972 * @return Modified output stream.
1973 */
John Richardson25f23682017-11-27 14:35:09 +00001974inline ::std::ostream &operator<<(::std::ostream &os, const HOGInfo &hog_info)
1975{
1976 os << "{CellSize=" << hog_info.cell_size() << ","
1977 << "BlockSize=" << hog_info.block_size() << ","
1978 << "DetectionWindowSize=" << hog_info.detection_window_size() << ","
1979 << "BlockStride=" << hog_info.block_stride() << ","
1980 << "NumBins=" << hog_info.num_bins() << ","
1981 << "NormType=" << hog_info.normalization_type() << ","
1982 << "L2HystThreshold=" << hog_info.l2_hyst_threshold() << ","
1983 << "PhaseType=" << hog_info.phase_type() << "}";
1984
1985 return os;
1986}
1987
Alex Gildayc357c472018-03-21 13:54:09 +00001988/** Formatted output of the HOGInfo type.
1989 *
1990 * @param[in] type Type to output
1991 *
1992 * @return Formatted string.
1993 */
John Richardson25f23682017-11-27 14:35:09 +00001994inline std::string to_string(const HOGInfo &type)
1995{
1996 std::stringstream str;
1997 str << type;
1998 return str.str();
1999}
2000
Alex Gildayc357c472018-03-21 13:54:09 +00002001/** Formatted output of the ConvolutionMethod type.
2002 *
2003 * @param[out] os Output stream
2004 * @param[in] conv_method Type to output
2005 *
2006 * @return Modified output stream.
2007 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002008inline ::std::ostream &operator<<(::std::ostream &os, const ConvolutionMethod &conv_method)
2009{
2010 switch(conv_method)
2011 {
2012 case ConvolutionMethod::GEMM:
2013 os << "GEMM";
2014 break;
2015 case ConvolutionMethod::DIRECT:
2016 os << "DIRECT";
2017 break;
2018 case ConvolutionMethod::WINOGRAD:
2019 os << "WINOGRAD";
2020 break;
2021 default:
2022 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2023 }
2024
2025 return os;
2026}
2027
Alex Gildayc357c472018-03-21 13:54:09 +00002028/** Formatted output of the ConvolutionMethod type.
2029 *
2030 * @param[in] conv_method Type to output
2031 *
2032 * @return Formatted string.
2033 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002034inline std::string to_string(const ConvolutionMethod &conv_method)
2035{
2036 std::stringstream str;
2037 str << conv_method;
2038 return str.str();
2039}
2040
Alex Gildayc357c472018-03-21 13:54:09 +00002041/** Formatted output of the GPUTarget type.
2042 *
2043 * @param[out] os Output stream
2044 * @param[in] gpu_target Type to output
2045 *
2046 * @return Modified output stream.
2047 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002048inline ::std::ostream &operator<<(::std::ostream &os, const GPUTarget &gpu_target)
2049{
2050 switch(gpu_target)
2051 {
2052 case GPUTarget::GPU_ARCH_MASK:
2053 os << "GPU_ARCH_MASK";
2054 break;
2055 case GPUTarget::MIDGARD:
2056 os << "MIDGARD";
2057 break;
2058 case GPUTarget::BIFROST:
2059 os << "BIFROST";
2060 break;
Georgios Pinitasd5462ff2019-07-03 19:33:57 +01002061 case GPUTarget::VALHALL:
2062 os << "VALHALL";
2063 break;
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002064 case GPUTarget::T600:
2065 os << "T600";
2066 break;
2067 case GPUTarget::T700:
2068 os << "T700";
2069 break;
2070 case GPUTarget::T800:
2071 os << "T800";
2072 break;
Michalis Spyroua9676112018-02-22 18:07:43 +00002073 case GPUTarget::G71:
2074 os << "G71";
2075 break;
2076 case GPUTarget::G72:
2077 os << "G72";
2078 break;
2079 case GPUTarget::G51:
2080 os << "G51";
2081 break;
2082 case GPUTarget::G51BIG:
2083 os << "G51BIG";
2084 break;
2085 case GPUTarget::G51LIT:
2086 os << "G51LIT";
2087 break;
Georgios Pinitasb03f7c52018-07-12 10:49:53 +01002088 case GPUTarget::G76:
2089 os << "G76";
Michalis Spyroua9676112018-02-22 18:07:43 +00002090 break;
Georgios Pinitasd5462ff2019-07-03 19:33:57 +01002091 case GPUTarget::G77:
2092 os << "G77";
Michalis Spyroua9676112018-02-22 18:07:43 +00002093 break;
Georgios Pinitas4ffc42a2020-12-01 16:28:24 +00002094 case GPUTarget::G78:
2095 os << "G78";
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002096 break;
Georgios Pinitasd5462ff2019-07-03 19:33:57 +01002097 case GPUTarget::TODX:
2098 os << "TODX";
2099 break;
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002100 default:
2101 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2102 }
2103
2104 return os;
2105}
2106
Alex Gildayc357c472018-03-21 13:54:09 +00002107/** Formatted output of the GPUTarget type.
2108 *
2109 * @param[in] gpu_target Type to output
2110 *
2111 * @return Formatted string.
2112 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002113inline std::string to_string(const GPUTarget &gpu_target)
2114{
2115 std::stringstream str;
2116 str << gpu_target;
2117 return str.str();
2118}
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00002119
John Richardson8de92612018-02-22 14:09:31 +00002120/** Formatted output of the DetectionWindow type.
2121 *
2122 * @param[out] os Output stream
2123 * @param[in] detection_window Type to output
2124 *
2125 * @return Modified output stream.
2126 */
John Richardson684cb0f2018-01-09 11:17:00 +00002127inline ::std::ostream &operator<<(::std::ostream &os, const DetectionWindow &detection_window)
2128{
2129 os << "{x=" << detection_window.x << ","
2130 << "y=" << detection_window.y << ","
2131 << "width=" << detection_window.width << ","
2132 << "height=" << detection_window.height << ","
2133 << "idx_class=" << detection_window.idx_class << ","
2134 << "score=" << detection_window.score << "}";
2135
2136 return os;
2137}
2138
Isabella Gottardi05e56442018-11-16 11:26:52 +00002139/** Formatted output of the DetectionOutputLayerCodeType type.
2140 *
2141 * @param[out] os Output stream
2142 * @param[in] detection_code Type to output
2143 *
2144 * @return Modified output stream.
2145 */
2146inline ::std::ostream &operator<<(::std::ostream &os, const DetectionOutputLayerCodeType &detection_code)
2147{
2148 switch(detection_code)
2149 {
2150 case DetectionOutputLayerCodeType::CENTER_SIZE:
2151 os << "CENTER_SIZE";
2152 break;
2153 case DetectionOutputLayerCodeType::CORNER:
2154 os << "CORNER";
2155 break;
2156 case DetectionOutputLayerCodeType::CORNER_SIZE:
2157 os << "CORNER_SIZE";
2158 break;
2159 case DetectionOutputLayerCodeType::TF_CENTER:
2160 os << "TF_CENTER";
2161 break;
2162 default:
2163 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2164 }
2165
2166 return os;
2167}
2168/** Formatted output of the DetectionOutputLayerCodeType type.
2169 *
2170 * @param[in] detection_code Type to output
2171 *
2172 * @return Formatted string.
2173 */
2174inline std::string to_string(const DetectionOutputLayerCodeType &detection_code)
2175{
2176 std::stringstream str;
2177 str << detection_code;
2178 return str.str();
2179}
2180
2181/** Formatted output of the DetectionOutputLayerInfo type.
2182 *
2183 * @param[out] os Output stream
2184 * @param[in] detection_info Type to output
2185 *
2186 * @return Modified output stream.
2187 */
2188inline ::std::ostream &operator<<(::std::ostream &os, const DetectionOutputLayerInfo &detection_info)
2189{
2190 os << "{Classes=" << detection_info.num_classes() << ","
2191 << "ShareLocation=" << detection_info.share_location() << ","
2192 << "CodeType=" << detection_info.code_type() << ","
2193 << "VarianceEncodedInTarget=" << detection_info.variance_encoded_in_target() << ","
2194 << "KeepTopK=" << detection_info.keep_top_k() << ","
2195 << "NMSThreshold=" << detection_info.nms_threshold() << ","
2196 << "Eta=" << detection_info.eta() << ","
2197 << "BackgroundLabelId=" << detection_info.background_label_id() << ","
2198 << "ConfidenceThreshold=" << detection_info.confidence_threshold() << ","
2199 << "TopK=" << detection_info.top_k() << ","
2200 << "NumLocClasses=" << detection_info.num_loc_classes()
2201 << "}";
2202
2203 return os;
2204}
2205
2206/** Formatted output of the DetectionOutputLayerInfo type.
2207 *
2208 * @param[in] detection_info Type to output
2209 *
2210 * @return Formatted string.
2211 */
2212inline std::string to_string(const DetectionOutputLayerInfo &detection_info)
2213{
2214 std::stringstream str;
2215 str << detection_info;
2216 return str.str();
2217}
Isabella Gottardia7acb3c2019-01-08 13:48:44 +00002218/** Formatted output of the DetectionPostProcessLayerInfo type.
2219 *
2220 * @param[out] os Output stream
2221 * @param[in] detection_info Type to output
2222 *
2223 * @return Modified output stream.
2224 */
2225inline ::std::ostream &operator<<(::std::ostream &os, const DetectionPostProcessLayerInfo &detection_info)
2226{
2227 os << "{MaxDetections=" << detection_info.max_detections() << ","
2228 << "MaxClassesPerDetection=" << detection_info.max_classes_per_detection() << ","
2229 << "NmsScoreThreshold=" << detection_info.nms_score_threshold() << ","
2230 << "NmsIouThreshold=" << detection_info.iou_threshold() << ","
2231 << "NumClasses=" << detection_info.num_classes() << ","
2232 << "ScaleValue_y=" << detection_info.scale_value_y() << ","
2233 << "ScaleValue_x=" << detection_info.scale_value_x() << ","
2234 << "ScaleValue_h=" << detection_info.scale_value_h() << ","
2235 << "ScaleValue_w=" << detection_info.scale_value_w() << ","
2236 << "UseRegularNms=" << detection_info.use_regular_nms() << ","
2237 << "DetectionPerClass=" << detection_info.detection_per_class()
2238 << "}";
2239
2240 return os;
2241}
2242
2243/** Formatted output of the DetectionPostProcessLayerInfo type.
2244 *
2245 * @param[in] detection_info Type to output
2246 *
2247 * @return Formatted string.
2248 */
2249inline std::string to_string(const DetectionPostProcessLayerInfo &detection_info)
2250{
2251 std::stringstream str;
2252 str << detection_info;
2253 return str.str();
2254}
John Richardson8de92612018-02-22 14:09:31 +00002255/** Formatted output of the DetectionWindow type.
2256 *
2257 * @param[in] detection_window Type to output
2258 *
2259 * @return Formatted string.
2260 */
2261inline std::string to_string(const DetectionWindow &detection_window)
2262{
2263 std::stringstream str;
2264 str << detection_window;
2265 return str.str();
2266}
2267
2268/** Formatted output of the Termination type.
2269 *
2270 * @param[out] os Output stream
2271 * @param[in] termination Type to output
2272 *
2273 * @return Modified output stream.
2274 */
2275inline ::std::ostream &operator<<(::std::ostream &os, const Termination &termination)
2276{
2277 switch(termination)
2278 {
2279 case Termination::TERM_CRITERIA_EPSILON:
2280 os << "TERM_CRITERIA_EPSILON";
2281 break;
2282 case Termination::TERM_CRITERIA_ITERATIONS:
2283 os << "TERM_CRITERIA_ITERATIONS";
2284 break;
2285 case Termination::TERM_CRITERIA_BOTH:
2286 os << "TERM_CRITERIA_BOTH";
2287 break;
2288 default:
2289 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2290 }
2291
2292 return os;
2293}
2294
2295/** Formatted output of the Termination type.
2296 *
2297 * @param[in] termination Type to output
2298 *
2299 * @return Formatted string.
2300 */
2301inline std::string to_string(const Termination &termination)
2302{
2303 std::stringstream str;
2304 str << termination;
2305 return str.str();
2306}
2307
Anthony Barbier8914e322018-08-10 15:28:25 +01002308/** Formatted output of the CPUModel type.
2309 *
2310 * @param[out] os Output stream
2311 * @param[in] cpu_model Model to output
2312 *
2313 * @return Modified output stream.
2314 */
2315inline ::std::ostream &operator<<(::std::ostream &os, const CPUModel &cpu_model)
2316{
2317 switch(cpu_model)
2318 {
2319 case CPUModel::GENERIC:
2320 os << "GENERIC";
2321 break;
2322 case CPUModel::GENERIC_FP16:
2323 os << "GENERIC_FP16";
2324 break;
2325 case CPUModel::GENERIC_FP16_DOT:
2326 os << "GENERIC_FP16_DOT";
2327 break;
2328 case CPUModel::A53:
2329 os << "A53";
2330 break;
2331 case CPUModel::A55r0:
2332 os << "A55r0";
2333 break;
2334 case CPUModel::A55r1:
2335 os << "A55r1";
2336 break;
David Mansell318c9f42020-07-08 13:28:45 +01002337 case CPUModel::A73:
2338 os << "A73";
2339 break;
2340 case CPUModel::X1:
2341 os << "X1";
2342 break;
Anthony Barbier8914e322018-08-10 15:28:25 +01002343 default:
2344 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2345 }
2346
2347 return os;
2348}
2349
2350/** Formatted output of the CPUModel type.
2351 *
2352 * @param[in] cpu_model Model to output
2353 *
2354 * @return Formatted string.
2355 */
2356inline std::string to_string(const CPUModel &cpu_model)
2357{
2358 std::stringstream str;
2359 str << cpu_model;
2360 return str.str();
2361}
Anthony Barbier671a11e2018-07-06 15:11:36 +01002362/** Formatted output of a vector of objects.
2363 *
2364 * @param[out] os Output stream
2365 * @param[in] args Vector of objects to print
2366 *
2367 * @return Modified output stream.
2368 */
2369template <typename T>
2370inline ::std::ostream &operator<<(::std::ostream &os, const std::vector<T> &args)
2371{
2372 os << "[";
2373 bool first = true;
2374 for(auto &arg : args)
2375 {
2376 if(first)
2377 {
2378 first = false;
2379 }
2380 else
2381 {
2382 os << ", ";
2383 }
2384 os << arg;
2385 }
2386 os << "]";
2387 return os;
2388}
2389
Michalis Spyrou6c7c38e2018-08-29 16:28:11 +01002390/** Formatted output of @ref PriorBoxLayerInfo.
2391 *
2392 * @param[out] os Output stream.
2393 * @param[in] info Type to output.
2394 *
2395 * @return Modified output stream.
2396 */
2397inline ::std::ostream &operator<<(::std::ostream &os, const PriorBoxLayerInfo &info)
2398{
2399 os << "Clip:" << info.clip()
2400 << "Flip:" << info.flip()
2401 << "StepX:" << info.steps()[0]
2402 << "StepY:" << info.steps()[1]
2403 << "MinSizes:" << info.min_sizes()
2404 << "MaxSizes:" << info.max_sizes()
2405 << "ImgSizeX:" << info.img_size().x
2406 << "ImgSizeY:" << info.img_size().y
2407 << "Offset:" << info.offset()
2408 << "Variances:" << info.variances();
2409
2410 return os;
2411}
2412
Anthony Barbier671a11e2018-07-06 15:11:36 +01002413/** Formatted output of a vector of objects.
2414 *
2415 * @param[in] args Vector of objects to print
2416 *
2417 * @return String representing args.
2418 */
2419template <typename T>
2420std::string to_string(const std::vector<T> &args)
2421{
2422 std::stringstream str;
2423 str << args;
2424 return str.str();
2425}
2426
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00002427/** Formatted output of the WinogradInfo type. */
2428inline ::std::ostream &operator<<(::std::ostream &os, const WinogradInfo &info)
2429{
2430 os << "{OutputTileSize=" << info.output_tile_size << ","
2431 << "KernelSize=" << info.kernel_size << ","
2432 << "PadStride=" << info.convolution_info << ","
2433 << "OutputDataLayout=" << info.output_data_layout << "}";
2434
2435 return os;
2436}
2437
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00002438inline std::string to_string(const WinogradInfo &type)
2439{
2440 std::stringstream str;
2441 str << type;
2442 return str.str();
2443}
Anthony Barbier671a11e2018-07-06 15:11:36 +01002444
2445/** Fallback method: try to use std::to_string:
2446 *
2447 * @param[in] val Value to convert to string
2448 *
2449 * @return String representing val.
2450 */
2451template <typename T>
2452inline std::string to_string(const T &val)
2453{
2454 return support::cpp11::to_string(val);
2455}
2456
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +01002457/** Convert a CLTunerMode value to a string
2458 *
2459 * @param val CLTunerMode value to be converted
2460 *
2461 * @return String representing the corresponding CLTunerMode.
2462 */
2463inline std::string to_string(const CLTunerMode val)
2464{
2465 switch(val)
2466 {
2467 case CLTunerMode::EXHAUSTIVE:
2468 {
2469 return std::string("Exhaustive");
2470 }
2471 case CLTunerMode::NORMAL:
2472 {
2473 return std::string("Normal");
2474 }
2475 case CLTunerMode::RAPID:
2476 {
2477 return std::string("Rapid");
2478 }
2479 default:
2480 {
2481 ARM_COMPUTE_ERROR("Invalid tuner mode.");
2482 return std::string("UNDEFINED");
2483 }
2484 }
2485}
SiCong Lidb4a6c12021-02-05 09:30:57 +00002486/** Converts a @ref CLGEMMKernelType to string
2487 *
2488 * @param[in] val CLGEMMKernelType value to be converted
2489 *
2490 * @return String representing the corresponding CLGEMMKernelType
2491 */
2492inline std::string to_string(CLGEMMKernelType val)
2493{
2494 switch(val)
2495 {
2496 case CLGEMMKernelType::NATIVE_V1:
2497 {
2498 return "Native_V1";
2499 }
2500 case CLGEMMKernelType::RESHAPED_V1:
2501 {
2502 return "Reshaped_V1";
2503 }
2504 case CLGEMMKernelType::NATIVE:
2505 {
2506 return "Native";
2507 }
2508 case CLGEMMKernelType::RESHAPED_ONLY_RHS:
2509 {
2510 return "Reshaped_Only_RHS";
2511 }
2512 case CLGEMMKernelType::RESHAPED:
2513 {
2514 return "Reshaped";
2515 }
2516 default:
2517 {
2518 return "Unknown";
2519 }
2520 }
2521}
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +01002522/** [Print CLTunerMode type] **/
2523/** Formatted output of the CLTunerMode type.
2524 *
2525 * @param[out] os Output stream.
2526 * @param[in] val CLTunerMode to output.
2527 *
2528 * @return Modified output stream.
2529 */
2530inline ::std::ostream &operator<<(::std::ostream &os, const CLTunerMode &val)
2531{
2532 os << to_string(val);
2533 return os;
2534}
2535
Anthony Barbier6ff3b192017-09-04 18:44:23 +01002536} // namespace arm_compute
Anthony Barbier4dbc0a92018-08-27 13:39:47 +01002537
2538#endif /* __ARM_COMPUTE_TYPE_PRINTER_H__ */