blob: 0bea40851913193d659b0d6bf4186c4b1120ffbe [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
ramelg01cbbb0382021-09-17 17:36:57 +010027#ifdef ARM_COMPUTE_OPENCL_ENABLED
28#include "arm_compute/core/CL/ICLTensor.h"
29#endif /* ARM_COMPUTE_OPENCL_ENABLED */
30
Anthony Barbier6ff3b192017-09-04 18:44:23 +010031#include "arm_compute/core/Dimensions.h"
32#include "arm_compute/core/Error.h"
Michele Di Giorgiob8fc60f2018-04-25 11:58:07 +010033#include "arm_compute/core/GPUTarget.h"
morgolockaba2f912020-05-05 16:28:19 +010034#include "arm_compute/core/KernelDescriptors.h"
John Richardson25f23682017-11-27 14:35:09 +000035#include "arm_compute/core/Size2D.h"
John Richardsona36eae12017-09-26 16:55:59 +010036#include "arm_compute/core/Strides.h"
Georgios Pinitas3faea252017-10-30 14:13:50 +000037#include "arm_compute/core/TensorInfo.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010038#include "arm_compute/core/Types.h"
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +010039#include "arm_compute/runtime/CL/CLTunerTypes.h"
SiCong Lidb4a6c12021-02-05 09:30:57 +000040#include "arm_compute/runtime/CL/CLTypes.h"
ramelg013ae3d882021-09-12 23:07:47 +010041#include "arm_compute/runtime/FunctionDescriptors.h"
ramelg01cbbb0382021-09-17 17:36:57 +010042#include "arm_compute/runtime/common/LSTMParams.h"
Matthew Bentham758b5ba2020-03-05 23:37:48 +000043#include "support/StringSupport.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010044
45#include <ostream>
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010046#include <sstream>
47#include <string>
Anthony Barbier6ff3b192017-09-04 18:44:23 +010048
49namespace arm_compute
50{
Anthony Barbierb940fd62018-06-04 14:14:32 +010051/** Formatted output if arg is not null
52 *
53 * @param[in] arg Object to print
54 *
55 * @return String representing arg.
56 */
57template <typename T>
58std::string to_string_if_not_null(T *arg)
59{
60 if(arg == nullptr)
61 {
62 return "nullptr";
63 }
64 else
65 {
66 return to_string(*arg);
67 }
68}
Anthony Barbierb4670212018-05-18 16:55:39 +010069
ramelg014a6d9e82021-10-02 14:34:36 +010070/** Fallback method: try to use std::to_string:
71 *
72 * @param[in] val Value to convert to string
73 *
74 * @return String representing val.
75 */
76template <typename T>
77inline std::string to_string(const T &val)
78{
79 return support::cpp11::to_string(val);
80}
81
ramelg01b1ba1e32021-09-25 11:53:26 +010082/** Formatted output of a vector of objects.
83 *
ramelg014a6d9e82021-10-02 14:34:36 +010084 * @note: Using the overloaded to_string() instead of overloaded operator<<(), because to_string() functions are
85 * overloaded for all types, where two or more of them can use the same operator<<(), ITensor is an example.
86 *
ramelg01b1ba1e32021-09-25 11:53:26 +010087 * @param[out] os Output stream
88 * @param[in] args Vector of objects to print
89 *
90 * @return Modified output stream.
91 */
92template <typename T>
ramelg014a6d9e82021-10-02 14:34:36 +010093::std::ostream &operator<<(::std::ostream &os, const std::vector<T> &args)
ramelg01b1ba1e32021-09-25 11:53:26 +010094{
95 const size_t max_print_size = 5U;
96
97 os << "[";
98 bool first = true;
99 size_t i;
100 for(i = 0; i < args.size(); ++i)
101 {
102 if(i == max_print_size)
103 {
104 break;
105 }
106 if(first)
107 {
108 first = false;
109 }
110 else
111 {
112 os << ", ";
113 }
ramelg014a6d9e82021-10-02 14:34:36 +0100114 os << to_string(args[i]);
ramelg01b1ba1e32021-09-25 11:53:26 +0100115 }
116 if(i < args.size())
117 {
118 os << ", ...";
119 }
120 os << "]";
121 return os;
122}
123
ramelg014a6d9e82021-10-02 14:34:36 +0100124/** Formatted output of a vector of objects.
125 *
126 * @param[in] args Vector of objects to print
127 *
128 * @return String representing args.
129 */
130template <typename T>
131std::string to_string(const std::vector<T> &args)
132{
133 std::stringstream str;
134 str << args;
135 return str.str();
136}
137
Alex Gildayc357c472018-03-21 13:54:09 +0000138/** Formatted output of the Dimensions type.
139 *
140 * @param[out] os Output stream.
141 * @param[in] dimensions Type to output.
142 *
143 * @return Modified output stream.
144 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100145template <typename T>
146inline ::std::ostream &operator<<(::std::ostream &os, const Dimensions<T> &dimensions)
147{
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100148 if(dimensions.num_dimensions() > 0)
149 {
150 os << dimensions[0];
151
152 for(unsigned int d = 1; d < dimensions.num_dimensions(); ++d)
153 {
Freddie Liardetdd23f2a2021-06-17 13:30:11 +0100154 os << "," << dimensions[d];
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100155 }
156 }
157
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100158 return os;
159}
160
Alex Gildayc357c472018-03-21 13:54:09 +0000161/** Formatted output of the RoundingPolicy type.
162 *
163 * @param[out] os Output stream.
164 * @param[in] rounding_policy Type to output.
165 *
166 * @return Modified output stream.
167 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100168inline ::std::ostream &operator<<(::std::ostream &os, const RoundingPolicy &rounding_policy)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100169{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100170 switch(rounding_policy)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100171 {
Anthony Barbier2a07e182017-08-04 18:20:27 +0100172 case RoundingPolicy::TO_ZERO:
173 os << "TO_ZERO";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100174 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100175 case RoundingPolicy::TO_NEAREST_UP:
176 os << "TO_NEAREST_UP";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100177 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100178 case RoundingPolicy::TO_NEAREST_EVEN:
179 os << "TO_NEAREST_EVEN";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100180 break;
181 default:
182 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
183 }
184
185 return os;
186}
187
Alex Gildayc357c472018-03-21 13:54:09 +0000188/** Formatted output of the WeightsInfo type.
189 *
190 * @param[out] os Output stream.
191 * @param[in] weights_info Type to output.
192 *
193 * @return Modified output stream.
194 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100195inline ::std::ostream &operator<<(::std::ostream &os, const WeightsInfo &weights_info)
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100196{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100197 os << weights_info.are_reshaped() << ";";
198 os << weights_info.num_kernels() << ";" << weights_info.kernel_size().first << "," << weights_info.kernel_size().second;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100199
200 return os;
201}
202
Alex Gildayc357c472018-03-21 13:54:09 +0000203/** Formatted output of the ROIPoolingInfo type.
204 *
205 * @param[out] os Output stream.
206 * @param[in] pool_info Type to output.
207 *
208 * @return Modified output stream.
209 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100210inline ::std::ostream &operator<<(::std::ostream &os, const ROIPoolingLayerInfo &pool_info)
Sanghoon Lee70f82912017-08-24 14:21:24 +0100211{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100212 os << pool_info.pooled_width() << "x" << pool_info.pooled_height() << "~" << pool_info.spatial_scale();
Georgios Pinitasd9769582017-08-03 10:19:40 +0100213 return os;
214}
215
giuros0118870812018-09-13 09:31:40 +0100216/** Formatted output of the ROIPoolingInfo type.
217 *
218 * @param[in] pool_info Type to output.
219 *
220 * @return Formatted string.
221 */
222inline std::string to_string(const ROIPoolingLayerInfo &pool_info)
223{
224 std::stringstream str;
225 str << pool_info;
226 return str.str();
227}
228
morgolockaba2f912020-05-05 16:28:19 +0100229/** Formatted output of the GEMMKernelInfo type.
230 *
231 * @param[out] os Output stream.
232 * @param[in] gemm_info Type to output.
233 *
234 * @return Modified output stream.
235 */
236inline ::std::ostream &operator<<(::std::ostream &os, const GEMMKernelInfo &gemm_info)
237{
238 os << "( m= " << gemm_info.m;
239 os << " n= " << gemm_info.n;
240 os << " k= " << gemm_info.k;
241 os << " depth_output_gemm3d= " << gemm_info.depth_output_gemm3d;
242 os << " reinterpret_input_as_3d= " << gemm_info.reinterpret_input_as_3d;
243 os << " broadcast_bias= " << gemm_info.broadcast_bias;
244 os << " fp_mixed_precision= " << gemm_info.fp_mixed_precision;
245 os << " mult_transpose1xW_width= " << gemm_info.mult_transpose1xW_width;
246 os << " mult_interleave4x4_height= " << gemm_info.mult_interleave4x4_height;
247 os << " a_offset = " << gemm_info.a_offset;
248 os << " b_offset = " << gemm_info.b_offset;
249 os << ")";
250 return os;
251}
252
253/** Formatted output of the GEMMLHSMatrixInfo type.
254 *
255 * @param[out] os Output stream.
256 * @param[in] gemm_info Type to output.
257 *
258 * @return Modified output stream.
259 */
260inline ::std::ostream &operator<<(::std::ostream &os, const GEMMLHSMatrixInfo &gemm_info)
261{
262 os << "( m0= " << (unsigned int)gemm_info.m0 << " k0= " << gemm_info.k0 << " v0= " << gemm_info.v0 << " trans= " << gemm_info.transpose << " inter= " << gemm_info.interleave << "})";
263 return os;
264}
265
266/** Formatted output of the GEMMRHSMatrixInfo type.
267 *
268 * @param[out] os Output stream.
269 * @param[in] gemm_info Type to output.
270 *
271 * @return Modified output stream.
272 */
273inline ::std::ostream &operator<<(::std::ostream &os, const GEMMRHSMatrixInfo &gemm_info)
274{
SiCong Lidb4a6c12021-02-05 09:30:57 +0000275 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=" <<
276 gemm_info.export_to_cl_image << "})";
morgolockaba2f912020-05-05 16:28:19 +0100277 return os;
278}
279
280/** Formatted output of the GEMMRHSMatrixInfo type.
281 *
282 * @param[in] gemm_info GEMMRHSMatrixInfo to output.
283 *
284 * @return Formatted string.
285 */
286inline std::string to_string(const GEMMRHSMatrixInfo &gemm_info)
287{
288 std::stringstream str;
289 str << gemm_info;
290 return str.str();
291}
292
293/** Formatted output of the GEMMLHSMatrixInfo type.
294 *
295 * @param[in] gemm_info GEMMLHSMatrixInfo to output.
296 *
297 * @return Formatted string.
298 */
299inline std::string to_string(const GEMMLHSMatrixInfo &gemm_info)
300{
301 std::stringstream str;
302 str << gemm_info;
303 return str.str();
304}
305
306/** Formatted output of the GEMMKernelInfo type.
307 *
308 * @param[in] gemm_info GEMMKernelInfo Type to output.
309 *
310 * @return Formatted string.
311 */
312inline std::string to_string(const GEMMKernelInfo &gemm_info)
313{
314 std::stringstream str;
315 str << gemm_info;
316 return str.str();
317}
318
giuros01c04a0e82018-10-03 12:44:35 +0100319/** Formatted output of the BoundingBoxTransformInfo type.
320 *
321 * @param[out] os Output stream.
322 * @param[in] bbox_info Type to output.
323 *
324 * @return Modified output stream.
325 */
326inline ::std::ostream &operator<<(::std::ostream &os, const BoundingBoxTransformInfo &bbox_info)
327{
328 auto weights = bbox_info.weights();
329 os << "(" << bbox_info.img_width() << "x" << bbox_info.img_height() << ")~" << bbox_info.scale() << "(weights = {" << weights[0] << ", " << weights[1] << ", " << weights[2] << ", " << weights[3] <<
330 "})";
331 return os;
332}
333
334/** Formatted output of the BoundingBoxTransformInfo type.
335 *
336 * @param[in] bbox_info Type to output.
337 *
338 * @return Formatted string.
339 */
340inline std::string to_string(const BoundingBoxTransformInfo &bbox_info)
341{
342 std::stringstream str;
343 str << bbox_info;
344 return str.str();
345}
346
Manuel Bottini5209be52019-02-13 16:34:56 +0000347/** Formatted output of the ComputeAnchorsInfo type.
348 *
349 * @param[out] os Output stream.
350 * @param[in] anchors_info Type to output.
351 *
352 * @return Modified output stream.
353 */
354inline ::std::ostream &operator<<(::std::ostream &os, const ComputeAnchorsInfo &anchors_info)
355{
356 os << "(" << anchors_info.feat_width() << "x" << anchors_info.feat_height() << ")~" << anchors_info.spatial_scale();
357 return os;
358}
359
360/** Formatted output of the ComputeAnchorsInfo type.
361 *
362 * @param[in] anchors_info Type to output.
363 *
364 * @return Formatted string.
365 */
366inline std::string to_string(const ComputeAnchorsInfo &anchors_info)
367{
368 std::stringstream str;
369 str << anchors_info;
370 return str.str();
371}
372
373/** Formatted output of the GenerateProposalsInfo type.
374 *
375 * @param[out] os Output stream.
376 * @param[in] proposals_info Type to output.
377 *
378 * @return Modified output stream.
379 */
380inline ::std::ostream &operator<<(::std::ostream &os, const GenerateProposalsInfo &proposals_info)
381{
382 os << "(" << proposals_info.im_width() << "x" << proposals_info.im_height() << ")~" << proposals_info.im_scale();
383 return os;
384}
385
386/** Formatted output of the GenerateProposalsInfo type.
387 *
388 * @param[in] proposals_info Type to output.
389 *
390 * @return Formatted string.
391 */
392inline std::string to_string(const GenerateProposalsInfo &proposals_info)
393{
394 std::stringstream str;
395 str << proposals_info;
396 return str.str();
397}
398
Alex Gildayc357c472018-03-21 13:54:09 +0000399/** Formatted output of the QuantizationInfo type.
400 *
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100401 * @param[out] os Output stream.
402 * @param[in] qinfo Type to output.
Alex Gildayc357c472018-03-21 13:54:09 +0000403 *
404 * @return Modified output stream.
405 */
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100406inline ::std::ostream &operator<<(::std::ostream &os, const QuantizationInfo &qinfo)
Chunosovd621bca2017-11-03 17:33:15 +0700407{
Georgios Pinitas3d13af82019-06-04 13:04:16 +0100408 const UniformQuantizationInfo uqinfo = qinfo.uniform();
409 os << "Scale:" << uqinfo.scale << "~";
410 os << "Offset:" << uqinfo.offset;
Chunosovd621bca2017-11-03 17:33:15 +0700411 return os;
412}
413
Alex Gildayc357c472018-03-21 13:54:09 +0000414/** Formatted output of the QuantizationInfo type.
415 *
416 * @param[in] quantization_info Type to output.
417 *
418 * @return Formatted string.
419 */
Chunosovd621bca2017-11-03 17:33:15 +0700420inline std::string to_string(const QuantizationInfo &quantization_info)
421{
422 std::stringstream str;
423 str << quantization_info;
424 return str.str();
425}
426
Alex Gildayc357c472018-03-21 13:54:09 +0000427/** Formatted output of the activation function type.
428 *
429 * @param[out] os Output stream.
430 * @param[in] act_function Type to output.
431 *
432 * @return Modified output stream.
433 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100434inline ::std::ostream &operator<<(::std::ostream &os, const ActivationLayerInfo::ActivationFunction &act_function)
435{
436 switch(act_function)
437 {
438 case ActivationLayerInfo::ActivationFunction::ABS:
439 os << "ABS";
440 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100441 case ActivationLayerInfo::ActivationFunction::LINEAR:
442 os << "LINEAR";
443 break;
444 case ActivationLayerInfo::ActivationFunction::LOGISTIC:
445 os << "LOGISTIC";
446 break;
447 case ActivationLayerInfo::ActivationFunction::RELU:
448 os << "RELU";
449 break;
Georgios Pinitas579c0492017-07-12 16:12:12 +0100450 case ActivationLayerInfo::ActivationFunction::BOUNDED_RELU:
451 os << "BOUNDED_RELU";
452 break;
453 case ActivationLayerInfo::ActivationFunction::LEAKY_RELU:
454 os << "LEAKY_RELU";
455 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100456 case ActivationLayerInfo::ActivationFunction::SOFT_RELU:
457 os << "SOFT_RELU";
458 break;
459 case ActivationLayerInfo::ActivationFunction::SQRT:
460 os << "SQRT";
461 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100462 case ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU:
463 os << "LU_BOUNDED_RELU";
Kevin Petitd9f80712017-12-06 12:18:48 +0000464 break;
Georgios Pinitasfb0fdcd2019-08-22 17:10:04 +0100465 case ActivationLayerInfo::ActivationFunction::ELU:
466 os << "ELU";
467 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100468 case ActivationLayerInfo::ActivationFunction::SQUARE:
469 os << "SQUARE";
470 break;
471 case ActivationLayerInfo::ActivationFunction::TANH:
472 os << "TANH";
473 break;
Usama Arif6a98a6e2019-05-10 17:07:27 +0100474 case ActivationLayerInfo::ActivationFunction::IDENTITY:
475 os << "IDENTITY";
476 break;
morgolock07df3d42020-02-27 11:46:28 +0000477 case ActivationLayerInfo::ActivationFunction::HARD_SWISH:
478 os << "HARD_SWISH";
479 break;
480
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100481 default:
482 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
483 }
484
485 return os;
486}
487
Alex Gildayc357c472018-03-21 13:54:09 +0000488/** Formatted output of the activation function info type.
489 *
490 * @param[in] info Type to output.
491 *
492 * @return Formatted string.
493 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100494inline std::string to_string(const arm_compute::ActivationLayerInfo &info)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100495{
496 std::stringstream str;
Isabella Gottardi3f217ec2018-02-12 14:59:19 +0000497 if(info.enabled())
498 {
499 str << info.activation();
500 }
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100501 return str.str();
502}
503
ramelg013ae3d882021-09-12 23:07:47 +0100504/** Formatted output of the activation function info type.
505 *
506 * @param[in] info Type to output.
507 *
508 * @return Formatted string.
509 */
510inline std::string to_string(const arm_compute::ActivationLayerInfo *info)
511{
512 std::string ret_str = "nullptr";
513 if(info != nullptr)
514 {
515 std::stringstream str;
516 if(info->enabled())
517 {
518 str << info->activation();
519 }
520 ret_str = str.str();
521 }
522 return ret_str;
523}
524
Alex Gildayc357c472018-03-21 13:54:09 +0000525/** Formatted output of the activation function type.
526 *
527 * @param[in] function Type to output.
528 *
529 * @return Formatted string.
530 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100531inline std::string to_string(const arm_compute::ActivationLayerInfo::ActivationFunction &function)
532{
533 std::stringstream str;
534 str << function;
535 return str.str();
536}
537
Alex Gildayc357c472018-03-21 13:54:09 +0000538/** Formatted output of the NormType type.
539 *
540 * @param[out] os Output stream.
541 * @param[in] norm_type Type to output.
542 *
543 * @return Modified output stream.
544 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100545inline ::std::ostream &operator<<(::std::ostream &os, const NormType &norm_type)
546{
547 switch(norm_type)
548 {
549 case NormType::CROSS_MAP:
550 os << "CROSS_MAP";
551 break;
552 case NormType::IN_MAP_1D:
553 os << "IN_MAP_1D";
554 break;
555 case NormType::IN_MAP_2D:
556 os << "IN_MAP_2D";
557 break;
558 default:
559 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
560 }
561
562 return os;
563}
564
Alex Gildayc357c472018-03-21 13:54:09 +0000565/** Formatted output of @ref NormalizationLayerInfo.
566 *
567 * @param[in] info Type to output.
568 *
569 * @return Formatted string.
570 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100571inline std::string to_string(const arm_compute::NormalizationLayerInfo &info)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100572{
573 std::stringstream str;
Michalis Spyroud466c2d2018-01-30 10:54:39 +0000574 str << info.type() << ":NormSize=" << info.norm_size();
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100575 return str.str();
576}
577
Alex Gildayc357c472018-03-21 13:54:09 +0000578/** Formatted output of @ref NormalizationLayerInfo.
579 *
580 * @param[out] os Output stream.
581 * @param[in] info Type to output.
582 *
583 * @return Modified output stream.
584 */
Georgios Pinitas6f669f02017-09-26 12:32:57 +0100585inline ::std::ostream &operator<<(::std::ostream &os, const NormalizationLayerInfo &info)
586{
Michalis Spyroud466c2d2018-01-30 10:54:39 +0000587 os << info.type() << ":NormSize=" << info.norm_size();
Georgios Pinitas6f669f02017-09-26 12:32:57 +0100588 return os;
589}
590
Alex Gildayc357c472018-03-21 13:54:09 +0000591/** Formatted output of the PoolingType type.
592 *
593 * @param[out] os Output stream.
594 * @param[in] pool_type Type to output.
595 *
596 * @return Modified output stream.
597 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100598inline ::std::ostream &operator<<(::std::ostream &os, const PoolingType &pool_type)
599{
600 switch(pool_type)
601 {
602 case PoolingType::AVG:
603 os << "AVG";
604 break;
605 case PoolingType::MAX:
606 os << "MAX";
607 break;
Georgios Pinitascdf51452017-08-31 14:21:36 +0100608 case PoolingType::L2:
609 os << "L2";
610 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100611 default:
612 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
613 }
614
615 return os;
616}
617
Alex Gildayc357c472018-03-21 13:54:09 +0000618/** Formatted output of @ref PoolingLayerInfo.
619 *
620 * @param[out] os Output stream.
621 * @param[in] info Type to output.
622 *
623 * @return Modified output stream.
624 */
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100625inline ::std::ostream &operator<<(::std::ostream &os, const PoolingLayerInfo &info)
626{
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +0000627 os << info.pool_type;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100628
629 return os;
630}
631
Alex Gildayc357c472018-03-21 13:54:09 +0000632/** Formatted output of @ref RoundingPolicy.
633 *
634 * @param[in] rounding_policy Type to output.
635 *
636 * @return Formatted string.
637 */
John Richardsondd715f22017-09-18 16:10:48 +0100638inline std::string to_string(const RoundingPolicy &rounding_policy)
639{
640 std::stringstream str;
641 str << rounding_policy;
642 return str.str();
643}
644
Vidhya Sudhan Loganathand646ae12018-11-19 15:18:20 +0000645/** [Print DataLayout type] **/
Alex Gildayc357c472018-03-21 13:54:09 +0000646/** Formatted output of the DataLayout type.
647 *
648 * @param[out] os Output stream.
649 * @param[in] data_layout Type to output.
650 *
651 * @return Modified output stream.
652 */
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000653inline ::std::ostream &operator<<(::std::ostream &os, const DataLayout &data_layout)
654{
655 switch(data_layout)
656 {
657 case DataLayout::UNKNOWN:
658 os << "UNKNOWN";
659 break;
660 case DataLayout::NHWC:
661 os << "NHWC";
662 break;
663 case DataLayout::NCHW:
664 os << "NCHW";
665 break;
Adnan AlSinane4563a02021-09-01 15:32:03 +0100666 case DataLayout::NDHWC:
667 os << "NDHWC";
668 break;
Giorgio Arenac9fe9fc2021-10-06 12:54:29 +0100669 case DataLayout::NCDHW:
670 os << "NCDHW";
671 break;
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000672 default:
673 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
674 }
675
676 return os;
677}
678
Alex Gildayc357c472018-03-21 13:54:09 +0000679/** Formatted output of the DataLayout type.
680 *
681 * @param[in] data_layout Type to output.
682 *
683 * @return Formatted string.
684 */
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000685inline std::string to_string(const arm_compute::DataLayout &data_layout)
686{
687 std::stringstream str;
688 str << data_layout;
689 return str.str();
690}
Vidhya Sudhan Loganathand646ae12018-11-19 15:18:20 +0000691/** [Print DataLayout type] **/
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000692
Georgios Pinitase2220552018-07-20 13:23:44 +0100693/** Formatted output of the DataLayoutDimension type.
694 *
695 * @param[out] os Output stream.
696 * @param[in] data_layout_dim Data layout dimension to print.
697 *
698 * @return Modified output stream.
699 */
700inline ::std::ostream &operator<<(::std::ostream &os, const DataLayoutDimension &data_layout_dim)
701{
702 switch(data_layout_dim)
703 {
704 case DataLayoutDimension::WIDTH:
705 os << "WIDTH";
706 break;
707 case DataLayoutDimension::HEIGHT:
708 os << "HEIGHT";
709 break;
710 case DataLayoutDimension::CHANNEL:
711 os << "CHANNEL";
712 break;
Giorgio Arenac9fe9fc2021-10-06 12:54:29 +0100713 case DataLayoutDimension::DEPTH:
714 os << "DEPTH";
715 break;
Georgios Pinitase2220552018-07-20 13:23:44 +0100716 case DataLayoutDimension::BATCHES:
717 os << "BATCHES";
718 break;
719 default:
720 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
721 }
722 return os;
723}
724
Alex Gildayc357c472018-03-21 13:54:09 +0000725/** Formatted output of the DataType type.
726 *
727 * @param[out] os Output stream.
728 * @param[in] data_type Type to output.
729 *
730 * @return Modified output stream.
731 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100732inline ::std::ostream &operator<<(::std::ostream &os, const DataType &data_type)
733{
734 switch(data_type)
735 {
736 case DataType::UNKNOWN:
737 os << "UNKNOWN";
738 break;
739 case DataType::U8:
740 os << "U8";
741 break;
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100742 case DataType::QSYMM8:
743 os << "QSYMM8";
744 break;
Chunosovd621bca2017-11-03 17:33:15 +0700745 case DataType::QASYMM8:
746 os << "QASYMM8";
747 break;
Georgios Pinitas448a81f2019-11-21 14:10:25 +0000748 case DataType::QASYMM8_SIGNED:
749 os << "QASYMM8_SIGNED";
750 break;
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100751 case DataType::QSYMM8_PER_CHANNEL:
752 os << "QSYMM8_PER_CHANNEL";
753 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100754 case DataType::S8:
755 os << "S8";
756 break;
757 case DataType::U16:
758 os << "U16";
759 break;
760 case DataType::S16:
761 os << "S16";
762 break;
Manuel Bottini3689fcd2019-06-14 17:18:12 +0100763 case DataType::QSYMM16:
764 os << "QSYMM16";
765 break;
Michele Di Giorgio35ea9a72019-08-23 12:02:06 +0100766 case DataType::QASYMM16:
767 os << "QASYMM16";
768 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100769 case DataType::U32:
770 os << "U32";
771 break;
772 case DataType::S32:
773 os << "S32";
774 break;
775 case DataType::U64:
776 os << "U64";
777 break;
778 case DataType::S64:
779 os << "S64";
780 break;
Georgios Pinitase8291ac2020-02-26 09:58:13 +0000781 case DataType::BFLOAT16:
782 os << "BFLOAT16";
783 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100784 case DataType::F16:
785 os << "F16";
786 break;
787 case DataType::F32:
788 os << "F32";
789 break;
790 case DataType::F64:
791 os << "F64";
792 break;
793 case DataType::SIZET:
794 os << "SIZET";
795 break;
796 default:
797 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
798 }
799
800 return os;
801}
802
Alex Gildayc357c472018-03-21 13:54:09 +0000803/** Formatted output of the DataType type.
804 *
805 * @param[in] data_type Type to output.
806 *
807 * @return Formatted string.
808 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100809inline std::string to_string(const arm_compute::DataType &data_type)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100810{
811 std::stringstream str;
812 str << data_type;
813 return str.str();
814}
815
Alex Gildayc357c472018-03-21 13:54:09 +0000816/** Formatted output of the Format type.
817 *
818 * @param[out] os Output stream.
819 * @param[in] format Type to output.
820 *
821 * @return Modified output stream.
822 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100823inline ::std::ostream &operator<<(::std::ostream &os, const Format &format)
824{
825 switch(format)
826 {
827 case Format::UNKNOWN:
828 os << "UNKNOWN";
829 break;
830 case Format::U8:
831 os << "U8";
832 break;
833 case Format::S16:
834 os << "S16";
835 break;
836 case Format::U16:
837 os << "U16";
838 break;
839 case Format::S32:
840 os << "S32";
841 break;
842 case Format::U32:
843 os << "U32";
844 break;
845 case Format::F16:
846 os << "F16";
847 break;
848 case Format::F32:
849 os << "F32";
850 break;
851 case Format::UV88:
852 os << "UV88";
853 break;
854 case Format::RGB888:
855 os << "RGB888";
856 break;
857 case Format::RGBA8888:
858 os << "RGBA8888";
859 break;
860 case Format::YUV444:
861 os << "YUV444";
862 break;
863 case Format::YUYV422:
864 os << "YUYV422";
865 break;
866 case Format::NV12:
867 os << "NV12";
868 break;
869 case Format::NV21:
870 os << "NV21";
871 break;
872 case Format::IYUV:
873 os << "IYUV";
874 break;
875 case Format::UYVY422:
876 os << "UYVY422";
877 break;
878 default:
879 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
880 }
881
882 return os;
883}
884
Alex Gildayc357c472018-03-21 13:54:09 +0000885/** Formatted output of the Format type.
886 *
887 * @param[in] format Type to output.
888 *
889 * @return Formatted string.
890 */
Moritz Pflanzer7655a672017-09-23 11:57:33 +0100891inline std::string to_string(const Format &format)
892{
893 std::stringstream str;
894 str << format;
895 return str.str();
896}
897
Alex Gildayc357c472018-03-21 13:54:09 +0000898/** Formatted output of the Channel type.
899 *
900 * @param[out] os Output stream.
901 * @param[in] channel Type to output.
902 *
903 * @return Modified output stream.
904 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100905inline ::std::ostream &operator<<(::std::ostream &os, const Channel &channel)
906{
907 switch(channel)
908 {
909 case Channel::UNKNOWN:
910 os << "UNKNOWN";
911 break;
912 case Channel::C0:
913 os << "C0";
914 break;
915 case Channel::C1:
916 os << "C1";
917 break;
918 case Channel::C2:
919 os << "C2";
920 break;
921 case Channel::C3:
922 os << "C3";
923 break;
924 case Channel::R:
925 os << "R";
926 break;
927 case Channel::G:
928 os << "G";
929 break;
930 case Channel::B:
931 os << "B";
932 break;
933 case Channel::A:
934 os << "A";
935 break;
936 case Channel::Y:
937 os << "Y";
938 break;
939 case Channel::U:
940 os << "U";
941 break;
942 case Channel::V:
943 os << "V";
944 break;
945 default:
946 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
947 }
948
949 return os;
950}
951
Alex Gildayc357c472018-03-21 13:54:09 +0000952/** Formatted output of the Channel type.
953 *
954 * @param[in] channel Type to output.
955 *
956 * @return Formatted string.
957 */
Ioan-Cristian Szabo9414f642017-10-27 17:35:40 +0100958inline std::string to_string(const Channel &channel)
959{
960 std::stringstream str;
961 str << channel;
962 return str.str();
963}
964
Alex Gildayc357c472018-03-21 13:54:09 +0000965/** Formatted output of the BorderMode type.
966 *
967 * @param[out] os Output stream.
968 * @param[in] mode Type to output.
969 *
970 * @return Modified output stream.
971 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100972inline ::std::ostream &operator<<(::std::ostream &os, const BorderMode &mode)
973{
974 switch(mode)
975 {
976 case BorderMode::UNDEFINED:
977 os << "UNDEFINED";
978 break;
979 case BorderMode::CONSTANT:
980 os << "CONSTANT";
981 break;
982 case BorderMode::REPLICATE:
983 os << "REPLICATE";
984 break;
985 default:
986 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
987 }
988
989 return os;
990}
991
Alex Gildayc357c472018-03-21 13:54:09 +0000992/** Formatted output of the BorderSize type.
993 *
994 * @param[out] os Output stream.
995 * @param[in] border Type to output.
996 *
997 * @return Modified output stream.
998 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100999inline ::std::ostream &operator<<(::std::ostream &os, const BorderSize &border)
1000{
Moritz Pflanzerc87fbf82017-07-18 14:02:10 +01001001 os << border.top << ","
1002 << border.right << ","
1003 << border.bottom << ","
1004 << border.left;
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001005
1006 return os;
1007}
Anthony Barbier2a07e182017-08-04 18:20:27 +01001008
Giuseppe Rossinid7647d42018-07-17 18:13:13 +01001009/** Formatted output of the PaddingList type.
1010 *
1011 * @param[out] os Output stream.
1012 * @param[in] padding Type to output.
1013 *
1014 * @return Modified output stream.
1015 */
1016inline ::std::ostream &operator<<(::std::ostream &os, const PaddingList &padding)
1017{
1018 os << "{";
1019 for(auto const &p : padding)
1020 {
1021 os << "{" << p.first << "," << p.second << "}";
1022 }
1023 os << "}";
1024 return os;
1025}
1026
giuros013175fcf2018-11-21 09:59:17 +00001027/** Formatted output of the Multiples type.
1028 *
1029 * @param[out] os Output stream.
1030 * @param[in] multiples Type to output.
1031 *
1032 * @return Modified output stream.
1033 */
1034inline ::std::ostream &operator<<(::std::ostream &os, const Multiples &multiples)
1035{
1036 os << "(";
1037 for(size_t i = 0; i < multiples.size() - 1; i++)
1038 {
1039 os << multiples[i] << ", ";
1040 }
1041 os << multiples.back() << ")";
1042 return os;
1043}
1044
Alex Gildayc357c472018-03-21 13:54:09 +00001045/** Formatted output of the InterpolationPolicy type.
1046 *
1047 * @param[out] os Output stream.
1048 * @param[in] policy Type to output.
1049 *
1050 * @return Modified output stream.
1051 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001052inline ::std::ostream &operator<<(::std::ostream &os, const InterpolationPolicy &policy)
1053{
1054 switch(policy)
1055 {
1056 case InterpolationPolicy::NEAREST_NEIGHBOR:
1057 os << "NEAREST_NEIGHBOR";
1058 break;
1059 case InterpolationPolicy::BILINEAR:
1060 os << "BILINEAR";
1061 break;
1062 case InterpolationPolicy::AREA:
1063 os << "AREA";
1064 break;
1065 default:
1066 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1067 }
1068
1069 return os;
1070}
1071
Alex Gildayc357c472018-03-21 13:54:09 +00001072/** Formatted output of the SamplingPolicy type.
1073 *
1074 * @param[out] os Output stream.
1075 * @param[in] policy Type to output.
1076 *
1077 * @return Modified output stream.
1078 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +07001079inline ::std::ostream &operator<<(::std::ostream &os, const SamplingPolicy &policy)
1080{
1081 switch(policy)
1082 {
1083 case SamplingPolicy::CENTER:
1084 os << "CENTER";
1085 break;
1086 case SamplingPolicy::TOP_LEFT:
1087 os << "TOP_LEFT";
1088 break;
1089 default:
1090 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1091 }
1092
1093 return os;
1094}
1095
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001096/** Formatted output of the ITensorInfo type.
1097 *
1098 * @param[out] os Output stream.
1099 * @param[in] info Tensor information.
1100 *
1101 * @return Modified output stream.
1102 */
1103inline ::std::ostream &operator<<(std::ostream &os, const ITensorInfo *info)
1104{
Georgios Pinitasc6f95102021-03-30 10:03:01 +01001105 const DataType data_type = info->data_type();
1106 const DataLayout data_layout = info->data_layout();
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001107
1108 os << "Shape=" << info->tensor_shape() << ","
1109 << "DataLayout=" << string_from_data_layout(data_layout) << ","
ramelg014a6d9e82021-10-02 14:34:36 +01001110 << "DataType=" << string_from_data_type(data_type);
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001111
1112 if(is_data_type_quantized(data_type))
1113 {
ramelg01b1ba1e32021-09-25 11:53:26 +01001114 const QuantizationInfo qinfo = info->quantization_info();
1115 const auto scales = qinfo.scale();
1116 const auto offsets = qinfo.offset();
1117
ramelg014a6d9e82021-10-02 14:34:36 +01001118 os << ", QuantizationInfo={"
ramelg01b1ba1e32021-09-25 11:53:26 +01001119 << "scales.size=" << scales.size()
1120 << ", scale(s)=" << scales << ", ";
1121
1122 os << "offsets.size=" << offsets.size()
1123 << ", offset(s)=" << offsets << "}";
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001124 }
1125 return os;
1126}
1127
ramelg013ae3d882021-09-12 23:07:47 +01001128/** Formatted output of the const TensorInfo& type.
Alex Gildayc357c472018-03-21 13:54:09 +00001129 *
Anthony Barbier366628a2018-08-01 13:55:03 +01001130 * @param[out] os Output stream.
1131 * @param[in] info Type to output.
1132 *
1133 * @return Modified output stream.
1134 */
1135inline ::std::ostream &operator<<(::std::ostream &os, const TensorInfo &info)
1136{
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001137 os << &info;
Georgios Pinitasc6f95102021-03-30 10:03:01 +01001138 return os;
Anthony Barbier366628a2018-08-01 13:55:03 +01001139}
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001140
ramelg013ae3d882021-09-12 23:07:47 +01001141/** Formatted output of the const TensorInfo& type.
Anthony Barbier366628a2018-08-01 13:55:03 +01001142 *
Alex Gildayc357c472018-03-21 13:54:09 +00001143 * @param[in] info Type to output.
1144 *
1145 * @return Formatted string.
1146 */
Georgios Pinitas3faea252017-10-30 14:13:50 +00001147inline std::string to_string(const TensorInfo &info)
1148{
1149 std::stringstream str;
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001150 str << &info;
Georgios Pinitas3faea252017-10-30 14:13:50 +00001151 return str.str();
1152}
1153
ramelg013ae3d882021-09-12 23:07:47 +01001154/** Formatted output of the const ITensorInfo& type.
1155 *
1156 * @param[in] info Type to output.
1157 *
1158 * @return Formatted string.
1159 */
1160inline std::string to_string(const ITensorInfo &info)
1161{
1162 std::stringstream str;
1163 str << &info;
1164 return str.str();
1165}
1166
ramelg013ae3d882021-09-12 23:07:47 +01001167/** Formatted output of the const ITensorInfo* type.
1168 *
1169 * @param[in] info Type to output.
1170 *
1171 * @return Formatted string.
1172 */
Ramy Elgammale920d6a2021-08-19 22:10:30 +01001173inline std::string to_string(const ITensorInfo *info)
1174{
ramelg013ae3d882021-09-12 23:07:47 +01001175 std::string ret_str = "nullptr";
1176 if(info != nullptr)
1177 {
1178 std::stringstream str;
1179 str << info;
1180 ret_str = str.str();
1181 }
1182 return ret_str;
1183}
1184
ramelg01cbbb0382021-09-17 17:36:57 +01001185/** Formatted output of the ITensorInfo* type.
1186 *
1187 * @param[in] info Type to output.
1188 *
1189 * @return Formatted string.
1190 */
1191inline std::string to_string(ITensorInfo *info)
1192{
1193 return to_string(static_cast<const ITensorInfo *>(info));
1194}
1195
1196/** Formatted output of the ITensorInfo type obtained from const ITensor* type.
ramelg013ae3d882021-09-12 23:07:47 +01001197 *
1198 * @param[in] tensor Type to output.
1199 *
1200 * @return Formatted string.
1201 */
1202inline std::string to_string(const ITensor *tensor)
1203{
1204 std::string ret_str = "nullptr";
1205 if(tensor != nullptr)
1206 {
1207 std::stringstream str;
ramelg01cbbb0382021-09-17 17:36:57 +01001208 str << "ITensor->info(): " << tensor->info();
ramelg013ae3d882021-09-12 23:07:47 +01001209 ret_str = str.str();
1210 }
1211 return ret_str;
1212}
1213
ramelg01cbbb0382021-09-17 17:36:57 +01001214/** Formatted output of the ITensorInfo type obtained from the ITensor* type.
ramelg013ae3d882021-09-12 23:07:47 +01001215 *
1216 * @param[in] tensor Type to output.
1217 *
1218 * @return Formatted string.
1219 */
1220inline std::string to_string(ITensor *tensor)
1221{
ramelg01cbbb0382021-09-17 17:36:57 +01001222 return to_string(static_cast<const ITensor *>(tensor));
ramelg013ae3d882021-09-12 23:07:47 +01001223}
1224
ramelg01cbbb0382021-09-17 17:36:57 +01001225/** Formatted output of the ITensorInfo type obtained from the ITensor& type.
ramelg013ae3d882021-09-12 23:07:47 +01001226 *
1227 * @param[in] tensor Type to output.
1228 *
1229 * @return Formatted string.
1230 */
1231inline std::string to_string(ITensor &tensor)
1232{
Ramy Elgammale920d6a2021-08-19 22:10:30 +01001233 std::stringstream str;
ramelg01cbbb0382021-09-17 17:36:57 +01001234 str << "ITensor.info(): " << tensor.info();
Ramy Elgammale920d6a2021-08-19 22:10:30 +01001235 return str.str();
1236}
1237
ramelg01cbbb0382021-09-17 17:36:57 +01001238#ifdef ARM_COMPUTE_OPENCL_ENABLED
1239/** Formatted output of the ITensorInfo type obtained from the const ICLTensor& type.
1240 *
1241 * @param[in] cl_tensor Type to output.
1242 *
1243 * @return Formatted string.
1244 */
1245inline std::string to_string(const ICLTensor *cl_tensor)
1246{
1247 std::string ret_str = "nullptr";
1248 if(cl_tensor != nullptr)
1249 {
1250 std::stringstream str;
1251 str << "ICLTensor->info(): " << cl_tensor->info();
1252 ret_str = str.str();
1253 }
1254 return ret_str;
1255}
1256
1257/** Formatted output of the ITensorInfo type obtained from the ICLTensor& type.
1258 *
1259 * @param[in] cl_tensor Type to output.
1260 *
1261 * @return Formatted string.
1262 */
1263inline std::string to_string(ICLTensor *cl_tensor)
1264{
1265 return to_string(static_cast<const ICLTensor *>(cl_tensor));
1266}
1267#endif /* ARM_COMPUTE_OPENCL_ENABLED */
1268
Alex Gildayc357c472018-03-21 13:54:09 +00001269/** Formatted output of the Dimensions type.
1270 *
1271 * @param[in] dimensions Type to output.
1272 *
1273 * @return Formatted string.
1274 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001275template <typename T>
1276inline std::string to_string(const Dimensions<T> &dimensions)
1277{
1278 std::stringstream str;
1279 str << dimensions;
1280 return str.str();
1281}
1282
Alex Gildayc357c472018-03-21 13:54:09 +00001283/** Formatted output of the Strides type.
1284 *
1285 * @param[in] stride Type to output.
1286 *
1287 * @return Formatted string.
1288 */
John Richardsona36eae12017-09-26 16:55:59 +01001289inline std::string to_string(const Strides &stride)
1290{
1291 std::stringstream str;
1292 str << stride;
1293 return str.str();
1294}
1295
Alex Gildayc357c472018-03-21 13:54:09 +00001296/** Formatted output of the TensorShape type.
1297 *
1298 * @param[in] shape Type to output.
1299 *
1300 * @return Formatted string.
1301 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001302inline std::string to_string(const TensorShape &shape)
1303{
1304 std::stringstream str;
1305 str << shape;
1306 return str.str();
1307}
1308
Alex Gildayc357c472018-03-21 13:54:09 +00001309/** Formatted output of the Coordinates type.
1310 *
1311 * @param[in] coord Type to output.
1312 *
1313 * @return Formatted string.
1314 */
Abe Mbise925ca0f2017-10-02 19:16:33 +01001315inline std::string to_string(const Coordinates &coord)
1316{
1317 std::stringstream str;
1318 str << coord;
1319 return str.str();
1320}
1321
Anthony Barbierb940fd62018-06-04 14:14:32 +01001322/** Formatted output of the GEMMReshapeInfo type.
1323 *
1324 * @param[out] os Output stream.
1325 * @param[in] info Type to output.
1326 *
1327 * @return Modified output stream.
1328 */
1329inline ::std::ostream &operator<<(::std::ostream &os, const GEMMReshapeInfo &info)
1330{
1331 os << "{m=" << info.m() << ",";
1332 os << "n=" << info.n() << ",";
1333 os << "k=" << info.k() << ",";
1334 os << "mult_transpose1xW_width=" << info.mult_transpose1xW_width() << ",";
1335 os << "mult_interleave4x4_height=" << info.mult_interleave4x4_height();
1336 os << "}";
1337
1338 return os;
1339}
1340
1341/** Formatted output of the GEMMInfo type.
1342 *
1343 * @param[out] os Output stream.
1344 * @param[in] info Type to output.
1345 *
1346 * @return Modified output stream.
1347 */
1348inline ::std::ostream &operator<<(::std::ostream &os, const GEMMInfo &info)
1349{
1350 os << "{is_a_reshaped=" << info.is_a_reshaped() << ",";
1351 os << "is_b_reshaped=" << info.is_b_reshaped() << ",";
1352 os << "reshape_b_only_on_first_run=" << info.reshape_b_only_on_first_run() << ",";
Anthony Barbierb4670212018-05-18 16:55:39 +01001353 os << "depth_output_gemm3d=" << info.depth_output_gemm3d() << ",";
1354 os << "reinterpret_input_as_3d=" << info.reinterpret_input_as_3d() << ",";
1355 os << "retain_internal_weights=" << info.retain_internal_weights() << ",";
1356 os << "fp_mixed_precision=" << info.fp_mixed_precision() << ",";
1357 os << "broadcast_bias=" << info.broadcast_bias() << ",";
ramelg01cbbb0382021-09-17 17:36:57 +01001358 os << "pretranspose_B=" << info.pretranspose_B() << ",";
Anthony Barbierb940fd62018-06-04 14:14:32 +01001359
1360 return os;
1361}
1362
1363/** Formatted output of the Window::Dimension type.
1364 *
1365 * @param[out] os Output stream.
1366 * @param[in] dim Type to output.
1367 *
1368 * @return Modified output stream.
1369 */
1370inline ::std::ostream &operator<<(::std::ostream &os, const Window::Dimension &dim)
1371{
1372 os << "{start=" << dim.start() << ", end=" << dim.end() << ", step=" << dim.step() << "}";
1373
1374 return os;
1375}
1376/** Formatted output of the Window type.
1377 *
1378 * @param[out] os Output stream.
1379 * @param[in] win Type to output.
1380 *
1381 * @return Modified output stream.
1382 */
1383inline ::std::ostream &operator<<(::std::ostream &os, const Window &win)
1384{
1385 os << "{";
1386 for(unsigned int i = 0; i < Coordinates::num_max_dimensions; i++)
1387 {
1388 if(i > 0)
1389 {
1390 os << ", ";
1391 }
1392 os << win[i];
1393 }
1394 os << "}";
1395
1396 return os;
1397}
1398
1399/** Formatted output of the WeightsInfo type.
1400 *
1401 * @param[in] info Type to output.
1402 *
1403 * @return Formatted string.
1404 */
1405inline std::string to_string(const WeightsInfo &info)
1406{
1407 std::stringstream str;
1408 str << info;
1409 return str.str();
1410}
1411
1412/** Formatted output of the GEMMReshapeInfo type.
1413 *
1414 * @param[in] info Type to output.
1415 *
1416 * @return Formatted string.
1417 */
1418inline std::string to_string(const GEMMReshapeInfo &info)
1419{
1420 std::stringstream str;
1421 str << info;
1422 return str.str();
1423}
1424
1425/** Formatted output of the GEMMInfo type.
1426 *
1427 * @param[in] info Type to output.
1428 *
1429 * @return Formatted string.
1430 */
1431inline std::string to_string(const GEMMInfo &info)
1432{
1433 std::stringstream str;
1434 str << info;
1435 return str.str();
1436}
1437
1438/** Formatted output of the Window::Dimension type.
1439 *
1440 * @param[in] dim Type to output.
1441 *
1442 * @return Formatted string.
1443 */
1444inline std::string to_string(const Window::Dimension &dim)
1445{
1446 std::stringstream str;
1447 str << dim;
1448 return str.str();
1449}
ramelg01cbbb0382021-09-17 17:36:57 +01001450/** Formatted output of the Window& type.
Anthony Barbierb940fd62018-06-04 14:14:32 +01001451 *
1452 * @param[in] win Type to output.
1453 *
1454 * @return Formatted string.
1455 */
1456inline std::string to_string(const Window &win)
1457{
1458 std::stringstream str;
1459 str << win;
1460 return str.str();
1461}
1462
ramelg01cbbb0382021-09-17 17:36:57 +01001463/** Formatted output of the Window* type.
1464 *
1465 * @param[in] win Type to output.
1466 *
1467 * @return Formatted string.
1468 */
1469inline std::string to_string(Window *win)
1470{
1471 std::string ret_str = "nullptr";
1472 if(win != nullptr)
1473 {
1474 std::stringstream str;
1475 str << *win;
1476 ret_str = str.str();
1477 }
1478 return ret_str;
1479}
1480
Alex Gildayc357c472018-03-21 13:54:09 +00001481/** Formatted output of the Rectangle type.
1482 *
1483 * @param[out] os Output stream.
1484 * @param[in] rect Type to output.
1485 *
1486 * @return Modified output stream.
1487 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001488inline ::std::ostream &operator<<(::std::ostream &os, const Rectangle &rect)
1489{
1490 os << rect.width << "x" << rect.height;
1491 os << "+" << rect.x << "+" << rect.y;
1492
1493 return os;
1494}
1495
Usama Arif8cf8c112019-03-14 15:36:54 +00001496/** Formatted output of the PaddingMode type.
1497 *
1498 * @param[out] os Output stream.
1499 * @param[in] mode Type to output.
1500 *
1501 * @return Modified output stream.
1502 */
1503inline ::std::ostream &operator<<(::std::ostream &os, const PaddingMode &mode)
1504{
1505 switch(mode)
1506 {
1507 case PaddingMode::CONSTANT:
1508 os << "CONSTANT";
1509 break;
1510 case PaddingMode::REFLECT:
1511 os << "REFLECT";
1512 break;
1513 case PaddingMode::SYMMETRIC:
1514 os << "SYMMETRIC";
1515 break;
1516 default:
1517 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1518 }
1519
1520 return os;
1521}
1522
1523/** Formatted output of the PaddingMode type.
1524 *
1525 * @param[in] mode Type to output.
1526 *
1527 * @return Formatted string.
1528 */
1529inline std::string to_string(const PaddingMode &mode)
1530{
1531 std::stringstream str;
1532 str << mode;
1533 return str.str();
1534}
1535
Alex Gildayc357c472018-03-21 13:54:09 +00001536/** Formatted output of the PadStrideInfo type.
1537 *
1538 * @param[out] os Output stream.
1539 * @param[in] pad_stride_info Type to output.
1540 *
1541 * @return Modified output stream.
1542 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001543inline ::std::ostream &operator<<(::std::ostream &os, const PadStrideInfo &pad_stride_info)
1544{
1545 os << pad_stride_info.stride().first << "," << pad_stride_info.stride().second;
1546 os << ";";
Jaroslaw Rzepeckia1ed41f2017-10-13 11:13:58 +01001547 os << pad_stride_info.pad_left() << "," << pad_stride_info.pad_right() << ","
1548 << pad_stride_info.pad_top() << "," << pad_stride_info.pad_bottom();
Anthony Barbier2a07e182017-08-04 18:20:27 +01001549
1550 return os;
1551}
1552
Alex Gildayc357c472018-03-21 13:54:09 +00001553/** Formatted output of the PadStrideInfo type.
1554 *
1555 * @param[in] pad_stride_info Type to output.
1556 *
1557 * @return Formatted string.
1558 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001559inline std::string to_string(const PadStrideInfo &pad_stride_info)
1560{
1561 std::stringstream str;
1562 str << pad_stride_info;
1563 return str.str();
1564}
1565
Alex Gildayc357c472018-03-21 13:54:09 +00001566/** Formatted output of the BorderMode type.
1567 *
1568 * @param[in] mode Type to output.
1569 *
1570 * @return Formatted string.
1571 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001572inline std::string to_string(const BorderMode &mode)
1573{
1574 std::stringstream str;
1575 str << mode;
1576 return str.str();
1577}
1578
Alex Gildayc357c472018-03-21 13:54:09 +00001579/** Formatted output of the BorderSize type.
1580 *
1581 * @param[in] border Type to output.
1582 *
1583 * @return Formatted string.
1584 */
John Richardsonb482ce12017-09-18 12:44:01 +01001585inline std::string to_string(const BorderSize &border)
1586{
1587 std::stringstream str;
1588 str << border;
1589 return str.str();
1590}
1591
Giuseppe Rossinid7647d42018-07-17 18:13:13 +01001592/** Formatted output of the PaddingList type.
1593 *
1594 * @param[in] padding Type to output.
1595 *
1596 * @return Formatted string.
1597 */
1598inline std::string to_string(const PaddingList &padding)
1599{
1600 std::stringstream str;
1601 str << padding;
1602 return str.str();
1603}
1604
giuros013175fcf2018-11-21 09:59:17 +00001605/** Formatted output of the Multiples type.
1606 *
1607 * @param[in] multiples Type to output.
1608 *
1609 * @return Formatted string.
1610 */
1611inline std::string to_string(const Multiples &multiples)
1612{
1613 std::stringstream str;
1614 str << multiples;
1615 return str.str();
1616}
1617
Alex Gildayc357c472018-03-21 13:54:09 +00001618/** Formatted output of the InterpolationPolicy type.
1619 *
1620 * @param[in] policy Type to output.
1621 *
1622 * @return Formatted string.
1623 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001624inline std::string to_string(const InterpolationPolicy &policy)
1625{
1626 std::stringstream str;
1627 str << policy;
1628 return str.str();
1629}
1630
Alex Gildayc357c472018-03-21 13:54:09 +00001631/** Formatted output of the SamplingPolicy type.
1632 *
1633 * @param[in] policy Type to output.
1634 *
1635 * @return Formatted string.
1636 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +07001637inline std::string to_string(const SamplingPolicy &policy)
1638{
1639 std::stringstream str;
1640 str << policy;
1641 return str.str();
1642}
1643
Alex Gildayc357c472018-03-21 13:54:09 +00001644/** Formatted output of the ConvertPolicy type.
1645 *
1646 * @param[out] os Output stream.
1647 * @param[in] policy Type to output.
1648 *
1649 * @return Modified output stream.
1650 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001651inline ::std::ostream &operator<<(::std::ostream &os, const ConvertPolicy &policy)
1652{
1653 switch(policy)
1654 {
1655 case ConvertPolicy::WRAP:
1656 os << "WRAP";
1657 break;
1658 case ConvertPolicy::SATURATE:
1659 os << "SATURATE";
1660 break;
1661 default:
1662 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1663 }
1664
1665 return os;
1666}
1667
1668inline std::string to_string(const ConvertPolicy &policy)
1669{
1670 std::stringstream str;
1671 str << policy;
1672 return str.str();
1673}
1674
giuros01164a2722018-11-20 18:34:46 +00001675/** Formatted output of the ArithmeticOperation type.
1676 *
1677 * @param[out] os Output stream.
1678 * @param[in] op Operation to output.
1679 *
1680 * @return Modified output stream.
1681 */
1682inline ::std::ostream &operator<<(::std::ostream &os, const ArithmeticOperation &op)
1683{
1684 switch(op)
1685 {
1686 case ArithmeticOperation::ADD:
1687 os << "ADD";
1688 break;
1689 case ArithmeticOperation::SUB:
1690 os << "SUB";
1691 break;
1692 case ArithmeticOperation::DIV:
1693 os << "DIV";
1694 break;
1695 case ArithmeticOperation::MAX:
1696 os << "MAX";
1697 break;
1698 case ArithmeticOperation::MIN:
1699 os << "MIN";
1700 break;
1701 case ArithmeticOperation::SQUARED_DIFF:
1702 os << "SQUARED_DIFF";
1703 break;
Usama Arif52c54f62019-05-14 10:22:36 +01001704 case ArithmeticOperation::POWER:
1705 os << "POWER";
1706 break;
giuros01164a2722018-11-20 18:34:46 +00001707 default:
1708 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1709 }
1710
1711 return os;
1712}
1713
1714/** Formatted output of the Arithmetic Operation
1715 *
1716 * @param[in] op Type to output.
1717 *
1718 * @return Formatted string.
1719 */
1720inline std::string to_string(const ArithmeticOperation &op)
1721{
1722 std::stringstream str;
1723 str << op;
1724 return str.str();
1725}
1726
Alex Gildayc357c472018-03-21 13:54:09 +00001727/** Formatted output of the Reduction Operations.
1728 *
1729 * @param[out] os Output stream.
1730 * @param[in] op Type to output.
1731 *
1732 * @return Modified output stream.
1733 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001734inline ::std::ostream &operator<<(::std::ostream &os, const ReductionOperation &op)
1735{
1736 switch(op)
1737 {
Michalis Spyrou7e9391b2018-10-05 14:49:28 +01001738 case ReductionOperation::SUM:
1739 os << "SUM";
1740 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +01001741 case ReductionOperation::SUM_SQUARE:
1742 os << "SUM_SQUARE";
1743 break;
Michalis Spyrou7e9391b2018-10-05 14:49:28 +01001744 case ReductionOperation::MEAN_SUM:
1745 os << "MEAN_SUM";
1746 break;
Michalis Spyrou7930db42018-11-22 17:36:28 +00001747 case ReductionOperation::ARG_IDX_MAX:
1748 os << "ARG_IDX_MAX";
1749 break;
1750 case ReductionOperation::ARG_IDX_MIN:
1751 os << "ARG_IDX_MIN";
1752 break;
Manuel Bottinib412fab2018-12-10 17:40:23 +00001753 case ReductionOperation::PROD:
1754 os << "PROD";
1755 break;
Usama Arifa4a08ad2019-05-20 12:38:33 +01001756 case ReductionOperation::MIN:
1757 os << "MIN";
1758 break;
Usama Arif28f0dd92019-05-20 13:44:34 +01001759 case ReductionOperation::MAX:
1760 os << "MAX";
1761 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +01001762 default:
1763 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1764 }
1765
1766 return os;
1767}
1768
Alex Gildayc357c472018-03-21 13:54:09 +00001769/** Formatted output of the Reduction Operations.
1770 *
1771 * @param[in] op Type to output.
1772 *
1773 * @return Formatted string.
1774 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001775inline std::string to_string(const ReductionOperation &op)
1776{
1777 std::stringstream str;
1778 str << op;
1779 return str.str();
1780}
1781
Georgios Pinitas7900a9e2018-11-23 11:44:58 +00001782/** Formatted output of the Comparison Operations.
1783 *
1784 * @param[out] os Output stream.
1785 * @param[in] op Type to output.
1786 *
1787 * @return Modified output stream.
1788 */
1789inline ::std::ostream &operator<<(::std::ostream &os, const ComparisonOperation &op)
1790{
1791 switch(op)
1792 {
1793 case ComparisonOperation::Equal:
1794 os << "Equal";
1795 break;
1796 case ComparisonOperation::NotEqual:
1797 os << "NotEqual";
1798 break;
1799 case ComparisonOperation::Greater:
1800 os << "Greater";
1801 break;
1802 case ComparisonOperation::GreaterEqual:
1803 os << "GreaterEqual";
1804 break;
1805 case ComparisonOperation::Less:
1806 os << "Less";
1807 break;
1808 case ComparisonOperation::LessEqual:
1809 os << "LessEqual";
1810 break;
1811 default:
1812 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1813 }
1814
1815 return os;
1816}
1817
Michalis Spyroue9362622018-11-23 17:41:37 +00001818/** Formatted output of the Elementwise unary Operations.
1819 *
1820 * @param[out] os Output stream.
1821 * @param[in] op Type to output.
1822 *
1823 * @return Modified output stream.
1824 */
1825inline ::std::ostream &operator<<(::std::ostream &os, const ElementWiseUnary &op)
1826{
1827 switch(op)
1828 {
1829 case ElementWiseUnary::RSQRT:
1830 os << "RSQRT";
1831 break;
1832 case ElementWiseUnary::EXP:
1833 os << "EXP";
1834 break;
Usama Arifeb312ef2019-05-13 17:45:54 +01001835 case ElementWiseUnary::NEG:
1836 os << "NEG";
1837 break;
Usama Arifac33d7e2019-05-20 14:21:40 +01001838 case ElementWiseUnary::LOG:
1839 os << "LOG";
1840 break;
ramelg01b1ba1e32021-09-25 11:53:26 +01001841 case ElementWiseUnary::SIN:
1842 os << "SIN";
1843 break;
1844 case ElementWiseUnary::ABS:
1845 os << "ABS";
1846 break;
Usama Arif6a4d5422019-05-24 14:53:59 +01001847 case ElementWiseUnary::ROUND:
1848 os << "ROUND";
1849 break;
ramelg01b1ba1e32021-09-25 11:53:26 +01001850 case ElementWiseUnary::LOGICAL_NOT:
1851 os << "LOGICAL_NOT";
1852 break;
Michalis Spyroue9362622018-11-23 17:41:37 +00001853 default:
1854 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1855 }
1856
1857 return os;
1858}
1859
Georgios Pinitas7900a9e2018-11-23 11:44:58 +00001860/** Formatted output of the Comparison Operations.
1861 *
1862 * @param[in] op Type to output.
1863 *
1864 * @return Formatted string.
1865 */
1866inline std::string to_string(const ComparisonOperation &op)
1867{
1868 std::stringstream str;
1869 str << op;
1870 return str.str();
1871}
1872
Michalis Spyroue9362622018-11-23 17:41:37 +00001873/** Formatted output of the Elementwise unary Operations.
1874 *
1875 * @param[in] op Type to output.
1876 *
1877 * @return Formatted string.
1878 */
1879inline std::string to_string(const ElementWiseUnary &op)
1880{
1881 std::stringstream str;
1882 str << op;
1883 return str.str();
1884}
1885
Alex Gildayc357c472018-03-21 13:54:09 +00001886/** Formatted output of the Norm Type.
1887 *
1888 * @param[in] type Type to output.
1889 *
1890 * @return Formatted string.
1891 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001892inline std::string to_string(const NormType &type)
1893{
1894 std::stringstream str;
1895 str << type;
1896 return str.str();
1897}
1898
Alex Gildayc357c472018-03-21 13:54:09 +00001899/** Formatted output of the Pooling Type.
1900 *
1901 * @param[in] type Type to output.
1902 *
1903 * @return Formatted string.
1904 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001905inline std::string to_string(const PoolingType &type)
1906{
1907 std::stringstream str;
1908 str << type;
1909 return str.str();
1910}
1911
Alex Gildayc357c472018-03-21 13:54:09 +00001912/** Formatted output of the Pooling Layer Info.
1913 *
1914 * @param[in] info Type to output.
1915 *
1916 * @return Formatted string.
1917 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001918inline std::string to_string(const PoolingLayerInfo &info)
1919{
1920 std::stringstream str;
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +00001921 str << "{Type=" << info.pool_type << ","
Sang-Hoon Park11fedda2020-01-15 14:44:04 +00001922 << "DataLayout=" << info.data_layout << ","
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +00001923 << "IsGlobalPooling=" << info.is_global_pooling;
1924 if(!info.is_global_pooling)
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001925 {
1926 str << ","
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +00001927 << "PoolSize=" << info.pool_size.width << "," << info.pool_size.height << ","
1928 << "PadStride=" << info.pad_stride_info;
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001929 }
1930 str << "}";
Anthony Barbier2a07e182017-08-04 18:20:27 +01001931 return str.str();
1932}
1933
Michalis Spyrou6c7c38e2018-08-29 16:28:11 +01001934/** Formatted output of the PriorBoxLayerInfo.
1935 *
1936 * @param[in] info Type to output.
1937 *
1938 * @return Formatted string.
1939 */
1940inline std::string to_string(const PriorBoxLayerInfo &info)
1941{
1942 std::stringstream str;
1943 str << "{";
1944 str << "Clip:" << info.clip()
1945 << "Flip:" << info.flip()
1946 << "StepX:" << info.steps()[0]
1947 << "StepY:" << info.steps()[1]
1948 << "MinSizes:" << info.min_sizes().size()
1949 << "MaxSizes:" << info.max_sizes().size()
1950 << "ImgSizeX:" << info.img_size().x
1951 << "ImgSizeY:" << info.img_size().y
1952 << "Offset:" << info.offset()
1953 << "Variances:" << info.variances().size();
1954 str << "}";
1955 return str.str();
1956}
1957
Alex Gildayc357c472018-03-21 13:54:09 +00001958/** Formatted output of the Size2D type.
1959 *
1960 * @param[out] os Output stream
1961 * @param[in] size Type to output
1962 *
1963 * @return Modified output stream.
1964 */
John Richardson25f23682017-11-27 14:35:09 +00001965inline ::std::ostream &operator<<(::std::ostream &os, const Size2D &size)
1966{
1967 os << size.width << "x" << size.height;
1968
1969 return os;
1970}
1971
Alex Gildayc357c472018-03-21 13:54:09 +00001972/** Formatted output of the Size2D type.
1973 *
1974 * @param[in] type Type to output
1975 *
1976 * @return Formatted string.
1977 */
John Richardson25f23682017-11-27 14:35:09 +00001978inline std::string to_string(const Size2D &type)
1979{
1980 std::stringstream str;
1981 str << type;
1982 return str.str();
1983}
1984
Alex Gildayc357c472018-03-21 13:54:09 +00001985/** Formatted output of the ConvolutionMethod type.
1986 *
1987 * @param[out] os Output stream
1988 * @param[in] conv_method Type to output
1989 *
1990 * @return Modified output stream.
1991 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001992inline ::std::ostream &operator<<(::std::ostream &os, const ConvolutionMethod &conv_method)
1993{
1994 switch(conv_method)
1995 {
1996 case ConvolutionMethod::GEMM:
1997 os << "GEMM";
1998 break;
1999 case ConvolutionMethod::DIRECT:
2000 os << "DIRECT";
2001 break;
2002 case ConvolutionMethod::WINOGRAD:
2003 os << "WINOGRAD";
2004 break;
2005 default:
2006 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2007 }
2008
2009 return os;
2010}
2011
Alex Gildayc357c472018-03-21 13:54:09 +00002012/** Formatted output of the ConvolutionMethod type.
2013 *
2014 * @param[in] conv_method Type to output
2015 *
2016 * @return Formatted string.
2017 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002018inline std::string to_string(const ConvolutionMethod &conv_method)
2019{
2020 std::stringstream str;
2021 str << conv_method;
2022 return str.str();
2023}
2024
Alex Gildayc357c472018-03-21 13:54:09 +00002025/** Formatted output of the GPUTarget type.
2026 *
2027 * @param[out] os Output stream
2028 * @param[in] gpu_target Type to output
2029 *
2030 * @return Modified output stream.
2031 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002032inline ::std::ostream &operator<<(::std::ostream &os, const GPUTarget &gpu_target)
2033{
2034 switch(gpu_target)
2035 {
2036 case GPUTarget::GPU_ARCH_MASK:
2037 os << "GPU_ARCH_MASK";
2038 break;
2039 case GPUTarget::MIDGARD:
2040 os << "MIDGARD";
2041 break;
2042 case GPUTarget::BIFROST:
2043 os << "BIFROST";
2044 break;
Georgios Pinitasd5462ff2019-07-03 19:33:57 +01002045 case GPUTarget::VALHALL:
2046 os << "VALHALL";
2047 break;
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002048 case GPUTarget::T600:
2049 os << "T600";
2050 break;
2051 case GPUTarget::T700:
2052 os << "T700";
2053 break;
2054 case GPUTarget::T800:
2055 os << "T800";
2056 break;
Michalis Spyroua9676112018-02-22 18:07:43 +00002057 case GPUTarget::G71:
2058 os << "G71";
2059 break;
2060 case GPUTarget::G72:
2061 os << "G72";
2062 break;
2063 case GPUTarget::G51:
2064 os << "G51";
2065 break;
2066 case GPUTarget::G51BIG:
2067 os << "G51BIG";
2068 break;
2069 case GPUTarget::G51LIT:
2070 os << "G51LIT";
2071 break;
Georgios Pinitasb03f7c52018-07-12 10:49:53 +01002072 case GPUTarget::G76:
2073 os << "G76";
Michalis Spyroua9676112018-02-22 18:07:43 +00002074 break;
Georgios Pinitasd5462ff2019-07-03 19:33:57 +01002075 case GPUTarget::G77:
2076 os << "G77";
Michalis Spyroua9676112018-02-22 18:07:43 +00002077 break;
Georgios Pinitas4ffc42a2020-12-01 16:28:24 +00002078 case GPUTarget::G78:
2079 os << "G78";
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002080 break;
Pablo Marquez Tellob1496e62021-06-25 14:49:37 +01002081 case GPUTarget::G31:
2082 os << "G31";
2083 break;
Georgios Pinitasd5462ff2019-07-03 19:33:57 +01002084 case GPUTarget::TODX:
2085 os << "TODX";
2086 break;
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002087 default:
2088 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2089 }
2090
2091 return os;
2092}
2093
Alex Gildayc357c472018-03-21 13:54:09 +00002094/** Formatted output of the GPUTarget type.
2095 *
2096 * @param[in] gpu_target Type to output
2097 *
2098 * @return Formatted string.
2099 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002100inline std::string to_string(const GPUTarget &gpu_target)
2101{
2102 std::stringstream str;
2103 str << gpu_target;
2104 return str.str();
2105}
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00002106
John Richardson8de92612018-02-22 14:09:31 +00002107/** Formatted output of the DetectionWindow type.
2108 *
2109 * @param[out] os Output stream
2110 * @param[in] detection_window Type to output
2111 *
2112 * @return Modified output stream.
2113 */
John Richardson684cb0f2018-01-09 11:17:00 +00002114inline ::std::ostream &operator<<(::std::ostream &os, const DetectionWindow &detection_window)
2115{
2116 os << "{x=" << detection_window.x << ","
2117 << "y=" << detection_window.y << ","
2118 << "width=" << detection_window.width << ","
2119 << "height=" << detection_window.height << ","
2120 << "idx_class=" << detection_window.idx_class << ","
2121 << "score=" << detection_window.score << "}";
2122
2123 return os;
2124}
2125
Isabella Gottardi05e56442018-11-16 11:26:52 +00002126/** Formatted output of the DetectionOutputLayerCodeType type.
2127 *
2128 * @param[out] os Output stream
2129 * @param[in] detection_code Type to output
2130 *
2131 * @return Modified output stream.
2132 */
2133inline ::std::ostream &operator<<(::std::ostream &os, const DetectionOutputLayerCodeType &detection_code)
2134{
2135 switch(detection_code)
2136 {
2137 case DetectionOutputLayerCodeType::CENTER_SIZE:
2138 os << "CENTER_SIZE";
2139 break;
2140 case DetectionOutputLayerCodeType::CORNER:
2141 os << "CORNER";
2142 break;
2143 case DetectionOutputLayerCodeType::CORNER_SIZE:
2144 os << "CORNER_SIZE";
2145 break;
2146 case DetectionOutputLayerCodeType::TF_CENTER:
2147 os << "TF_CENTER";
2148 break;
2149 default:
2150 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2151 }
2152
2153 return os;
2154}
2155/** Formatted output of the DetectionOutputLayerCodeType type.
2156 *
2157 * @param[in] detection_code Type to output
2158 *
2159 * @return Formatted string.
2160 */
2161inline std::string to_string(const DetectionOutputLayerCodeType &detection_code)
2162{
2163 std::stringstream str;
2164 str << detection_code;
2165 return str.str();
2166}
2167
2168/** Formatted output of the DetectionOutputLayerInfo type.
2169 *
2170 * @param[out] os Output stream
2171 * @param[in] detection_info Type to output
2172 *
2173 * @return Modified output stream.
2174 */
2175inline ::std::ostream &operator<<(::std::ostream &os, const DetectionOutputLayerInfo &detection_info)
2176{
2177 os << "{Classes=" << detection_info.num_classes() << ","
2178 << "ShareLocation=" << detection_info.share_location() << ","
2179 << "CodeType=" << detection_info.code_type() << ","
2180 << "VarianceEncodedInTarget=" << detection_info.variance_encoded_in_target() << ","
2181 << "KeepTopK=" << detection_info.keep_top_k() << ","
2182 << "NMSThreshold=" << detection_info.nms_threshold() << ","
2183 << "Eta=" << detection_info.eta() << ","
2184 << "BackgroundLabelId=" << detection_info.background_label_id() << ","
2185 << "ConfidenceThreshold=" << detection_info.confidence_threshold() << ","
2186 << "TopK=" << detection_info.top_k() << ","
2187 << "NumLocClasses=" << detection_info.num_loc_classes()
2188 << "}";
2189
2190 return os;
2191}
2192
2193/** Formatted output of the DetectionOutputLayerInfo type.
2194 *
2195 * @param[in] detection_info Type to output
2196 *
2197 * @return Formatted string.
2198 */
2199inline std::string to_string(const DetectionOutputLayerInfo &detection_info)
2200{
2201 std::stringstream str;
2202 str << detection_info;
2203 return str.str();
2204}
Isabella Gottardia7acb3c2019-01-08 13:48:44 +00002205/** Formatted output of the DetectionPostProcessLayerInfo type.
2206 *
2207 * @param[out] os Output stream
2208 * @param[in] detection_info Type to output
2209 *
2210 * @return Modified output stream.
2211 */
2212inline ::std::ostream &operator<<(::std::ostream &os, const DetectionPostProcessLayerInfo &detection_info)
2213{
2214 os << "{MaxDetections=" << detection_info.max_detections() << ","
2215 << "MaxClassesPerDetection=" << detection_info.max_classes_per_detection() << ","
2216 << "NmsScoreThreshold=" << detection_info.nms_score_threshold() << ","
2217 << "NmsIouThreshold=" << detection_info.iou_threshold() << ","
2218 << "NumClasses=" << detection_info.num_classes() << ","
2219 << "ScaleValue_y=" << detection_info.scale_value_y() << ","
2220 << "ScaleValue_x=" << detection_info.scale_value_x() << ","
2221 << "ScaleValue_h=" << detection_info.scale_value_h() << ","
2222 << "ScaleValue_w=" << detection_info.scale_value_w() << ","
2223 << "UseRegularNms=" << detection_info.use_regular_nms() << ","
2224 << "DetectionPerClass=" << detection_info.detection_per_class()
2225 << "}";
2226
2227 return os;
2228}
2229
2230/** Formatted output of the DetectionPostProcessLayerInfo type.
2231 *
2232 * @param[in] detection_info Type to output
2233 *
2234 * @return Formatted string.
2235 */
2236inline std::string to_string(const DetectionPostProcessLayerInfo &detection_info)
2237{
2238 std::stringstream str;
2239 str << detection_info;
2240 return str.str();
2241}
Georgios Pinitasc6f95102021-03-30 10:03:01 +01002242
John Richardson8de92612018-02-22 14:09:31 +00002243/** Formatted output of the DetectionWindow type.
2244 *
2245 * @param[in] detection_window Type to output
2246 *
2247 * @return Formatted string.
2248 */
2249inline std::string to_string(const DetectionWindow &detection_window)
2250{
2251 std::stringstream str;
2252 str << detection_window;
2253 return str.str();
2254}
2255
Michalis Spyrou6c7c38e2018-08-29 16:28:11 +01002256/** Formatted output of @ref PriorBoxLayerInfo.
2257 *
2258 * @param[out] os Output stream.
2259 * @param[in] info Type to output.
2260 *
2261 * @return Modified output stream.
2262 */
2263inline ::std::ostream &operator<<(::std::ostream &os, const PriorBoxLayerInfo &info)
2264{
2265 os << "Clip:" << info.clip()
2266 << "Flip:" << info.flip()
2267 << "StepX:" << info.steps()[0]
2268 << "StepY:" << info.steps()[1]
2269 << "MinSizes:" << info.min_sizes()
2270 << "MaxSizes:" << info.max_sizes()
2271 << "ImgSizeX:" << info.img_size().x
2272 << "ImgSizeY:" << info.img_size().y
2273 << "Offset:" << info.offset()
2274 << "Variances:" << info.variances();
2275
2276 return os;
2277}
2278
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00002279/** Formatted output of the WinogradInfo type. */
2280inline ::std::ostream &operator<<(::std::ostream &os, const WinogradInfo &info)
2281{
2282 os << "{OutputTileSize=" << info.output_tile_size << ","
2283 << "KernelSize=" << info.kernel_size << ","
2284 << "PadStride=" << info.convolution_info << ","
2285 << "OutputDataLayout=" << info.output_data_layout << "}";
2286
2287 return os;
2288}
2289
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00002290inline std::string to_string(const WinogradInfo &type)
2291{
2292 std::stringstream str;
2293 str << type;
2294 return str.str();
2295}
Anthony Barbier671a11e2018-07-06 15:11:36 +01002296
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +01002297/** Convert a CLTunerMode value to a string
2298 *
2299 * @param val CLTunerMode value to be converted
2300 *
2301 * @return String representing the corresponding CLTunerMode.
2302 */
2303inline std::string to_string(const CLTunerMode val)
2304{
2305 switch(val)
2306 {
2307 case CLTunerMode::EXHAUSTIVE:
2308 {
2309 return std::string("Exhaustive");
2310 }
2311 case CLTunerMode::NORMAL:
2312 {
2313 return std::string("Normal");
2314 }
2315 case CLTunerMode::RAPID:
2316 {
2317 return std::string("Rapid");
2318 }
2319 default:
2320 {
2321 ARM_COMPUTE_ERROR("Invalid tuner mode.");
2322 return std::string("UNDEFINED");
2323 }
2324 }
2325}
SiCong Lidb4a6c12021-02-05 09:30:57 +00002326/** Converts a @ref CLGEMMKernelType to string
2327 *
2328 * @param[in] val CLGEMMKernelType value to be converted
2329 *
2330 * @return String representing the corresponding CLGEMMKernelType
2331 */
2332inline std::string to_string(CLGEMMKernelType val)
2333{
2334 switch(val)
2335 {
2336 case CLGEMMKernelType::NATIVE_V1:
2337 {
2338 return "Native_V1";
2339 }
2340 case CLGEMMKernelType::RESHAPED_V1:
2341 {
2342 return "Reshaped_V1";
2343 }
2344 case CLGEMMKernelType::NATIVE:
2345 {
2346 return "Native";
2347 }
2348 case CLGEMMKernelType::RESHAPED_ONLY_RHS:
2349 {
2350 return "Reshaped_Only_RHS";
2351 }
2352 case CLGEMMKernelType::RESHAPED:
2353 {
2354 return "Reshaped";
2355 }
2356 default:
2357 {
2358 return "Unknown";
2359 }
2360 }
2361}
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +01002362/** [Print CLTunerMode type] **/
2363/** Formatted output of the CLTunerMode type.
2364 *
2365 * @param[out] os Output stream.
2366 * @param[in] val CLTunerMode to output.
2367 *
2368 * @return Modified output stream.
2369 */
2370inline ::std::ostream &operator<<(::std::ostream &os, const CLTunerMode &val)
2371{
2372 os << to_string(val);
2373 return os;
2374}
2375
ramelg013ae3d882021-09-12 23:07:47 +01002376/** Formatted output of the ConvolutionInfo type.
2377 *
2378 * @param[out] os Output stream.
2379 * @param[in] conv_info ConvolutionInfo to output.
2380 *
2381 * @return Modified output stream.
2382 */
2383inline ::std::ostream &operator<<(::std::ostream &os, const ConvolutionInfo &conv_info)
2384{
ramelg01cbbb0382021-09-17 17:36:57 +01002385 os << "{PadStrideInfo = " << conv_info.pad_stride_info << ", "
ramelg013ae3d882021-09-12 23:07:47 +01002386 << "depth_multiplier = " << conv_info.depth_multiplier << ", "
2387 << "act_info = " << to_string(conv_info.act_info) << ", "
ramelg01cbbb0382021-09-17 17:36:57 +01002388 << "dilation = " << conv_info.dilation << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002389 return os;
2390}
2391
2392/** Converts a @ref ConvolutionInfo to string
2393 *
2394 * @param[in] info ConvolutionInfo value to be converted
2395 *
2396 * @return String representing the corresponding ConvolutionInfo
2397 */
2398inline std::string to_string(const ConvolutionInfo &info)
2399{
2400 std::stringstream str;
2401 str << info;
2402 return str.str();
2403}
2404
2405/** Formatted output of the FullyConnectedLayerInfo type.
2406 *
2407 * @param[out] os Output stream.
2408 * @param[in] layer_info FullyConnectedLayerInfo to output.
2409 *
2410 * @return Modified output stream.
2411 */
2412inline ::std::ostream &operator<<(::std::ostream &os, const FullyConnectedLayerInfo &layer_info)
2413{
ramelg01cbbb0382021-09-17 17:36:57 +01002414 os << "{activation_info = " << to_string(layer_info.activation_info) << ", "
ramelg013ae3d882021-09-12 23:07:47 +01002415 << "weights_trained_layout = " << layer_info.weights_trained_layout << ", "
2416 << "transpose_weights = " << layer_info.transpose_weights << ", "
2417 << "are_weights_reshaped = " << layer_info.are_weights_reshaped << ", "
2418 << "retain_internal_weights = " << layer_info.retain_internal_weights << ", "
2419 << "constant_weights = " << layer_info.transpose_weights << ", "
ramelg01cbbb0382021-09-17 17:36:57 +01002420 << "fp_mixed_precision = " << layer_info.fp_mixed_precision << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002421 return os;
2422}
2423
2424/** Converts a @ref FullyConnectedLayerInfo to string
2425 *
2426 * @param[in] info FullyConnectedLayerInfo value to be converted
2427 *
2428 * @return String representing the corresponding FullyConnectedLayerInfo
2429 */
2430inline std::string to_string(const FullyConnectedLayerInfo &info)
2431{
2432 std::stringstream str;
2433 str << info;
2434 return str.str();
2435}
2436
2437/** Formatted output of the GEMMLowpOutputStageType type.
2438 *
2439 * @param[out] os Output stream.
2440 * @param[in] gemm_type GEMMLowpOutputStageType to output.
2441 *
2442 * @return Modified output stream.
2443 */
2444inline ::std::ostream &operator<<(::std::ostream &os, const GEMMLowpOutputStageType &gemm_type)
2445{
2446 switch(gemm_type)
2447 {
2448 case GEMMLowpOutputStageType::NONE:
2449 os << "NONE";
2450 break;
2451 case GEMMLowpOutputStageType::QUANTIZE_DOWN:
2452 os << "QUANTIZE_DOWN";
2453 break;
2454 case GEMMLowpOutputStageType::QUANTIZE_DOWN_FIXEDPOINT:
2455 os << "QUANTIZE_DOWN_FIXEDPOINT";
2456 break;
2457 case GEMMLowpOutputStageType::QUANTIZE_DOWN_FLOAT:
2458 os << "QUANTIZE_DOWN_FLOAT";
2459 break;
2460 default:
2461 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2462 }
2463 return os;
2464}
2465
2466/** Converts a @ref GEMMLowpOutputStageType to string
2467 *
2468 * @param[in] gemm_type GEMMLowpOutputStageType value to be converted
2469 *
2470 * @return String representing the corresponding GEMMLowpOutputStageType
2471 */
2472inline std::string to_string(const GEMMLowpOutputStageType &gemm_type)
2473{
2474 std::stringstream str;
2475 str << gemm_type;
2476 return str.str();
2477}
2478
2479/** Formatted output of the GEMMLowpOutputStageInfo type.
2480 *
2481 * @param[out] os Output stream.
2482 * @param[in] gemm_info GEMMLowpOutputStageInfo to output.
2483 *
2484 * @return Modified output stream.
2485 */
2486inline ::std::ostream &operator<<(::std::ostream &os, const GEMMLowpOutputStageInfo &gemm_info)
2487{
ramelg01cbbb0382021-09-17 17:36:57 +01002488 os << "{type = " << gemm_info.type << ", "
ramelg013ae3d882021-09-12 23:07:47 +01002489 << "gemlowp_offset = " << gemm_info.gemmlowp_offset << ", "
2490 << "gemmlowp_multiplier" << gemm_info.gemmlowp_multiplier << ", "
2491 << "gemmlowp_shift = " << gemm_info.gemmlowp_shift << ", "
2492 << "gemmlowp_min_bound = " << gemm_info.gemmlowp_min_bound << ", "
2493 << "gemmlowp_max_bound = " << gemm_info.gemmlowp_max_bound << ", "
2494 << "gemmlowp_multipliers = " << gemm_info.gemmlowp_multiplier << ", "
2495 << "gemmlowp_shifts = " << gemm_info.gemmlowp_shift << ", "
2496 << "gemmlowp_real_multiplier = " << gemm_info.gemmlowp_real_multiplier << ", "
2497 << "is_quantized_per_channel = " << gemm_info.is_quantized_per_channel << ", "
ramelg01cbbb0382021-09-17 17:36:57 +01002498 << "output_data_type = " << gemm_info.output_data_type << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002499 return os;
2500}
2501
2502/** Converts a @ref GEMMLowpOutputStageInfo to string
2503 *
2504 * @param[in] gemm_info GEMMLowpOutputStageInfo value to be converted
2505 *
2506 * @return String representing the corresponding GEMMLowpOutputStageInfo
2507 */
2508inline std::string to_string(const GEMMLowpOutputStageInfo &gemm_info)
2509{
2510 std::stringstream str;
2511 str << gemm_info;
2512 return str.str();
2513}
2514
2515/** Formatted output of the Conv2dInfo type.
2516 *
2517 * @param[out] os Output stream.
2518 * @param[in] conv_info Conv2dInfo to output.
2519 *
2520 * @return Modified output stream.
2521 */
2522inline ::std::ostream &operator<<(::std::ostream &os, const Conv2dInfo &conv_info)
2523{
ramelg01cbbb0382021-09-17 17:36:57 +01002524 os << "{conv_info = " << conv_info.conv_info << ", "
ramelg013ae3d882021-09-12 23:07:47 +01002525 << "dilation = " << conv_info.dilation << ", "
2526 << "act_info = " << to_string(conv_info.act_info) << ", "
2527 << "enable_fast_math = " << conv_info.enable_fast_math << ", "
ramelg01cbbb0382021-09-17 17:36:57 +01002528 << "num_groups = " << conv_info.num_groups << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002529 return os;
2530}
2531
2532/** Converts a @ref Conv2dInfo to string
2533 *
2534 * @param[in] conv_info Conv2dInfo value to be converted
2535 *
2536 * @return String representing the corresponding Conv2dInfo
2537 */
2538inline std::string to_string(const Conv2dInfo &conv_info)
2539{
2540 std::stringstream str;
2541 str << conv_info;
2542 return str.str();
2543}
2544
2545/** Formatted output of the PixelValue type.
2546 *
2547 * @param[out] os Output stream.
2548 * @param[in] pixel_value PixelValue to output.
2549 *
2550 * @return Modified output stream.
2551 */
2552inline ::std::ostream &operator<<(::std::ostream &os, const PixelValue &pixel_value)
2553{
ramelg01cbbb0382021-09-17 17:36:57 +01002554 os << "{value.u64= " << pixel_value.get<uint64_t>() << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002555 return os;
2556}
2557
2558/** Converts a @ref PixelValue to string
2559 *
2560 * @param[in] pixel_value PixelValue value to be converted
2561 *
2562 * @return String representing the corresponding PixelValue
2563 */
2564inline std::string to_string(const PixelValue &pixel_value)
2565{
2566 std::stringstream str;
2567 str << pixel_value;
2568 return str.str();
2569}
2570
2571/** Formatted output of the ScaleKernelInfo type.
2572 *
2573 * @param[out] os Output stream.
2574 * @param[in] scale_info ScaleKernelInfo to output.
2575 *
2576 * @return Modified output stream.
2577 */
2578inline ::std::ostream &operator<<(::std::ostream &os, const ScaleKernelInfo &scale_info)
2579{
ramelg01cbbb0382021-09-17 17:36:57 +01002580 os << "{interpolation_policy = " << scale_info.interpolation_policy << ", "
ramelg013ae3d882021-09-12 23:07:47 +01002581 << "BorderMode = " << scale_info.border_mode << ", "
2582 << "PixelValue = " << scale_info.constant_border_value << ", "
2583 << "SamplingPolicy = " << scale_info.sampling_policy << ", "
2584 << "use_padding = " << scale_info.use_padding << ", "
2585 << "align_corners = " << scale_info.align_corners << ", "
ramelg01cbbb0382021-09-17 17:36:57 +01002586 << "data_layout = " << scale_info.data_layout << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002587 return os;
2588}
2589
2590/** Converts a @ref ScaleKernelInfo to string
2591 *
2592 * @param[in] scale_info ScaleKernelInfo value to be converted
2593 *
2594 * @return String representing the corresponding ScaleKernelInfo
2595 */
2596inline std::string to_string(const ScaleKernelInfo &scale_info)
2597{
2598 std::stringstream str;
2599 str << scale_info;
2600 return str.str();
2601}
2602
2603/** Formatted output of the FFTDirection type.
2604 *
2605 * @param[out] os Output stream.
2606 * @param[in] fft_dir FFTDirection to output.
2607 *
2608 * @return Modified output stream.
2609 */
2610inline ::std::ostream &operator<<(::std::ostream &os, const FFTDirection &fft_dir)
2611{
2612 switch(fft_dir)
2613 {
2614 case FFTDirection::Forward:
2615 os << "Forward";
2616 break;
2617 case FFTDirection::Inverse:
2618 os << "Inverse";
2619 break;
2620 default:
2621 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2622 }
2623 return os;
2624}
2625
2626/** Converts a @ref FFT1DInfo to string
2627 *
2628 * @param[in] fft_dir FFT1DInfo value to be converted
2629 *
2630 * @return String representing the corresponding FFT1DInfo
2631 */
2632inline std::string to_string(const FFTDirection &fft_dir)
2633{
2634 std::stringstream str;
ramelg01cbbb0382021-09-17 17:36:57 +01002635 str << "{" << fft_dir << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002636 return str.str();
2637}
2638
2639/** Formatted output of the FFT1DInfo type.
2640 *
2641 * @param[out] os Output stream.
2642 * @param[in] fft1d_info FFT1DInfo to output.
2643 *
2644 * @return Modified output stream.
2645 */
2646inline ::std::ostream &operator<<(::std::ostream &os, const FFT1DInfo &fft1d_info)
2647{
ramelg01cbbb0382021-09-17 17:36:57 +01002648 os << "{axis = " << fft1d_info.axis << ", "
2649 << "direction = " << fft1d_info.direction << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002650 return os;
2651}
2652
2653/** Converts a @ref FFT1DInfo to string
2654 *
2655 * @param[in] fft1d_info FFT1DInfo value to be converted
2656 *
2657 * @return String representing the corresponding FFT1DInfo
2658 */
2659inline std::string to_string(const FFT1DInfo &fft1d_info)
2660{
2661 std::stringstream str;
2662 str << fft1d_info;
2663 return str.str();
2664}
2665
2666/** Formatted output of the FFT2DInfo type.
2667 *
2668 * @param[out] os Output stream.
2669 * @param[in] fft2d_info FFT2DInfo to output.
2670 *
2671 * @return Modified output stream.
2672 */
2673inline ::std::ostream &operator<<(::std::ostream &os, const FFT2DInfo &fft2d_info)
2674{
ramelg01cbbb0382021-09-17 17:36:57 +01002675 os << "{axis = " << fft2d_info.axis0 << ", "
ramelg013ae3d882021-09-12 23:07:47 +01002676 << "axis = " << fft2d_info.axis1 << ", "
ramelg01cbbb0382021-09-17 17:36:57 +01002677 << "direction = " << fft2d_info.direction << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002678 return os;
2679}
2680
2681/** Converts a @ref FFT2DInfo to string
2682 *
2683 * @param[in] fft2d_info FFT2DInfo value to be converted
2684 *
2685 * @return String representing the corresponding FFT2DInfo
2686 */
2687inline std::string to_string(const FFT2DInfo &fft2d_info)
2688{
2689 std::stringstream str;
2690 str << fft2d_info;
2691 return str.str();
2692}
2693
2694/** Formatted output of the Coordinates2D type.
2695 *
2696 * @param[out] os Output stream.
2697 * @param[in] coord_2d Coordinates2D to output.
2698 *
2699 * @return Modified output stream.
2700 */
2701inline ::std::ostream &operator<<(::std::ostream &os, const Coordinates2D &coord_2d)
2702{
ramelg01cbbb0382021-09-17 17:36:57 +01002703 os << "{x = " << coord_2d.x << ", "
2704 << "y = " << coord_2d.y << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002705 return os;
2706}
2707
2708/** Converts a @ref Coordinates2D to string
2709 *
2710 * @param[in] coord_2d Coordinates2D value to be converted
2711 *
2712 * @return String representing the corresponding Coordinates2D
2713 */
2714inline std::string to_string(const Coordinates2D &coord_2d)
2715{
2716 std::stringstream str;
2717 str << coord_2d;
2718 return str.str();
2719}
2720
2721/** Formatted output of the FuseBatchNormalizationType type.
2722 *
2723 * @param[out] os Output stream.
2724 * @param[in] fuse_type FuseBatchNormalizationType to output.
2725 *
2726 * @return Modified output stream.
2727 */
2728inline ::std::ostream &operator<<(::std::ostream &os, const FuseBatchNormalizationType &fuse_type)
2729{
2730 switch(fuse_type)
2731 {
2732 case FuseBatchNormalizationType::CONVOLUTION:
2733 os << "CONVOLUTION";
2734 break;
2735 case FuseBatchNormalizationType::DEPTHWISECONVOLUTION:
2736 os << "DEPTHWISECONVOLUTION";
2737 break;
2738 default:
2739 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2740 }
2741 return os;
2742}
2743
2744/** Converts a @ref FuseBatchNormalizationType to string
2745 *
2746 * @param[in] fuse_type FuseBatchNormalizationType value to be converted
2747 *
2748 * @return String representing the corresponding FuseBatchNormalizationType
2749 */
2750inline std::string to_string(const FuseBatchNormalizationType &fuse_type)
2751{
2752 std::stringstream str;
2753 str << fuse_type;
2754 return str.str();
2755}
2756
ramelg01cbbb0382021-09-17 17:36:57 +01002757/** Formatted output of the SoftmaxKernelInfo type.
2758 *
2759 * @param[out] os Output stream.
2760 * @param[in] info SoftmaxKernelInfo to output.
2761 *
2762 * @return Modified output stream.
2763 */
2764inline ::std::ostream &operator<<(::std::ostream &os, const SoftmaxKernelInfo &info)
2765{
2766 os << "{beta = " << info.beta << ", "
2767 << "is_log = " << info.is_log << ", "
2768 << "input_data_type = " << info.input_data_type << ", "
2769 << "axis = " << info.axis << "}";
2770 return os;
2771}
2772
2773/** Converts a @ref SoftmaxKernelInfo to string
2774 *
2775 * @param[in] info SoftmaxKernelInfo value to be converted
2776 *
2777 * @return String representing the corresponding SoftmaxKernelInfo
2778 */
2779inline std::string to_string(const SoftmaxKernelInfo &info)
2780{
2781 std::stringstream str;
2782 str << info;
2783 return str.str();
2784}
2785
2786/** Formatted output of the ScaleKernelInfo type.
2787 *
2788 * @param[out] os Output stream.
2789 * @param[in] lstm_params LSTMParams to output.
2790 *
2791 * @return Modified output stream.
2792 */
2793template <typename T>
ramelg014a6d9e82021-10-02 14:34:36 +01002794::std::ostream &operator<<(::std::ostream &os, const LSTMParams<T> &lstm_params)
ramelg01cbbb0382021-09-17 17:36:57 +01002795{
ramelg014a6d9e82021-10-02 14:34:36 +01002796 os << "{input_to_input_weights=" << to_string(lstm_params.input_to_input_weights()) << ", "
2797 << "recurrent_to_input_weights=" << to_string(lstm_params.recurrent_to_input_weights()) << ", "
2798 << "cell_to_input_weights=" << to_string(lstm_params.cell_to_input_weights()) << ", "
2799 << "input_gate_bias=" << to_string(lstm_params.input_gate_bias()) << ", "
2800 << "cell_to_forget_weights=" << to_string(lstm_params.cell_to_forget_weights()) << ", "
2801 << "cell_to_output_weights=" << to_string(lstm_params.cell_to_output_weights()) << ", "
2802 << "projection_weights=" << to_string(lstm_params.projection_weights()) << ", "
2803 << "projection_bias=" << to_string(lstm_params.projection_bias()) << ", "
2804 << "input_layer_norm_weights=" << to_string(lstm_params.input_layer_norm_weights()) << ", "
2805 << "forget_layer_norm_weights=" << to_string(lstm_params.forget_layer_norm_weights()) << ", "
2806 << "cell_layer_norm_weights=" << to_string(lstm_params.cell_layer_norm_weights()) << ", "
2807 << "output_layer_norm_weights=" << to_string(lstm_params.output_layer_norm_weights()) << ", "
ramelg01cbbb0382021-09-17 17:36:57 +01002808 << "cell_clip=" << lstm_params.cell_clip() << ", "
2809 << "projection_clip=" << lstm_params.projection_clip() << ", "
2810 << "input_intermediate_scale=" << lstm_params.input_intermediate_scale() << ", "
2811 << "forget_intermediate_scale=" << lstm_params.forget_intermediate_scale() << ", "
2812 << "cell_intermediate_scale=" << lstm_params.cell_intermediate_scale() << ", "
2813 << "hidden_state_zero=" << lstm_params.hidden_state_zero() << ", "
2814 << "hidden_state_scale=" << lstm_params.hidden_state_scale() << ", "
2815 << "has_peephole_opt=" << lstm_params.has_peephole_opt() << ", "
2816 << "has_projection=" << lstm_params.has_projection() << ", "
2817 << "has_cifg_opt=" << lstm_params.has_cifg_opt() << ", "
2818 << "use_layer_norm=" << lstm_params.use_layer_norm() << "}";
2819 return os;
2820}
2821
2822/** Converts a @ref LSTMParams to string
2823 *
2824 * @param[in] lstm_params LSTMParams<T> value to be converted
2825 *
2826 * @return String representing the corresponding LSTMParams
2827 */
2828template <typename T>
ramelg014a6d9e82021-10-02 14:34:36 +01002829std::string to_string(const LSTMParams<T> &lstm_params)
ramelg01cbbb0382021-09-17 17:36:57 +01002830{
2831 std::stringstream str;
2832 str << lstm_params;
2833 return str.str();
2834}
2835
2836/** Converts a @ref LSTMParams to string
2837 *
2838 * @param[in] num uint8_t value to be converted
2839 *
2840 * @return String representing the corresponding uint8_t
2841 */
2842inline std::string to_string(const uint8_t num)
2843{
2844 // Explicity cast the uint8_t to signed integer and call the corresponding overloaded to_string() function.
2845 return ::std::to_string(static_cast<int>(num));
2846}
2847
ramelg014a6d9e82021-10-02 14:34:36 +01002848/** Available non maxima suppression types */
2849/** Formatted output of the NMSType type.
2850 *
2851 * @param[out] os Output stream.
2852 * @param[in] nms_type NMSType to output.
2853 *
2854 * @return Modified output stream.
2855 */
2856inline ::std::ostream &operator<<(::std::ostream &os, const NMSType &nms_type)
2857{
2858 switch(nms_type)
2859 {
2860 case NMSType::LINEAR:
2861 os << "LINEAR";
2862 break;
2863 case NMSType::GAUSSIAN:
2864 os << "GAUSSIAN";
2865 break;
2866 case NMSType::ORIGINAL:
2867 os << "ORIGINAL";
2868 break;
2869 default:
2870 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2871 }
2872 return os;
2873}
2874
2875/** Converts a @ref NMSType to string
2876 *
2877 * @param[in] nms_type NMSType value to be converted
2878 *
2879 * @return String representing the corresponding NMSType
2880 */
2881inline std::string to_string(const NMSType nms_type)
2882{
2883 std::stringstream str;
2884 str << nms_type;
2885 return str.str();
2886}
2887
2888/** Formatted output of the BoxNMSLimitInfo type.
2889 *
2890 * @param[out] os Output stream.
2891 * @param[in] info BoxNMSLimitInfo to output.
2892 *
2893 * @return Modified output stream.
2894 */
2895inline ::std::ostream &operator<<(::std::ostream &os, const BoxNMSLimitInfo &info)
2896{
2897 os << "{score_thresh = " << info.score_thresh() << ", "
2898 << "nms = " << info.nms() << ", "
2899 << "detections_per_im = " << info.detections_per_im() << ", "
2900 << "soft_nms_enabled = " << info.soft_nms_enabled() << ", "
2901 << "soft_nms_min_score_thres = " << info.soft_nms_min_score_thres() << ", "
2902 << "suppress_size = " << info.suppress_size() << ", "
2903 << "min_size = " << info.min_size() << ", "
2904 << "im_width = " << info.im_width() << ", "
2905 << "im_height = " << info.im_height() << "}";
2906 return os;
2907}
2908
2909/** Converts a @ref BoxNMSLimitInfo to string
2910 *
2911 * @param[in] info BoxNMSLimitInfo value to be converted
2912 *
2913 * @return String representing the corresponding BoxNMSLimitInfo
2914 */
2915inline std::string to_string(const BoxNMSLimitInfo &info)
2916{
2917 std::stringstream str;
2918 str << info;
2919 return str.str();
2920}
2921
Anthony Barbier6ff3b192017-09-04 18:44:23 +01002922} // namespace arm_compute
Anthony Barbier4dbc0a92018-08-27 13:39:47 +01002923
2924#endif /* __ARM_COMPUTE_TYPE_PRINTER_H__ */