blob: e849edc0929784a711e3789c91af81b132acce3b [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001/*
SiCong Lidb4a6c12021-02-05 09:30:57 +00002 * Copyright (c) 2017-2021 Arm Limited.
Anthony Barbier6ff3b192017-09-04 18:44:23 +01003 *
4 * SPDX-License-Identifier: MIT
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
Anthony Barbier4dbc0a92018-08-27 13:39:47 +010024#ifndef __ARM_COMPUTE_TYPE_PRINTER_H__
25#define __ARM_COMPUTE_TYPE_PRINTER_H__
Anthony Barbier6ff3b192017-09-04 18:44:23 +010026
Anthony Barbier8914e322018-08-10 15:28:25 +010027#include "arm_compute/core/CPP/CPPTypes.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010028#include "arm_compute/core/Dimensions.h"
29#include "arm_compute/core/Error.h"
Michele Di Giorgiob8fc60f2018-04-25 11:58:07 +010030#include "arm_compute/core/GPUTarget.h"
morgolockaba2f912020-05-05 16:28:19 +010031#include "arm_compute/core/KernelDescriptors.h"
John Richardson25f23682017-11-27 14:35:09 +000032#include "arm_compute/core/Size2D.h"
John Richardsona36eae12017-09-26 16:55:59 +010033#include "arm_compute/core/Strides.h"
Georgios Pinitas3faea252017-10-30 14:13:50 +000034#include "arm_compute/core/TensorInfo.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010035#include "arm_compute/core/Types.h"
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +010036#include "arm_compute/runtime/CL/CLTunerTypes.h"
SiCong Lidb4a6c12021-02-05 09:30:57 +000037#include "arm_compute/runtime/CL/CLTypes.h"
Matthew Bentham758b5ba2020-03-05 23:37:48 +000038#include "support/StringSupport.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010039
40#include <ostream>
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010041#include <sstream>
42#include <string>
Anthony Barbier6ff3b192017-09-04 18:44:23 +010043
44namespace arm_compute
45{
Anthony Barbierb940fd62018-06-04 14:14:32 +010046/** Formatted output if arg is not null
47 *
48 * @param[in] arg Object to print
49 *
50 * @return String representing arg.
51 */
52template <typename T>
53std::string to_string_if_not_null(T *arg)
54{
55 if(arg == nullptr)
56 {
57 return "nullptr";
58 }
59 else
60 {
61 return to_string(*arg);
62 }
63}
Anthony Barbierb4670212018-05-18 16:55:39 +010064
Alex Gildayc357c472018-03-21 13:54:09 +000065/** Formatted output of the Dimensions type.
66 *
67 * @param[out] os Output stream.
68 * @param[in] dimensions Type to output.
69 *
70 * @return Modified output stream.
71 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +010072template <typename T>
73inline ::std::ostream &operator<<(::std::ostream &os, const Dimensions<T> &dimensions)
74{
Anthony Barbier6ff3b192017-09-04 18:44:23 +010075 if(dimensions.num_dimensions() > 0)
76 {
77 os << dimensions[0];
78
79 for(unsigned int d = 1; d < dimensions.num_dimensions(); ++d)
80 {
Moritz Pflanzerc87fbf82017-07-18 14:02:10 +010081 os << "x" << dimensions[d];
Anthony Barbier6ff3b192017-09-04 18:44:23 +010082 }
83 }
84
Anthony Barbier6ff3b192017-09-04 18:44:23 +010085 return os;
86}
87
Alex Gildayc357c472018-03-21 13:54:09 +000088/** Formatted output of the RoundingPolicy type.
89 *
90 * @param[out] os Output stream.
91 * @param[in] rounding_policy Type to output.
92 *
93 * @return Modified output stream.
94 */
Anthony Barbier2a07e182017-08-04 18:20:27 +010095inline ::std::ostream &operator<<(::std::ostream &os, const RoundingPolicy &rounding_policy)
Anthony Barbier6ff3b192017-09-04 18:44:23 +010096{
Anthony Barbier2a07e182017-08-04 18:20:27 +010097 switch(rounding_policy)
Anthony Barbier6ff3b192017-09-04 18:44:23 +010098 {
Anthony Barbier2a07e182017-08-04 18:20:27 +010099 case RoundingPolicy::TO_ZERO:
100 os << "TO_ZERO";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100101 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100102 case RoundingPolicy::TO_NEAREST_UP:
103 os << "TO_NEAREST_UP";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100104 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100105 case RoundingPolicy::TO_NEAREST_EVEN:
106 os << "TO_NEAREST_EVEN";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100107 break;
108 default:
109 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
110 }
111
112 return os;
113}
114
Alex Gildayc357c472018-03-21 13:54:09 +0000115/** Formatted output of the WeightsInfo type.
116 *
117 * @param[out] os Output stream.
118 * @param[in] weights_info Type to output.
119 *
120 * @return Modified output stream.
121 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100122inline ::std::ostream &operator<<(::std::ostream &os, const WeightsInfo &weights_info)
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100123{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100124 os << weights_info.are_reshaped() << ";";
125 os << weights_info.num_kernels() << ";" << weights_info.kernel_size().first << "," << weights_info.kernel_size().second;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100126
127 return os;
128}
129
Alex Gildayc357c472018-03-21 13:54:09 +0000130/** Formatted output of the ROIPoolingInfo type.
131 *
132 * @param[out] os Output stream.
133 * @param[in] pool_info Type to output.
134 *
135 * @return Modified output stream.
136 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100137inline ::std::ostream &operator<<(::std::ostream &os, const ROIPoolingLayerInfo &pool_info)
Sanghoon Lee70f82912017-08-24 14:21:24 +0100138{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100139 os << pool_info.pooled_width() << "x" << pool_info.pooled_height() << "~" << pool_info.spatial_scale();
Georgios Pinitasd9769582017-08-03 10:19:40 +0100140 return os;
141}
142
giuros0118870812018-09-13 09:31:40 +0100143/** Formatted output of the ROIPoolingInfo type.
144 *
145 * @param[in] pool_info Type to output.
146 *
147 * @return Formatted string.
148 */
149inline std::string to_string(const ROIPoolingLayerInfo &pool_info)
150{
151 std::stringstream str;
152 str << pool_info;
153 return str.str();
154}
155
morgolockaba2f912020-05-05 16:28:19 +0100156/** Formatted output of the GEMMKernelInfo type.
157 *
158 * @param[out] os Output stream.
159 * @param[in] gemm_info Type to output.
160 *
161 * @return Modified output stream.
162 */
163inline ::std::ostream &operator<<(::std::ostream &os, const GEMMKernelInfo &gemm_info)
164{
165 os << "( m= " << gemm_info.m;
166 os << " n= " << gemm_info.n;
167 os << " k= " << gemm_info.k;
168 os << " depth_output_gemm3d= " << gemm_info.depth_output_gemm3d;
169 os << " reinterpret_input_as_3d= " << gemm_info.reinterpret_input_as_3d;
170 os << " broadcast_bias= " << gemm_info.broadcast_bias;
171 os << " fp_mixed_precision= " << gemm_info.fp_mixed_precision;
172 os << " mult_transpose1xW_width= " << gemm_info.mult_transpose1xW_width;
173 os << " mult_interleave4x4_height= " << gemm_info.mult_interleave4x4_height;
174 os << " a_offset = " << gemm_info.a_offset;
175 os << " b_offset = " << gemm_info.b_offset;
176 os << ")";
177 return os;
178}
179
180/** Formatted output of the GEMMLHSMatrixInfo type.
181 *
182 * @param[out] os Output stream.
183 * @param[in] gemm_info Type to output.
184 *
185 * @return Modified output stream.
186 */
187inline ::std::ostream &operator<<(::std::ostream &os, const GEMMLHSMatrixInfo &gemm_info)
188{
189 os << "( m0= " << (unsigned int)gemm_info.m0 << " k0= " << gemm_info.k0 << " v0= " << gemm_info.v0 << " trans= " << gemm_info.transpose << " inter= " << gemm_info.interleave << "})";
190 return os;
191}
192
193/** Formatted output of the GEMMRHSMatrixInfo type.
194 *
195 * @param[out] os Output stream.
196 * @param[in] gemm_info Type to output.
197 *
198 * @return Modified output stream.
199 */
200inline ::std::ostream &operator<<(::std::ostream &os, const GEMMRHSMatrixInfo &gemm_info)
201{
SiCong Lidb4a6c12021-02-05 09:30:57 +0000202 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=" <<
203 gemm_info.export_to_cl_image << "})";
morgolockaba2f912020-05-05 16:28:19 +0100204 return os;
205}
206
207/** Formatted output of the GEMMRHSMatrixInfo type.
208 *
209 * @param[in] gemm_info GEMMRHSMatrixInfo to output.
210 *
211 * @return Formatted string.
212 */
213inline std::string to_string(const GEMMRHSMatrixInfo &gemm_info)
214{
215 std::stringstream str;
216 str << gemm_info;
217 return str.str();
218}
219
220/** Formatted output of the GEMMLHSMatrixInfo type.
221 *
222 * @param[in] gemm_info GEMMLHSMatrixInfo to output.
223 *
224 * @return Formatted string.
225 */
226inline std::string to_string(const GEMMLHSMatrixInfo &gemm_info)
227{
228 std::stringstream str;
229 str << gemm_info;
230 return str.str();
231}
232
233/** Formatted output of the GEMMKernelInfo type.
234 *
235 * @param[in] gemm_info GEMMKernelInfo Type to output.
236 *
237 * @return Formatted string.
238 */
239inline std::string to_string(const GEMMKernelInfo &gemm_info)
240{
241 std::stringstream str;
242 str << gemm_info;
243 return str.str();
244}
245
giuros01c04a0e82018-10-03 12:44:35 +0100246/** Formatted output of the BoundingBoxTransformInfo type.
247 *
248 * @param[out] os Output stream.
249 * @param[in] bbox_info Type to output.
250 *
251 * @return Modified output stream.
252 */
253inline ::std::ostream &operator<<(::std::ostream &os, const BoundingBoxTransformInfo &bbox_info)
254{
255 auto weights = bbox_info.weights();
256 os << "(" << bbox_info.img_width() << "x" << bbox_info.img_height() << ")~" << bbox_info.scale() << "(weights = {" << weights[0] << ", " << weights[1] << ", " << weights[2] << ", " << weights[3] <<
257 "})";
258 return os;
259}
260
261/** Formatted output of the BoundingBoxTransformInfo type.
262 *
263 * @param[in] bbox_info Type to output.
264 *
265 * @return Formatted string.
266 */
267inline std::string to_string(const BoundingBoxTransformInfo &bbox_info)
268{
269 std::stringstream str;
270 str << bbox_info;
271 return str.str();
272}
273
Manuel Bottini5209be52019-02-13 16:34:56 +0000274/** Formatted output of the ComputeAnchorsInfo type.
275 *
276 * @param[out] os Output stream.
277 * @param[in] anchors_info Type to output.
278 *
279 * @return Modified output stream.
280 */
281inline ::std::ostream &operator<<(::std::ostream &os, const ComputeAnchorsInfo &anchors_info)
282{
283 os << "(" << anchors_info.feat_width() << "x" << anchors_info.feat_height() << ")~" << anchors_info.spatial_scale();
284 return os;
285}
286
287/** Formatted output of the ComputeAnchorsInfo type.
288 *
289 * @param[in] anchors_info Type to output.
290 *
291 * @return Formatted string.
292 */
293inline std::string to_string(const ComputeAnchorsInfo &anchors_info)
294{
295 std::stringstream str;
296 str << anchors_info;
297 return str.str();
298}
299
300/** Formatted output of the GenerateProposalsInfo type.
301 *
302 * @param[out] os Output stream.
303 * @param[in] proposals_info Type to output.
304 *
305 * @return Modified output stream.
306 */
307inline ::std::ostream &operator<<(::std::ostream &os, const GenerateProposalsInfo &proposals_info)
308{
309 os << "(" << proposals_info.im_width() << "x" << proposals_info.im_height() << ")~" << proposals_info.im_scale();
310 return os;
311}
312
313/** Formatted output of the GenerateProposalsInfo type.
314 *
315 * @param[in] proposals_info Type to output.
316 *
317 * @return Formatted string.
318 */
319inline std::string to_string(const GenerateProposalsInfo &proposals_info)
320{
321 std::stringstream str;
322 str << proposals_info;
323 return str.str();
324}
325
Alex Gildayc357c472018-03-21 13:54:09 +0000326/** Formatted output of the QuantizationInfo type.
327 *
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100328 * @param[out] os Output stream.
329 * @param[in] qinfo Type to output.
Alex Gildayc357c472018-03-21 13:54:09 +0000330 *
331 * @return Modified output stream.
332 */
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100333inline ::std::ostream &operator<<(::std::ostream &os, const QuantizationInfo &qinfo)
Chunosovd621bca2017-11-03 17:33:15 +0700334{
Georgios Pinitas3d13af82019-06-04 13:04:16 +0100335 const UniformQuantizationInfo uqinfo = qinfo.uniform();
336 os << "Scale:" << uqinfo.scale << "~";
337 os << "Offset:" << uqinfo.offset;
Chunosovd621bca2017-11-03 17:33:15 +0700338 return os;
339}
340
Alex Gildayc357c472018-03-21 13:54:09 +0000341/** Formatted output of the QuantizationInfo type.
342 *
343 * @param[in] quantization_info Type to output.
344 *
345 * @return Formatted string.
346 */
Chunosovd621bca2017-11-03 17:33:15 +0700347inline std::string to_string(const QuantizationInfo &quantization_info)
348{
349 std::stringstream str;
350 str << quantization_info;
351 return str.str();
352}
353
Alex Gildayc357c472018-03-21 13:54:09 +0000354/** Formatted output of the activation function type.
355 *
356 * @param[out] os Output stream.
357 * @param[in] act_function Type to output.
358 *
359 * @return Modified output stream.
360 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100361inline ::std::ostream &operator<<(::std::ostream &os, const ActivationLayerInfo::ActivationFunction &act_function)
362{
363 switch(act_function)
364 {
365 case ActivationLayerInfo::ActivationFunction::ABS:
366 os << "ABS";
367 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100368 case ActivationLayerInfo::ActivationFunction::LINEAR:
369 os << "LINEAR";
370 break;
371 case ActivationLayerInfo::ActivationFunction::LOGISTIC:
372 os << "LOGISTIC";
373 break;
374 case ActivationLayerInfo::ActivationFunction::RELU:
375 os << "RELU";
376 break;
Georgios Pinitas579c0492017-07-12 16:12:12 +0100377 case ActivationLayerInfo::ActivationFunction::BOUNDED_RELU:
378 os << "BOUNDED_RELU";
379 break;
380 case ActivationLayerInfo::ActivationFunction::LEAKY_RELU:
381 os << "LEAKY_RELU";
382 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100383 case ActivationLayerInfo::ActivationFunction::SOFT_RELU:
384 os << "SOFT_RELU";
385 break;
386 case ActivationLayerInfo::ActivationFunction::SQRT:
387 os << "SQRT";
388 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100389 case ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU:
390 os << "LU_BOUNDED_RELU";
Kevin Petitd9f80712017-12-06 12:18:48 +0000391 break;
Georgios Pinitasfb0fdcd2019-08-22 17:10:04 +0100392 case ActivationLayerInfo::ActivationFunction::ELU:
393 os << "ELU";
394 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100395 case ActivationLayerInfo::ActivationFunction::SQUARE:
396 os << "SQUARE";
397 break;
398 case ActivationLayerInfo::ActivationFunction::TANH:
399 os << "TANH";
400 break;
Usama Arif6a98a6e2019-05-10 17:07:27 +0100401 case ActivationLayerInfo::ActivationFunction::IDENTITY:
402 os << "IDENTITY";
403 break;
morgolock07df3d42020-02-27 11:46:28 +0000404 case ActivationLayerInfo::ActivationFunction::HARD_SWISH:
405 os << "HARD_SWISH";
406 break;
407
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100408 default:
409 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
410 }
411
412 return os;
413}
414
Alex Gildayc357c472018-03-21 13:54:09 +0000415/** Formatted output of the activation function info type.
416 *
417 * @param[in] info Type to output.
418 *
419 * @return Formatted string.
420 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100421inline std::string to_string(const arm_compute::ActivationLayerInfo &info)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100422{
423 std::stringstream str;
Isabella Gottardi3f217ec2018-02-12 14:59:19 +0000424 if(info.enabled())
425 {
426 str << info.activation();
427 }
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100428 return str.str();
429}
430
Alex Gildayc357c472018-03-21 13:54:09 +0000431/** Formatted output of the activation function type.
432 *
433 * @param[in] function Type to output.
434 *
435 * @return Formatted string.
436 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100437inline std::string to_string(const arm_compute::ActivationLayerInfo::ActivationFunction &function)
438{
439 std::stringstream str;
440 str << function;
441 return str.str();
442}
443
Alex Gildayc357c472018-03-21 13:54:09 +0000444/** Formatted output of the NormType type.
445 *
446 * @param[out] os Output stream.
447 * @param[in] norm_type Type to output.
448 *
449 * @return Modified output stream.
450 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100451inline ::std::ostream &operator<<(::std::ostream &os, const NormType &norm_type)
452{
453 switch(norm_type)
454 {
455 case NormType::CROSS_MAP:
456 os << "CROSS_MAP";
457 break;
458 case NormType::IN_MAP_1D:
459 os << "IN_MAP_1D";
460 break;
461 case NormType::IN_MAP_2D:
462 os << "IN_MAP_2D";
463 break;
464 default:
465 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
466 }
467
468 return os;
469}
470
Alex Gildayc357c472018-03-21 13:54:09 +0000471/** Formatted output of @ref NormalizationLayerInfo.
472 *
473 * @param[in] info Type to output.
474 *
475 * @return Formatted string.
476 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100477inline std::string to_string(const arm_compute::NormalizationLayerInfo &info)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100478{
479 std::stringstream str;
Michalis Spyroud466c2d2018-01-30 10:54:39 +0000480 str << info.type() << ":NormSize=" << info.norm_size();
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100481 return str.str();
482}
483
Alex Gildayc357c472018-03-21 13:54:09 +0000484/** Formatted output of @ref NormalizationLayerInfo.
485 *
486 * @param[out] os Output stream.
487 * @param[in] info Type to output.
488 *
489 * @return Modified output stream.
490 */
Georgios Pinitas6f669f02017-09-26 12:32:57 +0100491inline ::std::ostream &operator<<(::std::ostream &os, const NormalizationLayerInfo &info)
492{
Michalis Spyroud466c2d2018-01-30 10:54:39 +0000493 os << info.type() << ":NormSize=" << info.norm_size();
Georgios Pinitas6f669f02017-09-26 12:32:57 +0100494 return os;
495}
496
Alex Gildayc357c472018-03-21 13:54:09 +0000497/** Formatted output of the PoolingType type.
498 *
499 * @param[out] os Output stream.
500 * @param[in] pool_type Type to output.
501 *
502 * @return Modified output stream.
503 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100504inline ::std::ostream &operator<<(::std::ostream &os, const PoolingType &pool_type)
505{
506 switch(pool_type)
507 {
508 case PoolingType::AVG:
509 os << "AVG";
510 break;
511 case PoolingType::MAX:
512 os << "MAX";
513 break;
Georgios Pinitascdf51452017-08-31 14:21:36 +0100514 case PoolingType::L2:
515 os << "L2";
516 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100517 default:
518 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
519 }
520
521 return os;
522}
523
Alex Gildayc357c472018-03-21 13:54:09 +0000524/** Formatted output of @ref PoolingLayerInfo.
525 *
526 * @param[out] os Output stream.
527 * @param[in] info Type to output.
528 *
529 * @return Modified output stream.
530 */
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100531inline ::std::ostream &operator<<(::std::ostream &os, const PoolingLayerInfo &info)
532{
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +0000533 os << info.pool_type;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100534
535 return os;
536}
537
Alex Gildayc357c472018-03-21 13:54:09 +0000538/** Formatted output of @ref RoundingPolicy.
539 *
540 * @param[in] rounding_policy Type to output.
541 *
542 * @return Formatted string.
543 */
John Richardsondd715f22017-09-18 16:10:48 +0100544inline std::string to_string(const RoundingPolicy &rounding_policy)
545{
546 std::stringstream str;
547 str << rounding_policy;
548 return str.str();
549}
550
Vidhya Sudhan Loganathand646ae12018-11-19 15:18:20 +0000551/** [Print DataLayout type] **/
Alex Gildayc357c472018-03-21 13:54:09 +0000552/** Formatted output of the DataLayout type.
553 *
554 * @param[out] os Output stream.
555 * @param[in] data_layout Type to output.
556 *
557 * @return Modified output stream.
558 */
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000559inline ::std::ostream &operator<<(::std::ostream &os, const DataLayout &data_layout)
560{
561 switch(data_layout)
562 {
563 case DataLayout::UNKNOWN:
564 os << "UNKNOWN";
565 break;
566 case DataLayout::NHWC:
567 os << "NHWC";
568 break;
569 case DataLayout::NCHW:
570 os << "NCHW";
571 break;
572 default:
573 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
574 }
575
576 return os;
577}
578
Alex Gildayc357c472018-03-21 13:54:09 +0000579/** Formatted output of the DataLayout type.
580 *
581 * @param[in] data_layout Type to output.
582 *
583 * @return Formatted string.
584 */
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000585inline std::string to_string(const arm_compute::DataLayout &data_layout)
586{
587 std::stringstream str;
588 str << data_layout;
589 return str.str();
590}
Vidhya Sudhan Loganathand646ae12018-11-19 15:18:20 +0000591/** [Print DataLayout type] **/
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000592
Georgios Pinitase2220552018-07-20 13:23:44 +0100593/** Formatted output of the DataLayoutDimension type.
594 *
595 * @param[out] os Output stream.
596 * @param[in] data_layout_dim Data layout dimension to print.
597 *
598 * @return Modified output stream.
599 */
600inline ::std::ostream &operator<<(::std::ostream &os, const DataLayoutDimension &data_layout_dim)
601{
602 switch(data_layout_dim)
603 {
604 case DataLayoutDimension::WIDTH:
605 os << "WIDTH";
606 break;
607 case DataLayoutDimension::HEIGHT:
608 os << "HEIGHT";
609 break;
610 case DataLayoutDimension::CHANNEL:
611 os << "CHANNEL";
612 break;
613 case DataLayoutDimension::BATCHES:
614 os << "BATCHES";
615 break;
616 default:
617 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
618 }
619 return os;
620}
621
Alex Gildayc357c472018-03-21 13:54:09 +0000622/** Formatted output of the DataType type.
623 *
624 * @param[out] os Output stream.
625 * @param[in] data_type Type to output.
626 *
627 * @return Modified output stream.
628 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100629inline ::std::ostream &operator<<(::std::ostream &os, const DataType &data_type)
630{
631 switch(data_type)
632 {
633 case DataType::UNKNOWN:
634 os << "UNKNOWN";
635 break;
636 case DataType::U8:
637 os << "U8";
638 break;
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100639 case DataType::QSYMM8:
640 os << "QSYMM8";
641 break;
Chunosovd621bca2017-11-03 17:33:15 +0700642 case DataType::QASYMM8:
643 os << "QASYMM8";
644 break;
Georgios Pinitas448a81f2019-11-21 14:10:25 +0000645 case DataType::QASYMM8_SIGNED:
646 os << "QASYMM8_SIGNED";
647 break;
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100648 case DataType::QSYMM8_PER_CHANNEL:
649 os << "QSYMM8_PER_CHANNEL";
650 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100651 case DataType::S8:
652 os << "S8";
653 break;
654 case DataType::U16:
655 os << "U16";
656 break;
657 case DataType::S16:
658 os << "S16";
659 break;
Manuel Bottini3689fcd2019-06-14 17:18:12 +0100660 case DataType::QSYMM16:
661 os << "QSYMM16";
662 break;
Michele Di Giorgio35ea9a72019-08-23 12:02:06 +0100663 case DataType::QASYMM16:
664 os << "QASYMM16";
665 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100666 case DataType::U32:
667 os << "U32";
668 break;
669 case DataType::S32:
670 os << "S32";
671 break;
672 case DataType::U64:
673 os << "U64";
674 break;
675 case DataType::S64:
676 os << "S64";
677 break;
Georgios Pinitase8291ac2020-02-26 09:58:13 +0000678 case DataType::BFLOAT16:
679 os << "BFLOAT16";
680 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100681 case DataType::F16:
682 os << "F16";
683 break;
684 case DataType::F32:
685 os << "F32";
686 break;
687 case DataType::F64:
688 os << "F64";
689 break;
690 case DataType::SIZET:
691 os << "SIZET";
692 break;
693 default:
694 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
695 }
696
697 return os;
698}
699
Alex Gildayc357c472018-03-21 13:54:09 +0000700/** Formatted output of the DataType type.
701 *
702 * @param[in] data_type Type to output.
703 *
704 * @return Formatted string.
705 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100706inline std::string to_string(const arm_compute::DataType &data_type)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100707{
708 std::stringstream str;
709 str << data_type;
710 return str.str();
711}
712
Alex Gildayc357c472018-03-21 13:54:09 +0000713/** Formatted output of the Format type.
714 *
715 * @param[out] os Output stream.
716 * @param[in] format Type to output.
717 *
718 * @return Modified output stream.
719 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100720inline ::std::ostream &operator<<(::std::ostream &os, const Format &format)
721{
722 switch(format)
723 {
724 case Format::UNKNOWN:
725 os << "UNKNOWN";
726 break;
727 case Format::U8:
728 os << "U8";
729 break;
730 case Format::S16:
731 os << "S16";
732 break;
733 case Format::U16:
734 os << "U16";
735 break;
736 case Format::S32:
737 os << "S32";
738 break;
739 case Format::U32:
740 os << "U32";
741 break;
742 case Format::F16:
743 os << "F16";
744 break;
745 case Format::F32:
746 os << "F32";
747 break;
748 case Format::UV88:
749 os << "UV88";
750 break;
751 case Format::RGB888:
752 os << "RGB888";
753 break;
754 case Format::RGBA8888:
755 os << "RGBA8888";
756 break;
757 case Format::YUV444:
758 os << "YUV444";
759 break;
760 case Format::YUYV422:
761 os << "YUYV422";
762 break;
763 case Format::NV12:
764 os << "NV12";
765 break;
766 case Format::NV21:
767 os << "NV21";
768 break;
769 case Format::IYUV:
770 os << "IYUV";
771 break;
772 case Format::UYVY422:
773 os << "UYVY422";
774 break;
775 default:
776 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
777 }
778
779 return os;
780}
781
Alex Gildayc357c472018-03-21 13:54:09 +0000782/** Formatted output of the Format type.
783 *
784 * @param[in] format Type to output.
785 *
786 * @return Formatted string.
787 */
Moritz Pflanzer7655a672017-09-23 11:57:33 +0100788inline std::string to_string(const Format &format)
789{
790 std::stringstream str;
791 str << format;
792 return str.str();
793}
794
Alex Gildayc357c472018-03-21 13:54:09 +0000795/** Formatted output of the Channel type.
796 *
797 * @param[out] os Output stream.
798 * @param[in] channel Type to output.
799 *
800 * @return Modified output stream.
801 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100802inline ::std::ostream &operator<<(::std::ostream &os, const Channel &channel)
803{
804 switch(channel)
805 {
806 case Channel::UNKNOWN:
807 os << "UNKNOWN";
808 break;
809 case Channel::C0:
810 os << "C0";
811 break;
812 case Channel::C1:
813 os << "C1";
814 break;
815 case Channel::C2:
816 os << "C2";
817 break;
818 case Channel::C3:
819 os << "C3";
820 break;
821 case Channel::R:
822 os << "R";
823 break;
824 case Channel::G:
825 os << "G";
826 break;
827 case Channel::B:
828 os << "B";
829 break;
830 case Channel::A:
831 os << "A";
832 break;
833 case Channel::Y:
834 os << "Y";
835 break;
836 case Channel::U:
837 os << "U";
838 break;
839 case Channel::V:
840 os << "V";
841 break;
842 default:
843 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
844 }
845
846 return os;
847}
848
Alex Gildayc357c472018-03-21 13:54:09 +0000849/** Formatted output of the Channel type.
850 *
851 * @param[in] channel Type to output.
852 *
853 * @return Formatted string.
854 */
Ioan-Cristian Szabo9414f642017-10-27 17:35:40 +0100855inline std::string to_string(const Channel &channel)
856{
857 std::stringstream str;
858 str << channel;
859 return str.str();
860}
861
Alex Gildayc357c472018-03-21 13:54:09 +0000862/** Formatted output of the BorderMode type.
863 *
864 * @param[out] os Output stream.
865 * @param[in] mode Type to output.
866 *
867 * @return Modified output stream.
868 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100869inline ::std::ostream &operator<<(::std::ostream &os, const BorderMode &mode)
870{
871 switch(mode)
872 {
873 case BorderMode::UNDEFINED:
874 os << "UNDEFINED";
875 break;
876 case BorderMode::CONSTANT:
877 os << "CONSTANT";
878 break;
879 case BorderMode::REPLICATE:
880 os << "REPLICATE";
881 break;
882 default:
883 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
884 }
885
886 return os;
887}
888
Alex Gildayc357c472018-03-21 13:54:09 +0000889/** Formatted output of the BorderSize type.
890 *
891 * @param[out] os Output stream.
892 * @param[in] border Type to output.
893 *
894 * @return Modified output stream.
895 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100896inline ::std::ostream &operator<<(::std::ostream &os, const BorderSize &border)
897{
Moritz Pflanzerc87fbf82017-07-18 14:02:10 +0100898 os << border.top << ","
899 << border.right << ","
900 << border.bottom << ","
901 << border.left;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100902
903 return os;
904}
Anthony Barbier2a07e182017-08-04 18:20:27 +0100905
Giuseppe Rossinid7647d42018-07-17 18:13:13 +0100906/** Formatted output of the PaddingList type.
907 *
908 * @param[out] os Output stream.
909 * @param[in] padding Type to output.
910 *
911 * @return Modified output stream.
912 */
913inline ::std::ostream &operator<<(::std::ostream &os, const PaddingList &padding)
914{
915 os << "{";
916 for(auto const &p : padding)
917 {
918 os << "{" << p.first << "," << p.second << "}";
919 }
920 os << "}";
921 return os;
922}
923
giuros013175fcf2018-11-21 09:59:17 +0000924/** Formatted output of the Multiples type.
925 *
926 * @param[out] os Output stream.
927 * @param[in] multiples Type to output.
928 *
929 * @return Modified output stream.
930 */
931inline ::std::ostream &operator<<(::std::ostream &os, const Multiples &multiples)
932{
933 os << "(";
934 for(size_t i = 0; i < multiples.size() - 1; i++)
935 {
936 os << multiples[i] << ", ";
937 }
938 os << multiples.back() << ")";
939 return os;
940}
941
Alex Gildayc357c472018-03-21 13:54:09 +0000942/** Formatted output of the InterpolationPolicy type.
943 *
944 * @param[out] os Output stream.
945 * @param[in] policy Type to output.
946 *
947 * @return Modified output stream.
948 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100949inline ::std::ostream &operator<<(::std::ostream &os, const InterpolationPolicy &policy)
950{
951 switch(policy)
952 {
953 case InterpolationPolicy::NEAREST_NEIGHBOR:
954 os << "NEAREST_NEIGHBOR";
955 break;
956 case InterpolationPolicy::BILINEAR:
957 os << "BILINEAR";
958 break;
959 case InterpolationPolicy::AREA:
960 os << "AREA";
961 break;
962 default:
963 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
964 }
965
966 return os;
967}
968
Alex Gildayc357c472018-03-21 13:54:09 +0000969/** Formatted output of the SamplingPolicy type.
970 *
971 * @param[out] os Output stream.
972 * @param[in] policy Type to output.
973 *
974 * @return Modified output stream.
975 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700976inline ::std::ostream &operator<<(::std::ostream &os, const SamplingPolicy &policy)
977{
978 switch(policy)
979 {
980 case SamplingPolicy::CENTER:
981 os << "CENTER";
982 break;
983 case SamplingPolicy::TOP_LEFT:
984 os << "TOP_LEFT";
985 break;
986 default:
987 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
988 }
989
990 return os;
991}
992
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +0000993/** Formatted output of the ITensorInfo type.
994 *
995 * @param[out] os Output stream.
996 * @param[in] info Tensor information.
997 *
998 * @return Modified output stream.
999 */
1000inline ::std::ostream &operator<<(std::ostream &os, const ITensorInfo *info)
1001{
Georgios Pinitasc6f95102021-03-30 10:03:01 +01001002 const DataType data_type = info->data_type();
1003 const DataLayout data_layout = info->data_layout();
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001004
1005 os << "Shape=" << info->tensor_shape() << ","
1006 << "DataLayout=" << string_from_data_layout(data_layout) << ","
1007 << "DataType=" << string_from_data_type(data_type) << ",";
1008
1009 if(is_data_type_quantized(data_type))
1010 {
1011 const QuantizationInfo qinfo = info->quantization_info();
1012 os << "QuantizationInfo=";
1013 if(is_data_type_quantized_per_channel(data_type))
1014 {
1015 os << "[";
1016 const auto scales = qinfo.scale();
1017 const auto offsets = qinfo.offset();
1018 os << "(" << scales[0] << ", " << offsets[0] << ")";
1019 for(size_t i = 1; i < scales.size(); ++i)
1020 {
1021 os << ",(" << scales[i] << ", " << offsets[i] << ")";
1022 }
1023 os << "]";
1024 }
1025 else
1026 {
1027 os << "(" << qinfo.uniform().scale << ", "
Georgios Pinitasc6f95102021-03-30 10:03:01 +01001028 << qinfo.uniform().offset << ")";
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001029 }
1030 }
1031 return os;
1032}
1033
Alex Gildayc357c472018-03-21 13:54:09 +00001034/** Formatted output of the TensorInfo type.
1035 *
Anthony Barbier366628a2018-08-01 13:55:03 +01001036 * @param[out] os Output stream.
1037 * @param[in] info Type to output.
1038 *
1039 * @return Modified output stream.
1040 */
1041inline ::std::ostream &operator<<(::std::ostream &os, const TensorInfo &info)
1042{
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001043 os << &info;
Georgios Pinitasc6f95102021-03-30 10:03:01 +01001044 return os;
Anthony Barbier366628a2018-08-01 13:55:03 +01001045}
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001046
Anthony Barbier366628a2018-08-01 13:55:03 +01001047/** Formatted output of the TensorInfo type.
1048 *
Alex Gildayc357c472018-03-21 13:54:09 +00001049 * @param[in] info Type to output.
1050 *
1051 * @return Formatted string.
1052 */
Georgios Pinitas3faea252017-10-30 14:13:50 +00001053inline std::string to_string(const TensorInfo &info)
1054{
1055 std::stringstream str;
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001056 str << &info;
Georgios Pinitas3faea252017-10-30 14:13:50 +00001057 return str.str();
1058}
1059
Alex Gildayc357c472018-03-21 13:54:09 +00001060/** Formatted output of the Dimensions type.
1061 *
1062 * @param[in] dimensions Type to output.
1063 *
1064 * @return Formatted string.
1065 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001066template <typename T>
1067inline std::string to_string(const Dimensions<T> &dimensions)
1068{
1069 std::stringstream str;
1070 str << dimensions;
1071 return str.str();
1072}
1073
Alex Gildayc357c472018-03-21 13:54:09 +00001074/** Formatted output of the Strides type.
1075 *
1076 * @param[in] stride Type to output.
1077 *
1078 * @return Formatted string.
1079 */
John Richardsona36eae12017-09-26 16:55:59 +01001080inline std::string to_string(const Strides &stride)
1081{
1082 std::stringstream str;
1083 str << stride;
1084 return str.str();
1085}
1086
Alex Gildayc357c472018-03-21 13:54:09 +00001087/** Formatted output of the TensorShape type.
1088 *
1089 * @param[in] shape Type to output.
1090 *
1091 * @return Formatted string.
1092 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001093inline std::string to_string(const TensorShape &shape)
1094{
1095 std::stringstream str;
1096 str << shape;
1097 return str.str();
1098}
1099
Alex Gildayc357c472018-03-21 13:54:09 +00001100/** Formatted output of the Coordinates type.
1101 *
1102 * @param[in] coord Type to output.
1103 *
1104 * @return Formatted string.
1105 */
Abe Mbise925ca0f2017-10-02 19:16:33 +01001106inline std::string to_string(const Coordinates &coord)
1107{
1108 std::stringstream str;
1109 str << coord;
1110 return str.str();
1111}
1112
Anthony Barbierb940fd62018-06-04 14:14:32 +01001113/** Formatted output of the GEMMReshapeInfo type.
1114 *
1115 * @param[out] os Output stream.
1116 * @param[in] info Type to output.
1117 *
1118 * @return Modified output stream.
1119 */
1120inline ::std::ostream &operator<<(::std::ostream &os, const GEMMReshapeInfo &info)
1121{
1122 os << "{m=" << info.m() << ",";
1123 os << "n=" << info.n() << ",";
1124 os << "k=" << info.k() << ",";
1125 os << "mult_transpose1xW_width=" << info.mult_transpose1xW_width() << ",";
1126 os << "mult_interleave4x4_height=" << info.mult_interleave4x4_height();
1127 os << "}";
1128
1129 return os;
1130}
1131
1132/** Formatted output of the GEMMInfo type.
1133 *
1134 * @param[out] os Output stream.
1135 * @param[in] info Type to output.
1136 *
1137 * @return Modified output stream.
1138 */
1139inline ::std::ostream &operator<<(::std::ostream &os, const GEMMInfo &info)
1140{
1141 os << "{is_a_reshaped=" << info.is_a_reshaped() << ",";
1142 os << "is_b_reshaped=" << info.is_b_reshaped() << ",";
1143 os << "reshape_b_only_on_first_run=" << info.reshape_b_only_on_first_run() << ",";
Anthony Barbierb4670212018-05-18 16:55:39 +01001144 os << "depth_output_gemm3d=" << info.depth_output_gemm3d() << ",";
1145 os << "reinterpret_input_as_3d=" << info.reinterpret_input_as_3d() << ",";
1146 os << "retain_internal_weights=" << info.retain_internal_weights() << ",";
1147 os << "fp_mixed_precision=" << info.fp_mixed_precision() << ",";
1148 os << "broadcast_bias=" << info.broadcast_bias() << ",";
1149 os << "pretranpose_B=" << info.pretranpose_B() << ",";
Anthony Barbierb940fd62018-06-04 14:14:32 +01001150
1151 return os;
1152}
1153
1154/** Formatted output of the Window::Dimension type.
1155 *
1156 * @param[out] os Output stream.
1157 * @param[in] dim Type to output.
1158 *
1159 * @return Modified output stream.
1160 */
1161inline ::std::ostream &operator<<(::std::ostream &os, const Window::Dimension &dim)
1162{
1163 os << "{start=" << dim.start() << ", end=" << dim.end() << ", step=" << dim.step() << "}";
1164
1165 return os;
1166}
1167/** Formatted output of the Window type.
1168 *
1169 * @param[out] os Output stream.
1170 * @param[in] win Type to output.
1171 *
1172 * @return Modified output stream.
1173 */
1174inline ::std::ostream &operator<<(::std::ostream &os, const Window &win)
1175{
1176 os << "{";
1177 for(unsigned int i = 0; i < Coordinates::num_max_dimensions; i++)
1178 {
1179 if(i > 0)
1180 {
1181 os << ", ";
1182 }
1183 os << win[i];
1184 }
1185 os << "}";
1186
1187 return os;
1188}
1189
1190/** Formatted output of the WeightsInfo type.
1191 *
1192 * @param[in] info Type to output.
1193 *
1194 * @return Formatted string.
1195 */
1196inline std::string to_string(const WeightsInfo &info)
1197{
1198 std::stringstream str;
1199 str << info;
1200 return str.str();
1201}
1202
1203/** Formatted output of the GEMMReshapeInfo type.
1204 *
1205 * @param[in] info Type to output.
1206 *
1207 * @return Formatted string.
1208 */
1209inline std::string to_string(const GEMMReshapeInfo &info)
1210{
1211 std::stringstream str;
1212 str << info;
1213 return str.str();
1214}
1215
1216/** Formatted output of the GEMMInfo type.
1217 *
1218 * @param[in] info Type to output.
1219 *
1220 * @return Formatted string.
1221 */
1222inline std::string to_string(const GEMMInfo &info)
1223{
1224 std::stringstream str;
1225 str << info;
1226 return str.str();
1227}
1228
1229/** Formatted output of the Window::Dimension type.
1230 *
1231 * @param[in] dim Type to output.
1232 *
1233 * @return Formatted string.
1234 */
1235inline std::string to_string(const Window::Dimension &dim)
1236{
1237 std::stringstream str;
1238 str << dim;
1239 return str.str();
1240}
1241/** Formatted output of the Window type.
1242 *
1243 * @param[in] win Type to output.
1244 *
1245 * @return Formatted string.
1246 */
1247inline std::string to_string(const Window &win)
1248{
1249 std::stringstream str;
1250 str << win;
1251 return str.str();
1252}
1253
Alex Gildayc357c472018-03-21 13:54:09 +00001254/** Formatted output of the Rectangle type.
1255 *
1256 * @param[out] os Output stream.
1257 * @param[in] rect Type to output.
1258 *
1259 * @return Modified output stream.
1260 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001261inline ::std::ostream &operator<<(::std::ostream &os, const Rectangle &rect)
1262{
1263 os << rect.width << "x" << rect.height;
1264 os << "+" << rect.x << "+" << rect.y;
1265
1266 return os;
1267}
1268
Usama Arif8cf8c112019-03-14 15:36:54 +00001269/** Formatted output of the PaddingMode type.
1270 *
1271 * @param[out] os Output stream.
1272 * @param[in] mode Type to output.
1273 *
1274 * @return Modified output stream.
1275 */
1276inline ::std::ostream &operator<<(::std::ostream &os, const PaddingMode &mode)
1277{
1278 switch(mode)
1279 {
1280 case PaddingMode::CONSTANT:
1281 os << "CONSTANT";
1282 break;
1283 case PaddingMode::REFLECT:
1284 os << "REFLECT";
1285 break;
1286 case PaddingMode::SYMMETRIC:
1287 os << "SYMMETRIC";
1288 break;
1289 default:
1290 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1291 }
1292
1293 return os;
1294}
1295
1296/** Formatted output of the PaddingMode type.
1297 *
1298 * @param[in] mode Type to output.
1299 *
1300 * @return Formatted string.
1301 */
1302inline std::string to_string(const PaddingMode &mode)
1303{
1304 std::stringstream str;
1305 str << mode;
1306 return str.str();
1307}
1308
Alex Gildayc357c472018-03-21 13:54:09 +00001309/** Formatted output of the PadStrideInfo type.
1310 *
1311 * @param[out] os Output stream.
1312 * @param[in] pad_stride_info Type to output.
1313 *
1314 * @return Modified output stream.
1315 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001316inline ::std::ostream &operator<<(::std::ostream &os, const PadStrideInfo &pad_stride_info)
1317{
1318 os << pad_stride_info.stride().first << "," << pad_stride_info.stride().second;
1319 os << ";";
Jaroslaw Rzepeckia1ed41f2017-10-13 11:13:58 +01001320 os << pad_stride_info.pad_left() << "," << pad_stride_info.pad_right() << ","
1321 << pad_stride_info.pad_top() << "," << pad_stride_info.pad_bottom();
Anthony Barbier2a07e182017-08-04 18:20:27 +01001322
1323 return os;
1324}
1325
Alex Gildayc357c472018-03-21 13:54:09 +00001326/** Formatted output of the PadStrideInfo type.
1327 *
1328 * @param[in] pad_stride_info Type to output.
1329 *
1330 * @return Formatted string.
1331 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001332inline std::string to_string(const PadStrideInfo &pad_stride_info)
1333{
1334 std::stringstream str;
1335 str << pad_stride_info;
1336 return str.str();
1337}
1338
Alex Gildayc357c472018-03-21 13:54:09 +00001339/** Formatted output of the BorderMode type.
1340 *
1341 * @param[in] mode Type to output.
1342 *
1343 * @return Formatted string.
1344 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001345inline std::string to_string(const BorderMode &mode)
1346{
1347 std::stringstream str;
1348 str << mode;
1349 return str.str();
1350}
1351
Alex Gildayc357c472018-03-21 13:54:09 +00001352/** Formatted output of the BorderSize type.
1353 *
1354 * @param[in] border Type to output.
1355 *
1356 * @return Formatted string.
1357 */
John Richardsonb482ce12017-09-18 12:44:01 +01001358inline std::string to_string(const BorderSize &border)
1359{
1360 std::stringstream str;
1361 str << border;
1362 return str.str();
1363}
1364
Giuseppe Rossinid7647d42018-07-17 18:13:13 +01001365/** Formatted output of the PaddingList type.
1366 *
1367 * @param[in] padding Type to output.
1368 *
1369 * @return Formatted string.
1370 */
1371inline std::string to_string(const PaddingList &padding)
1372{
1373 std::stringstream str;
1374 str << padding;
1375 return str.str();
1376}
1377
giuros013175fcf2018-11-21 09:59:17 +00001378/** Formatted output of the Multiples type.
1379 *
1380 * @param[in] multiples Type to output.
1381 *
1382 * @return Formatted string.
1383 */
1384inline std::string to_string(const Multiples &multiples)
1385{
1386 std::stringstream str;
1387 str << multiples;
1388 return str.str();
1389}
1390
Alex Gildayc357c472018-03-21 13:54:09 +00001391/** Formatted output of the InterpolationPolicy type.
1392 *
1393 * @param[in] policy Type to output.
1394 *
1395 * @return Formatted string.
1396 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001397inline std::string to_string(const InterpolationPolicy &policy)
1398{
1399 std::stringstream str;
1400 str << policy;
1401 return str.str();
1402}
1403
Alex Gildayc357c472018-03-21 13:54:09 +00001404/** Formatted output of the SamplingPolicy type.
1405 *
1406 * @param[in] policy Type to output.
1407 *
1408 * @return Formatted string.
1409 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +07001410inline std::string to_string(const SamplingPolicy &policy)
1411{
1412 std::stringstream str;
1413 str << policy;
1414 return str.str();
1415}
1416
Alex Gildayc357c472018-03-21 13:54:09 +00001417/** Formatted output of the ConvertPolicy type.
1418 *
1419 * @param[out] os Output stream.
1420 * @param[in] policy Type to output.
1421 *
1422 * @return Modified output stream.
1423 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001424inline ::std::ostream &operator<<(::std::ostream &os, const ConvertPolicy &policy)
1425{
1426 switch(policy)
1427 {
1428 case ConvertPolicy::WRAP:
1429 os << "WRAP";
1430 break;
1431 case ConvertPolicy::SATURATE:
1432 os << "SATURATE";
1433 break;
1434 default:
1435 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1436 }
1437
1438 return os;
1439}
1440
1441inline std::string to_string(const ConvertPolicy &policy)
1442{
1443 std::stringstream str;
1444 str << policy;
1445 return str.str();
1446}
1447
giuros01164a2722018-11-20 18:34:46 +00001448/** Formatted output of the ArithmeticOperation type.
1449 *
1450 * @param[out] os Output stream.
1451 * @param[in] op Operation to output.
1452 *
1453 * @return Modified output stream.
1454 */
1455inline ::std::ostream &operator<<(::std::ostream &os, const ArithmeticOperation &op)
1456{
1457 switch(op)
1458 {
1459 case ArithmeticOperation::ADD:
1460 os << "ADD";
1461 break;
1462 case ArithmeticOperation::SUB:
1463 os << "SUB";
1464 break;
1465 case ArithmeticOperation::DIV:
1466 os << "DIV";
1467 break;
1468 case ArithmeticOperation::MAX:
1469 os << "MAX";
1470 break;
1471 case ArithmeticOperation::MIN:
1472 os << "MIN";
1473 break;
1474 case ArithmeticOperation::SQUARED_DIFF:
1475 os << "SQUARED_DIFF";
1476 break;
Usama Arif52c54f62019-05-14 10:22:36 +01001477 case ArithmeticOperation::POWER:
1478 os << "POWER";
1479 break;
giuros01164a2722018-11-20 18:34:46 +00001480 default:
1481 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1482 }
1483
1484 return os;
1485}
1486
1487/** Formatted output of the Arithmetic Operation
1488 *
1489 * @param[in] op Type to output.
1490 *
1491 * @return Formatted string.
1492 */
1493inline std::string to_string(const ArithmeticOperation &op)
1494{
1495 std::stringstream str;
1496 str << op;
1497 return str.str();
1498}
1499
Alex Gildayc357c472018-03-21 13:54:09 +00001500/** Formatted output of the Reduction Operations.
1501 *
1502 * @param[out] os Output stream.
1503 * @param[in] op Type to output.
1504 *
1505 * @return Modified output stream.
1506 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001507inline ::std::ostream &operator<<(::std::ostream &os, const ReductionOperation &op)
1508{
1509 switch(op)
1510 {
Michalis Spyrou7e9391b2018-10-05 14:49:28 +01001511 case ReductionOperation::SUM:
1512 os << "SUM";
1513 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +01001514 case ReductionOperation::SUM_SQUARE:
1515 os << "SUM_SQUARE";
1516 break;
Michalis Spyrou7e9391b2018-10-05 14:49:28 +01001517 case ReductionOperation::MEAN_SUM:
1518 os << "MEAN_SUM";
1519 break;
Michalis Spyrou7930db42018-11-22 17:36:28 +00001520 case ReductionOperation::ARG_IDX_MAX:
1521 os << "ARG_IDX_MAX";
1522 break;
1523 case ReductionOperation::ARG_IDX_MIN:
1524 os << "ARG_IDX_MIN";
1525 break;
Manuel Bottinib412fab2018-12-10 17:40:23 +00001526 case ReductionOperation::PROD:
1527 os << "PROD";
1528 break;
Usama Arifa4a08ad2019-05-20 12:38:33 +01001529 case ReductionOperation::MIN:
1530 os << "MIN";
1531 break;
Usama Arif28f0dd92019-05-20 13:44:34 +01001532 case ReductionOperation::MAX:
1533 os << "MAX";
1534 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +01001535 default:
1536 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1537 }
1538
1539 return os;
1540}
1541
Alex Gildayc357c472018-03-21 13:54:09 +00001542/** Formatted output of the Reduction Operations.
1543 *
1544 * @param[in] op Type to output.
1545 *
1546 * @return Formatted string.
1547 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001548inline std::string to_string(const ReductionOperation &op)
1549{
1550 std::stringstream str;
1551 str << op;
1552 return str.str();
1553}
1554
Georgios Pinitas7900a9e2018-11-23 11:44:58 +00001555/** Formatted output of the Comparison Operations.
1556 *
1557 * @param[out] os Output stream.
1558 * @param[in] op Type to output.
1559 *
1560 * @return Modified output stream.
1561 */
1562inline ::std::ostream &operator<<(::std::ostream &os, const ComparisonOperation &op)
1563{
1564 switch(op)
1565 {
1566 case ComparisonOperation::Equal:
1567 os << "Equal";
1568 break;
1569 case ComparisonOperation::NotEqual:
1570 os << "NotEqual";
1571 break;
1572 case ComparisonOperation::Greater:
1573 os << "Greater";
1574 break;
1575 case ComparisonOperation::GreaterEqual:
1576 os << "GreaterEqual";
1577 break;
1578 case ComparisonOperation::Less:
1579 os << "Less";
1580 break;
1581 case ComparisonOperation::LessEqual:
1582 os << "LessEqual";
1583 break;
1584 default:
1585 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1586 }
1587
1588 return os;
1589}
1590
Michalis Spyroue9362622018-11-23 17:41:37 +00001591/** Formatted output of the Elementwise unary Operations.
1592 *
1593 * @param[out] os Output stream.
1594 * @param[in] op Type to output.
1595 *
1596 * @return Modified output stream.
1597 */
1598inline ::std::ostream &operator<<(::std::ostream &os, const ElementWiseUnary &op)
1599{
1600 switch(op)
1601 {
1602 case ElementWiseUnary::RSQRT:
1603 os << "RSQRT";
1604 break;
1605 case ElementWiseUnary::EXP:
1606 os << "EXP";
1607 break;
Usama Arifeb312ef2019-05-13 17:45:54 +01001608 case ElementWiseUnary::NEG:
1609 os << "NEG";
1610 break;
Usama Arifac33d7e2019-05-20 14:21:40 +01001611 case ElementWiseUnary::LOG:
1612 os << "LOG";
1613 break;
Usama Arif6a4d5422019-05-24 14:53:59 +01001614 case ElementWiseUnary::ROUND:
1615 os << "ROUND";
1616 break;
Michalis Spyroue9362622018-11-23 17:41:37 +00001617 default:
1618 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1619 }
1620
1621 return os;
1622}
1623
Georgios Pinitas7900a9e2018-11-23 11:44:58 +00001624/** Formatted output of the Comparison Operations.
1625 *
1626 * @param[in] op Type to output.
1627 *
1628 * @return Formatted string.
1629 */
1630inline std::string to_string(const ComparisonOperation &op)
1631{
1632 std::stringstream str;
1633 str << op;
1634 return str.str();
1635}
1636
Michalis Spyroue9362622018-11-23 17:41:37 +00001637/** Formatted output of the Elementwise unary Operations.
1638 *
1639 * @param[in] op Type to output.
1640 *
1641 * @return Formatted string.
1642 */
1643inline std::string to_string(const ElementWiseUnary &op)
1644{
1645 std::stringstream str;
1646 str << op;
1647 return str.str();
1648}
1649
Alex Gildayc357c472018-03-21 13:54:09 +00001650/** Formatted output of the Norm Type.
1651 *
1652 * @param[in] type Type to output.
1653 *
1654 * @return Formatted string.
1655 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001656inline std::string to_string(const NormType &type)
1657{
1658 std::stringstream str;
1659 str << type;
1660 return str.str();
1661}
1662
Alex Gildayc357c472018-03-21 13:54:09 +00001663/** Formatted output of the Pooling Type.
1664 *
1665 * @param[in] type Type to output.
1666 *
1667 * @return Formatted string.
1668 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001669inline std::string to_string(const PoolingType &type)
1670{
1671 std::stringstream str;
1672 str << type;
1673 return str.str();
1674}
1675
Alex Gildayc357c472018-03-21 13:54:09 +00001676/** Formatted output of the Pooling Layer Info.
1677 *
1678 * @param[in] info Type to output.
1679 *
1680 * @return Formatted string.
1681 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001682inline std::string to_string(const PoolingLayerInfo &info)
1683{
1684 std::stringstream str;
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +00001685 str << "{Type=" << info.pool_type << ","
Sang-Hoon Park11fedda2020-01-15 14:44:04 +00001686 << "DataLayout=" << info.data_layout << ","
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +00001687 << "IsGlobalPooling=" << info.is_global_pooling;
1688 if(!info.is_global_pooling)
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001689 {
1690 str << ","
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +00001691 << "PoolSize=" << info.pool_size.width << "," << info.pool_size.height << ","
1692 << "PadStride=" << info.pad_stride_info;
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001693 }
1694 str << "}";
Anthony Barbier2a07e182017-08-04 18:20:27 +01001695 return str.str();
1696}
1697
Michalis Spyrou6c7c38e2018-08-29 16:28:11 +01001698/** Formatted output of the PriorBoxLayerInfo.
1699 *
1700 * @param[in] info Type to output.
1701 *
1702 * @return Formatted string.
1703 */
1704inline std::string to_string(const PriorBoxLayerInfo &info)
1705{
1706 std::stringstream str;
1707 str << "{";
1708 str << "Clip:" << info.clip()
1709 << "Flip:" << info.flip()
1710 << "StepX:" << info.steps()[0]
1711 << "StepY:" << info.steps()[1]
1712 << "MinSizes:" << info.min_sizes().size()
1713 << "MaxSizes:" << info.max_sizes().size()
1714 << "ImgSizeX:" << info.img_size().x
1715 << "ImgSizeY:" << info.img_size().y
1716 << "Offset:" << info.offset()
1717 << "Variances:" << info.variances().size();
1718 str << "}";
1719 return str.str();
1720}
1721
Alex Gildayc357c472018-03-21 13:54:09 +00001722/** Formatted output of the Size2D type.
1723 *
1724 * @param[out] os Output stream
1725 * @param[in] size Type to output
1726 *
1727 * @return Modified output stream.
1728 */
John Richardson25f23682017-11-27 14:35:09 +00001729inline ::std::ostream &operator<<(::std::ostream &os, const Size2D &size)
1730{
1731 os << size.width << "x" << size.height;
1732
1733 return os;
1734}
1735
Alex Gildayc357c472018-03-21 13:54:09 +00001736/** Formatted output of the Size2D type.
1737 *
1738 * @param[in] type Type to output
1739 *
1740 * @return Formatted string.
1741 */
John Richardson25f23682017-11-27 14:35:09 +00001742inline std::string to_string(const Size2D &type)
1743{
1744 std::stringstream str;
1745 str << type;
1746 return str.str();
1747}
1748
Alex Gildayc357c472018-03-21 13:54:09 +00001749/** Formatted output of the ConvolutionMethod type.
1750 *
1751 * @param[out] os Output stream
1752 * @param[in] conv_method Type to output
1753 *
1754 * @return Modified output stream.
1755 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001756inline ::std::ostream &operator<<(::std::ostream &os, const ConvolutionMethod &conv_method)
1757{
1758 switch(conv_method)
1759 {
1760 case ConvolutionMethod::GEMM:
1761 os << "GEMM";
1762 break;
1763 case ConvolutionMethod::DIRECT:
1764 os << "DIRECT";
1765 break;
1766 case ConvolutionMethod::WINOGRAD:
1767 os << "WINOGRAD";
1768 break;
1769 default:
1770 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1771 }
1772
1773 return os;
1774}
1775
Alex Gildayc357c472018-03-21 13:54:09 +00001776/** Formatted output of the ConvolutionMethod type.
1777 *
1778 * @param[in] conv_method Type to output
1779 *
1780 * @return Formatted string.
1781 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001782inline std::string to_string(const ConvolutionMethod &conv_method)
1783{
1784 std::stringstream str;
1785 str << conv_method;
1786 return str.str();
1787}
1788
Alex Gildayc357c472018-03-21 13:54:09 +00001789/** Formatted output of the GPUTarget type.
1790 *
1791 * @param[out] os Output stream
1792 * @param[in] gpu_target Type to output
1793 *
1794 * @return Modified output stream.
1795 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001796inline ::std::ostream &operator<<(::std::ostream &os, const GPUTarget &gpu_target)
1797{
1798 switch(gpu_target)
1799 {
1800 case GPUTarget::GPU_ARCH_MASK:
1801 os << "GPU_ARCH_MASK";
1802 break;
1803 case GPUTarget::MIDGARD:
1804 os << "MIDGARD";
1805 break;
1806 case GPUTarget::BIFROST:
1807 os << "BIFROST";
1808 break;
Georgios Pinitasd5462ff2019-07-03 19:33:57 +01001809 case GPUTarget::VALHALL:
1810 os << "VALHALL";
1811 break;
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001812 case GPUTarget::T600:
1813 os << "T600";
1814 break;
1815 case GPUTarget::T700:
1816 os << "T700";
1817 break;
1818 case GPUTarget::T800:
1819 os << "T800";
1820 break;
Michalis Spyroua9676112018-02-22 18:07:43 +00001821 case GPUTarget::G71:
1822 os << "G71";
1823 break;
1824 case GPUTarget::G72:
1825 os << "G72";
1826 break;
1827 case GPUTarget::G51:
1828 os << "G51";
1829 break;
1830 case GPUTarget::G51BIG:
1831 os << "G51BIG";
1832 break;
1833 case GPUTarget::G51LIT:
1834 os << "G51LIT";
1835 break;
Georgios Pinitasb03f7c52018-07-12 10:49:53 +01001836 case GPUTarget::G76:
1837 os << "G76";
Michalis Spyroua9676112018-02-22 18:07:43 +00001838 break;
Georgios Pinitasd5462ff2019-07-03 19:33:57 +01001839 case GPUTarget::G77:
1840 os << "G77";
Michalis Spyroua9676112018-02-22 18:07:43 +00001841 break;
Georgios Pinitas4ffc42a2020-12-01 16:28:24 +00001842 case GPUTarget::G78:
1843 os << "G78";
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001844 break;
Georgios Pinitasd5462ff2019-07-03 19:33:57 +01001845 case GPUTarget::TODX:
1846 os << "TODX";
1847 break;
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001848 default:
1849 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1850 }
1851
1852 return os;
1853}
1854
Alex Gildayc357c472018-03-21 13:54:09 +00001855/** Formatted output of the GPUTarget type.
1856 *
1857 * @param[in] gpu_target Type to output
1858 *
1859 * @return Formatted string.
1860 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001861inline std::string to_string(const GPUTarget &gpu_target)
1862{
1863 std::stringstream str;
1864 str << gpu_target;
1865 return str.str();
1866}
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00001867
John Richardson8de92612018-02-22 14:09:31 +00001868/** Formatted output of the DetectionWindow type.
1869 *
1870 * @param[out] os Output stream
1871 * @param[in] detection_window Type to output
1872 *
1873 * @return Modified output stream.
1874 */
John Richardson684cb0f2018-01-09 11:17:00 +00001875inline ::std::ostream &operator<<(::std::ostream &os, const DetectionWindow &detection_window)
1876{
1877 os << "{x=" << detection_window.x << ","
1878 << "y=" << detection_window.y << ","
1879 << "width=" << detection_window.width << ","
1880 << "height=" << detection_window.height << ","
1881 << "idx_class=" << detection_window.idx_class << ","
1882 << "score=" << detection_window.score << "}";
1883
1884 return os;
1885}
1886
Isabella Gottardi05e56442018-11-16 11:26:52 +00001887/** Formatted output of the DetectionOutputLayerCodeType type.
1888 *
1889 * @param[out] os Output stream
1890 * @param[in] detection_code Type to output
1891 *
1892 * @return Modified output stream.
1893 */
1894inline ::std::ostream &operator<<(::std::ostream &os, const DetectionOutputLayerCodeType &detection_code)
1895{
1896 switch(detection_code)
1897 {
1898 case DetectionOutputLayerCodeType::CENTER_SIZE:
1899 os << "CENTER_SIZE";
1900 break;
1901 case DetectionOutputLayerCodeType::CORNER:
1902 os << "CORNER";
1903 break;
1904 case DetectionOutputLayerCodeType::CORNER_SIZE:
1905 os << "CORNER_SIZE";
1906 break;
1907 case DetectionOutputLayerCodeType::TF_CENTER:
1908 os << "TF_CENTER";
1909 break;
1910 default:
1911 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1912 }
1913
1914 return os;
1915}
1916/** Formatted output of the DetectionOutputLayerCodeType type.
1917 *
1918 * @param[in] detection_code Type to output
1919 *
1920 * @return Formatted string.
1921 */
1922inline std::string to_string(const DetectionOutputLayerCodeType &detection_code)
1923{
1924 std::stringstream str;
1925 str << detection_code;
1926 return str.str();
1927}
1928
1929/** Formatted output of the DetectionOutputLayerInfo type.
1930 *
1931 * @param[out] os Output stream
1932 * @param[in] detection_info Type to output
1933 *
1934 * @return Modified output stream.
1935 */
1936inline ::std::ostream &operator<<(::std::ostream &os, const DetectionOutputLayerInfo &detection_info)
1937{
1938 os << "{Classes=" << detection_info.num_classes() << ","
1939 << "ShareLocation=" << detection_info.share_location() << ","
1940 << "CodeType=" << detection_info.code_type() << ","
1941 << "VarianceEncodedInTarget=" << detection_info.variance_encoded_in_target() << ","
1942 << "KeepTopK=" << detection_info.keep_top_k() << ","
1943 << "NMSThreshold=" << detection_info.nms_threshold() << ","
1944 << "Eta=" << detection_info.eta() << ","
1945 << "BackgroundLabelId=" << detection_info.background_label_id() << ","
1946 << "ConfidenceThreshold=" << detection_info.confidence_threshold() << ","
1947 << "TopK=" << detection_info.top_k() << ","
1948 << "NumLocClasses=" << detection_info.num_loc_classes()
1949 << "}";
1950
1951 return os;
1952}
1953
1954/** Formatted output of the DetectionOutputLayerInfo type.
1955 *
1956 * @param[in] detection_info Type to output
1957 *
1958 * @return Formatted string.
1959 */
1960inline std::string to_string(const DetectionOutputLayerInfo &detection_info)
1961{
1962 std::stringstream str;
1963 str << detection_info;
1964 return str.str();
1965}
Isabella Gottardia7acb3c2019-01-08 13:48:44 +00001966/** Formatted output of the DetectionPostProcessLayerInfo type.
1967 *
1968 * @param[out] os Output stream
1969 * @param[in] detection_info Type to output
1970 *
1971 * @return Modified output stream.
1972 */
1973inline ::std::ostream &operator<<(::std::ostream &os, const DetectionPostProcessLayerInfo &detection_info)
1974{
1975 os << "{MaxDetections=" << detection_info.max_detections() << ","
1976 << "MaxClassesPerDetection=" << detection_info.max_classes_per_detection() << ","
1977 << "NmsScoreThreshold=" << detection_info.nms_score_threshold() << ","
1978 << "NmsIouThreshold=" << detection_info.iou_threshold() << ","
1979 << "NumClasses=" << detection_info.num_classes() << ","
1980 << "ScaleValue_y=" << detection_info.scale_value_y() << ","
1981 << "ScaleValue_x=" << detection_info.scale_value_x() << ","
1982 << "ScaleValue_h=" << detection_info.scale_value_h() << ","
1983 << "ScaleValue_w=" << detection_info.scale_value_w() << ","
1984 << "UseRegularNms=" << detection_info.use_regular_nms() << ","
1985 << "DetectionPerClass=" << detection_info.detection_per_class()
1986 << "}";
1987
1988 return os;
1989}
1990
1991/** Formatted output of the DetectionPostProcessLayerInfo type.
1992 *
1993 * @param[in] detection_info Type to output
1994 *
1995 * @return Formatted string.
1996 */
1997inline std::string to_string(const DetectionPostProcessLayerInfo &detection_info)
1998{
1999 std::stringstream str;
2000 str << detection_info;
2001 return str.str();
2002}
Georgios Pinitasc6f95102021-03-30 10:03:01 +01002003
John Richardson8de92612018-02-22 14:09:31 +00002004/** Formatted output of the DetectionWindow type.
2005 *
2006 * @param[in] detection_window Type to output
2007 *
2008 * @return Formatted string.
2009 */
2010inline std::string to_string(const DetectionWindow &detection_window)
2011{
2012 std::stringstream str;
2013 str << detection_window;
2014 return str.str();
2015}
2016
Anthony Barbier8914e322018-08-10 15:28:25 +01002017/** Formatted output of the CPUModel type.
2018 *
2019 * @param[out] os Output stream
2020 * @param[in] cpu_model Model to output
2021 *
2022 * @return Modified output stream.
2023 */
2024inline ::std::ostream &operator<<(::std::ostream &os, const CPUModel &cpu_model)
2025{
2026 switch(cpu_model)
2027 {
2028 case CPUModel::GENERIC:
2029 os << "GENERIC";
2030 break;
2031 case CPUModel::GENERIC_FP16:
2032 os << "GENERIC_FP16";
2033 break;
2034 case CPUModel::GENERIC_FP16_DOT:
2035 os << "GENERIC_FP16_DOT";
2036 break;
2037 case CPUModel::A53:
2038 os << "A53";
2039 break;
2040 case CPUModel::A55r0:
2041 os << "A55r0";
2042 break;
2043 case CPUModel::A55r1:
2044 os << "A55r1";
2045 break;
David Mansell318c9f42020-07-08 13:28:45 +01002046 case CPUModel::A73:
2047 os << "A73";
2048 break;
2049 case CPUModel::X1:
2050 os << "X1";
2051 break;
Anthony Barbier8914e322018-08-10 15:28:25 +01002052 default:
2053 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2054 }
2055
2056 return os;
2057}
2058
2059/** Formatted output of the CPUModel type.
2060 *
2061 * @param[in] cpu_model Model to output
2062 *
2063 * @return Formatted string.
2064 */
2065inline std::string to_string(const CPUModel &cpu_model)
2066{
2067 std::stringstream str;
2068 str << cpu_model;
2069 return str.str();
2070}
Anthony Barbier671a11e2018-07-06 15:11:36 +01002071/** Formatted output of a vector of objects.
2072 *
2073 * @param[out] os Output stream
2074 * @param[in] args Vector of objects to print
2075 *
2076 * @return Modified output stream.
2077 */
2078template <typename T>
2079inline ::std::ostream &operator<<(::std::ostream &os, const std::vector<T> &args)
2080{
2081 os << "[";
2082 bool first = true;
2083 for(auto &arg : args)
2084 {
2085 if(first)
2086 {
2087 first = false;
2088 }
2089 else
2090 {
2091 os << ", ";
2092 }
2093 os << arg;
2094 }
2095 os << "]";
2096 return os;
2097}
2098
Michalis Spyrou6c7c38e2018-08-29 16:28:11 +01002099/** Formatted output of @ref PriorBoxLayerInfo.
2100 *
2101 * @param[out] os Output stream.
2102 * @param[in] info Type to output.
2103 *
2104 * @return Modified output stream.
2105 */
2106inline ::std::ostream &operator<<(::std::ostream &os, const PriorBoxLayerInfo &info)
2107{
2108 os << "Clip:" << info.clip()
2109 << "Flip:" << info.flip()
2110 << "StepX:" << info.steps()[0]
2111 << "StepY:" << info.steps()[1]
2112 << "MinSizes:" << info.min_sizes()
2113 << "MaxSizes:" << info.max_sizes()
2114 << "ImgSizeX:" << info.img_size().x
2115 << "ImgSizeY:" << info.img_size().y
2116 << "Offset:" << info.offset()
2117 << "Variances:" << info.variances();
2118
2119 return os;
2120}
2121
Anthony Barbier671a11e2018-07-06 15:11:36 +01002122/** Formatted output of a vector of objects.
2123 *
2124 * @param[in] args Vector of objects to print
2125 *
2126 * @return String representing args.
2127 */
2128template <typename T>
2129std::string to_string(const std::vector<T> &args)
2130{
2131 std::stringstream str;
2132 str << args;
2133 return str.str();
2134}
2135
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00002136/** Formatted output of the WinogradInfo type. */
2137inline ::std::ostream &operator<<(::std::ostream &os, const WinogradInfo &info)
2138{
2139 os << "{OutputTileSize=" << info.output_tile_size << ","
2140 << "KernelSize=" << info.kernel_size << ","
2141 << "PadStride=" << info.convolution_info << ","
2142 << "OutputDataLayout=" << info.output_data_layout << "}";
2143
2144 return os;
2145}
2146
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00002147inline std::string to_string(const WinogradInfo &type)
2148{
2149 std::stringstream str;
2150 str << type;
2151 return str.str();
2152}
Anthony Barbier671a11e2018-07-06 15:11:36 +01002153
2154/** Fallback method: try to use std::to_string:
2155 *
2156 * @param[in] val Value to convert to string
2157 *
2158 * @return String representing val.
2159 */
2160template <typename T>
2161inline std::string to_string(const T &val)
2162{
2163 return support::cpp11::to_string(val);
2164}
2165
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +01002166/** Convert a CLTunerMode value to a string
2167 *
2168 * @param val CLTunerMode value to be converted
2169 *
2170 * @return String representing the corresponding CLTunerMode.
2171 */
2172inline std::string to_string(const CLTunerMode val)
2173{
2174 switch(val)
2175 {
2176 case CLTunerMode::EXHAUSTIVE:
2177 {
2178 return std::string("Exhaustive");
2179 }
2180 case CLTunerMode::NORMAL:
2181 {
2182 return std::string("Normal");
2183 }
2184 case CLTunerMode::RAPID:
2185 {
2186 return std::string("Rapid");
2187 }
2188 default:
2189 {
2190 ARM_COMPUTE_ERROR("Invalid tuner mode.");
2191 return std::string("UNDEFINED");
2192 }
2193 }
2194}
SiCong Lidb4a6c12021-02-05 09:30:57 +00002195/** Converts a @ref CLGEMMKernelType to string
2196 *
2197 * @param[in] val CLGEMMKernelType value to be converted
2198 *
2199 * @return String representing the corresponding CLGEMMKernelType
2200 */
2201inline std::string to_string(CLGEMMKernelType val)
2202{
2203 switch(val)
2204 {
2205 case CLGEMMKernelType::NATIVE_V1:
2206 {
2207 return "Native_V1";
2208 }
2209 case CLGEMMKernelType::RESHAPED_V1:
2210 {
2211 return "Reshaped_V1";
2212 }
2213 case CLGEMMKernelType::NATIVE:
2214 {
2215 return "Native";
2216 }
2217 case CLGEMMKernelType::RESHAPED_ONLY_RHS:
2218 {
2219 return "Reshaped_Only_RHS";
2220 }
2221 case CLGEMMKernelType::RESHAPED:
2222 {
2223 return "Reshaped";
2224 }
2225 default:
2226 {
2227 return "Unknown";
2228 }
2229 }
2230}
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +01002231/** [Print CLTunerMode type] **/
2232/** Formatted output of the CLTunerMode type.
2233 *
2234 * @param[out] os Output stream.
2235 * @param[in] val CLTunerMode to output.
2236 *
2237 * @return Modified output stream.
2238 */
2239inline ::std::ostream &operator<<(::std::ostream &os, const CLTunerMode &val)
2240{
2241 os << to_string(val);
2242 return os;
2243}
2244
Anthony Barbier6ff3b192017-09-04 18:44:23 +01002245} // namespace arm_compute
Anthony Barbier4dbc0a92018-08-27 13:39:47 +01002246
2247#endif /* __ARM_COMPUTE_TYPE_PRINTER_H__ */