blob: 58ddb3f7bfbcd5807928321897651a844d90bd9f [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
27#include "arm_compute/core/Dimensions.h"
28#include "arm_compute/core/Error.h"
Michele Di Giorgiob8fc60f2018-04-25 11:58:07 +010029#include "arm_compute/core/GPUTarget.h"
morgolockaba2f912020-05-05 16:28:19 +010030#include "arm_compute/core/KernelDescriptors.h"
John Richardson25f23682017-11-27 14:35:09 +000031#include "arm_compute/core/Size2D.h"
John Richardsona36eae12017-09-26 16:55:59 +010032#include "arm_compute/core/Strides.h"
Georgios Pinitas3faea252017-10-30 14:13:50 +000033#include "arm_compute/core/TensorInfo.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010034#include "arm_compute/core/Types.h"
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +010035#include "arm_compute/runtime/CL/CLTunerTypes.h"
SiCong Lidb4a6c12021-02-05 09:30:57 +000036#include "arm_compute/runtime/CL/CLTypes.h"
Matthew Bentham758b5ba2020-03-05 23:37:48 +000037#include "support/StringSupport.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010038
39#include <ostream>
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010040#include <sstream>
41#include <string>
Anthony Barbier6ff3b192017-09-04 18:44:23 +010042
43namespace arm_compute
44{
Anthony Barbierb940fd62018-06-04 14:14:32 +010045/** Formatted output if arg is not null
46 *
47 * @param[in] arg Object to print
48 *
49 * @return String representing arg.
50 */
51template <typename T>
52std::string to_string_if_not_null(T *arg)
53{
54 if(arg == nullptr)
55 {
56 return "nullptr";
57 }
58 else
59 {
60 return to_string(*arg);
61 }
62}
Anthony Barbierb4670212018-05-18 16:55:39 +010063
Alex Gildayc357c472018-03-21 13:54:09 +000064/** Formatted output of the Dimensions type.
65 *
66 * @param[out] os Output stream.
67 * @param[in] dimensions Type to output.
68 *
69 * @return Modified output stream.
70 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +010071template <typename T>
72inline ::std::ostream &operator<<(::std::ostream &os, const Dimensions<T> &dimensions)
73{
Anthony Barbier6ff3b192017-09-04 18:44:23 +010074 if(dimensions.num_dimensions() > 0)
75 {
76 os << dimensions[0];
77
78 for(unsigned int d = 1; d < dimensions.num_dimensions(); ++d)
79 {
Freddie Liardetdd23f2a2021-06-17 13:30:11 +010080 os << "," << dimensions[d];
Anthony Barbier6ff3b192017-09-04 18:44:23 +010081 }
82 }
83
Anthony Barbier6ff3b192017-09-04 18:44:23 +010084 return os;
85}
86
Alex Gildayc357c472018-03-21 13:54:09 +000087/** Formatted output of the RoundingPolicy type.
88 *
89 * @param[out] os Output stream.
90 * @param[in] rounding_policy Type to output.
91 *
92 * @return Modified output stream.
93 */
Anthony Barbier2a07e182017-08-04 18:20:27 +010094inline ::std::ostream &operator<<(::std::ostream &os, const RoundingPolicy &rounding_policy)
Anthony Barbier6ff3b192017-09-04 18:44:23 +010095{
Anthony Barbier2a07e182017-08-04 18:20:27 +010096 switch(rounding_policy)
Anthony Barbier6ff3b192017-09-04 18:44:23 +010097 {
Anthony Barbier2a07e182017-08-04 18:20:27 +010098 case RoundingPolicy::TO_ZERO:
99 os << "TO_ZERO";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100100 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100101 case RoundingPolicy::TO_NEAREST_UP:
102 os << "TO_NEAREST_UP";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100103 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100104 case RoundingPolicy::TO_NEAREST_EVEN:
105 os << "TO_NEAREST_EVEN";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100106 break;
107 default:
108 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
109 }
110
111 return os;
112}
113
Alex Gildayc357c472018-03-21 13:54:09 +0000114/** Formatted output of the WeightsInfo type.
115 *
116 * @param[out] os Output stream.
117 * @param[in] weights_info Type to output.
118 *
119 * @return Modified output stream.
120 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100121inline ::std::ostream &operator<<(::std::ostream &os, const WeightsInfo &weights_info)
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100122{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100123 os << weights_info.are_reshaped() << ";";
124 os << weights_info.num_kernels() << ";" << weights_info.kernel_size().first << "," << weights_info.kernel_size().second;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100125
126 return os;
127}
128
Alex Gildayc357c472018-03-21 13:54:09 +0000129/** Formatted output of the ROIPoolingInfo type.
130 *
131 * @param[out] os Output stream.
132 * @param[in] pool_info Type to output.
133 *
134 * @return Modified output stream.
135 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100136inline ::std::ostream &operator<<(::std::ostream &os, const ROIPoolingLayerInfo &pool_info)
Sanghoon Lee70f82912017-08-24 14:21:24 +0100137{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100138 os << pool_info.pooled_width() << "x" << pool_info.pooled_height() << "~" << pool_info.spatial_scale();
Georgios Pinitasd9769582017-08-03 10:19:40 +0100139 return os;
140}
141
giuros0118870812018-09-13 09:31:40 +0100142/** Formatted output of the ROIPoolingInfo type.
143 *
144 * @param[in] pool_info Type to output.
145 *
146 * @return Formatted string.
147 */
148inline std::string to_string(const ROIPoolingLayerInfo &pool_info)
149{
150 std::stringstream str;
151 str << pool_info;
152 return str.str();
153}
154
morgolockaba2f912020-05-05 16:28:19 +0100155/** Formatted output of the GEMMKernelInfo type.
156 *
157 * @param[out] os Output stream.
158 * @param[in] gemm_info Type to output.
159 *
160 * @return Modified output stream.
161 */
162inline ::std::ostream &operator<<(::std::ostream &os, const GEMMKernelInfo &gemm_info)
163{
164 os << "( m= " << gemm_info.m;
165 os << " n= " << gemm_info.n;
166 os << " k= " << gemm_info.k;
167 os << " depth_output_gemm3d= " << gemm_info.depth_output_gemm3d;
168 os << " reinterpret_input_as_3d= " << gemm_info.reinterpret_input_as_3d;
169 os << " broadcast_bias= " << gemm_info.broadcast_bias;
170 os << " fp_mixed_precision= " << gemm_info.fp_mixed_precision;
171 os << " mult_transpose1xW_width= " << gemm_info.mult_transpose1xW_width;
172 os << " mult_interleave4x4_height= " << gemm_info.mult_interleave4x4_height;
173 os << " a_offset = " << gemm_info.a_offset;
174 os << " b_offset = " << gemm_info.b_offset;
175 os << ")";
176 return os;
177}
178
179/** Formatted output of the GEMMLHSMatrixInfo type.
180 *
181 * @param[out] os Output stream.
182 * @param[in] gemm_info Type to output.
183 *
184 * @return Modified output stream.
185 */
186inline ::std::ostream &operator<<(::std::ostream &os, const GEMMLHSMatrixInfo &gemm_info)
187{
188 os << "( m0= " << (unsigned int)gemm_info.m0 << " k0= " << gemm_info.k0 << " v0= " << gemm_info.v0 << " trans= " << gemm_info.transpose << " inter= " << gemm_info.interleave << "})";
189 return os;
190}
191
192/** Formatted output of the GEMMRHSMatrixInfo type.
193 *
194 * @param[out] os Output stream.
195 * @param[in] gemm_info Type to output.
196 *
197 * @return Modified output stream.
198 */
199inline ::std::ostream &operator<<(::std::ostream &os, const GEMMRHSMatrixInfo &gemm_info)
200{
SiCong Lidb4a6c12021-02-05 09:30:57 +0000201 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=" <<
202 gemm_info.export_to_cl_image << "})";
morgolockaba2f912020-05-05 16:28:19 +0100203 return os;
204}
205
206/** Formatted output of the GEMMRHSMatrixInfo type.
207 *
208 * @param[in] gemm_info GEMMRHSMatrixInfo to output.
209 *
210 * @return Formatted string.
211 */
212inline std::string to_string(const GEMMRHSMatrixInfo &gemm_info)
213{
214 std::stringstream str;
215 str << gemm_info;
216 return str.str();
217}
218
219/** Formatted output of the GEMMLHSMatrixInfo type.
220 *
221 * @param[in] gemm_info GEMMLHSMatrixInfo to output.
222 *
223 * @return Formatted string.
224 */
225inline std::string to_string(const GEMMLHSMatrixInfo &gemm_info)
226{
227 std::stringstream str;
228 str << gemm_info;
229 return str.str();
230}
231
232/** Formatted output of the GEMMKernelInfo type.
233 *
234 * @param[in] gemm_info GEMMKernelInfo Type to output.
235 *
236 * @return Formatted string.
237 */
238inline std::string to_string(const GEMMKernelInfo &gemm_info)
239{
240 std::stringstream str;
241 str << gemm_info;
242 return str.str();
243}
244
giuros01c04a0e82018-10-03 12:44:35 +0100245/** Formatted output of the BoundingBoxTransformInfo type.
246 *
247 * @param[out] os Output stream.
248 * @param[in] bbox_info Type to output.
249 *
250 * @return Modified output stream.
251 */
252inline ::std::ostream &operator<<(::std::ostream &os, const BoundingBoxTransformInfo &bbox_info)
253{
254 auto weights = bbox_info.weights();
255 os << "(" << bbox_info.img_width() << "x" << bbox_info.img_height() << ")~" << bbox_info.scale() << "(weights = {" << weights[0] << ", " << weights[1] << ", " << weights[2] << ", " << weights[3] <<
256 "})";
257 return os;
258}
259
260/** Formatted output of the BoundingBoxTransformInfo type.
261 *
262 * @param[in] bbox_info Type to output.
263 *
264 * @return Formatted string.
265 */
266inline std::string to_string(const BoundingBoxTransformInfo &bbox_info)
267{
268 std::stringstream str;
269 str << bbox_info;
270 return str.str();
271}
272
Manuel Bottini5209be52019-02-13 16:34:56 +0000273/** Formatted output of the ComputeAnchorsInfo type.
274 *
275 * @param[out] os Output stream.
276 * @param[in] anchors_info Type to output.
277 *
278 * @return Modified output stream.
279 */
280inline ::std::ostream &operator<<(::std::ostream &os, const ComputeAnchorsInfo &anchors_info)
281{
282 os << "(" << anchors_info.feat_width() << "x" << anchors_info.feat_height() << ")~" << anchors_info.spatial_scale();
283 return os;
284}
285
286/** Formatted output of the ComputeAnchorsInfo type.
287 *
288 * @param[in] anchors_info Type to output.
289 *
290 * @return Formatted string.
291 */
292inline std::string to_string(const ComputeAnchorsInfo &anchors_info)
293{
294 std::stringstream str;
295 str << anchors_info;
296 return str.str();
297}
298
299/** Formatted output of the GenerateProposalsInfo type.
300 *
301 * @param[out] os Output stream.
302 * @param[in] proposals_info Type to output.
303 *
304 * @return Modified output stream.
305 */
306inline ::std::ostream &operator<<(::std::ostream &os, const GenerateProposalsInfo &proposals_info)
307{
308 os << "(" << proposals_info.im_width() << "x" << proposals_info.im_height() << ")~" << proposals_info.im_scale();
309 return os;
310}
311
312/** Formatted output of the GenerateProposalsInfo type.
313 *
314 * @param[in] proposals_info Type to output.
315 *
316 * @return Formatted string.
317 */
318inline std::string to_string(const GenerateProposalsInfo &proposals_info)
319{
320 std::stringstream str;
321 str << proposals_info;
322 return str.str();
323}
324
Alex Gildayc357c472018-03-21 13:54:09 +0000325/** Formatted output of the QuantizationInfo type.
326 *
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100327 * @param[out] os Output stream.
328 * @param[in] qinfo Type to output.
Alex Gildayc357c472018-03-21 13:54:09 +0000329 *
330 * @return Modified output stream.
331 */
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100332inline ::std::ostream &operator<<(::std::ostream &os, const QuantizationInfo &qinfo)
Chunosovd621bca2017-11-03 17:33:15 +0700333{
Georgios Pinitas3d13af82019-06-04 13:04:16 +0100334 const UniformQuantizationInfo uqinfo = qinfo.uniform();
335 os << "Scale:" << uqinfo.scale << "~";
336 os << "Offset:" << uqinfo.offset;
Chunosovd621bca2017-11-03 17:33:15 +0700337 return os;
338}
339
Alex Gildayc357c472018-03-21 13:54:09 +0000340/** Formatted output of the QuantizationInfo type.
341 *
342 * @param[in] quantization_info Type to output.
343 *
344 * @return Formatted string.
345 */
Chunosovd621bca2017-11-03 17:33:15 +0700346inline std::string to_string(const QuantizationInfo &quantization_info)
347{
348 std::stringstream str;
349 str << quantization_info;
350 return str.str();
351}
352
Alex Gildayc357c472018-03-21 13:54:09 +0000353/** Formatted output of the activation function type.
354 *
355 * @param[out] os Output stream.
356 * @param[in] act_function Type to output.
357 *
358 * @return Modified output stream.
359 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100360inline ::std::ostream &operator<<(::std::ostream &os, const ActivationLayerInfo::ActivationFunction &act_function)
361{
362 switch(act_function)
363 {
364 case ActivationLayerInfo::ActivationFunction::ABS:
365 os << "ABS";
366 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100367 case ActivationLayerInfo::ActivationFunction::LINEAR:
368 os << "LINEAR";
369 break;
370 case ActivationLayerInfo::ActivationFunction::LOGISTIC:
371 os << "LOGISTIC";
372 break;
373 case ActivationLayerInfo::ActivationFunction::RELU:
374 os << "RELU";
375 break;
Georgios Pinitas579c0492017-07-12 16:12:12 +0100376 case ActivationLayerInfo::ActivationFunction::BOUNDED_RELU:
377 os << "BOUNDED_RELU";
378 break;
379 case ActivationLayerInfo::ActivationFunction::LEAKY_RELU:
380 os << "LEAKY_RELU";
381 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100382 case ActivationLayerInfo::ActivationFunction::SOFT_RELU:
383 os << "SOFT_RELU";
384 break;
385 case ActivationLayerInfo::ActivationFunction::SQRT:
386 os << "SQRT";
387 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100388 case ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU:
389 os << "LU_BOUNDED_RELU";
Kevin Petitd9f80712017-12-06 12:18:48 +0000390 break;
Georgios Pinitasfb0fdcd2019-08-22 17:10:04 +0100391 case ActivationLayerInfo::ActivationFunction::ELU:
392 os << "ELU";
393 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100394 case ActivationLayerInfo::ActivationFunction::SQUARE:
395 os << "SQUARE";
396 break;
397 case ActivationLayerInfo::ActivationFunction::TANH:
398 os << "TANH";
399 break;
Usama Arif6a98a6e2019-05-10 17:07:27 +0100400 case ActivationLayerInfo::ActivationFunction::IDENTITY:
401 os << "IDENTITY";
402 break;
morgolock07df3d42020-02-27 11:46:28 +0000403 case ActivationLayerInfo::ActivationFunction::HARD_SWISH:
404 os << "HARD_SWISH";
405 break;
406
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100407 default:
408 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
409 }
410
411 return os;
412}
413
Alex Gildayc357c472018-03-21 13:54:09 +0000414/** Formatted output of the activation function info type.
415 *
416 * @param[in] info Type to output.
417 *
418 * @return Formatted string.
419 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100420inline std::string to_string(const arm_compute::ActivationLayerInfo &info)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100421{
422 std::stringstream str;
Isabella Gottardi3f217ec2018-02-12 14:59:19 +0000423 if(info.enabled())
424 {
425 str << info.activation();
426 }
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100427 return str.str();
428}
429
Alex Gildayc357c472018-03-21 13:54:09 +0000430/** Formatted output of the activation function type.
431 *
432 * @param[in] function Type to output.
433 *
434 * @return Formatted string.
435 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100436inline std::string to_string(const arm_compute::ActivationLayerInfo::ActivationFunction &function)
437{
438 std::stringstream str;
439 str << function;
440 return str.str();
441}
442
Alex Gildayc357c472018-03-21 13:54:09 +0000443/** Formatted output of the NormType type.
444 *
445 * @param[out] os Output stream.
446 * @param[in] norm_type Type to output.
447 *
448 * @return Modified output stream.
449 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100450inline ::std::ostream &operator<<(::std::ostream &os, const NormType &norm_type)
451{
452 switch(norm_type)
453 {
454 case NormType::CROSS_MAP:
455 os << "CROSS_MAP";
456 break;
457 case NormType::IN_MAP_1D:
458 os << "IN_MAP_1D";
459 break;
460 case NormType::IN_MAP_2D:
461 os << "IN_MAP_2D";
462 break;
463 default:
464 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
465 }
466
467 return os;
468}
469
Alex Gildayc357c472018-03-21 13:54:09 +0000470/** Formatted output of @ref NormalizationLayerInfo.
471 *
472 * @param[in] info Type to output.
473 *
474 * @return Formatted string.
475 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100476inline std::string to_string(const arm_compute::NormalizationLayerInfo &info)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100477{
478 std::stringstream str;
Michalis Spyroud466c2d2018-01-30 10:54:39 +0000479 str << info.type() << ":NormSize=" << info.norm_size();
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100480 return str.str();
481}
482
Alex Gildayc357c472018-03-21 13:54:09 +0000483/** Formatted output of @ref NormalizationLayerInfo.
484 *
485 * @param[out] os Output stream.
486 * @param[in] info Type to output.
487 *
488 * @return Modified output stream.
489 */
Georgios Pinitas6f669f02017-09-26 12:32:57 +0100490inline ::std::ostream &operator<<(::std::ostream &os, const NormalizationLayerInfo &info)
491{
Michalis Spyroud466c2d2018-01-30 10:54:39 +0000492 os << info.type() << ":NormSize=" << info.norm_size();
Georgios Pinitas6f669f02017-09-26 12:32:57 +0100493 return os;
494}
495
Alex Gildayc357c472018-03-21 13:54:09 +0000496/** Formatted output of the PoolingType type.
497 *
498 * @param[out] os Output stream.
499 * @param[in] pool_type Type to output.
500 *
501 * @return Modified output stream.
502 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100503inline ::std::ostream &operator<<(::std::ostream &os, const PoolingType &pool_type)
504{
505 switch(pool_type)
506 {
507 case PoolingType::AVG:
508 os << "AVG";
509 break;
510 case PoolingType::MAX:
511 os << "MAX";
512 break;
Georgios Pinitascdf51452017-08-31 14:21:36 +0100513 case PoolingType::L2:
514 os << "L2";
515 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100516 default:
517 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
518 }
519
520 return os;
521}
522
Alex Gildayc357c472018-03-21 13:54:09 +0000523/** Formatted output of @ref PoolingLayerInfo.
524 *
525 * @param[out] os Output stream.
526 * @param[in] info Type to output.
527 *
528 * @return Modified output stream.
529 */
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100530inline ::std::ostream &operator<<(::std::ostream &os, const PoolingLayerInfo &info)
531{
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +0000532 os << info.pool_type;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100533
534 return os;
535}
536
Alex Gildayc357c472018-03-21 13:54:09 +0000537/** Formatted output of @ref RoundingPolicy.
538 *
539 * @param[in] rounding_policy Type to output.
540 *
541 * @return Formatted string.
542 */
John Richardsondd715f22017-09-18 16:10:48 +0100543inline std::string to_string(const RoundingPolicy &rounding_policy)
544{
545 std::stringstream str;
546 str << rounding_policy;
547 return str.str();
548}
549
Vidhya Sudhan Loganathand646ae12018-11-19 15:18:20 +0000550/** [Print DataLayout type] **/
Alex Gildayc357c472018-03-21 13:54:09 +0000551/** Formatted output of the DataLayout type.
552 *
553 * @param[out] os Output stream.
554 * @param[in] data_layout Type to output.
555 *
556 * @return Modified output stream.
557 */
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000558inline ::std::ostream &operator<<(::std::ostream &os, const DataLayout &data_layout)
559{
560 switch(data_layout)
561 {
562 case DataLayout::UNKNOWN:
563 os << "UNKNOWN";
564 break;
565 case DataLayout::NHWC:
566 os << "NHWC";
567 break;
568 case DataLayout::NCHW:
569 os << "NCHW";
570 break;
571 default:
572 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
573 }
574
575 return os;
576}
577
Alex Gildayc357c472018-03-21 13:54:09 +0000578/** Formatted output of the DataLayout type.
579 *
580 * @param[in] data_layout Type to output.
581 *
582 * @return Formatted string.
583 */
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000584inline std::string to_string(const arm_compute::DataLayout &data_layout)
585{
586 std::stringstream str;
587 str << data_layout;
588 return str.str();
589}
Vidhya Sudhan Loganathand646ae12018-11-19 15:18:20 +0000590/** [Print DataLayout type] **/
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000591
Georgios Pinitase2220552018-07-20 13:23:44 +0100592/** Formatted output of the DataLayoutDimension type.
593 *
594 * @param[out] os Output stream.
595 * @param[in] data_layout_dim Data layout dimension to print.
596 *
597 * @return Modified output stream.
598 */
599inline ::std::ostream &operator<<(::std::ostream &os, const DataLayoutDimension &data_layout_dim)
600{
601 switch(data_layout_dim)
602 {
603 case DataLayoutDimension::WIDTH:
604 os << "WIDTH";
605 break;
606 case DataLayoutDimension::HEIGHT:
607 os << "HEIGHT";
608 break;
609 case DataLayoutDimension::CHANNEL:
610 os << "CHANNEL";
611 break;
612 case DataLayoutDimension::BATCHES:
613 os << "BATCHES";
614 break;
615 default:
616 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
617 }
618 return os;
619}
620
Alex Gildayc357c472018-03-21 13:54:09 +0000621/** Formatted output of the DataType type.
622 *
623 * @param[out] os Output stream.
624 * @param[in] data_type Type to output.
625 *
626 * @return Modified output stream.
627 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100628inline ::std::ostream &operator<<(::std::ostream &os, const DataType &data_type)
629{
630 switch(data_type)
631 {
632 case DataType::UNKNOWN:
633 os << "UNKNOWN";
634 break;
635 case DataType::U8:
636 os << "U8";
637 break;
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100638 case DataType::QSYMM8:
639 os << "QSYMM8";
640 break;
Chunosovd621bca2017-11-03 17:33:15 +0700641 case DataType::QASYMM8:
642 os << "QASYMM8";
643 break;
Georgios Pinitas448a81f2019-11-21 14:10:25 +0000644 case DataType::QASYMM8_SIGNED:
645 os << "QASYMM8_SIGNED";
646 break;
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100647 case DataType::QSYMM8_PER_CHANNEL:
648 os << "QSYMM8_PER_CHANNEL";
649 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100650 case DataType::S8:
651 os << "S8";
652 break;
653 case DataType::U16:
654 os << "U16";
655 break;
656 case DataType::S16:
657 os << "S16";
658 break;
Manuel Bottini3689fcd2019-06-14 17:18:12 +0100659 case DataType::QSYMM16:
660 os << "QSYMM16";
661 break;
Michele Di Giorgio35ea9a72019-08-23 12:02:06 +0100662 case DataType::QASYMM16:
663 os << "QASYMM16";
664 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100665 case DataType::U32:
666 os << "U32";
667 break;
668 case DataType::S32:
669 os << "S32";
670 break;
671 case DataType::U64:
672 os << "U64";
673 break;
674 case DataType::S64:
675 os << "S64";
676 break;
Georgios Pinitase8291ac2020-02-26 09:58:13 +0000677 case DataType::BFLOAT16:
678 os << "BFLOAT16";
679 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100680 case DataType::F16:
681 os << "F16";
682 break;
683 case DataType::F32:
684 os << "F32";
685 break;
686 case DataType::F64:
687 os << "F64";
688 break;
689 case DataType::SIZET:
690 os << "SIZET";
691 break;
692 default:
693 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
694 }
695
696 return os;
697}
698
Alex Gildayc357c472018-03-21 13:54:09 +0000699/** Formatted output of the DataType type.
700 *
701 * @param[in] data_type Type to output.
702 *
703 * @return Formatted string.
704 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100705inline std::string to_string(const arm_compute::DataType &data_type)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100706{
707 std::stringstream str;
708 str << data_type;
709 return str.str();
710}
711
Alex Gildayc357c472018-03-21 13:54:09 +0000712/** Formatted output of the Format type.
713 *
714 * @param[out] os Output stream.
715 * @param[in] format Type to output.
716 *
717 * @return Modified output stream.
718 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100719inline ::std::ostream &operator<<(::std::ostream &os, const Format &format)
720{
721 switch(format)
722 {
723 case Format::UNKNOWN:
724 os << "UNKNOWN";
725 break;
726 case Format::U8:
727 os << "U8";
728 break;
729 case Format::S16:
730 os << "S16";
731 break;
732 case Format::U16:
733 os << "U16";
734 break;
735 case Format::S32:
736 os << "S32";
737 break;
738 case Format::U32:
739 os << "U32";
740 break;
741 case Format::F16:
742 os << "F16";
743 break;
744 case Format::F32:
745 os << "F32";
746 break;
747 case Format::UV88:
748 os << "UV88";
749 break;
750 case Format::RGB888:
751 os << "RGB888";
752 break;
753 case Format::RGBA8888:
754 os << "RGBA8888";
755 break;
756 case Format::YUV444:
757 os << "YUV444";
758 break;
759 case Format::YUYV422:
760 os << "YUYV422";
761 break;
762 case Format::NV12:
763 os << "NV12";
764 break;
765 case Format::NV21:
766 os << "NV21";
767 break;
768 case Format::IYUV:
769 os << "IYUV";
770 break;
771 case Format::UYVY422:
772 os << "UYVY422";
773 break;
774 default:
775 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
776 }
777
778 return os;
779}
780
Alex Gildayc357c472018-03-21 13:54:09 +0000781/** Formatted output of the Format type.
782 *
783 * @param[in] format Type to output.
784 *
785 * @return Formatted string.
786 */
Moritz Pflanzer7655a672017-09-23 11:57:33 +0100787inline std::string to_string(const Format &format)
788{
789 std::stringstream str;
790 str << format;
791 return str.str();
792}
793
Alex Gildayc357c472018-03-21 13:54:09 +0000794/** Formatted output of the Channel type.
795 *
796 * @param[out] os Output stream.
797 * @param[in] channel Type to output.
798 *
799 * @return Modified output stream.
800 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100801inline ::std::ostream &operator<<(::std::ostream &os, const Channel &channel)
802{
803 switch(channel)
804 {
805 case Channel::UNKNOWN:
806 os << "UNKNOWN";
807 break;
808 case Channel::C0:
809 os << "C0";
810 break;
811 case Channel::C1:
812 os << "C1";
813 break;
814 case Channel::C2:
815 os << "C2";
816 break;
817 case Channel::C3:
818 os << "C3";
819 break;
820 case Channel::R:
821 os << "R";
822 break;
823 case Channel::G:
824 os << "G";
825 break;
826 case Channel::B:
827 os << "B";
828 break;
829 case Channel::A:
830 os << "A";
831 break;
832 case Channel::Y:
833 os << "Y";
834 break;
835 case Channel::U:
836 os << "U";
837 break;
838 case Channel::V:
839 os << "V";
840 break;
841 default:
842 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
843 }
844
845 return os;
846}
847
Alex Gildayc357c472018-03-21 13:54:09 +0000848/** Formatted output of the Channel type.
849 *
850 * @param[in] channel Type to output.
851 *
852 * @return Formatted string.
853 */
Ioan-Cristian Szabo9414f642017-10-27 17:35:40 +0100854inline std::string to_string(const Channel &channel)
855{
856 std::stringstream str;
857 str << channel;
858 return str.str();
859}
860
Alex Gildayc357c472018-03-21 13:54:09 +0000861/** Formatted output of the BorderMode type.
862 *
863 * @param[out] os Output stream.
864 * @param[in] mode Type to output.
865 *
866 * @return Modified output stream.
867 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100868inline ::std::ostream &operator<<(::std::ostream &os, const BorderMode &mode)
869{
870 switch(mode)
871 {
872 case BorderMode::UNDEFINED:
873 os << "UNDEFINED";
874 break;
875 case BorderMode::CONSTANT:
876 os << "CONSTANT";
877 break;
878 case BorderMode::REPLICATE:
879 os << "REPLICATE";
880 break;
881 default:
882 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
883 }
884
885 return os;
886}
887
Alex Gildayc357c472018-03-21 13:54:09 +0000888/** Formatted output of the BorderSize type.
889 *
890 * @param[out] os Output stream.
891 * @param[in] border Type to output.
892 *
893 * @return Modified output stream.
894 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100895inline ::std::ostream &operator<<(::std::ostream &os, const BorderSize &border)
896{
Moritz Pflanzerc87fbf82017-07-18 14:02:10 +0100897 os << border.top << ","
898 << border.right << ","
899 << border.bottom << ","
900 << border.left;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100901
902 return os;
903}
Anthony Barbier2a07e182017-08-04 18:20:27 +0100904
Giuseppe Rossinid7647d42018-07-17 18:13:13 +0100905/** Formatted output of the PaddingList type.
906 *
907 * @param[out] os Output stream.
908 * @param[in] padding Type to output.
909 *
910 * @return Modified output stream.
911 */
912inline ::std::ostream &operator<<(::std::ostream &os, const PaddingList &padding)
913{
914 os << "{";
915 for(auto const &p : padding)
916 {
917 os << "{" << p.first << "," << p.second << "}";
918 }
919 os << "}";
920 return os;
921}
922
giuros013175fcf2018-11-21 09:59:17 +0000923/** Formatted output of the Multiples type.
924 *
925 * @param[out] os Output stream.
926 * @param[in] multiples Type to output.
927 *
928 * @return Modified output stream.
929 */
930inline ::std::ostream &operator<<(::std::ostream &os, const Multiples &multiples)
931{
932 os << "(";
933 for(size_t i = 0; i < multiples.size() - 1; i++)
934 {
935 os << multiples[i] << ", ";
936 }
937 os << multiples.back() << ")";
938 return os;
939}
940
Alex Gildayc357c472018-03-21 13:54:09 +0000941/** Formatted output of the InterpolationPolicy type.
942 *
943 * @param[out] os Output stream.
944 * @param[in] policy Type to output.
945 *
946 * @return Modified output stream.
947 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100948inline ::std::ostream &operator<<(::std::ostream &os, const InterpolationPolicy &policy)
949{
950 switch(policy)
951 {
952 case InterpolationPolicy::NEAREST_NEIGHBOR:
953 os << "NEAREST_NEIGHBOR";
954 break;
955 case InterpolationPolicy::BILINEAR:
956 os << "BILINEAR";
957 break;
958 case InterpolationPolicy::AREA:
959 os << "AREA";
960 break;
961 default:
962 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
963 }
964
965 return os;
966}
967
Alex Gildayc357c472018-03-21 13:54:09 +0000968/** Formatted output of the SamplingPolicy type.
969 *
970 * @param[out] os Output stream.
971 * @param[in] policy Type to output.
972 *
973 * @return Modified output stream.
974 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700975inline ::std::ostream &operator<<(::std::ostream &os, const SamplingPolicy &policy)
976{
977 switch(policy)
978 {
979 case SamplingPolicy::CENTER:
980 os << "CENTER";
981 break;
982 case SamplingPolicy::TOP_LEFT:
983 os << "TOP_LEFT";
984 break;
985 default:
986 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
987 }
988
989 return os;
990}
991
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +0000992/** Formatted output of the ITensorInfo type.
993 *
994 * @param[out] os Output stream.
995 * @param[in] info Tensor information.
996 *
997 * @return Modified output stream.
998 */
999inline ::std::ostream &operator<<(std::ostream &os, const ITensorInfo *info)
1000{
Georgios Pinitasc6f95102021-03-30 10:03:01 +01001001 const DataType data_type = info->data_type();
1002 const DataLayout data_layout = info->data_layout();
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001003
1004 os << "Shape=" << info->tensor_shape() << ","
1005 << "DataLayout=" << string_from_data_layout(data_layout) << ","
1006 << "DataType=" << string_from_data_type(data_type) << ",";
1007
1008 if(is_data_type_quantized(data_type))
1009 {
1010 const QuantizationInfo qinfo = info->quantization_info();
1011 os << "QuantizationInfo=";
1012 if(is_data_type_quantized_per_channel(data_type))
1013 {
1014 os << "[";
1015 const auto scales = qinfo.scale();
1016 const auto offsets = qinfo.offset();
1017 os << "(" << scales[0] << ", " << offsets[0] << ")";
1018 for(size_t i = 1; i < scales.size(); ++i)
1019 {
1020 os << ",(" << scales[i] << ", " << offsets[i] << ")";
1021 }
1022 os << "]";
1023 }
1024 else
1025 {
1026 os << "(" << qinfo.uniform().scale << ", "
Georgios Pinitasc6f95102021-03-30 10:03:01 +01001027 << qinfo.uniform().offset << ")";
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001028 }
1029 }
1030 return os;
1031}
1032
Alex Gildayc357c472018-03-21 13:54:09 +00001033/** Formatted output of the TensorInfo type.
1034 *
Anthony Barbier366628a2018-08-01 13:55:03 +01001035 * @param[out] os Output stream.
1036 * @param[in] info Type to output.
1037 *
1038 * @return Modified output stream.
1039 */
1040inline ::std::ostream &operator<<(::std::ostream &os, const TensorInfo &info)
1041{
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001042 os << &info;
Georgios Pinitasc6f95102021-03-30 10:03:01 +01001043 return os;
Anthony Barbier366628a2018-08-01 13:55:03 +01001044}
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001045
Anthony Barbier366628a2018-08-01 13:55:03 +01001046/** Formatted output of the TensorInfo type.
1047 *
Alex Gildayc357c472018-03-21 13:54:09 +00001048 * @param[in] info Type to output.
1049 *
1050 * @return Formatted string.
1051 */
Georgios Pinitas3faea252017-10-30 14:13:50 +00001052inline std::string to_string(const TensorInfo &info)
1053{
1054 std::stringstream str;
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001055 str << &info;
Georgios Pinitas3faea252017-10-30 14:13:50 +00001056 return str.str();
1057}
1058
Ramy Elgammale920d6a2021-08-19 22:10:30 +01001059/** Formatted output of the ITensorInfo* type.
1060 *
1061 * @param[in] info Type to output.
1062 *
1063 * @return Formatted string.
1064 */
1065inline std::string to_string(const ITensorInfo *info)
1066{
1067 std::stringstream str;
1068 str << info;
1069 return str.str();
1070}
1071
Alex Gildayc357c472018-03-21 13:54:09 +00001072/** Formatted output of the Dimensions type.
1073 *
1074 * @param[in] dimensions Type to output.
1075 *
1076 * @return Formatted string.
1077 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001078template <typename T>
1079inline std::string to_string(const Dimensions<T> &dimensions)
1080{
1081 std::stringstream str;
1082 str << dimensions;
1083 return str.str();
1084}
1085
Alex Gildayc357c472018-03-21 13:54:09 +00001086/** Formatted output of the Strides type.
1087 *
1088 * @param[in] stride Type to output.
1089 *
1090 * @return Formatted string.
1091 */
John Richardsona36eae12017-09-26 16:55:59 +01001092inline std::string to_string(const Strides &stride)
1093{
1094 std::stringstream str;
1095 str << stride;
1096 return str.str();
1097}
1098
Alex Gildayc357c472018-03-21 13:54:09 +00001099/** Formatted output of the TensorShape type.
1100 *
1101 * @param[in] shape Type to output.
1102 *
1103 * @return Formatted string.
1104 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001105inline std::string to_string(const TensorShape &shape)
1106{
1107 std::stringstream str;
1108 str << shape;
1109 return str.str();
1110}
1111
Alex Gildayc357c472018-03-21 13:54:09 +00001112/** Formatted output of the Coordinates type.
1113 *
1114 * @param[in] coord Type to output.
1115 *
1116 * @return Formatted string.
1117 */
Abe Mbise925ca0f2017-10-02 19:16:33 +01001118inline std::string to_string(const Coordinates &coord)
1119{
1120 std::stringstream str;
1121 str << coord;
1122 return str.str();
1123}
1124
Anthony Barbierb940fd62018-06-04 14:14:32 +01001125/** Formatted output of the GEMMReshapeInfo type.
1126 *
1127 * @param[out] os Output stream.
1128 * @param[in] info Type to output.
1129 *
1130 * @return Modified output stream.
1131 */
1132inline ::std::ostream &operator<<(::std::ostream &os, const GEMMReshapeInfo &info)
1133{
1134 os << "{m=" << info.m() << ",";
1135 os << "n=" << info.n() << ",";
1136 os << "k=" << info.k() << ",";
1137 os << "mult_transpose1xW_width=" << info.mult_transpose1xW_width() << ",";
1138 os << "mult_interleave4x4_height=" << info.mult_interleave4x4_height();
1139 os << "}";
1140
1141 return os;
1142}
1143
1144/** Formatted output of the GEMMInfo type.
1145 *
1146 * @param[out] os Output stream.
1147 * @param[in] info Type to output.
1148 *
1149 * @return Modified output stream.
1150 */
1151inline ::std::ostream &operator<<(::std::ostream &os, const GEMMInfo &info)
1152{
1153 os << "{is_a_reshaped=" << info.is_a_reshaped() << ",";
1154 os << "is_b_reshaped=" << info.is_b_reshaped() << ",";
1155 os << "reshape_b_only_on_first_run=" << info.reshape_b_only_on_first_run() << ",";
Anthony Barbierb4670212018-05-18 16:55:39 +01001156 os << "depth_output_gemm3d=" << info.depth_output_gemm3d() << ",";
1157 os << "reinterpret_input_as_3d=" << info.reinterpret_input_as_3d() << ",";
1158 os << "retain_internal_weights=" << info.retain_internal_weights() << ",";
1159 os << "fp_mixed_precision=" << info.fp_mixed_precision() << ",";
1160 os << "broadcast_bias=" << info.broadcast_bias() << ",";
1161 os << "pretranpose_B=" << info.pretranpose_B() << ",";
Anthony Barbierb940fd62018-06-04 14:14:32 +01001162
1163 return os;
1164}
1165
1166/** Formatted output of the Window::Dimension type.
1167 *
1168 * @param[out] os Output stream.
1169 * @param[in] dim Type to output.
1170 *
1171 * @return Modified output stream.
1172 */
1173inline ::std::ostream &operator<<(::std::ostream &os, const Window::Dimension &dim)
1174{
1175 os << "{start=" << dim.start() << ", end=" << dim.end() << ", step=" << dim.step() << "}";
1176
1177 return os;
1178}
1179/** Formatted output of the Window type.
1180 *
1181 * @param[out] os Output stream.
1182 * @param[in] win Type to output.
1183 *
1184 * @return Modified output stream.
1185 */
1186inline ::std::ostream &operator<<(::std::ostream &os, const Window &win)
1187{
1188 os << "{";
1189 for(unsigned int i = 0; i < Coordinates::num_max_dimensions; i++)
1190 {
1191 if(i > 0)
1192 {
1193 os << ", ";
1194 }
1195 os << win[i];
1196 }
1197 os << "}";
1198
1199 return os;
1200}
1201
1202/** Formatted output of the WeightsInfo type.
1203 *
1204 * @param[in] info Type to output.
1205 *
1206 * @return Formatted string.
1207 */
1208inline std::string to_string(const WeightsInfo &info)
1209{
1210 std::stringstream str;
1211 str << info;
1212 return str.str();
1213}
1214
1215/** Formatted output of the GEMMReshapeInfo type.
1216 *
1217 * @param[in] info Type to output.
1218 *
1219 * @return Formatted string.
1220 */
1221inline std::string to_string(const GEMMReshapeInfo &info)
1222{
1223 std::stringstream str;
1224 str << info;
1225 return str.str();
1226}
1227
1228/** Formatted output of the GEMMInfo type.
1229 *
1230 * @param[in] info Type to output.
1231 *
1232 * @return Formatted string.
1233 */
1234inline std::string to_string(const GEMMInfo &info)
1235{
1236 std::stringstream str;
1237 str << info;
1238 return str.str();
1239}
1240
1241/** Formatted output of the Window::Dimension type.
1242 *
1243 * @param[in] dim Type to output.
1244 *
1245 * @return Formatted string.
1246 */
1247inline std::string to_string(const Window::Dimension &dim)
1248{
1249 std::stringstream str;
1250 str << dim;
1251 return str.str();
1252}
1253/** Formatted output of the Window type.
1254 *
1255 * @param[in] win Type to output.
1256 *
1257 * @return Formatted string.
1258 */
1259inline std::string to_string(const Window &win)
1260{
1261 std::stringstream str;
1262 str << win;
1263 return str.str();
1264}
1265
Alex Gildayc357c472018-03-21 13:54:09 +00001266/** Formatted output of the Rectangle type.
1267 *
1268 * @param[out] os Output stream.
1269 * @param[in] rect Type to output.
1270 *
1271 * @return Modified output stream.
1272 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001273inline ::std::ostream &operator<<(::std::ostream &os, const Rectangle &rect)
1274{
1275 os << rect.width << "x" << rect.height;
1276 os << "+" << rect.x << "+" << rect.y;
1277
1278 return os;
1279}
1280
Usama Arif8cf8c112019-03-14 15:36:54 +00001281/** Formatted output of the PaddingMode type.
1282 *
1283 * @param[out] os Output stream.
1284 * @param[in] mode Type to output.
1285 *
1286 * @return Modified output stream.
1287 */
1288inline ::std::ostream &operator<<(::std::ostream &os, const PaddingMode &mode)
1289{
1290 switch(mode)
1291 {
1292 case PaddingMode::CONSTANT:
1293 os << "CONSTANT";
1294 break;
1295 case PaddingMode::REFLECT:
1296 os << "REFLECT";
1297 break;
1298 case PaddingMode::SYMMETRIC:
1299 os << "SYMMETRIC";
1300 break;
1301 default:
1302 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1303 }
1304
1305 return os;
1306}
1307
1308/** Formatted output of the PaddingMode type.
1309 *
1310 * @param[in] mode Type to output.
1311 *
1312 * @return Formatted string.
1313 */
1314inline std::string to_string(const PaddingMode &mode)
1315{
1316 std::stringstream str;
1317 str << mode;
1318 return str.str();
1319}
1320
Alex Gildayc357c472018-03-21 13:54:09 +00001321/** Formatted output of the PadStrideInfo type.
1322 *
1323 * @param[out] os Output stream.
1324 * @param[in] pad_stride_info Type to output.
1325 *
1326 * @return Modified output stream.
1327 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001328inline ::std::ostream &operator<<(::std::ostream &os, const PadStrideInfo &pad_stride_info)
1329{
1330 os << pad_stride_info.stride().first << "," << pad_stride_info.stride().second;
1331 os << ";";
Jaroslaw Rzepeckia1ed41f2017-10-13 11:13:58 +01001332 os << pad_stride_info.pad_left() << "," << pad_stride_info.pad_right() << ","
1333 << pad_stride_info.pad_top() << "," << pad_stride_info.pad_bottom();
Anthony Barbier2a07e182017-08-04 18:20:27 +01001334
1335 return os;
1336}
1337
Alex Gildayc357c472018-03-21 13:54:09 +00001338/** Formatted output of the PadStrideInfo type.
1339 *
1340 * @param[in] pad_stride_info Type to output.
1341 *
1342 * @return Formatted string.
1343 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001344inline std::string to_string(const PadStrideInfo &pad_stride_info)
1345{
1346 std::stringstream str;
1347 str << pad_stride_info;
1348 return str.str();
1349}
1350
Alex Gildayc357c472018-03-21 13:54:09 +00001351/** Formatted output of the BorderMode type.
1352 *
1353 * @param[in] mode Type to output.
1354 *
1355 * @return Formatted string.
1356 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001357inline std::string to_string(const BorderMode &mode)
1358{
1359 std::stringstream str;
1360 str << mode;
1361 return str.str();
1362}
1363
Alex Gildayc357c472018-03-21 13:54:09 +00001364/** Formatted output of the BorderSize type.
1365 *
1366 * @param[in] border Type to output.
1367 *
1368 * @return Formatted string.
1369 */
John Richardsonb482ce12017-09-18 12:44:01 +01001370inline std::string to_string(const BorderSize &border)
1371{
1372 std::stringstream str;
1373 str << border;
1374 return str.str();
1375}
1376
Giuseppe Rossinid7647d42018-07-17 18:13:13 +01001377/** Formatted output of the PaddingList type.
1378 *
1379 * @param[in] padding Type to output.
1380 *
1381 * @return Formatted string.
1382 */
1383inline std::string to_string(const PaddingList &padding)
1384{
1385 std::stringstream str;
1386 str << padding;
1387 return str.str();
1388}
1389
giuros013175fcf2018-11-21 09:59:17 +00001390/** Formatted output of the Multiples type.
1391 *
1392 * @param[in] multiples Type to output.
1393 *
1394 * @return Formatted string.
1395 */
1396inline std::string to_string(const Multiples &multiples)
1397{
1398 std::stringstream str;
1399 str << multiples;
1400 return str.str();
1401}
1402
Alex Gildayc357c472018-03-21 13:54:09 +00001403/** Formatted output of the InterpolationPolicy type.
1404 *
1405 * @param[in] policy Type to output.
1406 *
1407 * @return Formatted string.
1408 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001409inline std::string to_string(const InterpolationPolicy &policy)
1410{
1411 std::stringstream str;
1412 str << policy;
1413 return str.str();
1414}
1415
Alex Gildayc357c472018-03-21 13:54:09 +00001416/** Formatted output of the SamplingPolicy type.
1417 *
1418 * @param[in] policy Type to output.
1419 *
1420 * @return Formatted string.
1421 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +07001422inline std::string to_string(const SamplingPolicy &policy)
1423{
1424 std::stringstream str;
1425 str << policy;
1426 return str.str();
1427}
1428
Alex Gildayc357c472018-03-21 13:54:09 +00001429/** Formatted output of the ConvertPolicy type.
1430 *
1431 * @param[out] os Output stream.
1432 * @param[in] policy Type to output.
1433 *
1434 * @return Modified output stream.
1435 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001436inline ::std::ostream &operator<<(::std::ostream &os, const ConvertPolicy &policy)
1437{
1438 switch(policy)
1439 {
1440 case ConvertPolicy::WRAP:
1441 os << "WRAP";
1442 break;
1443 case ConvertPolicy::SATURATE:
1444 os << "SATURATE";
1445 break;
1446 default:
1447 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1448 }
1449
1450 return os;
1451}
1452
1453inline std::string to_string(const ConvertPolicy &policy)
1454{
1455 std::stringstream str;
1456 str << policy;
1457 return str.str();
1458}
1459
giuros01164a2722018-11-20 18:34:46 +00001460/** Formatted output of the ArithmeticOperation type.
1461 *
1462 * @param[out] os Output stream.
1463 * @param[in] op Operation to output.
1464 *
1465 * @return Modified output stream.
1466 */
1467inline ::std::ostream &operator<<(::std::ostream &os, const ArithmeticOperation &op)
1468{
1469 switch(op)
1470 {
1471 case ArithmeticOperation::ADD:
1472 os << "ADD";
1473 break;
1474 case ArithmeticOperation::SUB:
1475 os << "SUB";
1476 break;
1477 case ArithmeticOperation::DIV:
1478 os << "DIV";
1479 break;
1480 case ArithmeticOperation::MAX:
1481 os << "MAX";
1482 break;
1483 case ArithmeticOperation::MIN:
1484 os << "MIN";
1485 break;
1486 case ArithmeticOperation::SQUARED_DIFF:
1487 os << "SQUARED_DIFF";
1488 break;
Usama Arif52c54f62019-05-14 10:22:36 +01001489 case ArithmeticOperation::POWER:
1490 os << "POWER";
1491 break;
giuros01164a2722018-11-20 18:34:46 +00001492 default:
1493 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1494 }
1495
1496 return os;
1497}
1498
1499/** Formatted output of the Arithmetic Operation
1500 *
1501 * @param[in] op Type to output.
1502 *
1503 * @return Formatted string.
1504 */
1505inline std::string to_string(const ArithmeticOperation &op)
1506{
1507 std::stringstream str;
1508 str << op;
1509 return str.str();
1510}
1511
Alex Gildayc357c472018-03-21 13:54:09 +00001512/** Formatted output of the Reduction Operations.
1513 *
1514 * @param[out] os Output stream.
1515 * @param[in] op Type to output.
1516 *
1517 * @return Modified output stream.
1518 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001519inline ::std::ostream &operator<<(::std::ostream &os, const ReductionOperation &op)
1520{
1521 switch(op)
1522 {
Michalis Spyrou7e9391b2018-10-05 14:49:28 +01001523 case ReductionOperation::SUM:
1524 os << "SUM";
1525 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +01001526 case ReductionOperation::SUM_SQUARE:
1527 os << "SUM_SQUARE";
1528 break;
Michalis Spyrou7e9391b2018-10-05 14:49:28 +01001529 case ReductionOperation::MEAN_SUM:
1530 os << "MEAN_SUM";
1531 break;
Michalis Spyrou7930db42018-11-22 17:36:28 +00001532 case ReductionOperation::ARG_IDX_MAX:
1533 os << "ARG_IDX_MAX";
1534 break;
1535 case ReductionOperation::ARG_IDX_MIN:
1536 os << "ARG_IDX_MIN";
1537 break;
Manuel Bottinib412fab2018-12-10 17:40:23 +00001538 case ReductionOperation::PROD:
1539 os << "PROD";
1540 break;
Usama Arifa4a08ad2019-05-20 12:38:33 +01001541 case ReductionOperation::MIN:
1542 os << "MIN";
1543 break;
Usama Arif28f0dd92019-05-20 13:44:34 +01001544 case ReductionOperation::MAX:
1545 os << "MAX";
1546 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +01001547 default:
1548 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1549 }
1550
1551 return os;
1552}
1553
Alex Gildayc357c472018-03-21 13:54:09 +00001554/** Formatted output of the Reduction Operations.
1555 *
1556 * @param[in] op Type to output.
1557 *
1558 * @return Formatted string.
1559 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001560inline std::string to_string(const ReductionOperation &op)
1561{
1562 std::stringstream str;
1563 str << op;
1564 return str.str();
1565}
1566
Georgios Pinitas7900a9e2018-11-23 11:44:58 +00001567/** Formatted output of the Comparison Operations.
1568 *
1569 * @param[out] os Output stream.
1570 * @param[in] op Type to output.
1571 *
1572 * @return Modified output stream.
1573 */
1574inline ::std::ostream &operator<<(::std::ostream &os, const ComparisonOperation &op)
1575{
1576 switch(op)
1577 {
1578 case ComparisonOperation::Equal:
1579 os << "Equal";
1580 break;
1581 case ComparisonOperation::NotEqual:
1582 os << "NotEqual";
1583 break;
1584 case ComparisonOperation::Greater:
1585 os << "Greater";
1586 break;
1587 case ComparisonOperation::GreaterEqual:
1588 os << "GreaterEqual";
1589 break;
1590 case ComparisonOperation::Less:
1591 os << "Less";
1592 break;
1593 case ComparisonOperation::LessEqual:
1594 os << "LessEqual";
1595 break;
1596 default:
1597 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1598 }
1599
1600 return os;
1601}
1602
Michalis Spyroue9362622018-11-23 17:41:37 +00001603/** Formatted output of the Elementwise unary Operations.
1604 *
1605 * @param[out] os Output stream.
1606 * @param[in] op Type to output.
1607 *
1608 * @return Modified output stream.
1609 */
1610inline ::std::ostream &operator<<(::std::ostream &os, const ElementWiseUnary &op)
1611{
1612 switch(op)
1613 {
1614 case ElementWiseUnary::RSQRT:
1615 os << "RSQRT";
1616 break;
1617 case ElementWiseUnary::EXP:
1618 os << "EXP";
1619 break;
Usama Arifeb312ef2019-05-13 17:45:54 +01001620 case ElementWiseUnary::NEG:
1621 os << "NEG";
1622 break;
Usama Arifac33d7e2019-05-20 14:21:40 +01001623 case ElementWiseUnary::LOG:
1624 os << "LOG";
1625 break;
Usama Arif6a4d5422019-05-24 14:53:59 +01001626 case ElementWiseUnary::ROUND:
1627 os << "ROUND";
1628 break;
Michalis Spyroue9362622018-11-23 17:41:37 +00001629 default:
1630 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1631 }
1632
1633 return os;
1634}
1635
Georgios Pinitas7900a9e2018-11-23 11:44:58 +00001636/** Formatted output of the Comparison Operations.
1637 *
1638 * @param[in] op Type to output.
1639 *
1640 * @return Formatted string.
1641 */
1642inline std::string to_string(const ComparisonOperation &op)
1643{
1644 std::stringstream str;
1645 str << op;
1646 return str.str();
1647}
1648
Michalis Spyroue9362622018-11-23 17:41:37 +00001649/** Formatted output of the Elementwise unary Operations.
1650 *
1651 * @param[in] op Type to output.
1652 *
1653 * @return Formatted string.
1654 */
1655inline std::string to_string(const ElementWiseUnary &op)
1656{
1657 std::stringstream str;
1658 str << op;
1659 return str.str();
1660}
1661
Alex Gildayc357c472018-03-21 13:54:09 +00001662/** Formatted output of the Norm Type.
1663 *
1664 * @param[in] type Type to output.
1665 *
1666 * @return Formatted string.
1667 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001668inline std::string to_string(const NormType &type)
1669{
1670 std::stringstream str;
1671 str << type;
1672 return str.str();
1673}
1674
Alex Gildayc357c472018-03-21 13:54:09 +00001675/** Formatted output of the Pooling Type.
1676 *
1677 * @param[in] type Type to output.
1678 *
1679 * @return Formatted string.
1680 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001681inline std::string to_string(const PoolingType &type)
1682{
1683 std::stringstream str;
1684 str << type;
1685 return str.str();
1686}
1687
Alex Gildayc357c472018-03-21 13:54:09 +00001688/** Formatted output of the Pooling Layer Info.
1689 *
1690 * @param[in] info Type to output.
1691 *
1692 * @return Formatted string.
1693 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001694inline std::string to_string(const PoolingLayerInfo &info)
1695{
1696 std::stringstream str;
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +00001697 str << "{Type=" << info.pool_type << ","
Sang-Hoon Park11fedda2020-01-15 14:44:04 +00001698 << "DataLayout=" << info.data_layout << ","
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +00001699 << "IsGlobalPooling=" << info.is_global_pooling;
1700 if(!info.is_global_pooling)
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001701 {
1702 str << ","
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +00001703 << "PoolSize=" << info.pool_size.width << "," << info.pool_size.height << ","
1704 << "PadStride=" << info.pad_stride_info;
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001705 }
1706 str << "}";
Anthony Barbier2a07e182017-08-04 18:20:27 +01001707 return str.str();
1708}
1709
Michalis Spyrou6c7c38e2018-08-29 16:28:11 +01001710/** Formatted output of the PriorBoxLayerInfo.
1711 *
1712 * @param[in] info Type to output.
1713 *
1714 * @return Formatted string.
1715 */
1716inline std::string to_string(const PriorBoxLayerInfo &info)
1717{
1718 std::stringstream str;
1719 str << "{";
1720 str << "Clip:" << info.clip()
1721 << "Flip:" << info.flip()
1722 << "StepX:" << info.steps()[0]
1723 << "StepY:" << info.steps()[1]
1724 << "MinSizes:" << info.min_sizes().size()
1725 << "MaxSizes:" << info.max_sizes().size()
1726 << "ImgSizeX:" << info.img_size().x
1727 << "ImgSizeY:" << info.img_size().y
1728 << "Offset:" << info.offset()
1729 << "Variances:" << info.variances().size();
1730 str << "}";
1731 return str.str();
1732}
1733
Alex Gildayc357c472018-03-21 13:54:09 +00001734/** Formatted output of the Size2D type.
1735 *
1736 * @param[out] os Output stream
1737 * @param[in] size Type to output
1738 *
1739 * @return Modified output stream.
1740 */
John Richardson25f23682017-11-27 14:35:09 +00001741inline ::std::ostream &operator<<(::std::ostream &os, const Size2D &size)
1742{
1743 os << size.width << "x" << size.height;
1744
1745 return os;
1746}
1747
Alex Gildayc357c472018-03-21 13:54:09 +00001748/** Formatted output of the Size2D type.
1749 *
1750 * @param[in] type Type to output
1751 *
1752 * @return Formatted string.
1753 */
John Richardson25f23682017-11-27 14:35:09 +00001754inline std::string to_string(const Size2D &type)
1755{
1756 std::stringstream str;
1757 str << type;
1758 return str.str();
1759}
1760
Alex Gildayc357c472018-03-21 13:54:09 +00001761/** Formatted output of the ConvolutionMethod type.
1762 *
1763 * @param[out] os Output stream
1764 * @param[in] conv_method Type to output
1765 *
1766 * @return Modified output stream.
1767 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001768inline ::std::ostream &operator<<(::std::ostream &os, const ConvolutionMethod &conv_method)
1769{
1770 switch(conv_method)
1771 {
1772 case ConvolutionMethod::GEMM:
1773 os << "GEMM";
1774 break;
1775 case ConvolutionMethod::DIRECT:
1776 os << "DIRECT";
1777 break;
1778 case ConvolutionMethod::WINOGRAD:
1779 os << "WINOGRAD";
1780 break;
1781 default:
1782 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1783 }
1784
1785 return os;
1786}
1787
Alex Gildayc357c472018-03-21 13:54:09 +00001788/** Formatted output of the ConvolutionMethod type.
1789 *
1790 * @param[in] conv_method Type to output
1791 *
1792 * @return Formatted string.
1793 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001794inline std::string to_string(const ConvolutionMethod &conv_method)
1795{
1796 std::stringstream str;
1797 str << conv_method;
1798 return str.str();
1799}
1800
Alex Gildayc357c472018-03-21 13:54:09 +00001801/** Formatted output of the GPUTarget type.
1802 *
1803 * @param[out] os Output stream
1804 * @param[in] gpu_target Type to output
1805 *
1806 * @return Modified output stream.
1807 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001808inline ::std::ostream &operator<<(::std::ostream &os, const GPUTarget &gpu_target)
1809{
1810 switch(gpu_target)
1811 {
1812 case GPUTarget::GPU_ARCH_MASK:
1813 os << "GPU_ARCH_MASK";
1814 break;
1815 case GPUTarget::MIDGARD:
1816 os << "MIDGARD";
1817 break;
1818 case GPUTarget::BIFROST:
1819 os << "BIFROST";
1820 break;
Georgios Pinitasd5462ff2019-07-03 19:33:57 +01001821 case GPUTarget::VALHALL:
1822 os << "VALHALL";
1823 break;
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001824 case GPUTarget::T600:
1825 os << "T600";
1826 break;
1827 case GPUTarget::T700:
1828 os << "T700";
1829 break;
1830 case GPUTarget::T800:
1831 os << "T800";
1832 break;
Michalis Spyroua9676112018-02-22 18:07:43 +00001833 case GPUTarget::G71:
1834 os << "G71";
1835 break;
1836 case GPUTarget::G72:
1837 os << "G72";
1838 break;
1839 case GPUTarget::G51:
1840 os << "G51";
1841 break;
1842 case GPUTarget::G51BIG:
1843 os << "G51BIG";
1844 break;
1845 case GPUTarget::G51LIT:
1846 os << "G51LIT";
1847 break;
Georgios Pinitasb03f7c52018-07-12 10:49:53 +01001848 case GPUTarget::G76:
1849 os << "G76";
Michalis Spyroua9676112018-02-22 18:07:43 +00001850 break;
Georgios Pinitasd5462ff2019-07-03 19:33:57 +01001851 case GPUTarget::G77:
1852 os << "G77";
Michalis Spyroua9676112018-02-22 18:07:43 +00001853 break;
Georgios Pinitas4ffc42a2020-12-01 16:28:24 +00001854 case GPUTarget::G78:
1855 os << "G78";
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001856 break;
Pablo Marquez Tellob1496e62021-06-25 14:49:37 +01001857 case GPUTarget::G31:
1858 os << "G31";
1859 break;
Georgios Pinitasd5462ff2019-07-03 19:33:57 +01001860 case GPUTarget::TODX:
1861 os << "TODX";
1862 break;
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001863 default:
1864 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1865 }
1866
1867 return os;
1868}
1869
Alex Gildayc357c472018-03-21 13:54:09 +00001870/** Formatted output of the GPUTarget type.
1871 *
1872 * @param[in] gpu_target Type to output
1873 *
1874 * @return Formatted string.
1875 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001876inline std::string to_string(const GPUTarget &gpu_target)
1877{
1878 std::stringstream str;
1879 str << gpu_target;
1880 return str.str();
1881}
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00001882
John Richardson8de92612018-02-22 14:09:31 +00001883/** Formatted output of the DetectionWindow type.
1884 *
1885 * @param[out] os Output stream
1886 * @param[in] detection_window Type to output
1887 *
1888 * @return Modified output stream.
1889 */
John Richardson684cb0f2018-01-09 11:17:00 +00001890inline ::std::ostream &operator<<(::std::ostream &os, const DetectionWindow &detection_window)
1891{
1892 os << "{x=" << detection_window.x << ","
1893 << "y=" << detection_window.y << ","
1894 << "width=" << detection_window.width << ","
1895 << "height=" << detection_window.height << ","
1896 << "idx_class=" << detection_window.idx_class << ","
1897 << "score=" << detection_window.score << "}";
1898
1899 return os;
1900}
1901
Isabella Gottardi05e56442018-11-16 11:26:52 +00001902/** Formatted output of the DetectionOutputLayerCodeType type.
1903 *
1904 * @param[out] os Output stream
1905 * @param[in] detection_code Type to output
1906 *
1907 * @return Modified output stream.
1908 */
1909inline ::std::ostream &operator<<(::std::ostream &os, const DetectionOutputLayerCodeType &detection_code)
1910{
1911 switch(detection_code)
1912 {
1913 case DetectionOutputLayerCodeType::CENTER_SIZE:
1914 os << "CENTER_SIZE";
1915 break;
1916 case DetectionOutputLayerCodeType::CORNER:
1917 os << "CORNER";
1918 break;
1919 case DetectionOutputLayerCodeType::CORNER_SIZE:
1920 os << "CORNER_SIZE";
1921 break;
1922 case DetectionOutputLayerCodeType::TF_CENTER:
1923 os << "TF_CENTER";
1924 break;
1925 default:
1926 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1927 }
1928
1929 return os;
1930}
1931/** Formatted output of the DetectionOutputLayerCodeType type.
1932 *
1933 * @param[in] detection_code Type to output
1934 *
1935 * @return Formatted string.
1936 */
1937inline std::string to_string(const DetectionOutputLayerCodeType &detection_code)
1938{
1939 std::stringstream str;
1940 str << detection_code;
1941 return str.str();
1942}
1943
1944/** Formatted output of the DetectionOutputLayerInfo type.
1945 *
1946 * @param[out] os Output stream
1947 * @param[in] detection_info Type to output
1948 *
1949 * @return Modified output stream.
1950 */
1951inline ::std::ostream &operator<<(::std::ostream &os, const DetectionOutputLayerInfo &detection_info)
1952{
1953 os << "{Classes=" << detection_info.num_classes() << ","
1954 << "ShareLocation=" << detection_info.share_location() << ","
1955 << "CodeType=" << detection_info.code_type() << ","
1956 << "VarianceEncodedInTarget=" << detection_info.variance_encoded_in_target() << ","
1957 << "KeepTopK=" << detection_info.keep_top_k() << ","
1958 << "NMSThreshold=" << detection_info.nms_threshold() << ","
1959 << "Eta=" << detection_info.eta() << ","
1960 << "BackgroundLabelId=" << detection_info.background_label_id() << ","
1961 << "ConfidenceThreshold=" << detection_info.confidence_threshold() << ","
1962 << "TopK=" << detection_info.top_k() << ","
1963 << "NumLocClasses=" << detection_info.num_loc_classes()
1964 << "}";
1965
1966 return os;
1967}
1968
1969/** Formatted output of the DetectionOutputLayerInfo type.
1970 *
1971 * @param[in] detection_info Type to output
1972 *
1973 * @return Formatted string.
1974 */
1975inline std::string to_string(const DetectionOutputLayerInfo &detection_info)
1976{
1977 std::stringstream str;
1978 str << detection_info;
1979 return str.str();
1980}
Isabella Gottardia7acb3c2019-01-08 13:48:44 +00001981/** Formatted output of the DetectionPostProcessLayerInfo type.
1982 *
1983 * @param[out] os Output stream
1984 * @param[in] detection_info Type to output
1985 *
1986 * @return Modified output stream.
1987 */
1988inline ::std::ostream &operator<<(::std::ostream &os, const DetectionPostProcessLayerInfo &detection_info)
1989{
1990 os << "{MaxDetections=" << detection_info.max_detections() << ","
1991 << "MaxClassesPerDetection=" << detection_info.max_classes_per_detection() << ","
1992 << "NmsScoreThreshold=" << detection_info.nms_score_threshold() << ","
1993 << "NmsIouThreshold=" << detection_info.iou_threshold() << ","
1994 << "NumClasses=" << detection_info.num_classes() << ","
1995 << "ScaleValue_y=" << detection_info.scale_value_y() << ","
1996 << "ScaleValue_x=" << detection_info.scale_value_x() << ","
1997 << "ScaleValue_h=" << detection_info.scale_value_h() << ","
1998 << "ScaleValue_w=" << detection_info.scale_value_w() << ","
1999 << "UseRegularNms=" << detection_info.use_regular_nms() << ","
2000 << "DetectionPerClass=" << detection_info.detection_per_class()
2001 << "}";
2002
2003 return os;
2004}
2005
2006/** Formatted output of the DetectionPostProcessLayerInfo type.
2007 *
2008 * @param[in] detection_info Type to output
2009 *
2010 * @return Formatted string.
2011 */
2012inline std::string to_string(const DetectionPostProcessLayerInfo &detection_info)
2013{
2014 std::stringstream str;
2015 str << detection_info;
2016 return str.str();
2017}
Georgios Pinitasc6f95102021-03-30 10:03:01 +01002018
John Richardson8de92612018-02-22 14:09:31 +00002019/** Formatted output of the DetectionWindow type.
2020 *
2021 * @param[in] detection_window Type to output
2022 *
2023 * @return Formatted string.
2024 */
2025inline std::string to_string(const DetectionWindow &detection_window)
2026{
2027 std::stringstream str;
2028 str << detection_window;
2029 return str.str();
2030}
2031
Anthony Barbier671a11e2018-07-06 15:11:36 +01002032/** Formatted output of a vector of objects.
2033 *
2034 * @param[out] os Output stream
2035 * @param[in] args Vector of objects to print
2036 *
2037 * @return Modified output stream.
2038 */
2039template <typename T>
2040inline ::std::ostream &operator<<(::std::ostream &os, const std::vector<T> &args)
2041{
2042 os << "[";
2043 bool first = true;
2044 for(auto &arg : args)
2045 {
2046 if(first)
2047 {
2048 first = false;
2049 }
2050 else
2051 {
2052 os << ", ";
2053 }
2054 os << arg;
2055 }
2056 os << "]";
2057 return os;
2058}
2059
Michalis Spyrou6c7c38e2018-08-29 16:28:11 +01002060/** Formatted output of @ref PriorBoxLayerInfo.
2061 *
2062 * @param[out] os Output stream.
2063 * @param[in] info Type to output.
2064 *
2065 * @return Modified output stream.
2066 */
2067inline ::std::ostream &operator<<(::std::ostream &os, const PriorBoxLayerInfo &info)
2068{
2069 os << "Clip:" << info.clip()
2070 << "Flip:" << info.flip()
2071 << "StepX:" << info.steps()[0]
2072 << "StepY:" << info.steps()[1]
2073 << "MinSizes:" << info.min_sizes()
2074 << "MaxSizes:" << info.max_sizes()
2075 << "ImgSizeX:" << info.img_size().x
2076 << "ImgSizeY:" << info.img_size().y
2077 << "Offset:" << info.offset()
2078 << "Variances:" << info.variances();
2079
2080 return os;
2081}
2082
Anthony Barbier671a11e2018-07-06 15:11:36 +01002083/** Formatted output of a vector of objects.
2084 *
2085 * @param[in] args Vector of objects to print
2086 *
2087 * @return String representing args.
2088 */
2089template <typename T>
2090std::string to_string(const std::vector<T> &args)
2091{
2092 std::stringstream str;
2093 str << args;
2094 return str.str();
2095}
2096
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00002097/** Formatted output of the WinogradInfo type. */
2098inline ::std::ostream &operator<<(::std::ostream &os, const WinogradInfo &info)
2099{
2100 os << "{OutputTileSize=" << info.output_tile_size << ","
2101 << "KernelSize=" << info.kernel_size << ","
2102 << "PadStride=" << info.convolution_info << ","
2103 << "OutputDataLayout=" << info.output_data_layout << "}";
2104
2105 return os;
2106}
2107
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00002108inline std::string to_string(const WinogradInfo &type)
2109{
2110 std::stringstream str;
2111 str << type;
2112 return str.str();
2113}
Anthony Barbier671a11e2018-07-06 15:11:36 +01002114
2115/** Fallback method: try to use std::to_string:
2116 *
2117 * @param[in] val Value to convert to string
2118 *
2119 * @return String representing val.
2120 */
2121template <typename T>
2122inline std::string to_string(const T &val)
2123{
2124 return support::cpp11::to_string(val);
2125}
2126
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +01002127/** Convert a CLTunerMode value to a string
2128 *
2129 * @param val CLTunerMode value to be converted
2130 *
2131 * @return String representing the corresponding CLTunerMode.
2132 */
2133inline std::string to_string(const CLTunerMode val)
2134{
2135 switch(val)
2136 {
2137 case CLTunerMode::EXHAUSTIVE:
2138 {
2139 return std::string("Exhaustive");
2140 }
2141 case CLTunerMode::NORMAL:
2142 {
2143 return std::string("Normal");
2144 }
2145 case CLTunerMode::RAPID:
2146 {
2147 return std::string("Rapid");
2148 }
2149 default:
2150 {
2151 ARM_COMPUTE_ERROR("Invalid tuner mode.");
2152 return std::string("UNDEFINED");
2153 }
2154 }
2155}
SiCong Lidb4a6c12021-02-05 09:30:57 +00002156/** Converts a @ref CLGEMMKernelType to string
2157 *
2158 * @param[in] val CLGEMMKernelType value to be converted
2159 *
2160 * @return String representing the corresponding CLGEMMKernelType
2161 */
2162inline std::string to_string(CLGEMMKernelType val)
2163{
2164 switch(val)
2165 {
2166 case CLGEMMKernelType::NATIVE_V1:
2167 {
2168 return "Native_V1";
2169 }
2170 case CLGEMMKernelType::RESHAPED_V1:
2171 {
2172 return "Reshaped_V1";
2173 }
2174 case CLGEMMKernelType::NATIVE:
2175 {
2176 return "Native";
2177 }
2178 case CLGEMMKernelType::RESHAPED_ONLY_RHS:
2179 {
2180 return "Reshaped_Only_RHS";
2181 }
2182 case CLGEMMKernelType::RESHAPED:
2183 {
2184 return "Reshaped";
2185 }
2186 default:
2187 {
2188 return "Unknown";
2189 }
2190 }
2191}
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +01002192/** [Print CLTunerMode type] **/
2193/** Formatted output of the CLTunerMode type.
2194 *
2195 * @param[out] os Output stream.
2196 * @param[in] val CLTunerMode to output.
2197 *
2198 * @return Modified output stream.
2199 */
2200inline ::std::ostream &operator<<(::std::ostream &os, const CLTunerMode &val)
2201{
2202 os << to_string(val);
2203 return os;
2204}
2205
Anthony Barbier6ff3b192017-09-04 18:44:23 +01002206} // namespace arm_compute
Anthony Barbier4dbc0a92018-08-27 13:39:47 +01002207
2208#endif /* __ARM_COMPUTE_TYPE_PRINTER_H__ */