blob: 3ccba2c7e9589f75419657c721698c18f09ca8dc [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
Alex Gildayc357c472018-03-21 13:54:09 +00001059/** Formatted output of the Dimensions type.
1060 *
1061 * @param[in] dimensions Type to output.
1062 *
1063 * @return Formatted string.
1064 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001065template <typename T>
1066inline std::string to_string(const Dimensions<T> &dimensions)
1067{
1068 std::stringstream str;
1069 str << dimensions;
1070 return str.str();
1071}
1072
Alex Gildayc357c472018-03-21 13:54:09 +00001073/** Formatted output of the Strides type.
1074 *
1075 * @param[in] stride Type to output.
1076 *
1077 * @return Formatted string.
1078 */
John Richardsona36eae12017-09-26 16:55:59 +01001079inline std::string to_string(const Strides &stride)
1080{
1081 std::stringstream str;
1082 str << stride;
1083 return str.str();
1084}
1085
Alex Gildayc357c472018-03-21 13:54:09 +00001086/** Formatted output of the TensorShape type.
1087 *
1088 * @param[in] shape Type to output.
1089 *
1090 * @return Formatted string.
1091 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001092inline std::string to_string(const TensorShape &shape)
1093{
1094 std::stringstream str;
1095 str << shape;
1096 return str.str();
1097}
1098
Alex Gildayc357c472018-03-21 13:54:09 +00001099/** Formatted output of the Coordinates type.
1100 *
1101 * @param[in] coord Type to output.
1102 *
1103 * @return Formatted string.
1104 */
Abe Mbise925ca0f2017-10-02 19:16:33 +01001105inline std::string to_string(const Coordinates &coord)
1106{
1107 std::stringstream str;
1108 str << coord;
1109 return str.str();
1110}
1111
Anthony Barbierb940fd62018-06-04 14:14:32 +01001112/** Formatted output of the GEMMReshapeInfo type.
1113 *
1114 * @param[out] os Output stream.
1115 * @param[in] info Type to output.
1116 *
1117 * @return Modified output stream.
1118 */
1119inline ::std::ostream &operator<<(::std::ostream &os, const GEMMReshapeInfo &info)
1120{
1121 os << "{m=" << info.m() << ",";
1122 os << "n=" << info.n() << ",";
1123 os << "k=" << info.k() << ",";
1124 os << "mult_transpose1xW_width=" << info.mult_transpose1xW_width() << ",";
1125 os << "mult_interleave4x4_height=" << info.mult_interleave4x4_height();
1126 os << "}";
1127
1128 return os;
1129}
1130
1131/** Formatted output of the GEMMInfo type.
1132 *
1133 * @param[out] os Output stream.
1134 * @param[in] info Type to output.
1135 *
1136 * @return Modified output stream.
1137 */
1138inline ::std::ostream &operator<<(::std::ostream &os, const GEMMInfo &info)
1139{
1140 os << "{is_a_reshaped=" << info.is_a_reshaped() << ",";
1141 os << "is_b_reshaped=" << info.is_b_reshaped() << ",";
1142 os << "reshape_b_only_on_first_run=" << info.reshape_b_only_on_first_run() << ",";
Anthony Barbierb4670212018-05-18 16:55:39 +01001143 os << "depth_output_gemm3d=" << info.depth_output_gemm3d() << ",";
1144 os << "reinterpret_input_as_3d=" << info.reinterpret_input_as_3d() << ",";
1145 os << "retain_internal_weights=" << info.retain_internal_weights() << ",";
1146 os << "fp_mixed_precision=" << info.fp_mixed_precision() << ",";
1147 os << "broadcast_bias=" << info.broadcast_bias() << ",";
1148 os << "pretranpose_B=" << info.pretranpose_B() << ",";
Anthony Barbierb940fd62018-06-04 14:14:32 +01001149
1150 return os;
1151}
1152
1153/** Formatted output of the Window::Dimension type.
1154 *
1155 * @param[out] os Output stream.
1156 * @param[in] dim Type to output.
1157 *
1158 * @return Modified output stream.
1159 */
1160inline ::std::ostream &operator<<(::std::ostream &os, const Window::Dimension &dim)
1161{
1162 os << "{start=" << dim.start() << ", end=" << dim.end() << ", step=" << dim.step() << "}";
1163
1164 return os;
1165}
1166/** Formatted output of the Window type.
1167 *
1168 * @param[out] os Output stream.
1169 * @param[in] win Type to output.
1170 *
1171 * @return Modified output stream.
1172 */
1173inline ::std::ostream &operator<<(::std::ostream &os, const Window &win)
1174{
1175 os << "{";
1176 for(unsigned int i = 0; i < Coordinates::num_max_dimensions; i++)
1177 {
1178 if(i > 0)
1179 {
1180 os << ", ";
1181 }
1182 os << win[i];
1183 }
1184 os << "}";
1185
1186 return os;
1187}
1188
1189/** Formatted output of the WeightsInfo type.
1190 *
1191 * @param[in] info Type to output.
1192 *
1193 * @return Formatted string.
1194 */
1195inline std::string to_string(const WeightsInfo &info)
1196{
1197 std::stringstream str;
1198 str << info;
1199 return str.str();
1200}
1201
1202/** Formatted output of the GEMMReshapeInfo type.
1203 *
1204 * @param[in] info Type to output.
1205 *
1206 * @return Formatted string.
1207 */
1208inline std::string to_string(const GEMMReshapeInfo &info)
1209{
1210 std::stringstream str;
1211 str << info;
1212 return str.str();
1213}
1214
1215/** Formatted output of the GEMMInfo type.
1216 *
1217 * @param[in] info Type to output.
1218 *
1219 * @return Formatted string.
1220 */
1221inline std::string to_string(const GEMMInfo &info)
1222{
1223 std::stringstream str;
1224 str << info;
1225 return str.str();
1226}
1227
1228/** Formatted output of the Window::Dimension type.
1229 *
1230 * @param[in] dim Type to output.
1231 *
1232 * @return Formatted string.
1233 */
1234inline std::string to_string(const Window::Dimension &dim)
1235{
1236 std::stringstream str;
1237 str << dim;
1238 return str.str();
1239}
1240/** Formatted output of the Window type.
1241 *
1242 * @param[in] win Type to output.
1243 *
1244 * @return Formatted string.
1245 */
1246inline std::string to_string(const Window &win)
1247{
1248 std::stringstream str;
1249 str << win;
1250 return str.str();
1251}
1252
Alex Gildayc357c472018-03-21 13:54:09 +00001253/** Formatted output of the Rectangle type.
1254 *
1255 * @param[out] os Output stream.
1256 * @param[in] rect Type to output.
1257 *
1258 * @return Modified output stream.
1259 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001260inline ::std::ostream &operator<<(::std::ostream &os, const Rectangle &rect)
1261{
1262 os << rect.width << "x" << rect.height;
1263 os << "+" << rect.x << "+" << rect.y;
1264
1265 return os;
1266}
1267
Usama Arif8cf8c112019-03-14 15:36:54 +00001268/** Formatted output of the PaddingMode type.
1269 *
1270 * @param[out] os Output stream.
1271 * @param[in] mode Type to output.
1272 *
1273 * @return Modified output stream.
1274 */
1275inline ::std::ostream &operator<<(::std::ostream &os, const PaddingMode &mode)
1276{
1277 switch(mode)
1278 {
1279 case PaddingMode::CONSTANT:
1280 os << "CONSTANT";
1281 break;
1282 case PaddingMode::REFLECT:
1283 os << "REFLECT";
1284 break;
1285 case PaddingMode::SYMMETRIC:
1286 os << "SYMMETRIC";
1287 break;
1288 default:
1289 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1290 }
1291
1292 return os;
1293}
1294
1295/** Formatted output of the PaddingMode type.
1296 *
1297 * @param[in] mode Type to output.
1298 *
1299 * @return Formatted string.
1300 */
1301inline std::string to_string(const PaddingMode &mode)
1302{
1303 std::stringstream str;
1304 str << mode;
1305 return str.str();
1306}
1307
Alex Gildayc357c472018-03-21 13:54:09 +00001308/** Formatted output of the PadStrideInfo type.
1309 *
1310 * @param[out] os Output stream.
1311 * @param[in] pad_stride_info Type to output.
1312 *
1313 * @return Modified output stream.
1314 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001315inline ::std::ostream &operator<<(::std::ostream &os, const PadStrideInfo &pad_stride_info)
1316{
1317 os << pad_stride_info.stride().first << "," << pad_stride_info.stride().second;
1318 os << ";";
Jaroslaw Rzepeckia1ed41f2017-10-13 11:13:58 +01001319 os << pad_stride_info.pad_left() << "," << pad_stride_info.pad_right() << ","
1320 << pad_stride_info.pad_top() << "," << pad_stride_info.pad_bottom();
Anthony Barbier2a07e182017-08-04 18:20:27 +01001321
1322 return os;
1323}
1324
Alex Gildayc357c472018-03-21 13:54:09 +00001325/** Formatted output of the PadStrideInfo type.
1326 *
1327 * @param[in] pad_stride_info Type to output.
1328 *
1329 * @return Formatted string.
1330 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001331inline std::string to_string(const PadStrideInfo &pad_stride_info)
1332{
1333 std::stringstream str;
1334 str << pad_stride_info;
1335 return str.str();
1336}
1337
Alex Gildayc357c472018-03-21 13:54:09 +00001338/** Formatted output of the BorderMode type.
1339 *
1340 * @param[in] mode Type to output.
1341 *
1342 * @return Formatted string.
1343 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001344inline std::string to_string(const BorderMode &mode)
1345{
1346 std::stringstream str;
1347 str << mode;
1348 return str.str();
1349}
1350
Alex Gildayc357c472018-03-21 13:54:09 +00001351/** Formatted output of the BorderSize type.
1352 *
1353 * @param[in] border Type to output.
1354 *
1355 * @return Formatted string.
1356 */
John Richardsonb482ce12017-09-18 12:44:01 +01001357inline std::string to_string(const BorderSize &border)
1358{
1359 std::stringstream str;
1360 str << border;
1361 return str.str();
1362}
1363
Giuseppe Rossinid7647d42018-07-17 18:13:13 +01001364/** Formatted output of the PaddingList type.
1365 *
1366 * @param[in] padding Type to output.
1367 *
1368 * @return Formatted string.
1369 */
1370inline std::string to_string(const PaddingList &padding)
1371{
1372 std::stringstream str;
1373 str << padding;
1374 return str.str();
1375}
1376
giuros013175fcf2018-11-21 09:59:17 +00001377/** Formatted output of the Multiples type.
1378 *
1379 * @param[in] multiples Type to output.
1380 *
1381 * @return Formatted string.
1382 */
1383inline std::string to_string(const Multiples &multiples)
1384{
1385 std::stringstream str;
1386 str << multiples;
1387 return str.str();
1388}
1389
Alex Gildayc357c472018-03-21 13:54:09 +00001390/** Formatted output of the InterpolationPolicy type.
1391 *
1392 * @param[in] policy Type to output.
1393 *
1394 * @return Formatted string.
1395 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001396inline std::string to_string(const InterpolationPolicy &policy)
1397{
1398 std::stringstream str;
1399 str << policy;
1400 return str.str();
1401}
1402
Alex Gildayc357c472018-03-21 13:54:09 +00001403/** Formatted output of the SamplingPolicy type.
1404 *
1405 * @param[in] policy Type to output.
1406 *
1407 * @return Formatted string.
1408 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +07001409inline std::string to_string(const SamplingPolicy &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 ConvertPolicy type.
1417 *
1418 * @param[out] os Output stream.
1419 * @param[in] policy Type to output.
1420 *
1421 * @return Modified output stream.
1422 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001423inline ::std::ostream &operator<<(::std::ostream &os, const ConvertPolicy &policy)
1424{
1425 switch(policy)
1426 {
1427 case ConvertPolicy::WRAP:
1428 os << "WRAP";
1429 break;
1430 case ConvertPolicy::SATURATE:
1431 os << "SATURATE";
1432 break;
1433 default:
1434 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1435 }
1436
1437 return os;
1438}
1439
1440inline std::string to_string(const ConvertPolicy &policy)
1441{
1442 std::stringstream str;
1443 str << policy;
1444 return str.str();
1445}
1446
giuros01164a2722018-11-20 18:34:46 +00001447/** Formatted output of the ArithmeticOperation type.
1448 *
1449 * @param[out] os Output stream.
1450 * @param[in] op Operation to output.
1451 *
1452 * @return Modified output stream.
1453 */
1454inline ::std::ostream &operator<<(::std::ostream &os, const ArithmeticOperation &op)
1455{
1456 switch(op)
1457 {
1458 case ArithmeticOperation::ADD:
1459 os << "ADD";
1460 break;
1461 case ArithmeticOperation::SUB:
1462 os << "SUB";
1463 break;
1464 case ArithmeticOperation::DIV:
1465 os << "DIV";
1466 break;
1467 case ArithmeticOperation::MAX:
1468 os << "MAX";
1469 break;
1470 case ArithmeticOperation::MIN:
1471 os << "MIN";
1472 break;
1473 case ArithmeticOperation::SQUARED_DIFF:
1474 os << "SQUARED_DIFF";
1475 break;
Usama Arif52c54f62019-05-14 10:22:36 +01001476 case ArithmeticOperation::POWER:
1477 os << "POWER";
1478 break;
giuros01164a2722018-11-20 18:34:46 +00001479 default:
1480 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1481 }
1482
1483 return os;
1484}
1485
1486/** Formatted output of the Arithmetic Operation
1487 *
1488 * @param[in] op Type to output.
1489 *
1490 * @return Formatted string.
1491 */
1492inline std::string to_string(const ArithmeticOperation &op)
1493{
1494 std::stringstream str;
1495 str << op;
1496 return str.str();
1497}
1498
Alex Gildayc357c472018-03-21 13:54:09 +00001499/** Formatted output of the Reduction Operations.
1500 *
1501 * @param[out] os Output stream.
1502 * @param[in] op Type to output.
1503 *
1504 * @return Modified output stream.
1505 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001506inline ::std::ostream &operator<<(::std::ostream &os, const ReductionOperation &op)
1507{
1508 switch(op)
1509 {
Michalis Spyrou7e9391b2018-10-05 14:49:28 +01001510 case ReductionOperation::SUM:
1511 os << "SUM";
1512 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +01001513 case ReductionOperation::SUM_SQUARE:
1514 os << "SUM_SQUARE";
1515 break;
Michalis Spyrou7e9391b2018-10-05 14:49:28 +01001516 case ReductionOperation::MEAN_SUM:
1517 os << "MEAN_SUM";
1518 break;
Michalis Spyrou7930db42018-11-22 17:36:28 +00001519 case ReductionOperation::ARG_IDX_MAX:
1520 os << "ARG_IDX_MAX";
1521 break;
1522 case ReductionOperation::ARG_IDX_MIN:
1523 os << "ARG_IDX_MIN";
1524 break;
Manuel Bottinib412fab2018-12-10 17:40:23 +00001525 case ReductionOperation::PROD:
1526 os << "PROD";
1527 break;
Usama Arifa4a08ad2019-05-20 12:38:33 +01001528 case ReductionOperation::MIN:
1529 os << "MIN";
1530 break;
Usama Arif28f0dd92019-05-20 13:44:34 +01001531 case ReductionOperation::MAX:
1532 os << "MAX";
1533 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +01001534 default:
1535 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1536 }
1537
1538 return os;
1539}
1540
Alex Gildayc357c472018-03-21 13:54:09 +00001541/** Formatted output of the Reduction Operations.
1542 *
1543 * @param[in] op Type to output.
1544 *
1545 * @return Formatted string.
1546 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001547inline std::string to_string(const ReductionOperation &op)
1548{
1549 std::stringstream str;
1550 str << op;
1551 return str.str();
1552}
1553
Georgios Pinitas7900a9e2018-11-23 11:44:58 +00001554/** Formatted output of the Comparison Operations.
1555 *
1556 * @param[out] os Output stream.
1557 * @param[in] op Type to output.
1558 *
1559 * @return Modified output stream.
1560 */
1561inline ::std::ostream &operator<<(::std::ostream &os, const ComparisonOperation &op)
1562{
1563 switch(op)
1564 {
1565 case ComparisonOperation::Equal:
1566 os << "Equal";
1567 break;
1568 case ComparisonOperation::NotEqual:
1569 os << "NotEqual";
1570 break;
1571 case ComparisonOperation::Greater:
1572 os << "Greater";
1573 break;
1574 case ComparisonOperation::GreaterEqual:
1575 os << "GreaterEqual";
1576 break;
1577 case ComparisonOperation::Less:
1578 os << "Less";
1579 break;
1580 case ComparisonOperation::LessEqual:
1581 os << "LessEqual";
1582 break;
1583 default:
1584 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1585 }
1586
1587 return os;
1588}
1589
Michalis Spyroue9362622018-11-23 17:41:37 +00001590/** Formatted output of the Elementwise unary Operations.
1591 *
1592 * @param[out] os Output stream.
1593 * @param[in] op Type to output.
1594 *
1595 * @return Modified output stream.
1596 */
1597inline ::std::ostream &operator<<(::std::ostream &os, const ElementWiseUnary &op)
1598{
1599 switch(op)
1600 {
1601 case ElementWiseUnary::RSQRT:
1602 os << "RSQRT";
1603 break;
1604 case ElementWiseUnary::EXP:
1605 os << "EXP";
1606 break;
Usama Arifeb312ef2019-05-13 17:45:54 +01001607 case ElementWiseUnary::NEG:
1608 os << "NEG";
1609 break;
Usama Arifac33d7e2019-05-20 14:21:40 +01001610 case ElementWiseUnary::LOG:
1611 os << "LOG";
1612 break;
Usama Arif6a4d5422019-05-24 14:53:59 +01001613 case ElementWiseUnary::ROUND:
1614 os << "ROUND";
1615 break;
Michalis Spyroue9362622018-11-23 17:41:37 +00001616 default:
1617 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1618 }
1619
1620 return os;
1621}
1622
Georgios Pinitas7900a9e2018-11-23 11:44:58 +00001623/** Formatted output of the Comparison Operations.
1624 *
1625 * @param[in] op Type to output.
1626 *
1627 * @return Formatted string.
1628 */
1629inline std::string to_string(const ComparisonOperation &op)
1630{
1631 std::stringstream str;
1632 str << op;
1633 return str.str();
1634}
1635
Michalis Spyroue9362622018-11-23 17:41:37 +00001636/** Formatted output of the Elementwise unary Operations.
1637 *
1638 * @param[in] op Type to output.
1639 *
1640 * @return Formatted string.
1641 */
1642inline std::string to_string(const ElementWiseUnary &op)
1643{
1644 std::stringstream str;
1645 str << op;
1646 return str.str();
1647}
1648
Alex Gildayc357c472018-03-21 13:54:09 +00001649/** Formatted output of the Norm Type.
1650 *
1651 * @param[in] type Type to output.
1652 *
1653 * @return Formatted string.
1654 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001655inline std::string to_string(const NormType &type)
1656{
1657 std::stringstream str;
1658 str << type;
1659 return str.str();
1660}
1661
Alex Gildayc357c472018-03-21 13:54:09 +00001662/** Formatted output of the Pooling 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 PoolingType &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 Layer Info.
1676 *
1677 * @param[in] info Type to output.
1678 *
1679 * @return Formatted string.
1680 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001681inline std::string to_string(const PoolingLayerInfo &info)
1682{
1683 std::stringstream str;
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +00001684 str << "{Type=" << info.pool_type << ","
Sang-Hoon Park11fedda2020-01-15 14:44:04 +00001685 << "DataLayout=" << info.data_layout << ","
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +00001686 << "IsGlobalPooling=" << info.is_global_pooling;
1687 if(!info.is_global_pooling)
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001688 {
1689 str << ","
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +00001690 << "PoolSize=" << info.pool_size.width << "," << info.pool_size.height << ","
1691 << "PadStride=" << info.pad_stride_info;
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001692 }
1693 str << "}";
Anthony Barbier2a07e182017-08-04 18:20:27 +01001694 return str.str();
1695}
1696
Michalis Spyrou6c7c38e2018-08-29 16:28:11 +01001697/** Formatted output of the PriorBoxLayerInfo.
1698 *
1699 * @param[in] info Type to output.
1700 *
1701 * @return Formatted string.
1702 */
1703inline std::string to_string(const PriorBoxLayerInfo &info)
1704{
1705 std::stringstream str;
1706 str << "{";
1707 str << "Clip:" << info.clip()
1708 << "Flip:" << info.flip()
1709 << "StepX:" << info.steps()[0]
1710 << "StepY:" << info.steps()[1]
1711 << "MinSizes:" << info.min_sizes().size()
1712 << "MaxSizes:" << info.max_sizes().size()
1713 << "ImgSizeX:" << info.img_size().x
1714 << "ImgSizeY:" << info.img_size().y
1715 << "Offset:" << info.offset()
1716 << "Variances:" << info.variances().size();
1717 str << "}";
1718 return str.str();
1719}
1720
Alex Gildayc357c472018-03-21 13:54:09 +00001721/** Formatted output of the Size2D type.
1722 *
1723 * @param[out] os Output stream
1724 * @param[in] size Type to output
1725 *
1726 * @return Modified output stream.
1727 */
John Richardson25f23682017-11-27 14:35:09 +00001728inline ::std::ostream &operator<<(::std::ostream &os, const Size2D &size)
1729{
1730 os << size.width << "x" << size.height;
1731
1732 return os;
1733}
1734
Alex Gildayc357c472018-03-21 13:54:09 +00001735/** Formatted output of the Size2D type.
1736 *
1737 * @param[in] type Type to output
1738 *
1739 * @return Formatted string.
1740 */
John Richardson25f23682017-11-27 14:35:09 +00001741inline std::string to_string(const Size2D &type)
1742{
1743 std::stringstream str;
1744 str << type;
1745 return str.str();
1746}
1747
Alex Gildayc357c472018-03-21 13:54:09 +00001748/** Formatted output of the ConvolutionMethod type.
1749 *
1750 * @param[out] os Output stream
1751 * @param[in] conv_method Type to output
1752 *
1753 * @return Modified output stream.
1754 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001755inline ::std::ostream &operator<<(::std::ostream &os, const ConvolutionMethod &conv_method)
1756{
1757 switch(conv_method)
1758 {
1759 case ConvolutionMethod::GEMM:
1760 os << "GEMM";
1761 break;
1762 case ConvolutionMethod::DIRECT:
1763 os << "DIRECT";
1764 break;
1765 case ConvolutionMethod::WINOGRAD:
1766 os << "WINOGRAD";
1767 break;
1768 default:
1769 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1770 }
1771
1772 return os;
1773}
1774
Alex Gildayc357c472018-03-21 13:54:09 +00001775/** Formatted output of the ConvolutionMethod type.
1776 *
1777 * @param[in] conv_method Type to output
1778 *
1779 * @return Formatted string.
1780 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001781inline std::string to_string(const ConvolutionMethod &conv_method)
1782{
1783 std::stringstream str;
1784 str << conv_method;
1785 return str.str();
1786}
1787
Alex Gildayc357c472018-03-21 13:54:09 +00001788/** Formatted output of the GPUTarget type.
1789 *
1790 * @param[out] os Output stream
1791 * @param[in] gpu_target Type to output
1792 *
1793 * @return Modified output stream.
1794 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001795inline ::std::ostream &operator<<(::std::ostream &os, const GPUTarget &gpu_target)
1796{
1797 switch(gpu_target)
1798 {
1799 case GPUTarget::GPU_ARCH_MASK:
1800 os << "GPU_ARCH_MASK";
1801 break;
1802 case GPUTarget::MIDGARD:
1803 os << "MIDGARD";
1804 break;
1805 case GPUTarget::BIFROST:
1806 os << "BIFROST";
1807 break;
Georgios Pinitasd5462ff2019-07-03 19:33:57 +01001808 case GPUTarget::VALHALL:
1809 os << "VALHALL";
1810 break;
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001811 case GPUTarget::T600:
1812 os << "T600";
1813 break;
1814 case GPUTarget::T700:
1815 os << "T700";
1816 break;
1817 case GPUTarget::T800:
1818 os << "T800";
1819 break;
Michalis Spyroua9676112018-02-22 18:07:43 +00001820 case GPUTarget::G71:
1821 os << "G71";
1822 break;
1823 case GPUTarget::G72:
1824 os << "G72";
1825 break;
1826 case GPUTarget::G51:
1827 os << "G51";
1828 break;
1829 case GPUTarget::G51BIG:
1830 os << "G51BIG";
1831 break;
1832 case GPUTarget::G51LIT:
1833 os << "G51LIT";
1834 break;
Georgios Pinitasb03f7c52018-07-12 10:49:53 +01001835 case GPUTarget::G76:
1836 os << "G76";
Michalis Spyroua9676112018-02-22 18:07:43 +00001837 break;
Georgios Pinitasd5462ff2019-07-03 19:33:57 +01001838 case GPUTarget::G77:
1839 os << "G77";
Michalis Spyroua9676112018-02-22 18:07:43 +00001840 break;
Georgios Pinitas4ffc42a2020-12-01 16:28:24 +00001841 case GPUTarget::G78:
1842 os << "G78";
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001843 break;
Pablo Marquez Tellob1496e62021-06-25 14:49:37 +01001844 case GPUTarget::G31:
1845 os << "G31";
1846 break;
Georgios Pinitasd5462ff2019-07-03 19:33:57 +01001847 case GPUTarget::TODX:
1848 os << "TODX";
1849 break;
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001850 default:
1851 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1852 }
1853
1854 return os;
1855}
1856
Alex Gildayc357c472018-03-21 13:54:09 +00001857/** Formatted output of the GPUTarget type.
1858 *
1859 * @param[in] gpu_target Type to output
1860 *
1861 * @return Formatted string.
1862 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001863inline std::string to_string(const GPUTarget &gpu_target)
1864{
1865 std::stringstream str;
1866 str << gpu_target;
1867 return str.str();
1868}
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00001869
John Richardson8de92612018-02-22 14:09:31 +00001870/** Formatted output of the DetectionWindow type.
1871 *
1872 * @param[out] os Output stream
1873 * @param[in] detection_window Type to output
1874 *
1875 * @return Modified output stream.
1876 */
John Richardson684cb0f2018-01-09 11:17:00 +00001877inline ::std::ostream &operator<<(::std::ostream &os, const DetectionWindow &detection_window)
1878{
1879 os << "{x=" << detection_window.x << ","
1880 << "y=" << detection_window.y << ","
1881 << "width=" << detection_window.width << ","
1882 << "height=" << detection_window.height << ","
1883 << "idx_class=" << detection_window.idx_class << ","
1884 << "score=" << detection_window.score << "}";
1885
1886 return os;
1887}
1888
Isabella Gottardi05e56442018-11-16 11:26:52 +00001889/** Formatted output of the DetectionOutputLayerCodeType type.
1890 *
1891 * @param[out] os Output stream
1892 * @param[in] detection_code Type to output
1893 *
1894 * @return Modified output stream.
1895 */
1896inline ::std::ostream &operator<<(::std::ostream &os, const DetectionOutputLayerCodeType &detection_code)
1897{
1898 switch(detection_code)
1899 {
1900 case DetectionOutputLayerCodeType::CENTER_SIZE:
1901 os << "CENTER_SIZE";
1902 break;
1903 case DetectionOutputLayerCodeType::CORNER:
1904 os << "CORNER";
1905 break;
1906 case DetectionOutputLayerCodeType::CORNER_SIZE:
1907 os << "CORNER_SIZE";
1908 break;
1909 case DetectionOutputLayerCodeType::TF_CENTER:
1910 os << "TF_CENTER";
1911 break;
1912 default:
1913 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1914 }
1915
1916 return os;
1917}
1918/** Formatted output of the DetectionOutputLayerCodeType type.
1919 *
1920 * @param[in] detection_code Type to output
1921 *
1922 * @return Formatted string.
1923 */
1924inline std::string to_string(const DetectionOutputLayerCodeType &detection_code)
1925{
1926 std::stringstream str;
1927 str << detection_code;
1928 return str.str();
1929}
1930
1931/** Formatted output of the DetectionOutputLayerInfo type.
1932 *
1933 * @param[out] os Output stream
1934 * @param[in] detection_info Type to output
1935 *
1936 * @return Modified output stream.
1937 */
1938inline ::std::ostream &operator<<(::std::ostream &os, const DetectionOutputLayerInfo &detection_info)
1939{
1940 os << "{Classes=" << detection_info.num_classes() << ","
1941 << "ShareLocation=" << detection_info.share_location() << ","
1942 << "CodeType=" << detection_info.code_type() << ","
1943 << "VarianceEncodedInTarget=" << detection_info.variance_encoded_in_target() << ","
1944 << "KeepTopK=" << detection_info.keep_top_k() << ","
1945 << "NMSThreshold=" << detection_info.nms_threshold() << ","
1946 << "Eta=" << detection_info.eta() << ","
1947 << "BackgroundLabelId=" << detection_info.background_label_id() << ","
1948 << "ConfidenceThreshold=" << detection_info.confidence_threshold() << ","
1949 << "TopK=" << detection_info.top_k() << ","
1950 << "NumLocClasses=" << detection_info.num_loc_classes()
1951 << "}";
1952
1953 return os;
1954}
1955
1956/** Formatted output of the DetectionOutputLayerInfo type.
1957 *
1958 * @param[in] detection_info Type to output
1959 *
1960 * @return Formatted string.
1961 */
1962inline std::string to_string(const DetectionOutputLayerInfo &detection_info)
1963{
1964 std::stringstream str;
1965 str << detection_info;
1966 return str.str();
1967}
Isabella Gottardia7acb3c2019-01-08 13:48:44 +00001968/** Formatted output of the DetectionPostProcessLayerInfo type.
1969 *
1970 * @param[out] os Output stream
1971 * @param[in] detection_info Type to output
1972 *
1973 * @return Modified output stream.
1974 */
1975inline ::std::ostream &operator<<(::std::ostream &os, const DetectionPostProcessLayerInfo &detection_info)
1976{
1977 os << "{MaxDetections=" << detection_info.max_detections() << ","
1978 << "MaxClassesPerDetection=" << detection_info.max_classes_per_detection() << ","
1979 << "NmsScoreThreshold=" << detection_info.nms_score_threshold() << ","
1980 << "NmsIouThreshold=" << detection_info.iou_threshold() << ","
1981 << "NumClasses=" << detection_info.num_classes() << ","
1982 << "ScaleValue_y=" << detection_info.scale_value_y() << ","
1983 << "ScaleValue_x=" << detection_info.scale_value_x() << ","
1984 << "ScaleValue_h=" << detection_info.scale_value_h() << ","
1985 << "ScaleValue_w=" << detection_info.scale_value_w() << ","
1986 << "UseRegularNms=" << detection_info.use_regular_nms() << ","
1987 << "DetectionPerClass=" << detection_info.detection_per_class()
1988 << "}";
1989
1990 return os;
1991}
1992
1993/** Formatted output of the DetectionPostProcessLayerInfo type.
1994 *
1995 * @param[in] detection_info Type to output
1996 *
1997 * @return Formatted string.
1998 */
1999inline std::string to_string(const DetectionPostProcessLayerInfo &detection_info)
2000{
2001 std::stringstream str;
2002 str << detection_info;
2003 return str.str();
2004}
Georgios Pinitasc6f95102021-03-30 10:03:01 +01002005
John Richardson8de92612018-02-22 14:09:31 +00002006/** Formatted output of the DetectionWindow type.
2007 *
2008 * @param[in] detection_window Type to output
2009 *
2010 * @return Formatted string.
2011 */
2012inline std::string to_string(const DetectionWindow &detection_window)
2013{
2014 std::stringstream str;
2015 str << detection_window;
2016 return str.str();
2017}
2018
Anthony Barbier671a11e2018-07-06 15:11:36 +01002019/** Formatted output of a vector of objects.
2020 *
2021 * @param[out] os Output stream
2022 * @param[in] args Vector of objects to print
2023 *
2024 * @return Modified output stream.
2025 */
2026template <typename T>
2027inline ::std::ostream &operator<<(::std::ostream &os, const std::vector<T> &args)
2028{
2029 os << "[";
2030 bool first = true;
2031 for(auto &arg : args)
2032 {
2033 if(first)
2034 {
2035 first = false;
2036 }
2037 else
2038 {
2039 os << ", ";
2040 }
2041 os << arg;
2042 }
2043 os << "]";
2044 return os;
2045}
2046
Michalis Spyrou6c7c38e2018-08-29 16:28:11 +01002047/** Formatted output of @ref PriorBoxLayerInfo.
2048 *
2049 * @param[out] os Output stream.
2050 * @param[in] info Type to output.
2051 *
2052 * @return Modified output stream.
2053 */
2054inline ::std::ostream &operator<<(::std::ostream &os, const PriorBoxLayerInfo &info)
2055{
2056 os << "Clip:" << info.clip()
2057 << "Flip:" << info.flip()
2058 << "StepX:" << info.steps()[0]
2059 << "StepY:" << info.steps()[1]
2060 << "MinSizes:" << info.min_sizes()
2061 << "MaxSizes:" << info.max_sizes()
2062 << "ImgSizeX:" << info.img_size().x
2063 << "ImgSizeY:" << info.img_size().y
2064 << "Offset:" << info.offset()
2065 << "Variances:" << info.variances();
2066
2067 return os;
2068}
2069
Anthony Barbier671a11e2018-07-06 15:11:36 +01002070/** Formatted output of a vector of objects.
2071 *
2072 * @param[in] args Vector of objects to print
2073 *
2074 * @return String representing args.
2075 */
2076template <typename T>
2077std::string to_string(const std::vector<T> &args)
2078{
2079 std::stringstream str;
2080 str << args;
2081 return str.str();
2082}
2083
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00002084/** Formatted output of the WinogradInfo type. */
2085inline ::std::ostream &operator<<(::std::ostream &os, const WinogradInfo &info)
2086{
2087 os << "{OutputTileSize=" << info.output_tile_size << ","
2088 << "KernelSize=" << info.kernel_size << ","
2089 << "PadStride=" << info.convolution_info << ","
2090 << "OutputDataLayout=" << info.output_data_layout << "}";
2091
2092 return os;
2093}
2094
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00002095inline std::string to_string(const WinogradInfo &type)
2096{
2097 std::stringstream str;
2098 str << type;
2099 return str.str();
2100}
Anthony Barbier671a11e2018-07-06 15:11:36 +01002101
2102/** Fallback method: try to use std::to_string:
2103 *
2104 * @param[in] val Value to convert to string
2105 *
2106 * @return String representing val.
2107 */
2108template <typename T>
2109inline std::string to_string(const T &val)
2110{
2111 return support::cpp11::to_string(val);
2112}
2113
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +01002114/** Convert a CLTunerMode value to a string
2115 *
2116 * @param val CLTunerMode value to be converted
2117 *
2118 * @return String representing the corresponding CLTunerMode.
2119 */
2120inline std::string to_string(const CLTunerMode val)
2121{
2122 switch(val)
2123 {
2124 case CLTunerMode::EXHAUSTIVE:
2125 {
2126 return std::string("Exhaustive");
2127 }
2128 case CLTunerMode::NORMAL:
2129 {
2130 return std::string("Normal");
2131 }
2132 case CLTunerMode::RAPID:
2133 {
2134 return std::string("Rapid");
2135 }
2136 default:
2137 {
2138 ARM_COMPUTE_ERROR("Invalid tuner mode.");
2139 return std::string("UNDEFINED");
2140 }
2141 }
2142}
SiCong Lidb4a6c12021-02-05 09:30:57 +00002143/** Converts a @ref CLGEMMKernelType to string
2144 *
2145 * @param[in] val CLGEMMKernelType value to be converted
2146 *
2147 * @return String representing the corresponding CLGEMMKernelType
2148 */
2149inline std::string to_string(CLGEMMKernelType val)
2150{
2151 switch(val)
2152 {
2153 case CLGEMMKernelType::NATIVE_V1:
2154 {
2155 return "Native_V1";
2156 }
2157 case CLGEMMKernelType::RESHAPED_V1:
2158 {
2159 return "Reshaped_V1";
2160 }
2161 case CLGEMMKernelType::NATIVE:
2162 {
2163 return "Native";
2164 }
2165 case CLGEMMKernelType::RESHAPED_ONLY_RHS:
2166 {
2167 return "Reshaped_Only_RHS";
2168 }
2169 case CLGEMMKernelType::RESHAPED:
2170 {
2171 return "Reshaped";
2172 }
2173 default:
2174 {
2175 return "Unknown";
2176 }
2177 }
2178}
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +01002179/** [Print CLTunerMode type] **/
2180/** Formatted output of the CLTunerMode type.
2181 *
2182 * @param[out] os Output stream.
2183 * @param[in] val CLTunerMode to output.
2184 *
2185 * @return Modified output stream.
2186 */
2187inline ::std::ostream &operator<<(::std::ostream &os, const CLTunerMode &val)
2188{
2189 os << to_string(val);
2190 return os;
2191}
2192
Anthony Barbier6ff3b192017-09-04 18:44:23 +01002193} // namespace arm_compute
Anthony Barbier4dbc0a92018-08-27 13:39:47 +01002194
2195#endif /* __ARM_COMPUTE_TYPE_PRINTER_H__ */