blob: 21f9c0849c6174d04a7b41aa1749c0d6ee94d795 [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001/*
Gian Marco Iodiceab2bc732022-01-19 10:06:45 +00002 * Copyright (c) 2017-2022 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"
SiCongLi1af54162021-10-06 15:25:57 +010039#include "arm_compute/core/experimental/IPostOp.h"
SiCongLi31778612021-11-12 17:33:45 +000040#include "arm_compute/core/experimental/PostOps.h"
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +010041#include "arm_compute/runtime/CL/CLTunerTypes.h"
SiCong Lidb4a6c12021-02-05 09:30:57 +000042#include "arm_compute/runtime/CL/CLTypes.h"
ramelg013ae3d882021-09-12 23:07:47 +010043#include "arm_compute/runtime/FunctionDescriptors.h"
ramelg01cbbb0382021-09-17 17:36:57 +010044#include "arm_compute/runtime/common/LSTMParams.h"
SiCongLi31778612021-11-12 17:33:45 +000045#include "support/Cast.h"
Matthew Bentham758b5ba2020-03-05 23:37:48 +000046#include "support/StringSupport.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010047#include <ostream>
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010048#include <sstream>
49#include <string>
Anthony Barbier6ff3b192017-09-04 18:44:23 +010050
51namespace arm_compute
52{
Anthony Barbierb940fd62018-06-04 14:14:32 +010053/** Formatted output if arg is not null
54 *
55 * @param[in] arg Object to print
56 *
57 * @return String representing arg.
58 */
59template <typename T>
60std::string to_string_if_not_null(T *arg)
61{
62 if(arg == nullptr)
63 {
64 return "nullptr";
65 }
66 else
67 {
68 return to_string(*arg);
69 }
70}
Anthony Barbierb4670212018-05-18 16:55:39 +010071
ramelg014a6d9e82021-10-02 14:34:36 +010072/** Fallback method: try to use std::to_string:
73 *
74 * @param[in] val Value to convert to string
75 *
76 * @return String representing val.
77 */
78template <typename T>
79inline std::string to_string(const T &val)
80{
81 return support::cpp11::to_string(val);
82}
83
ramelg01b1ba1e32021-09-25 11:53:26 +010084/** Formatted output of a vector of objects.
85 *
ramelg014a6d9e82021-10-02 14:34:36 +010086 * @note: Using the overloaded to_string() instead of overloaded operator<<(), because to_string() functions are
87 * overloaded for all types, where two or more of them can use the same operator<<(), ITensor is an example.
88 *
ramelg01b1ba1e32021-09-25 11:53:26 +010089 * @param[out] os Output stream
90 * @param[in] args Vector of objects to print
91 *
92 * @return Modified output stream.
93 */
94template <typename T>
ramelg014a6d9e82021-10-02 14:34:36 +010095::std::ostream &operator<<(::std::ostream &os, const std::vector<T> &args)
ramelg01b1ba1e32021-09-25 11:53:26 +010096{
97 const size_t max_print_size = 5U;
98
99 os << "[";
100 bool first = true;
101 size_t i;
102 for(i = 0; i < args.size(); ++i)
103 {
104 if(i == max_print_size)
105 {
106 break;
107 }
108 if(first)
109 {
110 first = false;
111 }
112 else
113 {
114 os << ", ";
115 }
ramelg014a6d9e82021-10-02 14:34:36 +0100116 os << to_string(args[i]);
ramelg01b1ba1e32021-09-25 11:53:26 +0100117 }
118 if(i < args.size())
119 {
120 os << ", ...";
121 }
122 os << "]";
123 return os;
124}
125
ramelg014a6d9e82021-10-02 14:34:36 +0100126/** Formatted output of a vector of objects.
127 *
128 * @param[in] args Vector of objects to print
129 *
130 * @return String representing args.
131 */
132template <typename T>
133std::string to_string(const std::vector<T> &args)
134{
135 std::stringstream str;
136 str << args;
137 return str.str();
138}
139
SiCongLi1af54162021-10-06 15:25:57 +0100140/** @name (EXPERIMENTAL_POST_OPS)
141 * @{
142 */
143/** Formmated output of the @ref experimental::PostOpType type
144 *
145 * @param[out] os Output stream.
146 * @param[in] post_op_type Type to output.
147 *
148 * @return Modified output stream.
149 */
150inline ::std::ostream &operator<<(::std::ostream &os, experimental::PostOpType post_op_type)
151{
152 os << "type=";
153 switch(post_op_type)
154 {
155 case experimental::PostOpType::Activation:
156 {
157 os << "Activation";
158 break;
159 }
160 case experimental::PostOpType::Eltwise_Add:
161 {
162 os << "Eltwise_Add";
163 break;
164 }
ramelg016049eda2021-10-29 10:52:53 +0100165 case experimental::PostOpType::Eltwise_PRelu:
166 {
167 os << "Eltwise_PRelu";
168 break;
169 }
SiCongLi1af54162021-10-06 15:25:57 +0100170 default:
171 {
172 ARM_COMPUTE_ERROR("Unsupported PostOpType");
173 break;
174 }
175 }
176 return os;
177}
178/** Converts a @ref experimental::PostOpType to string
179 *
180 * @param[in] post_op_type PostOpType value to be converted
181 *
182 * @return String representing the corresponding PostOpType
183 */
184inline std::string to_string(experimental::PostOpType post_op_type)
185{
186 std::stringstream str;
187 str << post_op_type;
188 return str.str();
189}
190/** Formatted output of the @ref experimental::IPostOp type.
191 *
192 * @param[out] os Output stream.
193 * @param[in] post_op Type to output.
194 *
195 * @return Modified output stream.
196 */
197template <typename T>
198inline ::std::ostream &operator<<(::std::ostream &os, const experimental::IPostOp<T> &post_op)
199{
200 os << "<";
201 os << post_op.type() << ",";
SiCongLieb8bd812021-10-29 15:05:49 +0100202 os << "prev_dst_pos=" << post_op.prev_dst_pos() << ",";
SiCongLi1af54162021-10-06 15:25:57 +0100203 switch(post_op.type())
204 {
205 case experimental::PostOpType::Activation:
206 {
207 const auto _post_op = utils::cast::polymorphic_downcast<const experimental::PostOpAct<T> *>(&post_op);
208 os << "act_info=" << &(_post_op->_act_info);
209 break;
210 }
211 case experimental::PostOpType::Eltwise_Add:
212 {
213 const auto _post_op = utils::cast::polymorphic_downcast<const experimental::PostOpEltwiseAdd<T> *>(&post_op);
214 os << "convert_policy=" << _post_op->_policy;
215 break;
216 }
ramelg016049eda2021-10-29 10:52:53 +0100217 case experimental::PostOpType::Eltwise_PRelu:
218 {
219 const auto _post_op = utils::cast::polymorphic_downcast<const experimental::PostOpEltwisePRelu<T> *>(&post_op);
220 os << "convert_policy=" << _post_op->_policy;
221 break;
222 }
SiCongLi1af54162021-10-06 15:25:57 +0100223 default:
224 {
225 ARM_COMPUTE_ERROR("Unsupported PostOpType");
226 break;
227 }
228 }
229 os << ">";
230 return os;
231}
232/** Converts an @ref experimental::IPostOp to string
233 *
234 * @param[in] post_op IPostOp value to be converted
235 *
236 * @return String representing the corresponding IPostOp
237 */
238template <typename T>
239inline std::string to_string(const experimental::IPostOp<T> &post_op)
240{
241 std::stringstream str;
242 str << post_op;
243 return str.str();
244}
245/** Formatted output of the @ref experimental::PostOpList type.
246 *
247 * @param[out] os Output stream.
248 * @param[in] post_ops Type to output.
249 *
250 * @return Modified output stream.
251 */
252template <typename T>
253inline ::std::ostream &operator<<(::std::ostream &os, const experimental::PostOpList<T> &post_ops)
254{
255 os << "[";
256 for(const auto &post_op : post_ops.get_list())
257 {
258 os << *post_op << ",";
259 }
260 os << "]";
261 return os;
262}
263/** Converts a @ref experimental::PostOpList to string
264 *
265 * @param[in] post_ops PostOpList value to be converted
266 *
267 * @return String representing the corresponding PostOpList
268 */
269template <typename T>
270inline std::string to_string(const experimental::PostOpList<T> &post_ops)
271{
272 std::stringstream str;
273 str << post_ops;
274 return str.str();
275}
276/** @} */ // end of group (EXPERIMENTAL_POST_OPS)
277
Alex Gildayc357c472018-03-21 13:54:09 +0000278/** Formatted output of the Dimensions type.
279 *
280 * @param[out] os Output stream.
281 * @param[in] dimensions Type to output.
282 *
283 * @return Modified output stream.
284 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100285template <typename T>
286inline ::std::ostream &operator<<(::std::ostream &os, const Dimensions<T> &dimensions)
287{
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100288 if(dimensions.num_dimensions() > 0)
289 {
290 os << dimensions[0];
291
292 for(unsigned int d = 1; d < dimensions.num_dimensions(); ++d)
293 {
Freddie Liardetdd23f2a2021-06-17 13:30:11 +0100294 os << "," << dimensions[d];
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100295 }
296 }
297
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100298 return os;
299}
300
Alex Gildayc357c472018-03-21 13:54:09 +0000301/** Formatted output of the RoundingPolicy type.
302 *
303 * @param[out] os Output stream.
304 * @param[in] rounding_policy Type to output.
305 *
306 * @return Modified output stream.
307 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100308inline ::std::ostream &operator<<(::std::ostream &os, const RoundingPolicy &rounding_policy)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100309{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100310 switch(rounding_policy)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100311 {
Anthony Barbier2a07e182017-08-04 18:20:27 +0100312 case RoundingPolicy::TO_ZERO:
313 os << "TO_ZERO";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100314 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100315 case RoundingPolicy::TO_NEAREST_UP:
316 os << "TO_NEAREST_UP";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100317 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100318 case RoundingPolicy::TO_NEAREST_EVEN:
319 os << "TO_NEAREST_EVEN";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100320 break;
321 default:
322 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
323 }
324
325 return os;
326}
327
Alex Gildayc357c472018-03-21 13:54:09 +0000328/** Formatted output of the WeightsInfo type.
329 *
330 * @param[out] os Output stream.
331 * @param[in] weights_info Type to output.
332 *
333 * @return Modified output stream.
334 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100335inline ::std::ostream &operator<<(::std::ostream &os, const WeightsInfo &weights_info)
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100336{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100337 os << weights_info.are_reshaped() << ";";
338 os << weights_info.num_kernels() << ";" << weights_info.kernel_size().first << "," << weights_info.kernel_size().second;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100339
340 return os;
341}
342
Alex Gildayc357c472018-03-21 13:54:09 +0000343/** Formatted output of the ROIPoolingInfo type.
344 *
345 * @param[out] os Output stream.
346 * @param[in] pool_info Type to output.
347 *
348 * @return Modified output stream.
349 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100350inline ::std::ostream &operator<<(::std::ostream &os, const ROIPoolingLayerInfo &pool_info)
Sanghoon Lee70f82912017-08-24 14:21:24 +0100351{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100352 os << pool_info.pooled_width() << "x" << pool_info.pooled_height() << "~" << pool_info.spatial_scale();
Georgios Pinitasd9769582017-08-03 10:19:40 +0100353 return os;
354}
355
giuros0118870812018-09-13 09:31:40 +0100356/** Formatted output of the ROIPoolingInfo type.
357 *
358 * @param[in] pool_info Type to output.
359 *
360 * @return Formatted string.
361 */
362inline std::string to_string(const ROIPoolingLayerInfo &pool_info)
363{
364 std::stringstream str;
365 str << pool_info;
366 return str.str();
367}
368
morgolockaba2f912020-05-05 16:28:19 +0100369/** Formatted output of the GEMMKernelInfo type.
370 *
371 * @param[out] os Output stream.
372 * @param[in] gemm_info Type to output.
373 *
374 * @return Modified output stream.
375 */
376inline ::std::ostream &operator<<(::std::ostream &os, const GEMMKernelInfo &gemm_info)
377{
SiCongLi579ca842021-10-18 09:38:33 +0100378 os << "( m=" << gemm_info.m;
379 os << " n=" << gemm_info.n;
380 os << " k=" << gemm_info.k;
381 os << " depth_output_gemm3d=" << gemm_info.depth_output_gemm3d;
382 os << " reinterpret_input_as_3d=" << gemm_info.reinterpret_input_as_3d;
383 os << " broadcast_bias=" << gemm_info.broadcast_bias;
384 os << " fp_mixed_precision=" << gemm_info.fp_mixed_precision;
385 os << " mult_transpose1xW_width=" << gemm_info.mult_transpose1xW_width;
386 os << " mult_interleave4x4_height=" << gemm_info.mult_interleave4x4_height;
387 os << " a_offset=" << gemm_info.a_offset;
388 os << " b_offset=" << gemm_info.b_offset;
389 os << "post_ops=" << gemm_info.post_ops;
morgolockaba2f912020-05-05 16:28:19 +0100390 os << ")";
391 return os;
392}
393
394/** Formatted output of the GEMMLHSMatrixInfo type.
395 *
396 * @param[out] os Output stream.
397 * @param[in] gemm_info Type to output.
398 *
399 * @return Modified output stream.
400 */
401inline ::std::ostream &operator<<(::std::ostream &os, const GEMMLHSMatrixInfo &gemm_info)
402{
SiCongLi579ca842021-10-18 09:38:33 +0100403 os << "( m0=" << (unsigned int)gemm_info.m0 << " k0=" << gemm_info.k0 << " v0=" << gemm_info.v0 << " trans=" << gemm_info.transpose << " inter=" << gemm_info.interleave << "})";
morgolockaba2f912020-05-05 16:28:19 +0100404 return os;
405}
406
407/** Formatted output of the GEMMRHSMatrixInfo type.
408 *
409 * @param[out] os Output stream.
410 * @param[in] gemm_info Type to output.
411 *
412 * @return Modified output stream.
413 */
414inline ::std::ostream &operator<<(::std::ostream &os, const GEMMRHSMatrixInfo &gemm_info)
415{
SiCongLi579ca842021-10-18 09:38:33 +0100416 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=" <<
SiCong Lidb4a6c12021-02-05 09:30:57 +0000417 gemm_info.export_to_cl_image << "})";
morgolockaba2f912020-05-05 16:28:19 +0100418 return os;
419}
420
421/** Formatted output of the GEMMRHSMatrixInfo type.
422 *
423 * @param[in] gemm_info GEMMRHSMatrixInfo to output.
424 *
425 * @return Formatted string.
426 */
427inline std::string to_string(const GEMMRHSMatrixInfo &gemm_info)
428{
429 std::stringstream str;
430 str << gemm_info;
431 return str.str();
432}
433
434/** Formatted output of the GEMMLHSMatrixInfo type.
435 *
436 * @param[in] gemm_info GEMMLHSMatrixInfo to output.
437 *
438 * @return Formatted string.
439 */
440inline std::string to_string(const GEMMLHSMatrixInfo &gemm_info)
441{
442 std::stringstream str;
443 str << gemm_info;
444 return str.str();
445}
446
447/** Formatted output of the GEMMKernelInfo type.
448 *
449 * @param[in] gemm_info GEMMKernelInfo Type to output.
450 *
451 * @return Formatted string.
452 */
453inline std::string to_string(const GEMMKernelInfo &gemm_info)
454{
455 std::stringstream str;
456 str << gemm_info;
457 return str.str();
458}
459
giuros01c04a0e82018-10-03 12:44:35 +0100460/** Formatted output of the BoundingBoxTransformInfo type.
461 *
462 * @param[out] os Output stream.
463 * @param[in] bbox_info Type to output.
464 *
465 * @return Modified output stream.
466 */
467inline ::std::ostream &operator<<(::std::ostream &os, const BoundingBoxTransformInfo &bbox_info)
468{
469 auto weights = bbox_info.weights();
SiCongLi579ca842021-10-18 09:38:33 +0100470 os << "(" << bbox_info.img_width() << "x" << bbox_info.img_height() << ")~" << bbox_info.scale() << "(weights={" << weights[0] << ", " << weights[1] << ", " << weights[2] << ", " << weights[3] <<
giuros01c04a0e82018-10-03 12:44:35 +0100471 "})";
472 return os;
473}
474
Pablo Marquez Tellod208f4f2022-07-19 12:19:46 +0100475#if defined(ARM_COMPUTE_ENABLE_BF16)
Ramy Elgammal91780022022-07-20 14:57:37 +0100476inline ::std::ostream &operator<<(::std::ostream &os, const bfloat16 &v)
Pablo Marquez Tellod208f4f2022-07-19 12:19:46 +0100477{
478 std::stringstream str;
479 str << v;
480 os << str.str();
481 return os;
482}
Ramy Elgammal91780022022-07-20 14:57:37 +0100483#endif /* defined(ARM_COMPUTE_ENABLE_BF16) */
Pablo Marquez Tellod208f4f2022-07-19 12:19:46 +0100484
giuros01c04a0e82018-10-03 12:44:35 +0100485/** Formatted output of the BoundingBoxTransformInfo type.
486 *
487 * @param[in] bbox_info Type to output.
488 *
489 * @return Formatted string.
490 */
491inline std::string to_string(const BoundingBoxTransformInfo &bbox_info)
492{
493 std::stringstream str;
494 str << bbox_info;
495 return str.str();
496}
497
Manuel Bottini5209be52019-02-13 16:34:56 +0000498/** Formatted output of the ComputeAnchorsInfo type.
499 *
500 * @param[out] os Output stream.
501 * @param[in] anchors_info Type to output.
502 *
503 * @return Modified output stream.
504 */
505inline ::std::ostream &operator<<(::std::ostream &os, const ComputeAnchorsInfo &anchors_info)
506{
507 os << "(" << anchors_info.feat_width() << "x" << anchors_info.feat_height() << ")~" << anchors_info.spatial_scale();
508 return os;
509}
510
511/** Formatted output of the ComputeAnchorsInfo type.
512 *
513 * @param[in] anchors_info Type to output.
514 *
515 * @return Formatted string.
516 */
517inline std::string to_string(const ComputeAnchorsInfo &anchors_info)
518{
519 std::stringstream str;
520 str << anchors_info;
521 return str.str();
522}
523
524/** Formatted output of the GenerateProposalsInfo type.
525 *
526 * @param[out] os Output stream.
527 * @param[in] proposals_info Type to output.
528 *
529 * @return Modified output stream.
530 */
531inline ::std::ostream &operator<<(::std::ostream &os, const GenerateProposalsInfo &proposals_info)
532{
533 os << "(" << proposals_info.im_width() << "x" << proposals_info.im_height() << ")~" << proposals_info.im_scale();
534 return os;
535}
536
537/** Formatted output of the GenerateProposalsInfo type.
538 *
539 * @param[in] proposals_info Type to output.
540 *
541 * @return Formatted string.
542 */
543inline std::string to_string(const GenerateProposalsInfo &proposals_info)
544{
545 std::stringstream str;
546 str << proposals_info;
547 return str.str();
548}
549
Alex Gildayc357c472018-03-21 13:54:09 +0000550/** Formatted output of the QuantizationInfo type.
551 *
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100552 * @param[out] os Output stream.
553 * @param[in] qinfo Type to output.
Alex Gildayc357c472018-03-21 13:54:09 +0000554 *
555 * @return Modified output stream.
556 */
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100557inline ::std::ostream &operator<<(::std::ostream &os, const QuantizationInfo &qinfo)
Chunosovd621bca2017-11-03 17:33:15 +0700558{
Georgios Pinitas3d13af82019-06-04 13:04:16 +0100559 const UniformQuantizationInfo uqinfo = qinfo.uniform();
560 os << "Scale:" << uqinfo.scale << "~";
561 os << "Offset:" << uqinfo.offset;
Chunosovd621bca2017-11-03 17:33:15 +0700562 return os;
563}
564
Alex Gildayc357c472018-03-21 13:54:09 +0000565/** Formatted output of the QuantizationInfo type.
566 *
567 * @param[in] quantization_info Type to output.
568 *
569 * @return Formatted string.
570 */
Chunosovd621bca2017-11-03 17:33:15 +0700571inline std::string to_string(const QuantizationInfo &quantization_info)
572{
573 std::stringstream str;
574 str << quantization_info;
575 return str.str();
576}
577
Alex Gildayc357c472018-03-21 13:54:09 +0000578/** Formatted output of the activation function type.
579 *
580 * @param[out] os Output stream.
581 * @param[in] act_function Type to output.
582 *
583 * @return Modified output stream.
584 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100585inline ::std::ostream &operator<<(::std::ostream &os, const ActivationLayerInfo::ActivationFunction &act_function)
586{
587 switch(act_function)
588 {
589 case ActivationLayerInfo::ActivationFunction::ABS:
590 os << "ABS";
591 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100592 case ActivationLayerInfo::ActivationFunction::LINEAR:
593 os << "LINEAR";
594 break;
595 case ActivationLayerInfo::ActivationFunction::LOGISTIC:
596 os << "LOGISTIC";
597 break;
598 case ActivationLayerInfo::ActivationFunction::RELU:
599 os << "RELU";
600 break;
Georgios Pinitas579c0492017-07-12 16:12:12 +0100601 case ActivationLayerInfo::ActivationFunction::BOUNDED_RELU:
602 os << "BOUNDED_RELU";
603 break;
604 case ActivationLayerInfo::ActivationFunction::LEAKY_RELU:
605 os << "LEAKY_RELU";
606 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100607 case ActivationLayerInfo::ActivationFunction::SOFT_RELU:
608 os << "SOFT_RELU";
609 break;
610 case ActivationLayerInfo::ActivationFunction::SQRT:
611 os << "SQRT";
612 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100613 case ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU:
614 os << "LU_BOUNDED_RELU";
Kevin Petitd9f80712017-12-06 12:18:48 +0000615 break;
Georgios Pinitasfb0fdcd2019-08-22 17:10:04 +0100616 case ActivationLayerInfo::ActivationFunction::ELU:
617 os << "ELU";
618 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100619 case ActivationLayerInfo::ActivationFunction::SQUARE:
620 os << "SQUARE";
621 break;
622 case ActivationLayerInfo::ActivationFunction::TANH:
623 os << "TANH";
624 break;
Usama Arif6a98a6e2019-05-10 17:07:27 +0100625 case ActivationLayerInfo::ActivationFunction::IDENTITY:
626 os << "IDENTITY";
627 break;
morgolock07df3d42020-02-27 11:46:28 +0000628 case ActivationLayerInfo::ActivationFunction::HARD_SWISH:
629 os << "HARD_SWISH";
630 break;
Murray Kornelsen926f5022022-07-13 21:22:39 -0400631 case ActivationLayerInfo::ActivationFunction::GELU:
632 os << "GELU";
633 break;
morgolock07df3d42020-02-27 11:46:28 +0000634
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100635 default:
636 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
637 }
638
639 return os;
640}
641
Alex Gildayc357c472018-03-21 13:54:09 +0000642/** Formatted output of the activation function info type.
643 *
SiCongLi1af54162021-10-06 15:25:57 +0100644 * @param[in] info ActivationLayerInfo to output.
Alex Gildayc357c472018-03-21 13:54:09 +0000645 *
646 * @return Formatted string.
647 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100648inline std::string to_string(const arm_compute::ActivationLayerInfo &info)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100649{
650 std::stringstream str;
Isabella Gottardi3f217ec2018-02-12 14:59:19 +0000651 if(info.enabled())
652 {
653 str << info.activation();
654 }
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100655 return str.str();
656}
657
SiCongLi1af54162021-10-06 15:25:57 +0100658/** Formatted output of the activation function info.
ramelg013ae3d882021-09-12 23:07:47 +0100659 *
SiCongLi1af54162021-10-06 15:25:57 +0100660 * @param[out] os Output stream.
661 * @param[in] info ActivationLayerInfo to output.
ramelg013ae3d882021-09-12 23:07:47 +0100662 *
663 * @return Formatted string.
664 */
SiCongLi1af54162021-10-06 15:25:57 +0100665inline ::std::ostream &operator<<(::std::ostream &os, const ActivationLayerInfo *info)
ramelg013ae3d882021-09-12 23:07:47 +0100666{
ramelg013ae3d882021-09-12 23:07:47 +0100667 if(info != nullptr)
668 {
ramelg013ae3d882021-09-12 23:07:47 +0100669 if(info->enabled())
670 {
SiCongLi1af54162021-10-06 15:25:57 +0100671 os << info->activation();
672 os << "(";
673 os << "VAL_A=" << info->a() << ",";
674 os << "VAL_B=" << info->b();
675 os << ")";
ramelg013ae3d882021-09-12 23:07:47 +0100676 }
SiCongLi1af54162021-10-06 15:25:57 +0100677 else
678 {
679 os << "disabled";
680 }
ramelg013ae3d882021-09-12 23:07:47 +0100681 }
SiCongLi1af54162021-10-06 15:25:57 +0100682 else
683 {
684 os << "nullptr";
685 }
686 return os;
ramelg013ae3d882021-09-12 23:07:47 +0100687}
688
Alex Gildayc357c472018-03-21 13:54:09 +0000689/** Formatted output of the activation function type.
690 *
691 * @param[in] function Type to output.
692 *
693 * @return Formatted string.
694 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100695inline std::string to_string(const arm_compute::ActivationLayerInfo::ActivationFunction &function)
696{
697 std::stringstream str;
698 str << function;
699 return str.str();
700}
701
Alex Gildayc357c472018-03-21 13:54:09 +0000702/** Formatted output of the NormType type.
703 *
704 * @param[out] os Output stream.
705 * @param[in] norm_type Type to output.
706 *
707 * @return Modified output stream.
708 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100709inline ::std::ostream &operator<<(::std::ostream &os, const NormType &norm_type)
710{
711 switch(norm_type)
712 {
713 case NormType::CROSS_MAP:
714 os << "CROSS_MAP";
715 break;
716 case NormType::IN_MAP_1D:
717 os << "IN_MAP_1D";
718 break;
719 case NormType::IN_MAP_2D:
720 os << "IN_MAP_2D";
721 break;
722 default:
723 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
724 }
725
726 return os;
727}
728
Alex Gildayc357c472018-03-21 13:54:09 +0000729/** Formatted output of @ref NormalizationLayerInfo.
730 *
731 * @param[in] info Type to output.
732 *
733 * @return Formatted string.
734 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100735inline std::string to_string(const arm_compute::NormalizationLayerInfo &info)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100736{
737 std::stringstream str;
Michalis Spyroud466c2d2018-01-30 10:54:39 +0000738 str << info.type() << ":NormSize=" << info.norm_size();
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100739 return str.str();
740}
741
Alex Gildayc357c472018-03-21 13:54:09 +0000742/** Formatted output of @ref NormalizationLayerInfo.
743 *
744 * @param[out] os Output stream.
745 * @param[in] info Type to output.
746 *
747 * @return Modified output stream.
748 */
Georgios Pinitas6f669f02017-09-26 12:32:57 +0100749inline ::std::ostream &operator<<(::std::ostream &os, const NormalizationLayerInfo &info)
750{
Michalis Spyroud466c2d2018-01-30 10:54:39 +0000751 os << info.type() << ":NormSize=" << info.norm_size();
Georgios Pinitas6f669f02017-09-26 12:32:57 +0100752 return os;
753}
754
Alex Gildayc357c472018-03-21 13:54:09 +0000755/** Formatted output of the PoolingType type.
756 *
757 * @param[out] os Output stream.
758 * @param[in] pool_type Type to output.
759 *
760 * @return Modified output stream.
761 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100762inline ::std::ostream &operator<<(::std::ostream &os, const PoolingType &pool_type)
763{
764 switch(pool_type)
765 {
766 case PoolingType::AVG:
767 os << "AVG";
768 break;
769 case PoolingType::MAX:
770 os << "MAX";
771 break;
Georgios Pinitascdf51452017-08-31 14:21:36 +0100772 case PoolingType::L2:
773 os << "L2";
774 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100775 default:
776 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
777 }
778
779 return os;
780}
781
Alex Gildayc357c472018-03-21 13:54:09 +0000782/** Formatted output of @ref PoolingLayerInfo.
783 *
784 * @param[out] os Output stream.
785 * @param[in] info Type to output.
786 *
787 * @return Modified output stream.
788 */
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100789inline ::std::ostream &operator<<(::std::ostream &os, const PoolingLayerInfo &info)
790{
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +0000791 os << info.pool_type;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100792
793 return os;
794}
795
Alex Gildayc357c472018-03-21 13:54:09 +0000796/** Formatted output of @ref RoundingPolicy.
797 *
798 * @param[in] rounding_policy Type to output.
799 *
800 * @return Formatted string.
801 */
John Richardsondd715f22017-09-18 16:10:48 +0100802inline std::string to_string(const RoundingPolicy &rounding_policy)
803{
804 std::stringstream str;
805 str << rounding_policy;
806 return str.str();
807}
808
Vidhya Sudhan Loganathand646ae12018-11-19 15:18:20 +0000809/** [Print DataLayout type] **/
Alex Gildayc357c472018-03-21 13:54:09 +0000810/** Formatted output of the DataLayout type.
811 *
812 * @param[out] os Output stream.
813 * @param[in] data_layout Type to output.
814 *
815 * @return Modified output stream.
816 */
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000817inline ::std::ostream &operator<<(::std::ostream &os, const DataLayout &data_layout)
818{
819 switch(data_layout)
820 {
821 case DataLayout::UNKNOWN:
822 os << "UNKNOWN";
823 break;
824 case DataLayout::NHWC:
825 os << "NHWC";
826 break;
827 case DataLayout::NCHW:
828 os << "NCHW";
829 break;
Adnan AlSinane4563a02021-09-01 15:32:03 +0100830 case DataLayout::NDHWC:
831 os << "NDHWC";
832 break;
Giorgio Arenac9fe9fc2021-10-06 12:54:29 +0100833 case DataLayout::NCDHW:
834 os << "NCDHW";
835 break;
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000836 default:
837 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
838 }
839
840 return os;
841}
842
Alex Gildayc357c472018-03-21 13:54:09 +0000843/** Formatted output of the DataLayout type.
844 *
845 * @param[in] data_layout Type to output.
846 *
847 * @return Formatted string.
848 */
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000849inline std::string to_string(const arm_compute::DataLayout &data_layout)
850{
851 std::stringstream str;
852 str << data_layout;
853 return str.str();
854}
Vidhya Sudhan Loganathand646ae12018-11-19 15:18:20 +0000855/** [Print DataLayout type] **/
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000856
Georgios Pinitase2220552018-07-20 13:23:44 +0100857/** Formatted output of the DataLayoutDimension type.
858 *
859 * @param[out] os Output stream.
860 * @param[in] data_layout_dim Data layout dimension to print.
861 *
862 * @return Modified output stream.
863 */
864inline ::std::ostream &operator<<(::std::ostream &os, const DataLayoutDimension &data_layout_dim)
865{
866 switch(data_layout_dim)
867 {
868 case DataLayoutDimension::WIDTH:
869 os << "WIDTH";
870 break;
871 case DataLayoutDimension::HEIGHT:
872 os << "HEIGHT";
873 break;
874 case DataLayoutDimension::CHANNEL:
875 os << "CHANNEL";
876 break;
Giorgio Arenac9fe9fc2021-10-06 12:54:29 +0100877 case DataLayoutDimension::DEPTH:
878 os << "DEPTH";
879 break;
Georgios Pinitase2220552018-07-20 13:23:44 +0100880 case DataLayoutDimension::BATCHES:
881 os << "BATCHES";
882 break;
883 default:
884 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
885 }
886 return os;
887}
888
Alex Gildayc357c472018-03-21 13:54:09 +0000889/** Formatted output of the DataType type.
890 *
891 * @param[out] os Output stream.
892 * @param[in] data_type Type to output.
893 *
894 * @return Modified output stream.
895 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100896inline ::std::ostream &operator<<(::std::ostream &os, const DataType &data_type)
897{
898 switch(data_type)
899 {
900 case DataType::UNKNOWN:
901 os << "UNKNOWN";
902 break;
903 case DataType::U8:
904 os << "U8";
905 break;
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100906 case DataType::QSYMM8:
907 os << "QSYMM8";
908 break;
Chunosovd621bca2017-11-03 17:33:15 +0700909 case DataType::QASYMM8:
910 os << "QASYMM8";
911 break;
Georgios Pinitas448a81f2019-11-21 14:10:25 +0000912 case DataType::QASYMM8_SIGNED:
913 os << "QASYMM8_SIGNED";
914 break;
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100915 case DataType::QSYMM8_PER_CHANNEL:
916 os << "QSYMM8_PER_CHANNEL";
917 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100918 case DataType::S8:
919 os << "S8";
920 break;
921 case DataType::U16:
922 os << "U16";
923 break;
924 case DataType::S16:
925 os << "S16";
926 break;
Manuel Bottini3689fcd2019-06-14 17:18:12 +0100927 case DataType::QSYMM16:
928 os << "QSYMM16";
929 break;
Michele Di Giorgio35ea9a72019-08-23 12:02:06 +0100930 case DataType::QASYMM16:
931 os << "QASYMM16";
932 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100933 case DataType::U32:
934 os << "U32";
935 break;
936 case DataType::S32:
937 os << "S32";
938 break;
939 case DataType::U64:
940 os << "U64";
941 break;
942 case DataType::S64:
943 os << "S64";
944 break;
Georgios Pinitase8291ac2020-02-26 09:58:13 +0000945 case DataType::BFLOAT16:
946 os << "BFLOAT16";
947 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100948 case DataType::F16:
949 os << "F16";
950 break;
951 case DataType::F32:
952 os << "F32";
953 break;
954 case DataType::F64:
955 os << "F64";
956 break;
957 case DataType::SIZET:
958 os << "SIZET";
959 break;
960 default:
961 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
962 }
963
964 return os;
965}
966
Alex Gildayc357c472018-03-21 13:54:09 +0000967/** Formatted output of the DataType type.
968 *
969 * @param[in] data_type Type to output.
970 *
971 * @return Formatted string.
972 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100973inline std::string to_string(const arm_compute::DataType &data_type)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100974{
975 std::stringstream str;
976 str << data_type;
977 return str.str();
978}
979
Alex Gildayc357c472018-03-21 13:54:09 +0000980/** Formatted output of the Format type.
981 *
982 * @param[out] os Output stream.
983 * @param[in] format Type to output.
984 *
985 * @return Modified output stream.
986 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100987inline ::std::ostream &operator<<(::std::ostream &os, const Format &format)
988{
989 switch(format)
990 {
991 case Format::UNKNOWN:
992 os << "UNKNOWN";
993 break;
994 case Format::U8:
995 os << "U8";
996 break;
997 case Format::S16:
998 os << "S16";
999 break;
1000 case Format::U16:
1001 os << "U16";
1002 break;
1003 case Format::S32:
1004 os << "S32";
1005 break;
1006 case Format::U32:
1007 os << "U32";
1008 break;
1009 case Format::F16:
1010 os << "F16";
1011 break;
1012 case Format::F32:
1013 os << "F32";
1014 break;
1015 case Format::UV88:
1016 os << "UV88";
1017 break;
1018 case Format::RGB888:
1019 os << "RGB888";
1020 break;
1021 case Format::RGBA8888:
1022 os << "RGBA8888";
1023 break;
1024 case Format::YUV444:
1025 os << "YUV444";
1026 break;
1027 case Format::YUYV422:
1028 os << "YUYV422";
1029 break;
1030 case Format::NV12:
1031 os << "NV12";
1032 break;
1033 case Format::NV21:
1034 os << "NV21";
1035 break;
1036 case Format::IYUV:
1037 os << "IYUV";
1038 break;
1039 case Format::UYVY422:
1040 os << "UYVY422";
1041 break;
1042 default:
1043 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1044 }
1045
1046 return os;
1047}
1048
Alex Gildayc357c472018-03-21 13:54:09 +00001049/** Formatted output of the Format type.
1050 *
1051 * @param[in] format Type to output.
1052 *
1053 * @return Formatted string.
1054 */
Moritz Pflanzer7655a672017-09-23 11:57:33 +01001055inline std::string to_string(const Format &format)
1056{
1057 std::stringstream str;
1058 str << format;
1059 return str.str();
1060}
1061
Alex Gildayc357c472018-03-21 13:54:09 +00001062/** Formatted output of the Channel type.
1063 *
1064 * @param[out] os Output stream.
1065 * @param[in] channel Type to output.
1066 *
1067 * @return Modified output stream.
1068 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001069inline ::std::ostream &operator<<(::std::ostream &os, const Channel &channel)
1070{
1071 switch(channel)
1072 {
1073 case Channel::UNKNOWN:
1074 os << "UNKNOWN";
1075 break;
1076 case Channel::C0:
1077 os << "C0";
1078 break;
1079 case Channel::C1:
1080 os << "C1";
1081 break;
1082 case Channel::C2:
1083 os << "C2";
1084 break;
1085 case Channel::C3:
1086 os << "C3";
1087 break;
1088 case Channel::R:
1089 os << "R";
1090 break;
1091 case Channel::G:
1092 os << "G";
1093 break;
1094 case Channel::B:
1095 os << "B";
1096 break;
1097 case Channel::A:
1098 os << "A";
1099 break;
1100 case Channel::Y:
1101 os << "Y";
1102 break;
1103 case Channel::U:
1104 os << "U";
1105 break;
1106 case Channel::V:
1107 os << "V";
1108 break;
1109 default:
1110 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1111 }
1112
1113 return os;
1114}
1115
Alex Gildayc357c472018-03-21 13:54:09 +00001116/** Formatted output of the Channel type.
1117 *
1118 * @param[in] channel Type to output.
1119 *
1120 * @return Formatted string.
1121 */
Ioan-Cristian Szabo9414f642017-10-27 17:35:40 +01001122inline std::string to_string(const Channel &channel)
1123{
1124 std::stringstream str;
1125 str << channel;
1126 return str.str();
1127}
1128
Alex Gildayc357c472018-03-21 13:54:09 +00001129/** Formatted output of the BorderMode type.
1130 *
1131 * @param[out] os Output stream.
1132 * @param[in] mode Type to output.
1133 *
1134 * @return Modified output stream.
1135 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001136inline ::std::ostream &operator<<(::std::ostream &os, const BorderMode &mode)
1137{
1138 switch(mode)
1139 {
1140 case BorderMode::UNDEFINED:
1141 os << "UNDEFINED";
1142 break;
1143 case BorderMode::CONSTANT:
1144 os << "CONSTANT";
1145 break;
1146 case BorderMode::REPLICATE:
1147 os << "REPLICATE";
1148 break;
1149 default:
1150 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1151 }
1152
1153 return os;
1154}
1155
Alex Gildayc357c472018-03-21 13:54:09 +00001156/** Formatted output of the BorderSize type.
1157 *
1158 * @param[out] os Output stream.
1159 * @param[in] border Type to output.
1160 *
1161 * @return Modified output stream.
1162 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001163inline ::std::ostream &operator<<(::std::ostream &os, const BorderSize &border)
1164{
Moritz Pflanzerc87fbf82017-07-18 14:02:10 +01001165 os << border.top << ","
1166 << border.right << ","
1167 << border.bottom << ","
1168 << border.left;
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001169
1170 return os;
1171}
Anthony Barbier2a07e182017-08-04 18:20:27 +01001172
Giuseppe Rossinid7647d42018-07-17 18:13:13 +01001173/** Formatted output of the PaddingList type.
1174 *
1175 * @param[out] os Output stream.
1176 * @param[in] padding Type to output.
1177 *
1178 * @return Modified output stream.
1179 */
1180inline ::std::ostream &operator<<(::std::ostream &os, const PaddingList &padding)
1181{
1182 os << "{";
1183 for(auto const &p : padding)
1184 {
1185 os << "{" << p.first << "," << p.second << "}";
1186 }
1187 os << "}";
1188 return os;
1189}
1190
giuros013175fcf2018-11-21 09:59:17 +00001191/** Formatted output of the Multiples type.
1192 *
1193 * @param[out] os Output stream.
1194 * @param[in] multiples Type to output.
1195 *
1196 * @return Modified output stream.
1197 */
1198inline ::std::ostream &operator<<(::std::ostream &os, const Multiples &multiples)
1199{
1200 os << "(";
1201 for(size_t i = 0; i < multiples.size() - 1; i++)
1202 {
1203 os << multiples[i] << ", ";
1204 }
1205 os << multiples.back() << ")";
1206 return os;
1207}
1208
Alex Gildayc357c472018-03-21 13:54:09 +00001209/** Formatted output of the InterpolationPolicy type.
1210 *
1211 * @param[out] os Output stream.
1212 * @param[in] policy Type to output.
1213 *
1214 * @return Modified output stream.
1215 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001216inline ::std::ostream &operator<<(::std::ostream &os, const InterpolationPolicy &policy)
1217{
1218 switch(policy)
1219 {
1220 case InterpolationPolicy::NEAREST_NEIGHBOR:
1221 os << "NEAREST_NEIGHBOR";
1222 break;
1223 case InterpolationPolicy::BILINEAR:
1224 os << "BILINEAR";
1225 break;
1226 case InterpolationPolicy::AREA:
1227 os << "AREA";
1228 break;
1229 default:
1230 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1231 }
1232
1233 return os;
1234}
1235
Alex Gildayc357c472018-03-21 13:54:09 +00001236/** Formatted output of the SamplingPolicy type.
1237 *
1238 * @param[out] os Output stream.
1239 * @param[in] policy Type to output.
1240 *
1241 * @return Modified output stream.
1242 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +07001243inline ::std::ostream &operator<<(::std::ostream &os, const SamplingPolicy &policy)
1244{
1245 switch(policy)
1246 {
1247 case SamplingPolicy::CENTER:
1248 os << "CENTER";
1249 break;
1250 case SamplingPolicy::TOP_LEFT:
1251 os << "TOP_LEFT";
1252 break;
1253 default:
1254 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1255 }
1256
1257 return os;
1258}
1259
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001260/** Formatted output of the ITensorInfo type.
1261 *
1262 * @param[out] os Output stream.
1263 * @param[in] info Tensor information.
1264 *
1265 * @return Modified output stream.
1266 */
1267inline ::std::ostream &operator<<(std::ostream &os, const ITensorInfo *info)
1268{
Georgios Pinitasc6f95102021-03-30 10:03:01 +01001269 const DataType data_type = info->data_type();
1270 const DataLayout data_layout = info->data_layout();
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001271
1272 os << "Shape=" << info->tensor_shape() << ","
1273 << "DataLayout=" << string_from_data_layout(data_layout) << ","
ramelg014a6d9e82021-10-02 14:34:36 +01001274 << "DataType=" << string_from_data_type(data_type);
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001275
1276 if(is_data_type_quantized(data_type))
1277 {
ramelg01b1ba1e32021-09-25 11:53:26 +01001278 const QuantizationInfo qinfo = info->quantization_info();
1279 const auto scales = qinfo.scale();
1280 const auto offsets = qinfo.offset();
1281
ramelg014a6d9e82021-10-02 14:34:36 +01001282 os << ", QuantizationInfo={"
ramelg01b1ba1e32021-09-25 11:53:26 +01001283 << "scales.size=" << scales.size()
1284 << ", scale(s)=" << scales << ", ";
1285
1286 os << "offsets.size=" << offsets.size()
1287 << ", offset(s)=" << offsets << "}";
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001288 }
1289 return os;
1290}
1291
ramelg013ae3d882021-09-12 23:07:47 +01001292/** Formatted output of the const TensorInfo& type.
Alex Gildayc357c472018-03-21 13:54:09 +00001293 *
Anthony Barbier366628a2018-08-01 13:55:03 +01001294 * @param[out] os Output stream.
1295 * @param[in] info Type to output.
1296 *
1297 * @return Modified output stream.
1298 */
1299inline ::std::ostream &operator<<(::std::ostream &os, const TensorInfo &info)
1300{
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001301 os << &info;
Georgios Pinitasc6f95102021-03-30 10:03:01 +01001302 return os;
Anthony Barbier366628a2018-08-01 13:55:03 +01001303}
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001304
ramelg013ae3d882021-09-12 23:07:47 +01001305/** Formatted output of the const TensorInfo& type.
Anthony Barbier366628a2018-08-01 13:55:03 +01001306 *
Alex Gildayc357c472018-03-21 13:54:09 +00001307 * @param[in] info Type to output.
1308 *
1309 * @return Formatted string.
1310 */
Georgios Pinitas3faea252017-10-30 14:13:50 +00001311inline std::string to_string(const TensorInfo &info)
1312{
1313 std::stringstream str;
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001314 str << &info;
Georgios Pinitas3faea252017-10-30 14:13:50 +00001315 return str.str();
1316}
1317
ramelg013ae3d882021-09-12 23:07:47 +01001318/** Formatted output of the const ITensorInfo& type.
1319 *
1320 * @param[in] info Type to output.
1321 *
1322 * @return Formatted string.
1323 */
1324inline std::string to_string(const ITensorInfo &info)
1325{
1326 std::stringstream str;
1327 str << &info;
1328 return str.str();
1329}
1330
ramelg013ae3d882021-09-12 23:07:47 +01001331/** Formatted output of the const ITensorInfo* type.
1332 *
1333 * @param[in] info Type to output.
1334 *
1335 * @return Formatted string.
1336 */
Ramy Elgammale920d6a2021-08-19 22:10:30 +01001337inline std::string to_string(const ITensorInfo *info)
1338{
ramelg013ae3d882021-09-12 23:07:47 +01001339 std::string ret_str = "nullptr";
1340 if(info != nullptr)
1341 {
1342 std::stringstream str;
1343 str << info;
1344 ret_str = str.str();
1345 }
1346 return ret_str;
1347}
1348
ramelg01cbbb0382021-09-17 17:36:57 +01001349/** Formatted output of the ITensorInfo* type.
1350 *
1351 * @param[in] info Type to output.
1352 *
1353 * @return Formatted string.
1354 */
1355inline std::string to_string(ITensorInfo *info)
1356{
1357 return to_string(static_cast<const ITensorInfo *>(info));
1358}
1359
1360/** Formatted output of the ITensorInfo type obtained from const ITensor* type.
ramelg013ae3d882021-09-12 23:07:47 +01001361 *
1362 * @param[in] tensor Type to output.
1363 *
1364 * @return Formatted string.
1365 */
1366inline std::string to_string(const ITensor *tensor)
1367{
1368 std::string ret_str = "nullptr";
1369 if(tensor != nullptr)
1370 {
1371 std::stringstream str;
ramelg01cbbb0382021-09-17 17:36:57 +01001372 str << "ITensor->info(): " << tensor->info();
ramelg013ae3d882021-09-12 23:07:47 +01001373 ret_str = str.str();
1374 }
1375 return ret_str;
1376}
1377
ramelg01cbbb0382021-09-17 17:36:57 +01001378/** Formatted output of the ITensorInfo type obtained from the ITensor* type.
ramelg013ae3d882021-09-12 23:07:47 +01001379 *
1380 * @param[in] tensor Type to output.
1381 *
1382 * @return Formatted string.
1383 */
1384inline std::string to_string(ITensor *tensor)
1385{
ramelg01cbbb0382021-09-17 17:36:57 +01001386 return to_string(static_cast<const ITensor *>(tensor));
ramelg013ae3d882021-09-12 23:07:47 +01001387}
1388
ramelg01cbbb0382021-09-17 17:36:57 +01001389/** Formatted output of the ITensorInfo type obtained from the ITensor& type.
ramelg013ae3d882021-09-12 23:07:47 +01001390 *
1391 * @param[in] tensor Type to output.
1392 *
1393 * @return Formatted string.
1394 */
1395inline std::string to_string(ITensor &tensor)
1396{
Ramy Elgammale920d6a2021-08-19 22:10:30 +01001397 std::stringstream str;
ramelg01cbbb0382021-09-17 17:36:57 +01001398 str << "ITensor.info(): " << tensor.info();
Ramy Elgammale920d6a2021-08-19 22:10:30 +01001399 return str.str();
1400}
1401
ramelg01cbbb0382021-09-17 17:36:57 +01001402#ifdef ARM_COMPUTE_OPENCL_ENABLED
1403/** Formatted output of the ITensorInfo type obtained from the const ICLTensor& type.
1404 *
1405 * @param[in] cl_tensor Type to output.
1406 *
1407 * @return Formatted string.
1408 */
1409inline std::string to_string(const ICLTensor *cl_tensor)
1410{
1411 std::string ret_str = "nullptr";
1412 if(cl_tensor != nullptr)
1413 {
1414 std::stringstream str;
1415 str << "ICLTensor->info(): " << cl_tensor->info();
1416 ret_str = str.str();
1417 }
1418 return ret_str;
1419}
1420
1421/** Formatted output of the ITensorInfo type obtained from the ICLTensor& type.
1422 *
1423 * @param[in] cl_tensor Type to output.
1424 *
1425 * @return Formatted string.
1426 */
1427inline std::string to_string(ICLTensor *cl_tensor)
1428{
1429 return to_string(static_cast<const ICLTensor *>(cl_tensor));
1430}
1431#endif /* ARM_COMPUTE_OPENCL_ENABLED */
1432
Alex Gildayc357c472018-03-21 13:54:09 +00001433/** Formatted output of the Dimensions type.
1434 *
1435 * @param[in] dimensions Type to output.
1436 *
1437 * @return Formatted string.
1438 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001439template <typename T>
1440inline std::string to_string(const Dimensions<T> &dimensions)
1441{
1442 std::stringstream str;
1443 str << dimensions;
1444 return str.str();
1445}
1446
Alex Gildayc357c472018-03-21 13:54:09 +00001447/** Formatted output of the Strides type.
1448 *
1449 * @param[in] stride Type to output.
1450 *
1451 * @return Formatted string.
1452 */
John Richardsona36eae12017-09-26 16:55:59 +01001453inline std::string to_string(const Strides &stride)
1454{
1455 std::stringstream str;
1456 str << stride;
1457 return str.str();
1458}
1459
Alex Gildayc357c472018-03-21 13:54:09 +00001460/** Formatted output of the TensorShape type.
1461 *
1462 * @param[in] shape Type to output.
1463 *
1464 * @return Formatted string.
1465 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001466inline std::string to_string(const TensorShape &shape)
1467{
1468 std::stringstream str;
1469 str << shape;
1470 return str.str();
1471}
1472
Alex Gildayc357c472018-03-21 13:54:09 +00001473/** Formatted output of the Coordinates type.
1474 *
1475 * @param[in] coord Type to output.
1476 *
1477 * @return Formatted string.
1478 */
Abe Mbise925ca0f2017-10-02 19:16:33 +01001479inline std::string to_string(const Coordinates &coord)
1480{
1481 std::stringstream str;
1482 str << coord;
1483 return str.str();
1484}
1485
Anthony Barbierb940fd62018-06-04 14:14:32 +01001486/** Formatted output of the GEMMReshapeInfo type.
1487 *
1488 * @param[out] os Output stream.
1489 * @param[in] info Type to output.
1490 *
1491 * @return Modified output stream.
1492 */
1493inline ::std::ostream &operator<<(::std::ostream &os, const GEMMReshapeInfo &info)
1494{
1495 os << "{m=" << info.m() << ",";
1496 os << "n=" << info.n() << ",";
1497 os << "k=" << info.k() << ",";
1498 os << "mult_transpose1xW_width=" << info.mult_transpose1xW_width() << ",";
1499 os << "mult_interleave4x4_height=" << info.mult_interleave4x4_height();
1500 os << "}";
1501
1502 return os;
1503}
1504
1505/** Formatted output of the GEMMInfo type.
1506 *
1507 * @param[out] os Output stream.
1508 * @param[in] info Type to output.
1509 *
1510 * @return Modified output stream.
1511 */
1512inline ::std::ostream &operator<<(::std::ostream &os, const GEMMInfo &info)
1513{
1514 os << "{is_a_reshaped=" << info.is_a_reshaped() << ",";
1515 os << "is_b_reshaped=" << info.is_b_reshaped() << ",";
1516 os << "reshape_b_only_on_first_run=" << info.reshape_b_only_on_first_run() << ",";
Anthony Barbierb4670212018-05-18 16:55:39 +01001517 os << "depth_output_gemm3d=" << info.depth_output_gemm3d() << ",";
1518 os << "reinterpret_input_as_3d=" << info.reinterpret_input_as_3d() << ",";
1519 os << "retain_internal_weights=" << info.retain_internal_weights() << ",";
1520 os << "fp_mixed_precision=" << info.fp_mixed_precision() << ",";
1521 os << "broadcast_bias=" << info.broadcast_bias() << ",";
ramelg01cbbb0382021-09-17 17:36:57 +01001522 os << "pretranspose_B=" << info.pretranspose_B() << ",";
SiCongLi579ca842021-10-18 09:38:33 +01001523 os << "post_ops=" << info.post_ops() << "}";
Anthony Barbierb940fd62018-06-04 14:14:32 +01001524
1525 return os;
1526}
1527
1528/** Formatted output of the Window::Dimension type.
1529 *
1530 * @param[out] os Output stream.
1531 * @param[in] dim Type to output.
1532 *
1533 * @return Modified output stream.
1534 */
1535inline ::std::ostream &operator<<(::std::ostream &os, const Window::Dimension &dim)
1536{
1537 os << "{start=" << dim.start() << ", end=" << dim.end() << ", step=" << dim.step() << "}";
1538
1539 return os;
1540}
1541/** Formatted output of the Window type.
1542 *
1543 * @param[out] os Output stream.
1544 * @param[in] win Type to output.
1545 *
1546 * @return Modified output stream.
1547 */
1548inline ::std::ostream &operator<<(::std::ostream &os, const Window &win)
1549{
1550 os << "{";
1551 for(unsigned int i = 0; i < Coordinates::num_max_dimensions; i++)
1552 {
1553 if(i > 0)
1554 {
1555 os << ", ";
1556 }
1557 os << win[i];
1558 }
1559 os << "}";
1560
1561 return os;
1562}
1563
1564/** Formatted output of the WeightsInfo type.
1565 *
1566 * @param[in] info Type to output.
1567 *
1568 * @return Formatted string.
1569 */
1570inline std::string to_string(const WeightsInfo &info)
1571{
1572 std::stringstream str;
1573 str << info;
1574 return str.str();
1575}
1576
1577/** Formatted output of the GEMMReshapeInfo type.
1578 *
1579 * @param[in] info Type to output.
1580 *
1581 * @return Formatted string.
1582 */
1583inline std::string to_string(const GEMMReshapeInfo &info)
1584{
1585 std::stringstream str;
1586 str << info;
1587 return str.str();
1588}
1589
1590/** Formatted output of the GEMMInfo type.
1591 *
1592 * @param[in] info Type to output.
1593 *
1594 * @return Formatted string.
1595 */
1596inline std::string to_string(const GEMMInfo &info)
1597{
1598 std::stringstream str;
1599 str << info;
1600 return str.str();
1601}
1602
1603/** Formatted output of the Window::Dimension type.
1604 *
1605 * @param[in] dim Type to output.
1606 *
1607 * @return Formatted string.
1608 */
1609inline std::string to_string(const Window::Dimension &dim)
1610{
1611 std::stringstream str;
1612 str << dim;
1613 return str.str();
1614}
ramelg01cbbb0382021-09-17 17:36:57 +01001615/** Formatted output of the Window& type.
Anthony Barbierb940fd62018-06-04 14:14:32 +01001616 *
1617 * @param[in] win Type to output.
1618 *
1619 * @return Formatted string.
1620 */
1621inline std::string to_string(const Window &win)
1622{
1623 std::stringstream str;
1624 str << win;
1625 return str.str();
1626}
1627
ramelg01cbbb0382021-09-17 17:36:57 +01001628/** Formatted output of the Window* type.
1629 *
1630 * @param[in] win Type to output.
1631 *
1632 * @return Formatted string.
1633 */
1634inline std::string to_string(Window *win)
1635{
1636 std::string ret_str = "nullptr";
1637 if(win != nullptr)
1638 {
1639 std::stringstream str;
1640 str << *win;
1641 ret_str = str.str();
1642 }
1643 return ret_str;
1644}
1645
Alex Gildayc357c472018-03-21 13:54:09 +00001646/** Formatted output of the Rectangle type.
1647 *
1648 * @param[out] os Output stream.
1649 * @param[in] rect Type to output.
1650 *
1651 * @return Modified output stream.
1652 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001653inline ::std::ostream &operator<<(::std::ostream &os, const Rectangle &rect)
1654{
1655 os << rect.width << "x" << rect.height;
1656 os << "+" << rect.x << "+" << rect.y;
1657
1658 return os;
1659}
1660
Usama Arif8cf8c112019-03-14 15:36:54 +00001661/** Formatted output of the PaddingMode type.
1662 *
1663 * @param[out] os Output stream.
1664 * @param[in] mode Type to output.
1665 *
1666 * @return Modified output stream.
1667 */
1668inline ::std::ostream &operator<<(::std::ostream &os, const PaddingMode &mode)
1669{
1670 switch(mode)
1671 {
1672 case PaddingMode::CONSTANT:
1673 os << "CONSTANT";
1674 break;
1675 case PaddingMode::REFLECT:
1676 os << "REFLECT";
1677 break;
1678 case PaddingMode::SYMMETRIC:
1679 os << "SYMMETRIC";
1680 break;
1681 default:
1682 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1683 }
1684
1685 return os;
1686}
1687
1688/** Formatted output of the PaddingMode type.
1689 *
1690 * @param[in] mode Type to output.
1691 *
1692 * @return Formatted string.
1693 */
1694inline std::string to_string(const PaddingMode &mode)
1695{
1696 std::stringstream str;
1697 str << mode;
1698 return str.str();
1699}
1700
Alex Gildayc357c472018-03-21 13:54:09 +00001701/** Formatted output of the PadStrideInfo type.
1702 *
1703 * @param[out] os Output stream.
1704 * @param[in] pad_stride_info Type to output.
1705 *
1706 * @return Modified output stream.
1707 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001708inline ::std::ostream &operator<<(::std::ostream &os, const PadStrideInfo &pad_stride_info)
1709{
1710 os << pad_stride_info.stride().first << "," << pad_stride_info.stride().second;
1711 os << ";";
Jaroslaw Rzepeckia1ed41f2017-10-13 11:13:58 +01001712 os << pad_stride_info.pad_left() << "," << pad_stride_info.pad_right() << ","
1713 << pad_stride_info.pad_top() << "," << pad_stride_info.pad_bottom();
Anthony Barbier2a07e182017-08-04 18:20:27 +01001714
1715 return os;
1716}
1717
Alex Gildayc357c472018-03-21 13:54:09 +00001718/** Formatted output of the PadStrideInfo type.
1719 *
1720 * @param[in] pad_stride_info Type to output.
1721 *
1722 * @return Formatted string.
1723 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001724inline std::string to_string(const PadStrideInfo &pad_stride_info)
1725{
1726 std::stringstream str;
1727 str << pad_stride_info;
1728 return str.str();
1729}
1730
Alex Gildayc357c472018-03-21 13:54:09 +00001731/** Formatted output of the BorderMode type.
1732 *
1733 * @param[in] mode Type to output.
1734 *
1735 * @return Formatted string.
1736 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001737inline std::string to_string(const BorderMode &mode)
1738{
1739 std::stringstream str;
1740 str << mode;
1741 return str.str();
1742}
1743
Alex Gildayc357c472018-03-21 13:54:09 +00001744/** Formatted output of the BorderSize type.
1745 *
1746 * @param[in] border Type to output.
1747 *
1748 * @return Formatted string.
1749 */
John Richardsonb482ce12017-09-18 12:44:01 +01001750inline std::string to_string(const BorderSize &border)
1751{
1752 std::stringstream str;
1753 str << border;
1754 return str.str();
1755}
1756
Giuseppe Rossinid7647d42018-07-17 18:13:13 +01001757/** Formatted output of the PaddingList type.
1758 *
1759 * @param[in] padding Type to output.
1760 *
1761 * @return Formatted string.
1762 */
1763inline std::string to_string(const PaddingList &padding)
1764{
1765 std::stringstream str;
1766 str << padding;
1767 return str.str();
1768}
1769
giuros013175fcf2018-11-21 09:59:17 +00001770/** Formatted output of the Multiples type.
1771 *
1772 * @param[in] multiples Type to output.
1773 *
1774 * @return Formatted string.
1775 */
1776inline std::string to_string(const Multiples &multiples)
1777{
1778 std::stringstream str;
1779 str << multiples;
1780 return str.str();
1781}
1782
Alex Gildayc357c472018-03-21 13:54:09 +00001783/** Formatted output of the InterpolationPolicy type.
1784 *
1785 * @param[in] policy Type to output.
1786 *
1787 * @return Formatted string.
1788 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001789inline std::string to_string(const InterpolationPolicy &policy)
1790{
1791 std::stringstream str;
1792 str << policy;
1793 return str.str();
1794}
1795
Alex Gildayc357c472018-03-21 13:54:09 +00001796/** Formatted output of the SamplingPolicy type.
1797 *
1798 * @param[in] policy Type to output.
1799 *
1800 * @return Formatted string.
1801 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +07001802inline std::string to_string(const SamplingPolicy &policy)
1803{
1804 std::stringstream str;
1805 str << policy;
1806 return str.str();
1807}
1808
Alex Gildayc357c472018-03-21 13:54:09 +00001809/** Formatted output of the ConvertPolicy type.
1810 *
1811 * @param[out] os Output stream.
1812 * @param[in] policy Type to output.
1813 *
1814 * @return Modified output stream.
1815 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001816inline ::std::ostream &operator<<(::std::ostream &os, const ConvertPolicy &policy)
1817{
1818 switch(policy)
1819 {
1820 case ConvertPolicy::WRAP:
1821 os << "WRAP";
1822 break;
1823 case ConvertPolicy::SATURATE:
1824 os << "SATURATE";
1825 break;
1826 default:
1827 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1828 }
1829
1830 return os;
1831}
1832
1833inline std::string to_string(const ConvertPolicy &policy)
1834{
1835 std::stringstream str;
1836 str << policy;
1837 return str.str();
1838}
1839
giuros01164a2722018-11-20 18:34:46 +00001840/** Formatted output of the ArithmeticOperation type.
1841 *
1842 * @param[out] os Output stream.
1843 * @param[in] op Operation to output.
1844 *
1845 * @return Modified output stream.
1846 */
1847inline ::std::ostream &operator<<(::std::ostream &os, const ArithmeticOperation &op)
1848{
1849 switch(op)
1850 {
1851 case ArithmeticOperation::ADD:
1852 os << "ADD";
1853 break;
1854 case ArithmeticOperation::SUB:
1855 os << "SUB";
1856 break;
1857 case ArithmeticOperation::DIV:
1858 os << "DIV";
1859 break;
1860 case ArithmeticOperation::MAX:
1861 os << "MAX";
1862 break;
1863 case ArithmeticOperation::MIN:
1864 os << "MIN";
1865 break;
1866 case ArithmeticOperation::SQUARED_DIFF:
1867 os << "SQUARED_DIFF";
1868 break;
Usama Arif52c54f62019-05-14 10:22:36 +01001869 case ArithmeticOperation::POWER:
1870 os << "POWER";
1871 break;
giuros01164a2722018-11-20 18:34:46 +00001872 default:
1873 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1874 }
1875
1876 return os;
1877}
1878
1879/** Formatted output of the Arithmetic Operation
1880 *
1881 * @param[in] op Type to output.
1882 *
1883 * @return Formatted string.
1884 */
1885inline std::string to_string(const ArithmeticOperation &op)
1886{
1887 std::stringstream str;
1888 str << op;
1889 return str.str();
1890}
1891
Alex Gildayc357c472018-03-21 13:54:09 +00001892/** Formatted output of the Reduction Operations.
1893 *
1894 * @param[out] os Output stream.
1895 * @param[in] op Type to output.
1896 *
1897 * @return Modified output stream.
1898 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001899inline ::std::ostream &operator<<(::std::ostream &os, const ReductionOperation &op)
1900{
1901 switch(op)
1902 {
Michalis Spyrou7e9391b2018-10-05 14:49:28 +01001903 case ReductionOperation::SUM:
1904 os << "SUM";
1905 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +01001906 case ReductionOperation::SUM_SQUARE:
1907 os << "SUM_SQUARE";
1908 break;
Michalis Spyrou7e9391b2018-10-05 14:49:28 +01001909 case ReductionOperation::MEAN_SUM:
1910 os << "MEAN_SUM";
1911 break;
Michalis Spyrou7930db42018-11-22 17:36:28 +00001912 case ReductionOperation::ARG_IDX_MAX:
1913 os << "ARG_IDX_MAX";
1914 break;
1915 case ReductionOperation::ARG_IDX_MIN:
1916 os << "ARG_IDX_MIN";
1917 break;
Manuel Bottinib412fab2018-12-10 17:40:23 +00001918 case ReductionOperation::PROD:
1919 os << "PROD";
1920 break;
Usama Arifa4a08ad2019-05-20 12:38:33 +01001921 case ReductionOperation::MIN:
1922 os << "MIN";
1923 break;
Usama Arif28f0dd92019-05-20 13:44:34 +01001924 case ReductionOperation::MAX:
1925 os << "MAX";
1926 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +01001927 default:
1928 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1929 }
1930
1931 return os;
1932}
1933
Alex Gildayc357c472018-03-21 13:54:09 +00001934/** Formatted output of the Reduction Operations.
1935 *
1936 * @param[in] op Type to output.
1937 *
1938 * @return Formatted string.
1939 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001940inline std::string to_string(const ReductionOperation &op)
1941{
1942 std::stringstream str;
1943 str << op;
1944 return str.str();
1945}
1946
Georgios Pinitas7900a9e2018-11-23 11:44:58 +00001947/** Formatted output of the Comparison Operations.
1948 *
1949 * @param[out] os Output stream.
1950 * @param[in] op Type to output.
1951 *
1952 * @return Modified output stream.
1953 */
1954inline ::std::ostream &operator<<(::std::ostream &os, const ComparisonOperation &op)
1955{
1956 switch(op)
1957 {
1958 case ComparisonOperation::Equal:
1959 os << "Equal";
1960 break;
1961 case ComparisonOperation::NotEqual:
1962 os << "NotEqual";
1963 break;
1964 case ComparisonOperation::Greater:
1965 os << "Greater";
1966 break;
1967 case ComparisonOperation::GreaterEqual:
1968 os << "GreaterEqual";
1969 break;
1970 case ComparisonOperation::Less:
1971 os << "Less";
1972 break;
1973 case ComparisonOperation::LessEqual:
1974 os << "LessEqual";
1975 break;
1976 default:
1977 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1978 }
1979
1980 return os;
1981}
1982
Michalis Spyroue9362622018-11-23 17:41:37 +00001983/** Formatted output of the Elementwise unary Operations.
1984 *
1985 * @param[out] os Output stream.
1986 * @param[in] op Type to output.
1987 *
1988 * @return Modified output stream.
1989 */
1990inline ::std::ostream &operator<<(::std::ostream &os, const ElementWiseUnary &op)
1991{
1992 switch(op)
1993 {
1994 case ElementWiseUnary::RSQRT:
1995 os << "RSQRT";
1996 break;
1997 case ElementWiseUnary::EXP:
1998 os << "EXP";
1999 break;
Usama Arifeb312ef2019-05-13 17:45:54 +01002000 case ElementWiseUnary::NEG:
2001 os << "NEG";
2002 break;
Usama Arifac33d7e2019-05-20 14:21:40 +01002003 case ElementWiseUnary::LOG:
2004 os << "LOG";
2005 break;
ramelg01b1ba1e32021-09-25 11:53:26 +01002006 case ElementWiseUnary::SIN:
2007 os << "SIN";
2008 break;
2009 case ElementWiseUnary::ABS:
2010 os << "ABS";
2011 break;
Usama Arif6a4d5422019-05-24 14:53:59 +01002012 case ElementWiseUnary::ROUND:
2013 os << "ROUND";
2014 break;
ramelg01b1ba1e32021-09-25 11:53:26 +01002015 case ElementWiseUnary::LOGICAL_NOT:
2016 os << "LOGICAL_NOT";
2017 break;
Michalis Spyroue9362622018-11-23 17:41:37 +00002018 default:
2019 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2020 }
2021
2022 return os;
2023}
2024
Georgios Pinitas7900a9e2018-11-23 11:44:58 +00002025/** Formatted output of the Comparison Operations.
2026 *
2027 * @param[in] op Type to output.
2028 *
2029 * @return Formatted string.
2030 */
2031inline std::string to_string(const ComparisonOperation &op)
2032{
2033 std::stringstream str;
2034 str << op;
2035 return str.str();
2036}
2037
Michalis Spyroue9362622018-11-23 17:41:37 +00002038/** Formatted output of the Elementwise unary Operations.
2039 *
2040 * @param[in] op Type to output.
2041 *
2042 * @return Formatted string.
2043 */
2044inline std::string to_string(const ElementWiseUnary &op)
2045{
2046 std::stringstream str;
2047 str << op;
2048 return str.str();
2049}
2050
Alex Gildayc357c472018-03-21 13:54:09 +00002051/** Formatted output of the Norm Type.
2052 *
2053 * @param[in] type Type to output.
2054 *
2055 * @return Formatted string.
2056 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01002057inline std::string to_string(const NormType &type)
2058{
2059 std::stringstream str;
2060 str << type;
2061 return str.str();
2062}
2063
Alex Gildayc357c472018-03-21 13:54:09 +00002064/** Formatted output of the Pooling Type.
2065 *
2066 * @param[in] type Type to output.
2067 *
2068 * @return Formatted string.
2069 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01002070inline std::string to_string(const PoolingType &type)
2071{
2072 std::stringstream str;
2073 str << type;
2074 return str.str();
2075}
2076
Alex Gildayc357c472018-03-21 13:54:09 +00002077/** Formatted output of the Pooling Layer Info.
2078 *
2079 * @param[in] info Type to output.
2080 *
2081 * @return Formatted string.
2082 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01002083inline std::string to_string(const PoolingLayerInfo &info)
2084{
2085 std::stringstream str;
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +00002086 str << "{Type=" << info.pool_type << ","
Sang-Hoon Park11fedda2020-01-15 14:44:04 +00002087 << "DataLayout=" << info.data_layout << ","
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +00002088 << "IsGlobalPooling=" << info.is_global_pooling;
2089 if(!info.is_global_pooling)
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00002090 {
2091 str << ","
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +00002092 << "PoolSize=" << info.pool_size.width << "," << info.pool_size.height << ","
2093 << "PadStride=" << info.pad_stride_info;
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00002094 }
2095 str << "}";
Anthony Barbier2a07e182017-08-04 18:20:27 +01002096 return str.str();
2097}
2098
ramelg0137515692022-02-26 22:06:20 +00002099/** Formatted output of the Size3D type.
2100 *
2101 * @param[out] os Output stream
2102 * @param[in] size Type to output
2103 *
2104 * @return Modified output stream.
2105 */
2106inline ::std::ostream &operator<<(::std::ostream &os, const Size3D &size)
2107{
2108 os << size.width << "x" << size.height << "x" << size.depth;
2109
2110 return os;
2111}
2112
2113/** Formatted output of the Size3D type.
2114 *
2115 * @param[in] type Type to output
2116 *
2117 * @return Formatted string.
2118 */
2119inline std::string to_string(const Size3D &type)
2120{
2121 std::stringstream str;
2122 str << type;
2123 return str.str();
2124}
2125
2126/** Formatted output of the Padding3D type.
2127 *
2128 * @param[out] os Output stream.
2129 * @param[in] padding3d Padding info for 3D spatial dimension shape.
2130 *
2131 * @return Modified output stream.
2132 */
2133inline ::std::ostream &operator<<(::std::ostream &os, const Padding3D &padding3d)
2134{
2135 os << padding3d.left << "," << padding3d.right << ","
2136 << padding3d.top << "," << padding3d.bottom << ","
2137 << padding3d.front << "," << padding3d.back;
2138 return os;
2139}
2140
2141/** Converts a @ref Padding3D to string
2142 *
2143 * @param[in] padding3d Padding3D value to be converted
2144 *
2145 * @return String representing the corresponding Padding3D
2146 */
2147inline std::string to_string(const Padding3D &padding3d)
2148{
2149 std::stringstream str;
2150 str << padding3d;
2151 return str.str();
2152}
2153
2154/** Formatted output of the DimensionRoundingType type.
2155 *
2156 * @param[out] os Output stream.
2157 * @param[in] rounding_type DimensionRoundingType Dimension rounding type when down-scaling, or compute output shape of pooling(2D or 3D).
2158 *
2159 * @return Modified output stream.
2160 */
2161inline ::std::ostream &operator<<(::std::ostream &os, const DimensionRoundingType &rounding_type)
2162{
2163 switch(rounding_type)
2164 {
2165 case DimensionRoundingType::CEIL:
2166 os << "CEIL";
2167 break;
2168 case DimensionRoundingType::FLOOR:
2169 os << "FLOOR";
2170 break;
2171 default:
2172 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2173 }
2174 return os;
2175}
2176
2177/** Formatted output of the Pooling 3d Layer Info.
2178 *
2179 * @param[out] os Output stream.
2180 * @param[in] info Pooling 3D layer info to print to output stream.
2181 *
2182 * @return Modified output stream.
2183 */
2184inline ::std::ostream &operator<<(::std::ostream &os, const Pooling3dLayerInfo &info)
2185{
2186 os << "{Type=" << info.pool_type << ","
2187 << "IsGlobalPooling=" << info.is_global_pooling;
2188 if(!info.is_global_pooling)
2189 {
2190 os << ","
2191 << "PoolSize=" << info.pool_size << ", "
2192 << "Stride=" << info.stride << ", "
2193 << "Padding=" << info.padding << ", "
2194 << "Exclude Padding=" << info.exclude_padding << ", "
2195 << "fp_mixed_precision=" << info.fp_mixed_precision << ", "
2196 << "DimensionRoundingType=" << info.round_type;
2197 }
2198 os << "}";
2199 return os;
2200}
2201
2202/** Formatted output of the Pooling 3d Layer Info.
2203 *
2204 * @param[in] info Type to output.
2205 *
2206 * @return Formatted string.
2207 */
2208inline std::string to_string(const Pooling3dLayerInfo &info)
2209{
2210 std::stringstream str;
2211 str << info;
2212 return str.str();
2213}
2214
Michalis Spyrou6c7c38e2018-08-29 16:28:11 +01002215/** Formatted output of the PriorBoxLayerInfo.
2216 *
2217 * @param[in] info Type to output.
2218 *
2219 * @return Formatted string.
2220 */
2221inline std::string to_string(const PriorBoxLayerInfo &info)
2222{
2223 std::stringstream str;
2224 str << "{";
2225 str << "Clip:" << info.clip()
2226 << "Flip:" << info.flip()
2227 << "StepX:" << info.steps()[0]
2228 << "StepY:" << info.steps()[1]
2229 << "MinSizes:" << info.min_sizes().size()
2230 << "MaxSizes:" << info.max_sizes().size()
2231 << "ImgSizeX:" << info.img_size().x
2232 << "ImgSizeY:" << info.img_size().y
2233 << "Offset:" << info.offset()
2234 << "Variances:" << info.variances().size();
2235 str << "}";
2236 return str.str();
2237}
2238
Alex Gildayc357c472018-03-21 13:54:09 +00002239/** Formatted output of the Size2D type.
2240 *
2241 * @param[out] os Output stream
2242 * @param[in] size Type to output
2243 *
2244 * @return Modified output stream.
2245 */
John Richardson25f23682017-11-27 14:35:09 +00002246inline ::std::ostream &operator<<(::std::ostream &os, const Size2D &size)
2247{
2248 os << size.width << "x" << size.height;
2249
2250 return os;
2251}
2252
Alex Gildayc357c472018-03-21 13:54:09 +00002253/** Formatted output of the Size2D type.
2254 *
2255 * @param[in] type Type to output
2256 *
2257 * @return Formatted string.
2258 */
John Richardson25f23682017-11-27 14:35:09 +00002259inline std::string to_string(const Size2D &type)
2260{
2261 std::stringstream str;
2262 str << type;
2263 return str.str();
2264}
2265
Alex Gildayc357c472018-03-21 13:54:09 +00002266/** Formatted output of the ConvolutionMethod type.
2267 *
2268 * @param[out] os Output stream
2269 * @param[in] conv_method Type to output
2270 *
2271 * @return Modified output stream.
2272 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002273inline ::std::ostream &operator<<(::std::ostream &os, const ConvolutionMethod &conv_method)
2274{
2275 switch(conv_method)
2276 {
2277 case ConvolutionMethod::GEMM:
2278 os << "GEMM";
2279 break;
2280 case ConvolutionMethod::DIRECT:
2281 os << "DIRECT";
2282 break;
2283 case ConvolutionMethod::WINOGRAD:
2284 os << "WINOGRAD";
2285 break;
SiCongLid9287352021-11-03 19:01:22 +00002286 case ConvolutionMethod::FFT:
2287 os << "FFT";
2288 break;
2289 case ConvolutionMethod::GEMM_CONV2D:
2290 os << "GEMM_CONV2D";
2291 break;
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002292 default:
2293 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2294 }
2295
2296 return os;
2297}
2298
Alex Gildayc357c472018-03-21 13:54:09 +00002299/** Formatted output of the ConvolutionMethod type.
2300 *
2301 * @param[in] conv_method Type to output
2302 *
2303 * @return Formatted string.
2304 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002305inline std::string to_string(const ConvolutionMethod &conv_method)
2306{
2307 std::stringstream str;
2308 str << conv_method;
2309 return str.str();
2310}
2311
Alex Gildayc357c472018-03-21 13:54:09 +00002312/** Formatted output of the GPUTarget type.
2313 *
2314 * @param[out] os Output stream
2315 * @param[in] gpu_target Type to output
2316 *
2317 * @return Modified output stream.
2318 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002319inline ::std::ostream &operator<<(::std::ostream &os, const GPUTarget &gpu_target)
2320{
2321 switch(gpu_target)
2322 {
2323 case GPUTarget::GPU_ARCH_MASK:
2324 os << "GPU_ARCH_MASK";
2325 break;
Gian Marco Iodice3c4d0852022-07-11 12:09:45 +01002326 case GPUTarget::GPU_GENERATION_MASK:
2327 os << "GPU_GENERATION_MASK";
2328 break;
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002329 case GPUTarget::MIDGARD:
2330 os << "MIDGARD";
2331 break;
2332 case GPUTarget::BIFROST:
2333 os << "BIFROST";
2334 break;
Georgios Pinitasd5462ff2019-07-03 19:33:57 +01002335 case GPUTarget::VALHALL:
2336 os << "VALHALL";
2337 break;
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002338 case GPUTarget::T600:
2339 os << "T600";
2340 break;
2341 case GPUTarget::T700:
2342 os << "T700";
2343 break;
2344 case GPUTarget::T800:
2345 os << "T800";
2346 break;
Michalis Spyroua9676112018-02-22 18:07:43 +00002347 case GPUTarget::G71:
2348 os << "G71";
2349 break;
2350 case GPUTarget::G72:
2351 os << "G72";
2352 break;
2353 case GPUTarget::G51:
2354 os << "G51";
2355 break;
2356 case GPUTarget::G51BIG:
2357 os << "G51BIG";
2358 break;
2359 case GPUTarget::G51LIT:
2360 os << "G51LIT";
2361 break;
Gian Marco Iodice3c4d0852022-07-11 12:09:45 +01002362 case GPUTarget::G31:
2363 os << "G31";
2364 break;
Georgios Pinitasb03f7c52018-07-12 10:49:53 +01002365 case GPUTarget::G76:
2366 os << "G76";
Michalis Spyroua9676112018-02-22 18:07:43 +00002367 break;
Gian Marco Iodice3c4d0852022-07-11 12:09:45 +01002368 case GPUTarget::G52:
2369 os << "G52";
2370 break;
2371 case GPUTarget::G52LIT:
2372 os << "G52LIT";
2373 break;
Georgios Pinitasd5462ff2019-07-03 19:33:57 +01002374 case GPUTarget::G77:
2375 os << "G77";
Michalis Spyroua9676112018-02-22 18:07:43 +00002376 break;
Gian Marco Iodice3c4d0852022-07-11 12:09:45 +01002377 case GPUTarget::G57:
2378 os << "G57";
2379 break;
Georgios Pinitas4ffc42a2020-12-01 16:28:24 +00002380 case GPUTarget::G78:
2381 os << "G78";
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002382 break;
Gian Marco Iodice3c4d0852022-07-11 12:09:45 +01002383 case GPUTarget::G68:
2384 os << "G68";
2385 break;
2386 case GPUTarget::G78AE:
2387 os << "G78AE";
Pablo Marquez Tellob1496e62021-06-25 14:49:37 +01002388 break;
Gian Marco Iodiceab2bc732022-01-19 10:06:45 +00002389 case GPUTarget::G710:
2390 os << "G710";
Georgios Pinitasd5462ff2019-07-03 19:33:57 +01002391 break;
Gian Marco Iodice3c4d0852022-07-11 12:09:45 +01002392 case GPUTarget::G610:
2393 os << "G610";
2394 break;
2395 case GPUTarget::G510:
2396 os << "G510";
2397 break;
2398 case GPUTarget::G310:
2399 os << "G310";
2400 break;
Gunes Bayir4bfc70e2021-12-10 16:17:56 +00002401 case GPUTarget::G715:
2402 os << "G715";
2403 break;
2404 case GPUTarget::G615:
2405 os << "G615";
2406 break;
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002407 default:
2408 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2409 }
2410
2411 return os;
2412}
2413
Alex Gildayc357c472018-03-21 13:54:09 +00002414/** Formatted output of the GPUTarget type.
2415 *
2416 * @param[in] gpu_target Type to output
2417 *
2418 * @return Formatted string.
2419 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002420inline std::string to_string(const GPUTarget &gpu_target)
2421{
2422 std::stringstream str;
2423 str << gpu_target;
2424 return str.str();
2425}
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00002426
John Richardson8de92612018-02-22 14:09:31 +00002427/** Formatted output of the DetectionWindow type.
2428 *
2429 * @param[out] os Output stream
2430 * @param[in] detection_window Type to output
2431 *
2432 * @return Modified output stream.
2433 */
John Richardson684cb0f2018-01-09 11:17:00 +00002434inline ::std::ostream &operator<<(::std::ostream &os, const DetectionWindow &detection_window)
2435{
2436 os << "{x=" << detection_window.x << ","
2437 << "y=" << detection_window.y << ","
2438 << "width=" << detection_window.width << ","
2439 << "height=" << detection_window.height << ","
2440 << "idx_class=" << detection_window.idx_class << ","
2441 << "score=" << detection_window.score << "}";
2442
2443 return os;
2444}
2445
Isabella Gottardi05e56442018-11-16 11:26:52 +00002446/** Formatted output of the DetectionOutputLayerCodeType type.
2447 *
2448 * @param[out] os Output stream
2449 * @param[in] detection_code Type to output
2450 *
2451 * @return Modified output stream.
2452 */
2453inline ::std::ostream &operator<<(::std::ostream &os, const DetectionOutputLayerCodeType &detection_code)
2454{
2455 switch(detection_code)
2456 {
2457 case DetectionOutputLayerCodeType::CENTER_SIZE:
2458 os << "CENTER_SIZE";
2459 break;
2460 case DetectionOutputLayerCodeType::CORNER:
2461 os << "CORNER";
2462 break;
2463 case DetectionOutputLayerCodeType::CORNER_SIZE:
2464 os << "CORNER_SIZE";
2465 break;
2466 case DetectionOutputLayerCodeType::TF_CENTER:
2467 os << "TF_CENTER";
2468 break;
2469 default:
2470 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2471 }
2472
2473 return os;
2474}
2475/** Formatted output of the DetectionOutputLayerCodeType type.
2476 *
2477 * @param[in] detection_code Type to output
2478 *
2479 * @return Formatted string.
2480 */
2481inline std::string to_string(const DetectionOutputLayerCodeType &detection_code)
2482{
2483 std::stringstream str;
2484 str << detection_code;
2485 return str.str();
2486}
2487
2488/** Formatted output of the DetectionOutputLayerInfo type.
2489 *
2490 * @param[out] os Output stream
2491 * @param[in] detection_info Type to output
2492 *
2493 * @return Modified output stream.
2494 */
2495inline ::std::ostream &operator<<(::std::ostream &os, const DetectionOutputLayerInfo &detection_info)
2496{
2497 os << "{Classes=" << detection_info.num_classes() << ","
2498 << "ShareLocation=" << detection_info.share_location() << ","
2499 << "CodeType=" << detection_info.code_type() << ","
2500 << "VarianceEncodedInTarget=" << detection_info.variance_encoded_in_target() << ","
2501 << "KeepTopK=" << detection_info.keep_top_k() << ","
2502 << "NMSThreshold=" << detection_info.nms_threshold() << ","
2503 << "Eta=" << detection_info.eta() << ","
2504 << "BackgroundLabelId=" << detection_info.background_label_id() << ","
2505 << "ConfidenceThreshold=" << detection_info.confidence_threshold() << ","
2506 << "TopK=" << detection_info.top_k() << ","
2507 << "NumLocClasses=" << detection_info.num_loc_classes()
2508 << "}";
2509
2510 return os;
2511}
2512
2513/** Formatted output of the DetectionOutputLayerInfo type.
2514 *
2515 * @param[in] detection_info Type to output
2516 *
2517 * @return Formatted string.
2518 */
2519inline std::string to_string(const DetectionOutputLayerInfo &detection_info)
2520{
2521 std::stringstream str;
2522 str << detection_info;
2523 return str.str();
2524}
Isabella Gottardia7acb3c2019-01-08 13:48:44 +00002525/** Formatted output of the DetectionPostProcessLayerInfo type.
2526 *
2527 * @param[out] os Output stream
2528 * @param[in] detection_info Type to output
2529 *
2530 * @return Modified output stream.
2531 */
2532inline ::std::ostream &operator<<(::std::ostream &os, const DetectionPostProcessLayerInfo &detection_info)
2533{
2534 os << "{MaxDetections=" << detection_info.max_detections() << ","
2535 << "MaxClassesPerDetection=" << detection_info.max_classes_per_detection() << ","
2536 << "NmsScoreThreshold=" << detection_info.nms_score_threshold() << ","
2537 << "NmsIouThreshold=" << detection_info.iou_threshold() << ","
2538 << "NumClasses=" << detection_info.num_classes() << ","
2539 << "ScaleValue_y=" << detection_info.scale_value_y() << ","
2540 << "ScaleValue_x=" << detection_info.scale_value_x() << ","
2541 << "ScaleValue_h=" << detection_info.scale_value_h() << ","
2542 << "ScaleValue_w=" << detection_info.scale_value_w() << ","
2543 << "UseRegularNms=" << detection_info.use_regular_nms() << ","
2544 << "DetectionPerClass=" << detection_info.detection_per_class()
2545 << "}";
2546
2547 return os;
2548}
2549
2550/** Formatted output of the DetectionPostProcessLayerInfo type.
2551 *
2552 * @param[in] detection_info Type to output
2553 *
2554 * @return Formatted string.
2555 */
2556inline std::string to_string(const DetectionPostProcessLayerInfo &detection_info)
2557{
2558 std::stringstream str;
2559 str << detection_info;
2560 return str.str();
2561}
Georgios Pinitasc6f95102021-03-30 10:03:01 +01002562
John Richardson8de92612018-02-22 14:09:31 +00002563/** Formatted output of the DetectionWindow type.
2564 *
2565 * @param[in] detection_window Type to output
2566 *
2567 * @return Formatted string.
2568 */
2569inline std::string to_string(const DetectionWindow &detection_window)
2570{
2571 std::stringstream str;
2572 str << detection_window;
2573 return str.str();
2574}
2575
Michalis Spyrou6c7c38e2018-08-29 16:28:11 +01002576/** Formatted output of @ref PriorBoxLayerInfo.
2577 *
2578 * @param[out] os Output stream.
2579 * @param[in] info Type to output.
2580 *
2581 * @return Modified output stream.
2582 */
2583inline ::std::ostream &operator<<(::std::ostream &os, const PriorBoxLayerInfo &info)
2584{
2585 os << "Clip:" << info.clip()
2586 << "Flip:" << info.flip()
2587 << "StepX:" << info.steps()[0]
2588 << "StepY:" << info.steps()[1]
2589 << "MinSizes:" << info.min_sizes()
2590 << "MaxSizes:" << info.max_sizes()
2591 << "ImgSizeX:" << info.img_size().x
2592 << "ImgSizeY:" << info.img_size().y
2593 << "Offset:" << info.offset()
2594 << "Variances:" << info.variances();
2595
2596 return os;
2597}
2598
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00002599/** Formatted output of the WinogradInfo type. */
2600inline ::std::ostream &operator<<(::std::ostream &os, const WinogradInfo &info)
2601{
2602 os << "{OutputTileSize=" << info.output_tile_size << ","
2603 << "KernelSize=" << info.kernel_size << ","
2604 << "PadStride=" << info.convolution_info << ","
2605 << "OutputDataLayout=" << info.output_data_layout << "}";
2606
2607 return os;
2608}
2609
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00002610inline std::string to_string(const WinogradInfo &type)
2611{
2612 std::stringstream str;
2613 str << type;
2614 return str.str();
2615}
Anthony Barbier671a11e2018-07-06 15:11:36 +01002616
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +01002617/** Convert a CLTunerMode value to a string
2618 *
2619 * @param val CLTunerMode value to be converted
2620 *
2621 * @return String representing the corresponding CLTunerMode.
2622 */
2623inline std::string to_string(const CLTunerMode val)
2624{
2625 switch(val)
2626 {
2627 case CLTunerMode::EXHAUSTIVE:
2628 {
2629 return std::string("Exhaustive");
2630 }
2631 case CLTunerMode::NORMAL:
2632 {
2633 return std::string("Normal");
2634 }
2635 case CLTunerMode::RAPID:
2636 {
2637 return std::string("Rapid");
2638 }
2639 default:
2640 {
2641 ARM_COMPUTE_ERROR("Invalid tuner mode.");
2642 return std::string("UNDEFINED");
2643 }
2644 }
2645}
SiCong Lidb4a6c12021-02-05 09:30:57 +00002646/** Converts a @ref CLGEMMKernelType to string
2647 *
2648 * @param[in] val CLGEMMKernelType value to be converted
2649 *
2650 * @return String representing the corresponding CLGEMMKernelType
2651 */
2652inline std::string to_string(CLGEMMKernelType val)
2653{
2654 switch(val)
2655 {
SiCong Lidb4a6c12021-02-05 09:30:57 +00002656 case CLGEMMKernelType::NATIVE:
2657 {
2658 return "Native";
2659 }
2660 case CLGEMMKernelType::RESHAPED_ONLY_RHS:
2661 {
2662 return "Reshaped_Only_RHS";
2663 }
2664 case CLGEMMKernelType::RESHAPED:
2665 {
2666 return "Reshaped";
2667 }
2668 default:
2669 {
2670 return "Unknown";
2671 }
2672 }
2673}
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +01002674/** [Print CLTunerMode type] **/
2675/** Formatted output of the CLTunerMode type.
2676 *
2677 * @param[out] os Output stream.
2678 * @param[in] val CLTunerMode to output.
2679 *
2680 * @return Modified output stream.
2681 */
2682inline ::std::ostream &operator<<(::std::ostream &os, const CLTunerMode &val)
2683{
2684 os << to_string(val);
2685 return os;
2686}
2687
ramelg013ae3d882021-09-12 23:07:47 +01002688/** Formatted output of the ConvolutionInfo type.
2689 *
2690 * @param[out] os Output stream.
2691 * @param[in] conv_info ConvolutionInfo to output.
2692 *
2693 * @return Modified output stream.
2694 */
2695inline ::std::ostream &operator<<(::std::ostream &os, const ConvolutionInfo &conv_info)
2696{
SiCongLi579ca842021-10-18 09:38:33 +01002697 os << "{PadStrideInfo=" << conv_info.pad_stride_info << ", "
2698 << "depth_multiplier=" << conv_info.depth_multiplier << ", "
2699 << "act_info=" << to_string(conv_info.act_info) << ", "
2700 << "dilation=" << conv_info.dilation << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002701 return os;
2702}
2703
2704/** Converts a @ref ConvolutionInfo to string
2705 *
2706 * @param[in] info ConvolutionInfo value to be converted
2707 *
2708 * @return String representing the corresponding ConvolutionInfo
2709 */
2710inline std::string to_string(const ConvolutionInfo &info)
2711{
2712 std::stringstream str;
2713 str << info;
2714 return str.str();
2715}
2716
2717/** Formatted output of the FullyConnectedLayerInfo type.
2718 *
2719 * @param[out] os Output stream.
2720 * @param[in] layer_info FullyConnectedLayerInfo to output.
2721 *
2722 * @return Modified output stream.
2723 */
2724inline ::std::ostream &operator<<(::std::ostream &os, const FullyConnectedLayerInfo &layer_info)
2725{
SiCongLi579ca842021-10-18 09:38:33 +01002726 os << "{activation_info=" << to_string(layer_info.activation_info) << ", "
2727 << "weights_trained_layout=" << layer_info.weights_trained_layout << ", "
2728 << "transpose_weights=" << layer_info.transpose_weights << ", "
2729 << "are_weights_reshaped=" << layer_info.are_weights_reshaped << ", "
2730 << "retain_internal_weights=" << layer_info.retain_internal_weights << ", "
2731 << "constant_weights=" << layer_info.transpose_weights << ", "
2732 << "fp_mixed_precision=" << layer_info.fp_mixed_precision << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002733 return os;
2734}
2735
2736/** Converts a @ref FullyConnectedLayerInfo to string
2737 *
2738 * @param[in] info FullyConnectedLayerInfo value to be converted
2739 *
2740 * @return String representing the corresponding FullyConnectedLayerInfo
2741 */
2742inline std::string to_string(const FullyConnectedLayerInfo &info)
2743{
2744 std::stringstream str;
2745 str << info;
2746 return str.str();
2747}
2748
2749/** Formatted output of the GEMMLowpOutputStageType type.
2750 *
2751 * @param[out] os Output stream.
2752 * @param[in] gemm_type GEMMLowpOutputStageType to output.
2753 *
2754 * @return Modified output stream.
2755 */
2756inline ::std::ostream &operator<<(::std::ostream &os, const GEMMLowpOutputStageType &gemm_type)
2757{
2758 switch(gemm_type)
2759 {
2760 case GEMMLowpOutputStageType::NONE:
2761 os << "NONE";
2762 break;
2763 case GEMMLowpOutputStageType::QUANTIZE_DOWN:
2764 os << "QUANTIZE_DOWN";
2765 break;
2766 case GEMMLowpOutputStageType::QUANTIZE_DOWN_FIXEDPOINT:
2767 os << "QUANTIZE_DOWN_FIXEDPOINT";
2768 break;
2769 case GEMMLowpOutputStageType::QUANTIZE_DOWN_FLOAT:
2770 os << "QUANTIZE_DOWN_FLOAT";
2771 break;
2772 default:
2773 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2774 }
2775 return os;
2776}
2777
2778/** Converts a @ref GEMMLowpOutputStageType to string
2779 *
2780 * @param[in] gemm_type GEMMLowpOutputStageType value to be converted
2781 *
2782 * @return String representing the corresponding GEMMLowpOutputStageType
2783 */
2784inline std::string to_string(const GEMMLowpOutputStageType &gemm_type)
2785{
2786 std::stringstream str;
2787 str << gemm_type;
2788 return str.str();
2789}
2790
2791/** Formatted output of the GEMMLowpOutputStageInfo type.
2792 *
2793 * @param[out] os Output stream.
2794 * @param[in] gemm_info GEMMLowpOutputStageInfo to output.
2795 *
2796 * @return Modified output stream.
2797 */
2798inline ::std::ostream &operator<<(::std::ostream &os, const GEMMLowpOutputStageInfo &gemm_info)
2799{
SiCongLi579ca842021-10-18 09:38:33 +01002800 os << "{type=" << gemm_info.type << ", "
2801 << "gemlowp_offset=" << gemm_info.gemmlowp_offset << ", "
2802 << "gemmlowp_multiplier=" << gemm_info.gemmlowp_multiplier << ", "
2803 << "gemmlowp_shift=" << gemm_info.gemmlowp_shift << ", "
2804 << "gemmlowp_min_bound=" << gemm_info.gemmlowp_min_bound << ", "
2805 << "gemmlowp_max_bound=" << gemm_info.gemmlowp_max_bound << ", "
2806 << "gemmlowp_multipliers=" << gemm_info.gemmlowp_multiplier << ", "
2807 << "gemmlowp_shifts=" << gemm_info.gemmlowp_shift << ", "
2808 << "gemmlowp_real_multiplier=" << gemm_info.gemmlowp_real_multiplier << ", "
2809 << "is_quantized_per_channel=" << gemm_info.is_quantized_per_channel << ", "
2810 << "output_data_type=" << gemm_info.output_data_type << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002811 return os;
2812}
2813
2814/** Converts a @ref GEMMLowpOutputStageInfo to string
2815 *
2816 * @param[in] gemm_info GEMMLowpOutputStageInfo value to be converted
2817 *
2818 * @return String representing the corresponding GEMMLowpOutputStageInfo
2819 */
2820inline std::string to_string(const GEMMLowpOutputStageInfo &gemm_info)
2821{
2822 std::stringstream str;
2823 str << gemm_info;
2824 return str.str();
2825}
2826
2827/** Formatted output of the Conv2dInfo type.
2828 *
2829 * @param[out] os Output stream.
2830 * @param[in] conv_info Conv2dInfo to output.
2831 *
2832 * @return Modified output stream.
2833 */
2834inline ::std::ostream &operator<<(::std::ostream &os, const Conv2dInfo &conv_info)
2835{
SiCongLi579ca842021-10-18 09:38:33 +01002836 os << "{conv_info=" << conv_info.conv_info << ", "
2837 << "dilation=" << conv_info.dilation << ", "
2838 << "act_info=" << to_string(conv_info.act_info) << ", "
2839 << "enable_fast_math=" << conv_info.enable_fast_math << ", "
2840 << "num_groups=" << conv_info.num_groups << ","
2841 << "post_ops=" << conv_info.post_ops << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002842 return os;
2843}
2844
2845/** Converts a @ref Conv2dInfo to string
2846 *
2847 * @param[in] conv_info Conv2dInfo value to be converted
2848 *
2849 * @return String representing the corresponding Conv2dInfo
2850 */
2851inline std::string to_string(const Conv2dInfo &conv_info)
2852{
2853 std::stringstream str;
2854 str << conv_info;
2855 return str.str();
2856}
2857
2858/** Formatted output of the PixelValue type.
2859 *
2860 * @param[out] os Output stream.
2861 * @param[in] pixel_value PixelValue to output.
2862 *
2863 * @return Modified output stream.
2864 */
2865inline ::std::ostream &operator<<(::std::ostream &os, const PixelValue &pixel_value)
2866{
SiCongLi579ca842021-10-18 09:38:33 +01002867 os << "{value.u64=" << pixel_value.get<uint64_t>() << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002868 return os;
2869}
2870
2871/** Converts a @ref PixelValue to string
2872 *
2873 * @param[in] pixel_value PixelValue value to be converted
2874 *
2875 * @return String representing the corresponding PixelValue
2876 */
2877inline std::string to_string(const PixelValue &pixel_value)
2878{
2879 std::stringstream str;
2880 str << pixel_value;
2881 return str.str();
2882}
2883
2884/** Formatted output of the ScaleKernelInfo type.
2885 *
2886 * @param[out] os Output stream.
2887 * @param[in] scale_info ScaleKernelInfo to output.
2888 *
2889 * @return Modified output stream.
2890 */
2891inline ::std::ostream &operator<<(::std::ostream &os, const ScaleKernelInfo &scale_info)
2892{
SiCongLi579ca842021-10-18 09:38:33 +01002893 os << "{interpolation_policy=" << scale_info.interpolation_policy << ", "
2894 << "BorderMode=" << scale_info.border_mode << ", "
2895 << "PixelValue=" << scale_info.constant_border_value << ", "
2896 << "SamplingPolicy=" << scale_info.sampling_policy << ", "
2897 << "use_padding=" << scale_info.use_padding << ", "
2898 << "align_corners=" << scale_info.align_corners << ", "
2899 << "data_layout=" << scale_info.data_layout << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002900 return os;
2901}
2902
2903/** Converts a @ref ScaleKernelInfo to string
2904 *
2905 * @param[in] scale_info ScaleKernelInfo value to be converted
2906 *
2907 * @return String representing the corresponding ScaleKernelInfo
2908 */
2909inline std::string to_string(const ScaleKernelInfo &scale_info)
2910{
2911 std::stringstream str;
2912 str << scale_info;
2913 return str.str();
2914}
2915
2916/** Formatted output of the FFTDirection type.
2917 *
2918 * @param[out] os Output stream.
2919 * @param[in] fft_dir FFTDirection to output.
2920 *
2921 * @return Modified output stream.
2922 */
2923inline ::std::ostream &operator<<(::std::ostream &os, const FFTDirection &fft_dir)
2924{
2925 switch(fft_dir)
2926 {
2927 case FFTDirection::Forward:
2928 os << "Forward";
2929 break;
2930 case FFTDirection::Inverse:
2931 os << "Inverse";
2932 break;
2933 default:
2934 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2935 }
2936 return os;
2937}
2938
2939/** Converts a @ref FFT1DInfo to string
2940 *
2941 * @param[in] fft_dir FFT1DInfo value to be converted
2942 *
2943 * @return String representing the corresponding FFT1DInfo
2944 */
2945inline std::string to_string(const FFTDirection &fft_dir)
2946{
2947 std::stringstream str;
ramelg01cbbb0382021-09-17 17:36:57 +01002948 str << "{" << fft_dir << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002949 return str.str();
2950}
2951
2952/** Formatted output of the FFT1DInfo type.
2953 *
2954 * @param[out] os Output stream.
2955 * @param[in] fft1d_info FFT1DInfo to output.
2956 *
2957 * @return Modified output stream.
2958 */
2959inline ::std::ostream &operator<<(::std::ostream &os, const FFT1DInfo &fft1d_info)
2960{
SiCongLi579ca842021-10-18 09:38:33 +01002961 os << "{axis=" << fft1d_info.axis << ", "
2962 << "direction=" << fft1d_info.direction << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002963 return os;
2964}
2965
2966/** Converts a @ref FFT1DInfo to string
2967 *
2968 * @param[in] fft1d_info FFT1DInfo value to be converted
2969 *
2970 * @return String representing the corresponding FFT1DInfo
2971 */
2972inline std::string to_string(const FFT1DInfo &fft1d_info)
2973{
2974 std::stringstream str;
2975 str << fft1d_info;
2976 return str.str();
2977}
2978
2979/** Formatted output of the FFT2DInfo type.
2980 *
2981 * @param[out] os Output stream.
2982 * @param[in] fft2d_info FFT2DInfo to output.
2983 *
2984 * @return Modified output stream.
2985 */
2986inline ::std::ostream &operator<<(::std::ostream &os, const FFT2DInfo &fft2d_info)
2987{
SiCongLi579ca842021-10-18 09:38:33 +01002988 os << "{axis=" << fft2d_info.axis0 << ", "
2989 << "axis=" << fft2d_info.axis1 << ", "
2990 << "direction=" << fft2d_info.direction << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002991 return os;
2992}
2993
2994/** Converts a @ref FFT2DInfo to string
2995 *
2996 * @param[in] fft2d_info FFT2DInfo value to be converted
2997 *
2998 * @return String representing the corresponding FFT2DInfo
2999 */
3000inline std::string to_string(const FFT2DInfo &fft2d_info)
3001{
3002 std::stringstream str;
3003 str << fft2d_info;
3004 return str.str();
3005}
3006
3007/** Formatted output of the Coordinates2D type.
3008 *
3009 * @param[out] os Output stream.
3010 * @param[in] coord_2d Coordinates2D to output.
3011 *
3012 * @return Modified output stream.
3013 */
3014inline ::std::ostream &operator<<(::std::ostream &os, const Coordinates2D &coord_2d)
3015{
SiCongLi579ca842021-10-18 09:38:33 +01003016 os << "{x=" << coord_2d.x << ", "
3017 << "y=" << coord_2d.y << "}";
ramelg013ae3d882021-09-12 23:07:47 +01003018 return os;
3019}
3020
3021/** Converts a @ref Coordinates2D to string
3022 *
3023 * @param[in] coord_2d Coordinates2D value to be converted
3024 *
3025 * @return String representing the corresponding Coordinates2D
3026 */
3027inline std::string to_string(const Coordinates2D &coord_2d)
3028{
3029 std::stringstream str;
3030 str << coord_2d;
3031 return str.str();
3032}
3033
3034/** Formatted output of the FuseBatchNormalizationType type.
3035 *
3036 * @param[out] os Output stream.
3037 * @param[in] fuse_type FuseBatchNormalizationType to output.
3038 *
3039 * @return Modified output stream.
3040 */
3041inline ::std::ostream &operator<<(::std::ostream &os, const FuseBatchNormalizationType &fuse_type)
3042{
3043 switch(fuse_type)
3044 {
3045 case FuseBatchNormalizationType::CONVOLUTION:
3046 os << "CONVOLUTION";
3047 break;
3048 case FuseBatchNormalizationType::DEPTHWISECONVOLUTION:
3049 os << "DEPTHWISECONVOLUTION";
3050 break;
3051 default:
3052 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
3053 }
3054 return os;
3055}
3056
3057/** Converts a @ref FuseBatchNormalizationType to string
3058 *
3059 * @param[in] fuse_type FuseBatchNormalizationType value to be converted
3060 *
3061 * @return String representing the corresponding FuseBatchNormalizationType
3062 */
3063inline std::string to_string(const FuseBatchNormalizationType &fuse_type)
3064{
3065 std::stringstream str;
3066 str << fuse_type;
3067 return str.str();
3068}
3069
ramelg01cbbb0382021-09-17 17:36:57 +01003070/** Formatted output of the SoftmaxKernelInfo type.
3071 *
3072 * @param[out] os Output stream.
3073 * @param[in] info SoftmaxKernelInfo to output.
3074 *
3075 * @return Modified output stream.
3076 */
3077inline ::std::ostream &operator<<(::std::ostream &os, const SoftmaxKernelInfo &info)
3078{
SiCongLi579ca842021-10-18 09:38:33 +01003079 os << "{beta=" << info.beta << ", "
3080 << "is_log=" << info.is_log << ", "
3081 << "input_data_type=" << info.input_data_type << ", "
3082 << "axis=" << info.axis << "}";
ramelg01cbbb0382021-09-17 17:36:57 +01003083 return os;
3084}
3085
3086/** Converts a @ref SoftmaxKernelInfo to string
3087 *
3088 * @param[in] info SoftmaxKernelInfo value to be converted
3089 *
3090 * @return String representing the corresponding SoftmaxKernelInfo
3091 */
3092inline std::string to_string(const SoftmaxKernelInfo &info)
3093{
3094 std::stringstream str;
3095 str << info;
3096 return str.str();
3097}
3098
3099/** Formatted output of the ScaleKernelInfo type.
3100 *
3101 * @param[out] os Output stream.
3102 * @param[in] lstm_params LSTMParams to output.
3103 *
3104 * @return Modified output stream.
3105 */
3106template <typename T>
ramelg014a6d9e82021-10-02 14:34:36 +01003107::std::ostream &operator<<(::std::ostream &os, const LSTMParams<T> &lstm_params)
ramelg01cbbb0382021-09-17 17:36:57 +01003108{
ramelg014a6d9e82021-10-02 14:34:36 +01003109 os << "{input_to_input_weights=" << to_string(lstm_params.input_to_input_weights()) << ", "
3110 << "recurrent_to_input_weights=" << to_string(lstm_params.recurrent_to_input_weights()) << ", "
3111 << "cell_to_input_weights=" << to_string(lstm_params.cell_to_input_weights()) << ", "
3112 << "input_gate_bias=" << to_string(lstm_params.input_gate_bias()) << ", "
3113 << "cell_to_forget_weights=" << to_string(lstm_params.cell_to_forget_weights()) << ", "
3114 << "cell_to_output_weights=" << to_string(lstm_params.cell_to_output_weights()) << ", "
3115 << "projection_weights=" << to_string(lstm_params.projection_weights()) << ", "
3116 << "projection_bias=" << to_string(lstm_params.projection_bias()) << ", "
3117 << "input_layer_norm_weights=" << to_string(lstm_params.input_layer_norm_weights()) << ", "
3118 << "forget_layer_norm_weights=" << to_string(lstm_params.forget_layer_norm_weights()) << ", "
3119 << "cell_layer_norm_weights=" << to_string(lstm_params.cell_layer_norm_weights()) << ", "
3120 << "output_layer_norm_weights=" << to_string(lstm_params.output_layer_norm_weights()) << ", "
ramelg01cbbb0382021-09-17 17:36:57 +01003121 << "cell_clip=" << lstm_params.cell_clip() << ", "
3122 << "projection_clip=" << lstm_params.projection_clip() << ", "
3123 << "input_intermediate_scale=" << lstm_params.input_intermediate_scale() << ", "
3124 << "forget_intermediate_scale=" << lstm_params.forget_intermediate_scale() << ", "
3125 << "cell_intermediate_scale=" << lstm_params.cell_intermediate_scale() << ", "
3126 << "hidden_state_zero=" << lstm_params.hidden_state_zero() << ", "
3127 << "hidden_state_scale=" << lstm_params.hidden_state_scale() << ", "
3128 << "has_peephole_opt=" << lstm_params.has_peephole_opt() << ", "
3129 << "has_projection=" << lstm_params.has_projection() << ", "
3130 << "has_cifg_opt=" << lstm_params.has_cifg_opt() << ", "
3131 << "use_layer_norm=" << lstm_params.use_layer_norm() << "}";
3132 return os;
3133}
3134
3135/** Converts a @ref LSTMParams to string
3136 *
3137 * @param[in] lstm_params LSTMParams<T> value to be converted
3138 *
3139 * @return String representing the corresponding LSTMParams
3140 */
3141template <typename T>
ramelg014a6d9e82021-10-02 14:34:36 +01003142std::string to_string(const LSTMParams<T> &lstm_params)
ramelg01cbbb0382021-09-17 17:36:57 +01003143{
3144 std::stringstream str;
3145 str << lstm_params;
3146 return str.str();
3147}
3148
3149/** Converts a @ref LSTMParams to string
3150 *
3151 * @param[in] num uint8_t value to be converted
3152 *
3153 * @return String representing the corresponding uint8_t
3154 */
3155inline std::string to_string(const uint8_t num)
3156{
3157 // Explicity cast the uint8_t to signed integer and call the corresponding overloaded to_string() function.
3158 return ::std::to_string(static_cast<int>(num));
3159}
3160
ramelg014a6d9e82021-10-02 14:34:36 +01003161/** Available non maxima suppression types */
3162/** Formatted output of the NMSType type.
3163 *
3164 * @param[out] os Output stream.
3165 * @param[in] nms_type NMSType to output.
3166 *
3167 * @return Modified output stream.
3168 */
3169inline ::std::ostream &operator<<(::std::ostream &os, const NMSType &nms_type)
3170{
3171 switch(nms_type)
3172 {
3173 case NMSType::LINEAR:
3174 os << "LINEAR";
3175 break;
3176 case NMSType::GAUSSIAN:
3177 os << "GAUSSIAN";
3178 break;
3179 case NMSType::ORIGINAL:
3180 os << "ORIGINAL";
3181 break;
3182 default:
3183 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
3184 }
3185 return os;
3186}
3187
3188/** Converts a @ref NMSType to string
3189 *
3190 * @param[in] nms_type NMSType value to be converted
3191 *
3192 * @return String representing the corresponding NMSType
3193 */
3194inline std::string to_string(const NMSType nms_type)
3195{
3196 std::stringstream str;
3197 str << nms_type;
3198 return str.str();
3199}
3200
3201/** Formatted output of the BoxNMSLimitInfo type.
3202 *
3203 * @param[out] os Output stream.
3204 * @param[in] info BoxNMSLimitInfo to output.
3205 *
3206 * @return Modified output stream.
3207 */
3208inline ::std::ostream &operator<<(::std::ostream &os, const BoxNMSLimitInfo &info)
3209{
SiCongLi579ca842021-10-18 09:38:33 +01003210 os << "{score_thresh=" << info.score_thresh() << ", "
3211 << "nms=" << info.nms() << ", "
3212 << "detections_per_im=" << info.detections_per_im() << ", "
3213 << "soft_nms_enabled=" << info.soft_nms_enabled() << ", "
3214 << "soft_nms_min_score_thres=" << info.soft_nms_min_score_thres() << ", "
3215 << "suppress_size=" << info.suppress_size() << ", "
3216 << "min_size=" << info.min_size() << ", "
3217 << "im_width=" << info.im_width() << ", "
3218 << "im_height=" << info.im_height() << "}";
ramelg014a6d9e82021-10-02 14:34:36 +01003219 return os;
3220}
3221
3222/** Converts a @ref BoxNMSLimitInfo to string
3223 *
3224 * @param[in] info BoxNMSLimitInfo value to be converted
3225 *
3226 * @return String representing the corresponding BoxNMSLimitInfo
3227 */
3228inline std::string to_string(const BoxNMSLimitInfo &info)
3229{
3230 std::stringstream str;
3231 str << info;
3232 return str.str();
3233}
3234
Giorgio Arena945ae9e2021-10-13 11:13:04 +01003235/** Converts a @ref DimensionRoundingType to string
3236 *
3237 * @param[in] rounding_type DimensionRoundingType value to be converted
3238 *
3239 * @return String representing the corresponding DimensionRoundingType
3240 */
3241inline std::string to_string(const DimensionRoundingType &rounding_type)
3242{
3243 std::stringstream str;
3244 str << rounding_type;
3245 return str.str();
3246}
3247
Giorgio Arena945ae9e2021-10-13 11:13:04 +01003248/** Formatted output of the Conv3dInfo type.
3249 *
3250 * @param[out] os Output stream.
3251 * @param[in] conv3d_info Type to output.
3252 *
3253 * @return Modified output stream.
3254 */
3255inline ::std::ostream &operator<<(::std::ostream &os, const Conv3dInfo &conv3d_info)
3256{
3257 os << conv3d_info.stride;
3258 os << ";";
3259 os << conv3d_info.padding;
3260 os << ";";
3261 os << to_string(conv3d_info.act_info);
3262 os << ";";
3263 os << conv3d_info.dilation;
3264 os << ";";
3265 os << conv3d_info.round_type;
3266 os << ";";
3267 os << conv3d_info.enable_fast_math;
3268
3269 return os;
3270}
3271
3272/** Formatted output of the Conv3dInfo type.
3273 *
3274 * @param[in] conv3d_info Type to output.
3275 *
3276 * @return Formatted string.
3277 */
3278inline std::string to_string(const Conv3dInfo &conv3d_info)
3279{
3280 std::stringstream str;
3281 str << conv3d_info;
3282 return str.str();
3283}
3284
Ramy Elgammal91780022022-07-20 14:57:37 +01003285/** Formatted output of the arm_compute::WeightFormat type.
3286 *
3287 * @param[in] wf arm_compute::WeightFormat Type to output.
3288 *
3289 * @return Formatted string.
3290 */
3291inline std::string to_string(const WeightFormat wf)
Francesco Petrogalli553f6952022-06-30 10:22:01 +00003292{
Ramy Elgammal91780022022-07-20 14:57:37 +01003293#define __CASE_WEIGHT_FORMAT(wf) \
3294case WeightFormat::wf: \
3295 return #wf;
3296 switch(wf)
3297 {
3298 __CASE_WEIGHT_FORMAT(UNSPECIFIED)
3299 __CASE_WEIGHT_FORMAT(ANY)
3300 __CASE_WEIGHT_FORMAT(OHWI)
3301 __CASE_WEIGHT_FORMAT(OHWIo2)
3302 __CASE_WEIGHT_FORMAT(OHWIo4)
3303 __CASE_WEIGHT_FORMAT(OHWIo8)
3304 __CASE_WEIGHT_FORMAT(OHWIo16)
3305 __CASE_WEIGHT_FORMAT(OHWIo32)
3306 __CASE_WEIGHT_FORMAT(OHWIo64)
3307 __CASE_WEIGHT_FORMAT(OHWIo128)
3308 __CASE_WEIGHT_FORMAT(OHWIo4i2)
3309 __CASE_WEIGHT_FORMAT(OHWIo4i2_bf16)
3310 __CASE_WEIGHT_FORMAT(OHWIo8i2)
3311 __CASE_WEIGHT_FORMAT(OHWIo8i2_bf16)
3312 __CASE_WEIGHT_FORMAT(OHWIo16i2)
3313 __CASE_WEIGHT_FORMAT(OHWIo16i2_bf16)
3314 __CASE_WEIGHT_FORMAT(OHWIo32i2)
3315 __CASE_WEIGHT_FORMAT(OHWIo32i2_bf16)
3316 __CASE_WEIGHT_FORMAT(OHWIo64i2)
3317 __CASE_WEIGHT_FORMAT(OHWIo64i2_bf16)
3318 __CASE_WEIGHT_FORMAT(OHWIo4i4)
3319 __CASE_WEIGHT_FORMAT(OHWIo4i4_bf16)
3320 __CASE_WEIGHT_FORMAT(OHWIo8i4)
3321 __CASE_WEIGHT_FORMAT(OHWIo8i4_bf16)
3322 __CASE_WEIGHT_FORMAT(OHWIo16i4)
3323 __CASE_WEIGHT_FORMAT(OHWIo16i4_bf16)
3324 __CASE_WEIGHT_FORMAT(OHWIo32i4)
3325 __CASE_WEIGHT_FORMAT(OHWIo32i4_bf16)
3326 __CASE_WEIGHT_FORMAT(OHWIo64i4)
3327 __CASE_WEIGHT_FORMAT(OHWIo64i4_bf16)
3328 __CASE_WEIGHT_FORMAT(OHWIo2i8)
3329 __CASE_WEIGHT_FORMAT(OHWIo4i8)
3330 __CASE_WEIGHT_FORMAT(OHWIo8i8)
3331 __CASE_WEIGHT_FORMAT(OHWIo16i8)
3332 __CASE_WEIGHT_FORMAT(OHWIo32i8)
3333 __CASE_WEIGHT_FORMAT(OHWIo64i8)
3334 default:
3335 return "invalid value";
3336 }
3337#undef __CASE_WEIGHT_FORMAT
Francesco Petrogalli553f6952022-06-30 10:22:01 +00003338}
3339
Ramy Elgammal91780022022-07-20 14:57:37 +01003340/** Formatted output of the arm_compute::WeightFormat type.
3341 *
3342 * @param[out] os Output stream.
3343 * @param[in] wf WeightFormat to output.
3344 *
3345 * @return Modified output stream.
3346 */
3347inline ::std::ostream &operator<<(::std::ostream &os, const arm_compute::WeightFormat &wf)
3348{
3349 os << to_string(wf);
3350 return os;
3351}
3352
3353/** Formatted output of the std::tuple<TensorShape, TensorShape, arm_compute::WeightFormat> tuple.
3354 *
3355 * @param[in] values tuple of input and output tensor shapes and WeightFormat used.
3356 *
3357 * @return Formatted string.
3358 */
3359inline std::string to_string(const std::tuple<TensorShape, TensorShape, arm_compute::WeightFormat> values)
Francesco Petrogalli553f6952022-06-30 10:22:01 +00003360{
3361 std::stringstream str;
3362 str << "[Input shape = " << std::get<0>(values);
3363 str << ", ";
3364 str << "Expected output shape = " << std::get<1>(values);
3365
3366 str << ", ";
3367 str << "WeightFormat = " << std::get<2>(values) << "]";
3368 return str.str();
3369}
3370
Anthony Barbier6ff3b192017-09-04 18:44:23 +01003371} // namespace arm_compute
Anthony Barbier4dbc0a92018-08-27 13:39:47 +01003372
3373#endif /* __ARM_COMPUTE_TYPE_PRINTER_H__ */