blob: 9f20b38b964aea158d0601fbbbcca622de0c476a [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"
Ramy Elgammal73f19af2022-10-23 11:44:49 +010041#include "arm_compute/dynamic_fusion/sketch/OperatorAttributes.h"
Gunes Bayir1dc6ff12022-12-06 20:48:31 +000042#include "arm_compute/dynamic_fusion/sketch/attributes/CastAttributes.h"
Jakub Sujak32741722022-11-25 16:43:18 +000043#include "arm_compute/dynamic_fusion/sketch/attributes/ClampAttributes.h"
Gunes Bayir7dc02342022-11-21 21:46:50 +000044#include "arm_compute/dynamic_fusion/sketch/attributes/DepthwiseConv2dAttributes.h"
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +010045#include "arm_compute/runtime/CL/CLTunerTypes.h"
SiCong Lidb4a6c12021-02-05 09:30:57 +000046#include "arm_compute/runtime/CL/CLTypes.h"
ramelg013ae3d882021-09-12 23:07:47 +010047#include "arm_compute/runtime/FunctionDescriptors.h"
ramelg01cbbb0382021-09-17 17:36:57 +010048#include "arm_compute/runtime/common/LSTMParams.h"
SiCongLi31778612021-11-12 17:33:45 +000049#include "support/Cast.h"
Matthew Bentham758b5ba2020-03-05 23:37:48 +000050#include "support/StringSupport.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010051#include <ostream>
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010052#include <sstream>
53#include <string>
Anthony Barbier6ff3b192017-09-04 18:44:23 +010054
55namespace arm_compute
56{
Anthony Barbierb940fd62018-06-04 14:14:32 +010057/** Formatted output if arg is not null
58 *
59 * @param[in] arg Object to print
60 *
61 * @return String representing arg.
62 */
63template <typename T>
64std::string to_string_if_not_null(T *arg)
65{
66 if(arg == nullptr)
67 {
68 return "nullptr";
69 }
70 else
71 {
72 return to_string(*arg);
73 }
74}
Anthony Barbierb4670212018-05-18 16:55:39 +010075
ramelg014a6d9e82021-10-02 14:34:36 +010076/** Fallback method: try to use std::to_string:
77 *
78 * @param[in] val Value to convert to string
79 *
80 * @return String representing val.
81 */
82template <typename T>
83inline std::string to_string(const T &val)
84{
85 return support::cpp11::to_string(val);
86}
87
ramelg01b1ba1e32021-09-25 11:53:26 +010088/** Formatted output of a vector of objects.
89 *
ramelg014a6d9e82021-10-02 14:34:36 +010090 * @note: Using the overloaded to_string() instead of overloaded operator<<(), because to_string() functions are
91 * overloaded for all types, where two or more of them can use the same operator<<(), ITensor is an example.
92 *
ramelg01b1ba1e32021-09-25 11:53:26 +010093 * @param[out] os Output stream
94 * @param[in] args Vector of objects to print
95 *
96 * @return Modified output stream.
97 */
98template <typename T>
ramelg014a6d9e82021-10-02 14:34:36 +010099::std::ostream &operator<<(::std::ostream &os, const std::vector<T> &args)
ramelg01b1ba1e32021-09-25 11:53:26 +0100100{
101 const size_t max_print_size = 5U;
102
103 os << "[";
104 bool first = true;
105 size_t i;
106 for(i = 0; i < args.size(); ++i)
107 {
108 if(i == max_print_size)
109 {
110 break;
111 }
112 if(first)
113 {
114 first = false;
115 }
116 else
117 {
118 os << ", ";
119 }
ramelg014a6d9e82021-10-02 14:34:36 +0100120 os << to_string(args[i]);
ramelg01b1ba1e32021-09-25 11:53:26 +0100121 }
122 if(i < args.size())
123 {
124 os << ", ...";
125 }
126 os << "]";
127 return os;
128}
129
ramelg014a6d9e82021-10-02 14:34:36 +0100130/** Formatted output of a vector of objects.
131 *
132 * @param[in] args Vector of objects to print
133 *
134 * @return String representing args.
135 */
136template <typename T>
137std::string to_string(const std::vector<T> &args)
138{
139 std::stringstream str;
140 str << args;
141 return str.str();
142}
143
SiCongLi1af54162021-10-06 15:25:57 +0100144/** @name (EXPERIMENTAL_POST_OPS)
145 * @{
146 */
147/** Formmated output of the @ref experimental::PostOpType type
148 *
149 * @param[out] os Output stream.
150 * @param[in] post_op_type Type to output.
151 *
152 * @return Modified output stream.
153 */
154inline ::std::ostream &operator<<(::std::ostream &os, experimental::PostOpType post_op_type)
155{
156 os << "type=";
157 switch(post_op_type)
158 {
159 case experimental::PostOpType::Activation:
160 {
161 os << "Activation";
162 break;
163 }
164 case experimental::PostOpType::Eltwise_Add:
165 {
166 os << "Eltwise_Add";
167 break;
168 }
ramelg016049eda2021-10-29 10:52:53 +0100169 case experimental::PostOpType::Eltwise_PRelu:
170 {
171 os << "Eltwise_PRelu";
172 break;
173 }
SiCongLi1af54162021-10-06 15:25:57 +0100174 default:
175 {
176 ARM_COMPUTE_ERROR("Unsupported PostOpType");
177 break;
178 }
179 }
180 return os;
181}
182/** Converts a @ref experimental::PostOpType to string
183 *
184 * @param[in] post_op_type PostOpType value to be converted
185 *
186 * @return String representing the corresponding PostOpType
187 */
188inline std::string to_string(experimental::PostOpType post_op_type)
189{
190 std::stringstream str;
191 str << post_op_type;
192 return str.str();
193}
194/** Formatted output of the @ref experimental::IPostOp type.
195 *
196 * @param[out] os Output stream.
197 * @param[in] post_op Type to output.
198 *
199 * @return Modified output stream.
200 */
201template <typename T>
202inline ::std::ostream &operator<<(::std::ostream &os, const experimental::IPostOp<T> &post_op)
203{
204 os << "<";
205 os << post_op.type() << ",";
SiCongLieb8bd812021-10-29 15:05:49 +0100206 os << "prev_dst_pos=" << post_op.prev_dst_pos() << ",";
SiCongLi1af54162021-10-06 15:25:57 +0100207 switch(post_op.type())
208 {
209 case experimental::PostOpType::Activation:
210 {
211 const auto _post_op = utils::cast::polymorphic_downcast<const experimental::PostOpAct<T> *>(&post_op);
212 os << "act_info=" << &(_post_op->_act_info);
213 break;
214 }
215 case experimental::PostOpType::Eltwise_Add:
216 {
217 const auto _post_op = utils::cast::polymorphic_downcast<const experimental::PostOpEltwiseAdd<T> *>(&post_op);
218 os << "convert_policy=" << _post_op->_policy;
219 break;
220 }
ramelg016049eda2021-10-29 10:52:53 +0100221 case experimental::PostOpType::Eltwise_PRelu:
222 {
223 const auto _post_op = utils::cast::polymorphic_downcast<const experimental::PostOpEltwisePRelu<T> *>(&post_op);
224 os << "convert_policy=" << _post_op->_policy;
225 break;
226 }
SiCongLi1af54162021-10-06 15:25:57 +0100227 default:
228 {
229 ARM_COMPUTE_ERROR("Unsupported PostOpType");
230 break;
231 }
232 }
233 os << ">";
234 return os;
235}
236/** Converts an @ref experimental::IPostOp to string
237 *
238 * @param[in] post_op IPostOp value to be converted
239 *
240 * @return String representing the corresponding IPostOp
241 */
242template <typename T>
243inline std::string to_string(const experimental::IPostOp<T> &post_op)
244{
245 std::stringstream str;
246 str << post_op;
247 return str.str();
248}
249/** Formatted output of the @ref experimental::PostOpList type.
250 *
251 * @param[out] os Output stream.
252 * @param[in] post_ops Type to output.
253 *
254 * @return Modified output stream.
255 */
256template <typename T>
257inline ::std::ostream &operator<<(::std::ostream &os, const experimental::PostOpList<T> &post_ops)
258{
259 os << "[";
260 for(const auto &post_op : post_ops.get_list())
261 {
262 os << *post_op << ",";
263 }
264 os << "]";
265 return os;
266}
267/** Converts a @ref experimental::PostOpList to string
268 *
269 * @param[in] post_ops PostOpList value to be converted
270 *
271 * @return String representing the corresponding PostOpList
272 */
273template <typename T>
274inline std::string to_string(const experimental::PostOpList<T> &post_ops)
275{
276 std::stringstream str;
277 str << post_ops;
278 return str.str();
279}
280/** @} */ // end of group (EXPERIMENTAL_POST_OPS)
281
Alex Gildayc357c472018-03-21 13:54:09 +0000282/** Formatted output of the Dimensions type.
283 *
284 * @param[out] os Output stream.
285 * @param[in] dimensions Type to output.
286 *
287 * @return Modified output stream.
288 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100289template <typename T>
290inline ::std::ostream &operator<<(::std::ostream &os, const Dimensions<T> &dimensions)
291{
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100292 if(dimensions.num_dimensions() > 0)
293 {
294 os << dimensions[0];
295
296 for(unsigned int d = 1; d < dimensions.num_dimensions(); ++d)
297 {
Freddie Liardetdd23f2a2021-06-17 13:30:11 +0100298 os << "," << dimensions[d];
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100299 }
300 }
301
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100302 return os;
303}
304
Alex Gildayc357c472018-03-21 13:54:09 +0000305/** Formatted output of the RoundingPolicy type.
306 *
307 * @param[out] os Output stream.
308 * @param[in] rounding_policy Type to output.
309 *
310 * @return Modified output stream.
311 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100312inline ::std::ostream &operator<<(::std::ostream &os, const RoundingPolicy &rounding_policy)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100313{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100314 switch(rounding_policy)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100315 {
Anthony Barbier2a07e182017-08-04 18:20:27 +0100316 case RoundingPolicy::TO_ZERO:
317 os << "TO_ZERO";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100318 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100319 case RoundingPolicy::TO_NEAREST_UP:
320 os << "TO_NEAREST_UP";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100321 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100322 case RoundingPolicy::TO_NEAREST_EVEN:
323 os << "TO_NEAREST_EVEN";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100324 break;
325 default:
326 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
327 }
328
329 return os;
330}
331
Alex Gildayc357c472018-03-21 13:54:09 +0000332/** Formatted output of the WeightsInfo type.
333 *
334 * @param[out] os Output stream.
335 * @param[in] weights_info Type to output.
336 *
337 * @return Modified output stream.
338 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100339inline ::std::ostream &operator<<(::std::ostream &os, const WeightsInfo &weights_info)
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100340{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100341 os << weights_info.are_reshaped() << ";";
342 os << weights_info.num_kernels() << ";" << weights_info.kernel_size().first << "," << weights_info.kernel_size().second;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100343
344 return os;
345}
346
Alex Gildayc357c472018-03-21 13:54:09 +0000347/** Formatted output of the ROIPoolingInfo type.
348 *
349 * @param[out] os Output stream.
350 * @param[in] pool_info Type to output.
351 *
352 * @return Modified output stream.
353 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100354inline ::std::ostream &operator<<(::std::ostream &os, const ROIPoolingLayerInfo &pool_info)
Sanghoon Lee70f82912017-08-24 14:21:24 +0100355{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100356 os << pool_info.pooled_width() << "x" << pool_info.pooled_height() << "~" << pool_info.spatial_scale();
Georgios Pinitasd9769582017-08-03 10:19:40 +0100357 return os;
358}
359
giuros0118870812018-09-13 09:31:40 +0100360/** Formatted output of the ROIPoolingInfo type.
361 *
362 * @param[in] pool_info Type to output.
363 *
364 * @return Formatted string.
365 */
366inline std::string to_string(const ROIPoolingLayerInfo &pool_info)
367{
368 std::stringstream str;
369 str << pool_info;
370 return str.str();
371}
372
morgolockaba2f912020-05-05 16:28:19 +0100373/** Formatted output of the GEMMKernelInfo type.
374 *
375 * @param[out] os Output stream.
376 * @param[in] gemm_info Type to output.
377 *
378 * @return Modified output stream.
379 */
380inline ::std::ostream &operator<<(::std::ostream &os, const GEMMKernelInfo &gemm_info)
381{
SiCongLi579ca842021-10-18 09:38:33 +0100382 os << "( m=" << gemm_info.m;
383 os << " n=" << gemm_info.n;
384 os << " k=" << gemm_info.k;
385 os << " depth_output_gemm3d=" << gemm_info.depth_output_gemm3d;
386 os << " reinterpret_input_as_3d=" << gemm_info.reinterpret_input_as_3d;
387 os << " broadcast_bias=" << gemm_info.broadcast_bias;
388 os << " fp_mixed_precision=" << gemm_info.fp_mixed_precision;
389 os << " mult_transpose1xW_width=" << gemm_info.mult_transpose1xW_width;
390 os << " mult_interleave4x4_height=" << gemm_info.mult_interleave4x4_height;
391 os << " a_offset=" << gemm_info.a_offset;
392 os << " b_offset=" << gemm_info.b_offset;
393 os << "post_ops=" << gemm_info.post_ops;
morgolockaba2f912020-05-05 16:28:19 +0100394 os << ")";
395 return os;
396}
397
398/** Formatted output of the GEMMLHSMatrixInfo type.
399 *
400 * @param[out] os Output stream.
401 * @param[in] gemm_info Type to output.
402 *
403 * @return Modified output stream.
404 */
405inline ::std::ostream &operator<<(::std::ostream &os, const GEMMLHSMatrixInfo &gemm_info)
406{
SiCongLi579ca842021-10-18 09:38:33 +0100407 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 +0100408 return os;
409}
410
411/** Formatted output of the GEMMRHSMatrixInfo type.
412 *
413 * @param[out] os Output stream.
414 * @param[in] gemm_info Type to output.
415 *
416 * @return Modified output stream.
417 */
418inline ::std::ostream &operator<<(::std::ostream &os, const GEMMRHSMatrixInfo &gemm_info)
419{
SiCongLi579ca842021-10-18 09:38:33 +0100420 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 +0000421 gemm_info.export_to_cl_image << "})";
morgolockaba2f912020-05-05 16:28:19 +0100422 return os;
423}
424
425/** Formatted output of the GEMMRHSMatrixInfo type.
426 *
427 * @param[in] gemm_info GEMMRHSMatrixInfo to output.
428 *
429 * @return Formatted string.
430 */
431inline std::string to_string(const GEMMRHSMatrixInfo &gemm_info)
432{
433 std::stringstream str;
434 str << gemm_info;
435 return str.str();
436}
437
438/** Formatted output of the GEMMLHSMatrixInfo type.
439 *
440 * @param[in] gemm_info GEMMLHSMatrixInfo to output.
441 *
442 * @return Formatted string.
443 */
444inline std::string to_string(const GEMMLHSMatrixInfo &gemm_info)
445{
446 std::stringstream str;
447 str << gemm_info;
448 return str.str();
449}
450
451/** Formatted output of the GEMMKernelInfo type.
452 *
453 * @param[in] gemm_info GEMMKernelInfo Type to output.
454 *
455 * @return Formatted string.
456 */
457inline std::string to_string(const GEMMKernelInfo &gemm_info)
458{
459 std::stringstream str;
460 str << gemm_info;
461 return str.str();
462}
463
giuros01c04a0e82018-10-03 12:44:35 +0100464/** Formatted output of the BoundingBoxTransformInfo type.
465 *
466 * @param[out] os Output stream.
467 * @param[in] bbox_info Type to output.
468 *
469 * @return Modified output stream.
470 */
471inline ::std::ostream &operator<<(::std::ostream &os, const BoundingBoxTransformInfo &bbox_info)
472{
473 auto weights = bbox_info.weights();
SiCongLi579ca842021-10-18 09:38:33 +0100474 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 +0100475 "})";
476 return os;
477}
478
Pablo Marquez Tellod208f4f2022-07-19 12:19:46 +0100479#if defined(ARM_COMPUTE_ENABLE_BF16)
Ramy Elgammal91780022022-07-20 14:57:37 +0100480inline ::std::ostream &operator<<(::std::ostream &os, const bfloat16 &v)
Pablo Marquez Tellod208f4f2022-07-19 12:19:46 +0100481{
482 std::stringstream str;
483 str << v;
484 os << str.str();
485 return os;
486}
Ramy Elgammal91780022022-07-20 14:57:37 +0100487#endif /* defined(ARM_COMPUTE_ENABLE_BF16) */
Pablo Marquez Tellod208f4f2022-07-19 12:19:46 +0100488
giuros01c04a0e82018-10-03 12:44:35 +0100489/** Formatted output of the BoundingBoxTransformInfo type.
490 *
491 * @param[in] bbox_info Type to output.
492 *
493 * @return Formatted string.
494 */
495inline std::string to_string(const BoundingBoxTransformInfo &bbox_info)
496{
497 std::stringstream str;
498 str << bbox_info;
499 return str.str();
500}
501
Manuel Bottini5209be52019-02-13 16:34:56 +0000502/** Formatted output of the ComputeAnchorsInfo type.
503 *
504 * @param[out] os Output stream.
505 * @param[in] anchors_info Type to output.
506 *
507 * @return Modified output stream.
508 */
509inline ::std::ostream &operator<<(::std::ostream &os, const ComputeAnchorsInfo &anchors_info)
510{
511 os << "(" << anchors_info.feat_width() << "x" << anchors_info.feat_height() << ")~" << anchors_info.spatial_scale();
512 return os;
513}
514
515/** Formatted output of the ComputeAnchorsInfo type.
516 *
517 * @param[in] anchors_info Type to output.
518 *
519 * @return Formatted string.
520 */
521inline std::string to_string(const ComputeAnchorsInfo &anchors_info)
522{
523 std::stringstream str;
524 str << anchors_info;
525 return str.str();
526}
527
528/** Formatted output of the GenerateProposalsInfo type.
529 *
530 * @param[out] os Output stream.
531 * @param[in] proposals_info Type to output.
532 *
533 * @return Modified output stream.
534 */
535inline ::std::ostream &operator<<(::std::ostream &os, const GenerateProposalsInfo &proposals_info)
536{
537 os << "(" << proposals_info.im_width() << "x" << proposals_info.im_height() << ")~" << proposals_info.im_scale();
538 return os;
539}
540
541/** Formatted output of the GenerateProposalsInfo type.
542 *
543 * @param[in] proposals_info Type to output.
544 *
545 * @return Formatted string.
546 */
547inline std::string to_string(const GenerateProposalsInfo &proposals_info)
548{
549 std::stringstream str;
550 str << proposals_info;
551 return str.str();
552}
553
Alex Gildayc357c472018-03-21 13:54:09 +0000554/** Formatted output of the QuantizationInfo type.
555 *
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100556 * @param[out] os Output stream.
557 * @param[in] qinfo Type to output.
Alex Gildayc357c472018-03-21 13:54:09 +0000558 *
559 * @return Modified output stream.
560 */
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100561inline ::std::ostream &operator<<(::std::ostream &os, const QuantizationInfo &qinfo)
Chunosovd621bca2017-11-03 17:33:15 +0700562{
Georgios Pinitas3d13af82019-06-04 13:04:16 +0100563 const UniformQuantizationInfo uqinfo = qinfo.uniform();
564 os << "Scale:" << uqinfo.scale << "~";
565 os << "Offset:" << uqinfo.offset;
Chunosovd621bca2017-11-03 17:33:15 +0700566 return os;
567}
568
Alex Gildayc357c472018-03-21 13:54:09 +0000569/** Formatted output of the QuantizationInfo type.
570 *
571 * @param[in] quantization_info Type to output.
572 *
573 * @return Formatted string.
574 */
Chunosovd621bca2017-11-03 17:33:15 +0700575inline std::string to_string(const QuantizationInfo &quantization_info)
576{
577 std::stringstream str;
578 str << quantization_info;
579 return str.str();
580}
581
Alex Gildayc357c472018-03-21 13:54:09 +0000582/** Formatted output of the activation function type.
583 *
584 * @param[out] os Output stream.
585 * @param[in] act_function Type to output.
586 *
587 * @return Modified output stream.
588 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100589inline ::std::ostream &operator<<(::std::ostream &os, const ActivationLayerInfo::ActivationFunction &act_function)
590{
591 switch(act_function)
592 {
593 case ActivationLayerInfo::ActivationFunction::ABS:
594 os << "ABS";
595 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100596 case ActivationLayerInfo::ActivationFunction::LINEAR:
597 os << "LINEAR";
598 break;
599 case ActivationLayerInfo::ActivationFunction::LOGISTIC:
600 os << "LOGISTIC";
601 break;
602 case ActivationLayerInfo::ActivationFunction::RELU:
603 os << "RELU";
604 break;
Georgios Pinitas579c0492017-07-12 16:12:12 +0100605 case ActivationLayerInfo::ActivationFunction::BOUNDED_RELU:
606 os << "BOUNDED_RELU";
607 break;
608 case ActivationLayerInfo::ActivationFunction::LEAKY_RELU:
609 os << "LEAKY_RELU";
610 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100611 case ActivationLayerInfo::ActivationFunction::SOFT_RELU:
612 os << "SOFT_RELU";
613 break;
614 case ActivationLayerInfo::ActivationFunction::SQRT:
615 os << "SQRT";
616 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100617 case ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU:
618 os << "LU_BOUNDED_RELU";
Kevin Petitd9f80712017-12-06 12:18:48 +0000619 break;
Georgios Pinitasfb0fdcd2019-08-22 17:10:04 +0100620 case ActivationLayerInfo::ActivationFunction::ELU:
621 os << "ELU";
622 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100623 case ActivationLayerInfo::ActivationFunction::SQUARE:
624 os << "SQUARE";
625 break;
626 case ActivationLayerInfo::ActivationFunction::TANH:
627 os << "TANH";
628 break;
Usama Arif6a98a6e2019-05-10 17:07:27 +0100629 case ActivationLayerInfo::ActivationFunction::IDENTITY:
630 os << "IDENTITY";
631 break;
morgolock07df3d42020-02-27 11:46:28 +0000632 case ActivationLayerInfo::ActivationFunction::HARD_SWISH:
633 os << "HARD_SWISH";
634 break;
Jonathan Deakind6b8a712022-08-23 11:44:18 +0100635 case ActivationLayerInfo::ActivationFunction::SWISH:
636 os << "SWISH";
637 break;
Murray Kornelsen926f5022022-07-13 21:22:39 -0400638 case ActivationLayerInfo::ActivationFunction::GELU:
639 os << "GELU";
640 break;
morgolock07df3d42020-02-27 11:46:28 +0000641
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100642 default:
643 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
644 }
645
646 return os;
647}
648
Alex Gildayc357c472018-03-21 13:54:09 +0000649/** Formatted output of the activation function info type.
650 *
SiCongLi1af54162021-10-06 15:25:57 +0100651 * @param[in] info ActivationLayerInfo to output.
Alex Gildayc357c472018-03-21 13:54:09 +0000652 *
653 * @return Formatted string.
654 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100655inline std::string to_string(const arm_compute::ActivationLayerInfo &info)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100656{
657 std::stringstream str;
Isabella Gottardi3f217ec2018-02-12 14:59:19 +0000658 if(info.enabled())
659 {
660 str << info.activation();
661 }
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100662 return str.str();
663}
664
SiCongLi1af54162021-10-06 15:25:57 +0100665/** Formatted output of the activation function info.
ramelg013ae3d882021-09-12 23:07:47 +0100666 *
SiCongLi1af54162021-10-06 15:25:57 +0100667 * @param[out] os Output stream.
668 * @param[in] info ActivationLayerInfo to output.
ramelg013ae3d882021-09-12 23:07:47 +0100669 *
670 * @return Formatted string.
671 */
SiCongLi1af54162021-10-06 15:25:57 +0100672inline ::std::ostream &operator<<(::std::ostream &os, const ActivationLayerInfo *info)
ramelg013ae3d882021-09-12 23:07:47 +0100673{
ramelg013ae3d882021-09-12 23:07:47 +0100674 if(info != nullptr)
675 {
ramelg013ae3d882021-09-12 23:07:47 +0100676 if(info->enabled())
677 {
SiCongLi1af54162021-10-06 15:25:57 +0100678 os << info->activation();
679 os << "(";
680 os << "VAL_A=" << info->a() << ",";
681 os << "VAL_B=" << info->b();
682 os << ")";
ramelg013ae3d882021-09-12 23:07:47 +0100683 }
SiCongLi1af54162021-10-06 15:25:57 +0100684 else
685 {
686 os << "disabled";
687 }
ramelg013ae3d882021-09-12 23:07:47 +0100688 }
SiCongLi1af54162021-10-06 15:25:57 +0100689 else
690 {
691 os << "nullptr";
692 }
693 return os;
ramelg013ae3d882021-09-12 23:07:47 +0100694}
695
Alex Gildayc357c472018-03-21 13:54:09 +0000696/** Formatted output of the activation function type.
697 *
698 * @param[in] function Type to output.
699 *
700 * @return Formatted string.
701 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100702inline std::string to_string(const arm_compute::ActivationLayerInfo::ActivationFunction &function)
703{
704 std::stringstream str;
705 str << function;
706 return str.str();
707}
708
Alex Gildayc357c472018-03-21 13:54:09 +0000709/** Formatted output of the NormType type.
710 *
711 * @param[out] os Output stream.
712 * @param[in] norm_type Type to output.
713 *
714 * @return Modified output stream.
715 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100716inline ::std::ostream &operator<<(::std::ostream &os, const NormType &norm_type)
717{
718 switch(norm_type)
719 {
720 case NormType::CROSS_MAP:
721 os << "CROSS_MAP";
722 break;
723 case NormType::IN_MAP_1D:
724 os << "IN_MAP_1D";
725 break;
726 case NormType::IN_MAP_2D:
727 os << "IN_MAP_2D";
728 break;
729 default:
730 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
731 }
732
733 return os;
734}
735
Alex Gildayc357c472018-03-21 13:54:09 +0000736/** Formatted output of @ref NormalizationLayerInfo.
737 *
738 * @param[in] info Type to output.
739 *
740 * @return Formatted string.
741 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100742inline std::string to_string(const arm_compute::NormalizationLayerInfo &info)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100743{
744 std::stringstream str;
Michalis Spyroud466c2d2018-01-30 10:54:39 +0000745 str << info.type() << ":NormSize=" << info.norm_size();
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100746 return str.str();
747}
748
Alex Gildayc357c472018-03-21 13:54:09 +0000749/** Formatted output of @ref NormalizationLayerInfo.
750 *
751 * @param[out] os Output stream.
752 * @param[in] info Type to output.
753 *
754 * @return Modified output stream.
755 */
Georgios Pinitas6f669f02017-09-26 12:32:57 +0100756inline ::std::ostream &operator<<(::std::ostream &os, const NormalizationLayerInfo &info)
757{
Michalis Spyroud466c2d2018-01-30 10:54:39 +0000758 os << info.type() << ":NormSize=" << info.norm_size();
Georgios Pinitas6f669f02017-09-26 12:32:57 +0100759 return os;
760}
761
Alex Gildayc357c472018-03-21 13:54:09 +0000762/** Formatted output of the PoolingType type.
763 *
764 * @param[out] os Output stream.
765 * @param[in] pool_type Type to output.
766 *
767 * @return Modified output stream.
768 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100769inline ::std::ostream &operator<<(::std::ostream &os, const PoolingType &pool_type)
770{
771 switch(pool_type)
772 {
773 case PoolingType::AVG:
774 os << "AVG";
775 break;
776 case PoolingType::MAX:
777 os << "MAX";
778 break;
Georgios Pinitascdf51452017-08-31 14:21:36 +0100779 case PoolingType::L2:
780 os << "L2";
781 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100782 default:
783 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
784 }
785
786 return os;
787}
788
Alex Gildayc357c472018-03-21 13:54:09 +0000789/** Formatted output of @ref PoolingLayerInfo.
790 *
791 * @param[out] os Output stream.
792 * @param[in] info Type to output.
793 *
794 * @return Modified output stream.
795 */
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100796inline ::std::ostream &operator<<(::std::ostream &os, const PoolingLayerInfo &info)
797{
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +0000798 os << info.pool_type;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100799
800 return os;
801}
802
Alex Gildayc357c472018-03-21 13:54:09 +0000803/** Formatted output of @ref RoundingPolicy.
804 *
805 * @param[in] rounding_policy Type to output.
806 *
807 * @return Formatted string.
808 */
John Richardsondd715f22017-09-18 16:10:48 +0100809inline std::string to_string(const RoundingPolicy &rounding_policy)
810{
811 std::stringstream str;
812 str << rounding_policy;
813 return str.str();
814}
815
Vidhya Sudhan Loganathand646ae12018-11-19 15:18:20 +0000816/** [Print DataLayout type] **/
Alex Gildayc357c472018-03-21 13:54:09 +0000817/** Formatted output of the DataLayout type.
818 *
819 * @param[out] os Output stream.
820 * @param[in] data_layout Type to output.
821 *
822 * @return Modified output stream.
823 */
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000824inline ::std::ostream &operator<<(::std::ostream &os, const DataLayout &data_layout)
825{
826 switch(data_layout)
827 {
828 case DataLayout::UNKNOWN:
829 os << "UNKNOWN";
830 break;
831 case DataLayout::NHWC:
832 os << "NHWC";
833 break;
834 case DataLayout::NCHW:
835 os << "NCHW";
836 break;
Adnan AlSinane4563a02021-09-01 15:32:03 +0100837 case DataLayout::NDHWC:
838 os << "NDHWC";
839 break;
Giorgio Arenac9fe9fc2021-10-06 12:54:29 +0100840 case DataLayout::NCDHW:
841 os << "NCDHW";
842 break;
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000843 default:
844 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
845 }
846
847 return os;
848}
849
Alex Gildayc357c472018-03-21 13:54:09 +0000850/** Formatted output of the DataLayout type.
851 *
852 * @param[in] data_layout Type to output.
853 *
854 * @return Formatted string.
855 */
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000856inline std::string to_string(const arm_compute::DataLayout &data_layout)
857{
858 std::stringstream str;
859 str << data_layout;
860 return str.str();
861}
Vidhya Sudhan Loganathand646ae12018-11-19 15:18:20 +0000862/** [Print DataLayout type] **/
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000863
Georgios Pinitase2220552018-07-20 13:23:44 +0100864/** Formatted output of the DataLayoutDimension type.
865 *
866 * @param[out] os Output stream.
867 * @param[in] data_layout_dim Data layout dimension to print.
868 *
869 * @return Modified output stream.
870 */
871inline ::std::ostream &operator<<(::std::ostream &os, const DataLayoutDimension &data_layout_dim)
872{
873 switch(data_layout_dim)
874 {
875 case DataLayoutDimension::WIDTH:
876 os << "WIDTH";
877 break;
878 case DataLayoutDimension::HEIGHT:
879 os << "HEIGHT";
880 break;
881 case DataLayoutDimension::CHANNEL:
882 os << "CHANNEL";
883 break;
Giorgio Arenac9fe9fc2021-10-06 12:54:29 +0100884 case DataLayoutDimension::DEPTH:
885 os << "DEPTH";
886 break;
Georgios Pinitase2220552018-07-20 13:23:44 +0100887 case DataLayoutDimension::BATCHES:
888 os << "BATCHES";
889 break;
890 default:
891 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
892 }
893 return os;
894}
895
Alex Gildayc357c472018-03-21 13:54:09 +0000896/** Formatted output of the DataType type.
897 *
898 * @param[out] os Output stream.
899 * @param[in] data_type Type to output.
900 *
901 * @return Modified output stream.
902 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100903inline ::std::ostream &operator<<(::std::ostream &os, const DataType &data_type)
904{
905 switch(data_type)
906 {
907 case DataType::UNKNOWN:
908 os << "UNKNOWN";
909 break;
910 case DataType::U8:
911 os << "U8";
912 break;
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100913 case DataType::QSYMM8:
914 os << "QSYMM8";
915 break;
Chunosovd621bca2017-11-03 17:33:15 +0700916 case DataType::QASYMM8:
917 os << "QASYMM8";
918 break;
Georgios Pinitas448a81f2019-11-21 14:10:25 +0000919 case DataType::QASYMM8_SIGNED:
920 os << "QASYMM8_SIGNED";
921 break;
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100922 case DataType::QSYMM8_PER_CHANNEL:
923 os << "QSYMM8_PER_CHANNEL";
924 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100925 case DataType::S8:
926 os << "S8";
927 break;
928 case DataType::U16:
929 os << "U16";
930 break;
931 case DataType::S16:
932 os << "S16";
933 break;
Manuel Bottini3689fcd2019-06-14 17:18:12 +0100934 case DataType::QSYMM16:
935 os << "QSYMM16";
936 break;
Michele Di Giorgio35ea9a72019-08-23 12:02:06 +0100937 case DataType::QASYMM16:
938 os << "QASYMM16";
939 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100940 case DataType::U32:
941 os << "U32";
942 break;
943 case DataType::S32:
944 os << "S32";
945 break;
946 case DataType::U64:
947 os << "U64";
948 break;
949 case DataType::S64:
950 os << "S64";
951 break;
Georgios Pinitase8291ac2020-02-26 09:58:13 +0000952 case DataType::BFLOAT16:
953 os << "BFLOAT16";
954 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100955 case DataType::F16:
956 os << "F16";
957 break;
958 case DataType::F32:
959 os << "F32";
960 break;
961 case DataType::F64:
962 os << "F64";
963 break;
964 case DataType::SIZET:
965 os << "SIZET";
966 break;
967 default:
968 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
969 }
970
971 return os;
972}
973
Alex Gildayc357c472018-03-21 13:54:09 +0000974/** Formatted output of the DataType type.
975 *
976 * @param[in] data_type Type to output.
977 *
978 * @return Formatted string.
979 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100980inline std::string to_string(const arm_compute::DataType &data_type)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100981{
982 std::stringstream str;
983 str << data_type;
984 return str.str();
985}
986
Alex Gildayc357c472018-03-21 13:54:09 +0000987/** Formatted output of the Format type.
988 *
989 * @param[out] os Output stream.
990 * @param[in] format Type to output.
991 *
992 * @return Modified output stream.
993 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100994inline ::std::ostream &operator<<(::std::ostream &os, const Format &format)
995{
996 switch(format)
997 {
998 case Format::UNKNOWN:
999 os << "UNKNOWN";
1000 break;
1001 case Format::U8:
1002 os << "U8";
1003 break;
1004 case Format::S16:
1005 os << "S16";
1006 break;
1007 case Format::U16:
1008 os << "U16";
1009 break;
1010 case Format::S32:
1011 os << "S32";
1012 break;
1013 case Format::U32:
1014 os << "U32";
1015 break;
1016 case Format::F16:
1017 os << "F16";
1018 break;
1019 case Format::F32:
1020 os << "F32";
1021 break;
1022 case Format::UV88:
1023 os << "UV88";
1024 break;
1025 case Format::RGB888:
1026 os << "RGB888";
1027 break;
1028 case Format::RGBA8888:
1029 os << "RGBA8888";
1030 break;
1031 case Format::YUV444:
1032 os << "YUV444";
1033 break;
1034 case Format::YUYV422:
1035 os << "YUYV422";
1036 break;
1037 case Format::NV12:
1038 os << "NV12";
1039 break;
1040 case Format::NV21:
1041 os << "NV21";
1042 break;
1043 case Format::IYUV:
1044 os << "IYUV";
1045 break;
1046 case Format::UYVY422:
1047 os << "UYVY422";
1048 break;
1049 default:
1050 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1051 }
1052
1053 return os;
1054}
1055
Alex Gildayc357c472018-03-21 13:54:09 +00001056/** Formatted output of the Format type.
1057 *
1058 * @param[in] format Type to output.
1059 *
1060 * @return Formatted string.
1061 */
Moritz Pflanzer7655a672017-09-23 11:57:33 +01001062inline std::string to_string(const Format &format)
1063{
1064 std::stringstream str;
1065 str << format;
1066 return str.str();
1067}
1068
Alex Gildayc357c472018-03-21 13:54:09 +00001069/** Formatted output of the Channel type.
1070 *
1071 * @param[out] os Output stream.
1072 * @param[in] channel Type to output.
1073 *
1074 * @return Modified output stream.
1075 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001076inline ::std::ostream &operator<<(::std::ostream &os, const Channel &channel)
1077{
1078 switch(channel)
1079 {
1080 case Channel::UNKNOWN:
1081 os << "UNKNOWN";
1082 break;
1083 case Channel::C0:
1084 os << "C0";
1085 break;
1086 case Channel::C1:
1087 os << "C1";
1088 break;
1089 case Channel::C2:
1090 os << "C2";
1091 break;
1092 case Channel::C3:
1093 os << "C3";
1094 break;
1095 case Channel::R:
1096 os << "R";
1097 break;
1098 case Channel::G:
1099 os << "G";
1100 break;
1101 case Channel::B:
1102 os << "B";
1103 break;
1104 case Channel::A:
1105 os << "A";
1106 break;
1107 case Channel::Y:
1108 os << "Y";
1109 break;
1110 case Channel::U:
1111 os << "U";
1112 break;
1113 case Channel::V:
1114 os << "V";
1115 break;
1116 default:
1117 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1118 }
1119
1120 return os;
1121}
1122
Alex Gildayc357c472018-03-21 13:54:09 +00001123/** Formatted output of the Channel type.
1124 *
1125 * @param[in] channel Type to output.
1126 *
1127 * @return Formatted string.
1128 */
Ioan-Cristian Szabo9414f642017-10-27 17:35:40 +01001129inline std::string to_string(const Channel &channel)
1130{
1131 std::stringstream str;
1132 str << channel;
1133 return str.str();
1134}
1135
Alex Gildayc357c472018-03-21 13:54:09 +00001136/** Formatted output of the BorderMode type.
1137 *
1138 * @param[out] os Output stream.
1139 * @param[in] mode Type to output.
1140 *
1141 * @return Modified output stream.
1142 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001143inline ::std::ostream &operator<<(::std::ostream &os, const BorderMode &mode)
1144{
1145 switch(mode)
1146 {
1147 case BorderMode::UNDEFINED:
1148 os << "UNDEFINED";
1149 break;
1150 case BorderMode::CONSTANT:
1151 os << "CONSTANT";
1152 break;
1153 case BorderMode::REPLICATE:
1154 os << "REPLICATE";
1155 break;
1156 default:
1157 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1158 }
1159
1160 return os;
1161}
1162
Alex Gildayc357c472018-03-21 13:54:09 +00001163/** Formatted output of the BorderSize type.
1164 *
1165 * @param[out] os Output stream.
1166 * @param[in] border Type to output.
1167 *
1168 * @return Modified output stream.
1169 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001170inline ::std::ostream &operator<<(::std::ostream &os, const BorderSize &border)
1171{
Moritz Pflanzerc87fbf82017-07-18 14:02:10 +01001172 os << border.top << ","
1173 << border.right << ","
1174 << border.bottom << ","
1175 << border.left;
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001176
1177 return os;
1178}
Anthony Barbier2a07e182017-08-04 18:20:27 +01001179
Giuseppe Rossinid7647d42018-07-17 18:13:13 +01001180/** Formatted output of the PaddingList type.
1181 *
1182 * @param[out] os Output stream.
1183 * @param[in] padding Type to output.
1184 *
1185 * @return Modified output stream.
1186 */
1187inline ::std::ostream &operator<<(::std::ostream &os, const PaddingList &padding)
1188{
1189 os << "{";
1190 for(auto const &p : padding)
1191 {
1192 os << "{" << p.first << "," << p.second << "}";
1193 }
1194 os << "}";
1195 return os;
1196}
1197
giuros013175fcf2018-11-21 09:59:17 +00001198/** Formatted output of the Multiples type.
1199 *
1200 * @param[out] os Output stream.
1201 * @param[in] multiples Type to output.
1202 *
1203 * @return Modified output stream.
1204 */
1205inline ::std::ostream &operator<<(::std::ostream &os, const Multiples &multiples)
1206{
1207 os << "(";
1208 for(size_t i = 0; i < multiples.size() - 1; i++)
1209 {
1210 os << multiples[i] << ", ";
1211 }
1212 os << multiples.back() << ")";
1213 return os;
1214}
1215
Alex Gildayc357c472018-03-21 13:54:09 +00001216/** Formatted output of the InterpolationPolicy type.
1217 *
1218 * @param[out] os Output stream.
1219 * @param[in] policy Type to output.
1220 *
1221 * @return Modified output stream.
1222 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001223inline ::std::ostream &operator<<(::std::ostream &os, const InterpolationPolicy &policy)
1224{
1225 switch(policy)
1226 {
1227 case InterpolationPolicy::NEAREST_NEIGHBOR:
1228 os << "NEAREST_NEIGHBOR";
1229 break;
1230 case InterpolationPolicy::BILINEAR:
1231 os << "BILINEAR";
1232 break;
1233 case InterpolationPolicy::AREA:
1234 os << "AREA";
1235 break;
1236 default:
1237 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1238 }
1239
1240 return os;
1241}
1242
Alex Gildayc357c472018-03-21 13:54:09 +00001243/** Formatted output of the SamplingPolicy type.
1244 *
1245 * @param[out] os Output stream.
1246 * @param[in] policy Type to output.
1247 *
1248 * @return Modified output stream.
1249 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +07001250inline ::std::ostream &operator<<(::std::ostream &os, const SamplingPolicy &policy)
1251{
1252 switch(policy)
1253 {
1254 case SamplingPolicy::CENTER:
1255 os << "CENTER";
1256 break;
1257 case SamplingPolicy::TOP_LEFT:
1258 os << "TOP_LEFT";
1259 break;
1260 default:
1261 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1262 }
1263
1264 return os;
1265}
1266
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001267/** Formatted output of the ITensorInfo type.
1268 *
1269 * @param[out] os Output stream.
1270 * @param[in] info Tensor information.
1271 *
1272 * @return Modified output stream.
1273 */
1274inline ::std::ostream &operator<<(std::ostream &os, const ITensorInfo *info)
1275{
Georgios Pinitasc6f95102021-03-30 10:03:01 +01001276 const DataType data_type = info->data_type();
1277 const DataLayout data_layout = info->data_layout();
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001278
1279 os << "Shape=" << info->tensor_shape() << ","
1280 << "DataLayout=" << string_from_data_layout(data_layout) << ","
ramelg014a6d9e82021-10-02 14:34:36 +01001281 << "DataType=" << string_from_data_type(data_type);
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001282
1283 if(is_data_type_quantized(data_type))
1284 {
ramelg01b1ba1e32021-09-25 11:53:26 +01001285 const QuantizationInfo qinfo = info->quantization_info();
1286 const auto scales = qinfo.scale();
1287 const auto offsets = qinfo.offset();
1288
ramelg014a6d9e82021-10-02 14:34:36 +01001289 os << ", QuantizationInfo={"
ramelg01b1ba1e32021-09-25 11:53:26 +01001290 << "scales.size=" << scales.size()
1291 << ", scale(s)=" << scales << ", ";
1292
1293 os << "offsets.size=" << offsets.size()
1294 << ", offset(s)=" << offsets << "}";
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001295 }
1296 return os;
1297}
1298
ramelg013ae3d882021-09-12 23:07:47 +01001299/** Formatted output of the const TensorInfo& type.
Alex Gildayc357c472018-03-21 13:54:09 +00001300 *
Anthony Barbier366628a2018-08-01 13:55:03 +01001301 * @param[out] os Output stream.
1302 * @param[in] info Type to output.
1303 *
1304 * @return Modified output stream.
1305 */
1306inline ::std::ostream &operator<<(::std::ostream &os, const TensorInfo &info)
1307{
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001308 os << &info;
Georgios Pinitasc6f95102021-03-30 10:03:01 +01001309 return os;
Anthony Barbier366628a2018-08-01 13:55:03 +01001310}
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001311
ramelg013ae3d882021-09-12 23:07:47 +01001312/** Formatted output of the const TensorInfo& type.
Anthony Barbier366628a2018-08-01 13:55:03 +01001313 *
Alex Gildayc357c472018-03-21 13:54:09 +00001314 * @param[in] info Type to output.
1315 *
1316 * @return Formatted string.
1317 */
Georgios Pinitas3faea252017-10-30 14:13:50 +00001318inline std::string to_string(const TensorInfo &info)
1319{
1320 std::stringstream str;
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001321 str << &info;
Georgios Pinitas3faea252017-10-30 14:13:50 +00001322 return str.str();
1323}
1324
ramelg013ae3d882021-09-12 23:07:47 +01001325/** Formatted output of the const ITensorInfo& type.
1326 *
1327 * @param[in] info Type to output.
1328 *
1329 * @return Formatted string.
1330 */
1331inline std::string to_string(const ITensorInfo &info)
1332{
1333 std::stringstream str;
1334 str << &info;
1335 return str.str();
1336}
1337
ramelg013ae3d882021-09-12 23:07:47 +01001338/** Formatted output of the const ITensorInfo* type.
1339 *
1340 * @param[in] info Type to output.
1341 *
1342 * @return Formatted string.
1343 */
Ramy Elgammale920d6a2021-08-19 22:10:30 +01001344inline std::string to_string(const ITensorInfo *info)
1345{
ramelg013ae3d882021-09-12 23:07:47 +01001346 std::string ret_str = "nullptr";
1347 if(info != nullptr)
1348 {
1349 std::stringstream str;
1350 str << info;
1351 ret_str = str.str();
1352 }
1353 return ret_str;
1354}
1355
ramelg01cbbb0382021-09-17 17:36:57 +01001356/** Formatted output of the ITensorInfo* type.
1357 *
1358 * @param[in] info Type to output.
1359 *
1360 * @return Formatted string.
1361 */
1362inline std::string to_string(ITensorInfo *info)
1363{
1364 return to_string(static_cast<const ITensorInfo *>(info));
1365}
1366
1367/** Formatted output of the ITensorInfo type obtained from const ITensor* type.
ramelg013ae3d882021-09-12 23:07:47 +01001368 *
1369 * @param[in] tensor Type to output.
1370 *
1371 * @return Formatted string.
1372 */
1373inline std::string to_string(const ITensor *tensor)
1374{
1375 std::string ret_str = "nullptr";
1376 if(tensor != nullptr)
1377 {
1378 std::stringstream str;
ramelg01cbbb0382021-09-17 17:36:57 +01001379 str << "ITensor->info(): " << tensor->info();
ramelg013ae3d882021-09-12 23:07:47 +01001380 ret_str = str.str();
1381 }
1382 return ret_str;
1383}
1384
ramelg01cbbb0382021-09-17 17:36:57 +01001385/** Formatted output of the ITensorInfo type obtained from the ITensor* type.
ramelg013ae3d882021-09-12 23:07:47 +01001386 *
1387 * @param[in] tensor Type to output.
1388 *
1389 * @return Formatted string.
1390 */
1391inline std::string to_string(ITensor *tensor)
1392{
ramelg01cbbb0382021-09-17 17:36:57 +01001393 return to_string(static_cast<const ITensor *>(tensor));
ramelg013ae3d882021-09-12 23:07:47 +01001394}
1395
ramelg01cbbb0382021-09-17 17:36:57 +01001396/** Formatted output of the ITensorInfo type obtained from the ITensor& type.
ramelg013ae3d882021-09-12 23:07:47 +01001397 *
1398 * @param[in] tensor Type to output.
1399 *
1400 * @return Formatted string.
1401 */
1402inline std::string to_string(ITensor &tensor)
1403{
Ramy Elgammale920d6a2021-08-19 22:10:30 +01001404 std::stringstream str;
ramelg01cbbb0382021-09-17 17:36:57 +01001405 str << "ITensor.info(): " << tensor.info();
Ramy Elgammale920d6a2021-08-19 22:10:30 +01001406 return str.str();
1407}
1408
ramelg01cbbb0382021-09-17 17:36:57 +01001409#ifdef ARM_COMPUTE_OPENCL_ENABLED
1410/** Formatted output of the ITensorInfo type obtained from the const ICLTensor& type.
1411 *
1412 * @param[in] cl_tensor Type to output.
1413 *
1414 * @return Formatted string.
1415 */
1416inline std::string to_string(const ICLTensor *cl_tensor)
1417{
1418 std::string ret_str = "nullptr";
1419 if(cl_tensor != nullptr)
1420 {
1421 std::stringstream str;
1422 str << "ICLTensor->info(): " << cl_tensor->info();
1423 ret_str = str.str();
1424 }
1425 return ret_str;
1426}
1427
1428/** Formatted output of the ITensorInfo type obtained from the ICLTensor& type.
1429 *
1430 * @param[in] cl_tensor Type to output.
1431 *
1432 * @return Formatted string.
1433 */
1434inline std::string to_string(ICLTensor *cl_tensor)
1435{
1436 return to_string(static_cast<const ICLTensor *>(cl_tensor));
1437}
1438#endif /* ARM_COMPUTE_OPENCL_ENABLED */
1439
Alex Gildayc357c472018-03-21 13:54:09 +00001440/** Formatted output of the Dimensions type.
1441 *
1442 * @param[in] dimensions Type to output.
1443 *
1444 * @return Formatted string.
1445 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001446template <typename T>
1447inline std::string to_string(const Dimensions<T> &dimensions)
1448{
1449 std::stringstream str;
1450 str << dimensions;
1451 return str.str();
1452}
1453
Alex Gildayc357c472018-03-21 13:54:09 +00001454/** Formatted output of the Strides type.
1455 *
1456 * @param[in] stride Type to output.
1457 *
1458 * @return Formatted string.
1459 */
John Richardsona36eae12017-09-26 16:55:59 +01001460inline std::string to_string(const Strides &stride)
1461{
1462 std::stringstream str;
1463 str << stride;
1464 return str.str();
1465}
1466
Alex Gildayc357c472018-03-21 13:54:09 +00001467/** Formatted output of the TensorShape type.
1468 *
1469 * @param[in] shape Type to output.
1470 *
1471 * @return Formatted string.
1472 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001473inline std::string to_string(const TensorShape &shape)
1474{
1475 std::stringstream str;
1476 str << shape;
1477 return str.str();
1478}
1479
Alex Gildayc357c472018-03-21 13:54:09 +00001480/** Formatted output of the Coordinates type.
1481 *
1482 * @param[in] coord Type to output.
1483 *
1484 * @return Formatted string.
1485 */
Abe Mbise925ca0f2017-10-02 19:16:33 +01001486inline std::string to_string(const Coordinates &coord)
1487{
1488 std::stringstream str;
1489 str << coord;
1490 return str.str();
1491}
1492
Anthony Barbierb940fd62018-06-04 14:14:32 +01001493/** Formatted output of the GEMMReshapeInfo type.
1494 *
1495 * @param[out] os Output stream.
1496 * @param[in] info Type to output.
1497 *
1498 * @return Modified output stream.
1499 */
1500inline ::std::ostream &operator<<(::std::ostream &os, const GEMMReshapeInfo &info)
1501{
1502 os << "{m=" << info.m() << ",";
1503 os << "n=" << info.n() << ",";
1504 os << "k=" << info.k() << ",";
1505 os << "mult_transpose1xW_width=" << info.mult_transpose1xW_width() << ",";
1506 os << "mult_interleave4x4_height=" << info.mult_interleave4x4_height();
1507 os << "}";
1508
1509 return os;
1510}
1511
1512/** Formatted output of the GEMMInfo type.
1513 *
1514 * @param[out] os Output stream.
1515 * @param[in] info Type to output.
1516 *
1517 * @return Modified output stream.
1518 */
1519inline ::std::ostream &operator<<(::std::ostream &os, const GEMMInfo &info)
1520{
1521 os << "{is_a_reshaped=" << info.is_a_reshaped() << ",";
1522 os << "is_b_reshaped=" << info.is_b_reshaped() << ",";
1523 os << "reshape_b_only_on_first_run=" << info.reshape_b_only_on_first_run() << ",";
Anthony Barbierb4670212018-05-18 16:55:39 +01001524 os << "depth_output_gemm3d=" << info.depth_output_gemm3d() << ",";
1525 os << "reinterpret_input_as_3d=" << info.reinterpret_input_as_3d() << ",";
1526 os << "retain_internal_weights=" << info.retain_internal_weights() << ",";
1527 os << "fp_mixed_precision=" << info.fp_mixed_precision() << ",";
1528 os << "broadcast_bias=" << info.broadcast_bias() << ",";
ramelg01cbbb0382021-09-17 17:36:57 +01001529 os << "pretranspose_B=" << info.pretranspose_B() << ",";
SiCongLi579ca842021-10-18 09:38:33 +01001530 os << "post_ops=" << info.post_ops() << "}";
Anthony Barbierb940fd62018-06-04 14:14:32 +01001531
1532 return os;
1533}
1534
1535/** Formatted output of the Window::Dimension type.
1536 *
1537 * @param[out] os Output stream.
1538 * @param[in] dim Type to output.
1539 *
1540 * @return Modified output stream.
1541 */
1542inline ::std::ostream &operator<<(::std::ostream &os, const Window::Dimension &dim)
1543{
1544 os << "{start=" << dim.start() << ", end=" << dim.end() << ", step=" << dim.step() << "}";
1545
1546 return os;
1547}
1548/** Formatted output of the Window type.
1549 *
1550 * @param[out] os Output stream.
1551 * @param[in] win Type to output.
1552 *
1553 * @return Modified output stream.
1554 */
1555inline ::std::ostream &operator<<(::std::ostream &os, const Window &win)
1556{
1557 os << "{";
1558 for(unsigned int i = 0; i < Coordinates::num_max_dimensions; i++)
1559 {
1560 if(i > 0)
1561 {
1562 os << ", ";
1563 }
1564 os << win[i];
1565 }
1566 os << "}";
1567
1568 return os;
1569}
1570
1571/** Formatted output of the WeightsInfo type.
1572 *
1573 * @param[in] info Type to output.
1574 *
1575 * @return Formatted string.
1576 */
1577inline std::string to_string(const WeightsInfo &info)
1578{
1579 std::stringstream str;
1580 str << info;
1581 return str.str();
1582}
1583
1584/** Formatted output of the GEMMReshapeInfo type.
1585 *
1586 * @param[in] info Type to output.
1587 *
1588 * @return Formatted string.
1589 */
1590inline std::string to_string(const GEMMReshapeInfo &info)
1591{
1592 std::stringstream str;
1593 str << info;
1594 return str.str();
1595}
1596
1597/** Formatted output of the GEMMInfo type.
1598 *
1599 * @param[in] info Type to output.
1600 *
1601 * @return Formatted string.
1602 */
1603inline std::string to_string(const GEMMInfo &info)
1604{
1605 std::stringstream str;
1606 str << info;
1607 return str.str();
1608}
1609
1610/** Formatted output of the Window::Dimension type.
1611 *
1612 * @param[in] dim Type to output.
1613 *
1614 * @return Formatted string.
1615 */
1616inline std::string to_string(const Window::Dimension &dim)
1617{
1618 std::stringstream str;
1619 str << dim;
1620 return str.str();
1621}
ramelg01cbbb0382021-09-17 17:36:57 +01001622/** Formatted output of the Window& type.
Anthony Barbierb940fd62018-06-04 14:14:32 +01001623 *
1624 * @param[in] win Type to output.
1625 *
1626 * @return Formatted string.
1627 */
1628inline std::string to_string(const Window &win)
1629{
1630 std::stringstream str;
1631 str << win;
1632 return str.str();
1633}
1634
ramelg01cbbb0382021-09-17 17:36:57 +01001635/** Formatted output of the Window* type.
1636 *
1637 * @param[in] win Type to output.
1638 *
1639 * @return Formatted string.
1640 */
1641inline std::string to_string(Window *win)
1642{
1643 std::string ret_str = "nullptr";
1644 if(win != nullptr)
1645 {
1646 std::stringstream str;
1647 str << *win;
1648 ret_str = str.str();
1649 }
1650 return ret_str;
1651}
1652
Alex Gildayc357c472018-03-21 13:54:09 +00001653/** Formatted output of the Rectangle type.
1654 *
1655 * @param[out] os Output stream.
1656 * @param[in] rect Type to output.
1657 *
1658 * @return Modified output stream.
1659 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001660inline ::std::ostream &operator<<(::std::ostream &os, const Rectangle &rect)
1661{
1662 os << rect.width << "x" << rect.height;
1663 os << "+" << rect.x << "+" << rect.y;
1664
1665 return os;
1666}
1667
Usama Arif8cf8c112019-03-14 15:36:54 +00001668/** Formatted output of the PaddingMode type.
1669 *
1670 * @param[out] os Output stream.
1671 * @param[in] mode Type to output.
1672 *
1673 * @return Modified output stream.
1674 */
1675inline ::std::ostream &operator<<(::std::ostream &os, const PaddingMode &mode)
1676{
1677 switch(mode)
1678 {
1679 case PaddingMode::CONSTANT:
1680 os << "CONSTANT";
1681 break;
1682 case PaddingMode::REFLECT:
1683 os << "REFLECT";
1684 break;
1685 case PaddingMode::SYMMETRIC:
1686 os << "SYMMETRIC";
1687 break;
1688 default:
1689 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1690 }
1691
1692 return os;
1693}
1694
1695/** Formatted output of the PaddingMode type.
1696 *
1697 * @param[in] mode Type to output.
1698 *
1699 * @return Formatted string.
1700 */
1701inline std::string to_string(const PaddingMode &mode)
1702{
1703 std::stringstream str;
1704 str << mode;
1705 return str.str();
1706}
1707
Alex Gildayc357c472018-03-21 13:54:09 +00001708/** Formatted output of the PadStrideInfo type.
1709 *
1710 * @param[out] os Output stream.
1711 * @param[in] pad_stride_info Type to output.
1712 *
1713 * @return Modified output stream.
1714 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001715inline ::std::ostream &operator<<(::std::ostream &os, const PadStrideInfo &pad_stride_info)
1716{
1717 os << pad_stride_info.stride().first << "," << pad_stride_info.stride().second;
1718 os << ";";
Jaroslaw Rzepeckia1ed41f2017-10-13 11:13:58 +01001719 os << pad_stride_info.pad_left() << "," << pad_stride_info.pad_right() << ","
1720 << pad_stride_info.pad_top() << "," << pad_stride_info.pad_bottom();
Anthony Barbier2a07e182017-08-04 18:20:27 +01001721
1722 return os;
1723}
1724
Alex Gildayc357c472018-03-21 13:54:09 +00001725/** Formatted output of the PadStrideInfo type.
1726 *
1727 * @param[in] pad_stride_info Type to output.
1728 *
1729 * @return Formatted string.
1730 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001731inline std::string to_string(const PadStrideInfo &pad_stride_info)
1732{
1733 std::stringstream str;
1734 str << pad_stride_info;
1735 return str.str();
1736}
1737
Alex Gildayc357c472018-03-21 13:54:09 +00001738/** Formatted output of the BorderMode type.
1739 *
1740 * @param[in] mode Type to output.
1741 *
1742 * @return Formatted string.
1743 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001744inline std::string to_string(const BorderMode &mode)
1745{
1746 std::stringstream str;
1747 str << mode;
1748 return str.str();
1749}
1750
Alex Gildayc357c472018-03-21 13:54:09 +00001751/** Formatted output of the BorderSize type.
1752 *
1753 * @param[in] border Type to output.
1754 *
1755 * @return Formatted string.
1756 */
John Richardsonb482ce12017-09-18 12:44:01 +01001757inline std::string to_string(const BorderSize &border)
1758{
1759 std::stringstream str;
1760 str << border;
1761 return str.str();
1762}
1763
Giuseppe Rossinid7647d42018-07-17 18:13:13 +01001764/** Formatted output of the PaddingList type.
1765 *
1766 * @param[in] padding Type to output.
1767 *
1768 * @return Formatted string.
1769 */
1770inline std::string to_string(const PaddingList &padding)
1771{
1772 std::stringstream str;
1773 str << padding;
1774 return str.str();
1775}
1776
giuros013175fcf2018-11-21 09:59:17 +00001777/** Formatted output of the Multiples type.
1778 *
1779 * @param[in] multiples Type to output.
1780 *
1781 * @return Formatted string.
1782 */
1783inline std::string to_string(const Multiples &multiples)
1784{
1785 std::stringstream str;
1786 str << multiples;
1787 return str.str();
1788}
1789
Alex Gildayc357c472018-03-21 13:54:09 +00001790/** Formatted output of the InterpolationPolicy type.
1791 *
1792 * @param[in] policy Type to output.
1793 *
1794 * @return Formatted string.
1795 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001796inline std::string to_string(const InterpolationPolicy &policy)
1797{
1798 std::stringstream str;
1799 str << policy;
1800 return str.str();
1801}
1802
Alex Gildayc357c472018-03-21 13:54:09 +00001803/** Formatted output of the SamplingPolicy type.
1804 *
1805 * @param[in] policy Type to output.
1806 *
1807 * @return Formatted string.
1808 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +07001809inline std::string to_string(const SamplingPolicy &policy)
1810{
1811 std::stringstream str;
1812 str << policy;
1813 return str.str();
1814}
1815
Alex Gildayc357c472018-03-21 13:54:09 +00001816/** Formatted output of the ConvertPolicy type.
1817 *
1818 * @param[out] os Output stream.
1819 * @param[in] policy Type to output.
1820 *
1821 * @return Modified output stream.
1822 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001823inline ::std::ostream &operator<<(::std::ostream &os, const ConvertPolicy &policy)
1824{
1825 switch(policy)
1826 {
1827 case ConvertPolicy::WRAP:
1828 os << "WRAP";
1829 break;
1830 case ConvertPolicy::SATURATE:
1831 os << "SATURATE";
1832 break;
1833 default:
1834 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1835 }
1836
1837 return os;
1838}
1839
1840inline std::string to_string(const ConvertPolicy &policy)
1841{
1842 std::stringstream str;
1843 str << policy;
1844 return str.str();
1845}
1846
giuros01164a2722018-11-20 18:34:46 +00001847/** Formatted output of the ArithmeticOperation type.
1848 *
1849 * @param[out] os Output stream.
1850 * @param[in] op Operation to output.
1851 *
1852 * @return Modified output stream.
1853 */
1854inline ::std::ostream &operator<<(::std::ostream &os, const ArithmeticOperation &op)
1855{
1856 switch(op)
1857 {
1858 case ArithmeticOperation::ADD:
1859 os << "ADD";
1860 break;
1861 case ArithmeticOperation::SUB:
1862 os << "SUB";
1863 break;
1864 case ArithmeticOperation::DIV:
1865 os << "DIV";
1866 break;
1867 case ArithmeticOperation::MAX:
1868 os << "MAX";
1869 break;
1870 case ArithmeticOperation::MIN:
1871 os << "MIN";
1872 break;
1873 case ArithmeticOperation::SQUARED_DIFF:
1874 os << "SQUARED_DIFF";
1875 break;
Usama Arif52c54f62019-05-14 10:22:36 +01001876 case ArithmeticOperation::POWER:
1877 os << "POWER";
1878 break;
Ramy Elgammal404462a2022-11-08 02:14:46 +00001879 case ArithmeticOperation::PRELU:
1880 os << "PRELU";
1881 break;
giuros01164a2722018-11-20 18:34:46 +00001882 default:
1883 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1884 }
1885
1886 return os;
1887}
1888
1889/** Formatted output of the Arithmetic Operation
1890 *
1891 * @param[in] op Type to output.
1892 *
1893 * @return Formatted string.
1894 */
1895inline std::string to_string(const ArithmeticOperation &op)
1896{
1897 std::stringstream str;
1898 str << op;
1899 return str.str();
1900}
1901
Alex Gildayc357c472018-03-21 13:54:09 +00001902/** Formatted output of the Reduction Operations.
1903 *
1904 * @param[out] os Output stream.
1905 * @param[in] op Type to output.
1906 *
1907 * @return Modified output stream.
1908 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001909inline ::std::ostream &operator<<(::std::ostream &os, const ReductionOperation &op)
1910{
1911 switch(op)
1912 {
Michalis Spyrou7e9391b2018-10-05 14:49:28 +01001913 case ReductionOperation::SUM:
1914 os << "SUM";
1915 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +01001916 case ReductionOperation::SUM_SQUARE:
1917 os << "SUM_SQUARE";
1918 break;
Michalis Spyrou7e9391b2018-10-05 14:49:28 +01001919 case ReductionOperation::MEAN_SUM:
1920 os << "MEAN_SUM";
1921 break;
Michalis Spyrou7930db42018-11-22 17:36:28 +00001922 case ReductionOperation::ARG_IDX_MAX:
1923 os << "ARG_IDX_MAX";
1924 break;
1925 case ReductionOperation::ARG_IDX_MIN:
1926 os << "ARG_IDX_MIN";
1927 break;
Manuel Bottinib412fab2018-12-10 17:40:23 +00001928 case ReductionOperation::PROD:
1929 os << "PROD";
1930 break;
Usama Arifa4a08ad2019-05-20 12:38:33 +01001931 case ReductionOperation::MIN:
1932 os << "MIN";
1933 break;
Usama Arif28f0dd92019-05-20 13:44:34 +01001934 case ReductionOperation::MAX:
1935 os << "MAX";
1936 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +01001937 default:
1938 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1939 }
1940
1941 return os;
1942}
1943
Alex Gildayc357c472018-03-21 13:54:09 +00001944/** Formatted output of the Reduction Operations.
1945 *
1946 * @param[in] op Type to output.
1947 *
1948 * @return Formatted string.
1949 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001950inline std::string to_string(const ReductionOperation &op)
1951{
1952 std::stringstream str;
1953 str << op;
1954 return str.str();
1955}
1956
Georgios Pinitas7900a9e2018-11-23 11:44:58 +00001957/** Formatted output of the Comparison Operations.
1958 *
1959 * @param[out] os Output stream.
1960 * @param[in] op Type to output.
1961 *
1962 * @return Modified output stream.
1963 */
1964inline ::std::ostream &operator<<(::std::ostream &os, const ComparisonOperation &op)
1965{
1966 switch(op)
1967 {
1968 case ComparisonOperation::Equal:
1969 os << "Equal";
1970 break;
1971 case ComparisonOperation::NotEqual:
1972 os << "NotEqual";
1973 break;
1974 case ComparisonOperation::Greater:
1975 os << "Greater";
1976 break;
1977 case ComparisonOperation::GreaterEqual:
1978 os << "GreaterEqual";
1979 break;
1980 case ComparisonOperation::Less:
1981 os << "Less";
1982 break;
1983 case ComparisonOperation::LessEqual:
1984 os << "LessEqual";
1985 break;
1986 default:
1987 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1988 }
1989
1990 return os;
1991}
1992
Michalis Spyroue9362622018-11-23 17:41:37 +00001993/** Formatted output of the Elementwise unary Operations.
1994 *
1995 * @param[out] os Output stream.
1996 * @param[in] op Type to output.
1997 *
1998 * @return Modified output stream.
1999 */
2000inline ::std::ostream &operator<<(::std::ostream &os, const ElementWiseUnary &op)
2001{
2002 switch(op)
2003 {
2004 case ElementWiseUnary::RSQRT:
2005 os << "RSQRT";
2006 break;
2007 case ElementWiseUnary::EXP:
2008 os << "EXP";
2009 break;
Usama Arifeb312ef2019-05-13 17:45:54 +01002010 case ElementWiseUnary::NEG:
2011 os << "NEG";
2012 break;
Usama Arifac33d7e2019-05-20 14:21:40 +01002013 case ElementWiseUnary::LOG:
2014 os << "LOG";
2015 break;
ramelg01b1ba1e32021-09-25 11:53:26 +01002016 case ElementWiseUnary::SIN:
2017 os << "SIN";
2018 break;
2019 case ElementWiseUnary::ABS:
2020 os << "ABS";
2021 break;
Usama Arif6a4d5422019-05-24 14:53:59 +01002022 case ElementWiseUnary::ROUND:
2023 os << "ROUND";
2024 break;
ramelg01b1ba1e32021-09-25 11:53:26 +01002025 case ElementWiseUnary::LOGICAL_NOT:
2026 os << "LOGICAL_NOT";
2027 break;
Michalis Spyroue9362622018-11-23 17:41:37 +00002028 default:
2029 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2030 }
2031
2032 return os;
2033}
2034
Georgios Pinitas7900a9e2018-11-23 11:44:58 +00002035/** Formatted output of the Comparison Operations.
2036 *
2037 * @param[in] op Type to output.
2038 *
2039 * @return Formatted string.
2040 */
2041inline std::string to_string(const ComparisonOperation &op)
2042{
2043 std::stringstream str;
2044 str << op;
2045 return str.str();
2046}
2047
Michalis Spyroue9362622018-11-23 17:41:37 +00002048/** Formatted output of the Elementwise unary Operations.
2049 *
2050 * @param[in] op Type to output.
2051 *
2052 * @return Formatted string.
2053 */
2054inline std::string to_string(const ElementWiseUnary &op)
2055{
2056 std::stringstream str;
2057 str << op;
2058 return str.str();
2059}
2060
Alex Gildayc357c472018-03-21 13:54:09 +00002061/** Formatted output of the Norm Type.
2062 *
2063 * @param[in] type Type to output.
2064 *
2065 * @return Formatted string.
2066 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01002067inline std::string to_string(const NormType &type)
2068{
2069 std::stringstream str;
2070 str << type;
2071 return str.str();
2072}
2073
Alex Gildayc357c472018-03-21 13:54:09 +00002074/** Formatted output of the Pooling Type.
2075 *
2076 * @param[in] type Type to output.
2077 *
2078 * @return Formatted string.
2079 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01002080inline std::string to_string(const PoolingType &type)
2081{
2082 std::stringstream str;
2083 str << type;
2084 return str.str();
2085}
2086
Alex Gildayc357c472018-03-21 13:54:09 +00002087/** Formatted output of the Pooling Layer Info.
2088 *
2089 * @param[in] info Type to output.
2090 *
2091 * @return Formatted string.
2092 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01002093inline std::string to_string(const PoolingLayerInfo &info)
2094{
2095 std::stringstream str;
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +00002096 str << "{Type=" << info.pool_type << ","
Sang-Hoon Park11fedda2020-01-15 14:44:04 +00002097 << "DataLayout=" << info.data_layout << ","
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +00002098 << "IsGlobalPooling=" << info.is_global_pooling;
2099 if(!info.is_global_pooling)
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00002100 {
2101 str << ","
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +00002102 << "PoolSize=" << info.pool_size.width << "," << info.pool_size.height << ","
2103 << "PadStride=" << info.pad_stride_info;
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00002104 }
2105 str << "}";
Anthony Barbier2a07e182017-08-04 18:20:27 +01002106 return str.str();
2107}
2108
ramelg0137515692022-02-26 22:06:20 +00002109/** Formatted output of the Size3D type.
2110 *
2111 * @param[out] os Output stream
2112 * @param[in] size Type to output
2113 *
2114 * @return Modified output stream.
2115 */
2116inline ::std::ostream &operator<<(::std::ostream &os, const Size3D &size)
2117{
2118 os << size.width << "x" << size.height << "x" << size.depth;
2119
2120 return os;
2121}
2122
2123/** Formatted output of the Size3D type.
2124 *
2125 * @param[in] type Type to output
2126 *
2127 * @return Formatted string.
2128 */
2129inline std::string to_string(const Size3D &type)
2130{
2131 std::stringstream str;
2132 str << type;
2133 return str.str();
2134}
2135
2136/** Formatted output of the Padding3D type.
2137 *
2138 * @param[out] os Output stream.
2139 * @param[in] padding3d Padding info for 3D spatial dimension shape.
2140 *
2141 * @return Modified output stream.
2142 */
2143inline ::std::ostream &operator<<(::std::ostream &os, const Padding3D &padding3d)
2144{
2145 os << padding3d.left << "," << padding3d.right << ","
2146 << padding3d.top << "," << padding3d.bottom << ","
2147 << padding3d.front << "," << padding3d.back;
2148 return os;
2149}
2150
2151/** Converts a @ref Padding3D to string
2152 *
2153 * @param[in] padding3d Padding3D value to be converted
2154 *
2155 * @return String representing the corresponding Padding3D
2156 */
2157inline std::string to_string(const Padding3D &padding3d)
2158{
2159 std::stringstream str;
2160 str << padding3d;
2161 return str.str();
2162}
2163
2164/** Formatted output of the DimensionRoundingType type.
2165 *
2166 * @param[out] os Output stream.
2167 * @param[in] rounding_type DimensionRoundingType Dimension rounding type when down-scaling, or compute output shape of pooling(2D or 3D).
2168 *
2169 * @return Modified output stream.
2170 */
2171inline ::std::ostream &operator<<(::std::ostream &os, const DimensionRoundingType &rounding_type)
2172{
2173 switch(rounding_type)
2174 {
2175 case DimensionRoundingType::CEIL:
2176 os << "CEIL";
2177 break;
2178 case DimensionRoundingType::FLOOR:
2179 os << "FLOOR";
2180 break;
2181 default:
2182 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2183 }
2184 return os;
2185}
2186
2187/** Formatted output of the Pooling 3d Layer Info.
2188 *
2189 * @param[out] os Output stream.
2190 * @param[in] info Pooling 3D layer info to print to output stream.
2191 *
2192 * @return Modified output stream.
2193 */
2194inline ::std::ostream &operator<<(::std::ostream &os, const Pooling3dLayerInfo &info)
2195{
2196 os << "{Type=" << info.pool_type << ","
2197 << "IsGlobalPooling=" << info.is_global_pooling;
2198 if(!info.is_global_pooling)
2199 {
2200 os << ","
2201 << "PoolSize=" << info.pool_size << ", "
2202 << "Stride=" << info.stride << ", "
2203 << "Padding=" << info.padding << ", "
2204 << "Exclude Padding=" << info.exclude_padding << ", "
2205 << "fp_mixed_precision=" << info.fp_mixed_precision << ", "
2206 << "DimensionRoundingType=" << info.round_type;
2207 }
2208 os << "}";
2209 return os;
2210}
2211
2212/** Formatted output of the Pooling 3d Layer Info.
2213 *
2214 * @param[in] info Type to output.
2215 *
2216 * @return Formatted string.
2217 */
2218inline std::string to_string(const Pooling3dLayerInfo &info)
2219{
2220 std::stringstream str;
2221 str << info;
2222 return str.str();
2223}
2224
Michalis Spyrou6c7c38e2018-08-29 16:28:11 +01002225/** Formatted output of the PriorBoxLayerInfo.
2226 *
2227 * @param[in] info Type to output.
2228 *
2229 * @return Formatted string.
2230 */
2231inline std::string to_string(const PriorBoxLayerInfo &info)
2232{
2233 std::stringstream str;
2234 str << "{";
2235 str << "Clip:" << info.clip()
2236 << "Flip:" << info.flip()
2237 << "StepX:" << info.steps()[0]
2238 << "StepY:" << info.steps()[1]
2239 << "MinSizes:" << info.min_sizes().size()
2240 << "MaxSizes:" << info.max_sizes().size()
2241 << "ImgSizeX:" << info.img_size().x
2242 << "ImgSizeY:" << info.img_size().y
2243 << "Offset:" << info.offset()
2244 << "Variances:" << info.variances().size();
2245 str << "}";
2246 return str.str();
2247}
2248
Alex Gildayc357c472018-03-21 13:54:09 +00002249/** Formatted output of the Size2D type.
2250 *
2251 * @param[out] os Output stream
2252 * @param[in] size Type to output
2253 *
2254 * @return Modified output stream.
2255 */
John Richardson25f23682017-11-27 14:35:09 +00002256inline ::std::ostream &operator<<(::std::ostream &os, const Size2D &size)
2257{
2258 os << size.width << "x" << size.height;
2259
2260 return os;
2261}
2262
Alex Gildayc357c472018-03-21 13:54:09 +00002263/** Formatted output of the Size2D type.
2264 *
2265 * @param[in] type Type to output
2266 *
2267 * @return Formatted string.
2268 */
John Richardson25f23682017-11-27 14:35:09 +00002269inline std::string to_string(const Size2D &type)
2270{
2271 std::stringstream str;
2272 str << type;
2273 return str.str();
2274}
2275
Alex Gildayc357c472018-03-21 13:54:09 +00002276/** Formatted output of the ConvolutionMethod type.
2277 *
2278 * @param[out] os Output stream
2279 * @param[in] conv_method Type to output
2280 *
2281 * @return Modified output stream.
2282 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002283inline ::std::ostream &operator<<(::std::ostream &os, const ConvolutionMethod &conv_method)
2284{
2285 switch(conv_method)
2286 {
2287 case ConvolutionMethod::GEMM:
2288 os << "GEMM";
2289 break;
2290 case ConvolutionMethod::DIRECT:
2291 os << "DIRECT";
2292 break;
2293 case ConvolutionMethod::WINOGRAD:
2294 os << "WINOGRAD";
2295 break;
SiCongLid9287352021-11-03 19:01:22 +00002296 case ConvolutionMethod::FFT:
2297 os << "FFT";
2298 break;
2299 case ConvolutionMethod::GEMM_CONV2D:
2300 os << "GEMM_CONV2D";
2301 break;
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002302 default:
2303 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2304 }
2305
2306 return os;
2307}
2308
Alex Gildayc357c472018-03-21 13:54:09 +00002309/** Formatted output of the ConvolutionMethod type.
2310 *
2311 * @param[in] conv_method Type to output
2312 *
2313 * @return Formatted string.
2314 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002315inline std::string to_string(const ConvolutionMethod &conv_method)
2316{
2317 std::stringstream str;
2318 str << conv_method;
2319 return str.str();
2320}
2321
Alex Gildayc357c472018-03-21 13:54:09 +00002322/** Formatted output of the GPUTarget type.
2323 *
2324 * @param[out] os Output stream
2325 * @param[in] gpu_target Type to output
2326 *
2327 * @return Modified output stream.
2328 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002329inline ::std::ostream &operator<<(::std::ostream &os, const GPUTarget &gpu_target)
2330{
2331 switch(gpu_target)
2332 {
2333 case GPUTarget::GPU_ARCH_MASK:
2334 os << "GPU_ARCH_MASK";
2335 break;
Gian Marco Iodice3c4d0852022-07-11 12:09:45 +01002336 case GPUTarget::GPU_GENERATION_MASK:
2337 os << "GPU_GENERATION_MASK";
2338 break;
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002339 case GPUTarget::MIDGARD:
2340 os << "MIDGARD";
2341 break;
2342 case GPUTarget::BIFROST:
2343 os << "BIFROST";
2344 break;
Georgios Pinitasd5462ff2019-07-03 19:33:57 +01002345 case GPUTarget::VALHALL:
2346 os << "VALHALL";
2347 break;
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002348 case GPUTarget::T600:
2349 os << "T600";
2350 break;
2351 case GPUTarget::T700:
2352 os << "T700";
2353 break;
2354 case GPUTarget::T800:
2355 os << "T800";
2356 break;
Michalis Spyroua9676112018-02-22 18:07:43 +00002357 case GPUTarget::G71:
2358 os << "G71";
2359 break;
2360 case GPUTarget::G72:
2361 os << "G72";
2362 break;
2363 case GPUTarget::G51:
2364 os << "G51";
2365 break;
2366 case GPUTarget::G51BIG:
2367 os << "G51BIG";
2368 break;
2369 case GPUTarget::G51LIT:
2370 os << "G51LIT";
2371 break;
Gian Marco Iodice3c4d0852022-07-11 12:09:45 +01002372 case GPUTarget::G31:
2373 os << "G31";
2374 break;
Georgios Pinitasb03f7c52018-07-12 10:49:53 +01002375 case GPUTarget::G76:
2376 os << "G76";
Michalis Spyroua9676112018-02-22 18:07:43 +00002377 break;
Gian Marco Iodice3c4d0852022-07-11 12:09:45 +01002378 case GPUTarget::G52:
2379 os << "G52";
2380 break;
2381 case GPUTarget::G52LIT:
2382 os << "G52LIT";
2383 break;
Georgios Pinitasd5462ff2019-07-03 19:33:57 +01002384 case GPUTarget::G77:
2385 os << "G77";
Michalis Spyroua9676112018-02-22 18:07:43 +00002386 break;
Gian Marco Iodice3c4d0852022-07-11 12:09:45 +01002387 case GPUTarget::G57:
2388 os << "G57";
2389 break;
Georgios Pinitas4ffc42a2020-12-01 16:28:24 +00002390 case GPUTarget::G78:
2391 os << "G78";
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002392 break;
Gian Marco Iodice3c4d0852022-07-11 12:09:45 +01002393 case GPUTarget::G68:
2394 os << "G68";
2395 break;
2396 case GPUTarget::G78AE:
2397 os << "G78AE";
Pablo Marquez Tellob1496e62021-06-25 14:49:37 +01002398 break;
Gian Marco Iodiceab2bc732022-01-19 10:06:45 +00002399 case GPUTarget::G710:
2400 os << "G710";
Georgios Pinitasd5462ff2019-07-03 19:33:57 +01002401 break;
Gian Marco Iodice3c4d0852022-07-11 12:09:45 +01002402 case GPUTarget::G610:
2403 os << "G610";
2404 break;
2405 case GPUTarget::G510:
2406 os << "G510";
2407 break;
2408 case GPUTarget::G310:
2409 os << "G310";
2410 break;
Gunes Bayir4bfc70e2021-12-10 16:17:56 +00002411 case GPUTarget::G715:
2412 os << "G715";
2413 break;
2414 case GPUTarget::G615:
2415 os << "G615";
2416 break;
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002417 default:
2418 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2419 }
2420
2421 return os;
2422}
2423
Alex Gildayc357c472018-03-21 13:54:09 +00002424/** Formatted output of the GPUTarget type.
2425 *
2426 * @param[in] gpu_target Type to output
2427 *
2428 * @return Formatted string.
2429 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002430inline std::string to_string(const GPUTarget &gpu_target)
2431{
2432 std::stringstream str;
2433 str << gpu_target;
2434 return str.str();
2435}
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00002436
John Richardson8de92612018-02-22 14:09:31 +00002437/** Formatted output of the DetectionWindow type.
2438 *
2439 * @param[out] os Output stream
2440 * @param[in] detection_window Type to output
2441 *
2442 * @return Modified output stream.
2443 */
John Richardson684cb0f2018-01-09 11:17:00 +00002444inline ::std::ostream &operator<<(::std::ostream &os, const DetectionWindow &detection_window)
2445{
2446 os << "{x=" << detection_window.x << ","
2447 << "y=" << detection_window.y << ","
2448 << "width=" << detection_window.width << ","
2449 << "height=" << detection_window.height << ","
2450 << "idx_class=" << detection_window.idx_class << ","
2451 << "score=" << detection_window.score << "}";
2452
2453 return os;
2454}
2455
Isabella Gottardi05e56442018-11-16 11:26:52 +00002456/** Formatted output of the DetectionOutputLayerCodeType type.
2457 *
2458 * @param[out] os Output stream
2459 * @param[in] detection_code Type to output
2460 *
2461 * @return Modified output stream.
2462 */
2463inline ::std::ostream &operator<<(::std::ostream &os, const DetectionOutputLayerCodeType &detection_code)
2464{
2465 switch(detection_code)
2466 {
2467 case DetectionOutputLayerCodeType::CENTER_SIZE:
2468 os << "CENTER_SIZE";
2469 break;
2470 case DetectionOutputLayerCodeType::CORNER:
2471 os << "CORNER";
2472 break;
2473 case DetectionOutputLayerCodeType::CORNER_SIZE:
2474 os << "CORNER_SIZE";
2475 break;
2476 case DetectionOutputLayerCodeType::TF_CENTER:
2477 os << "TF_CENTER";
2478 break;
2479 default:
2480 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2481 }
2482
2483 return os;
2484}
2485/** Formatted output of the DetectionOutputLayerCodeType type.
2486 *
2487 * @param[in] detection_code Type to output
2488 *
2489 * @return Formatted string.
2490 */
2491inline std::string to_string(const DetectionOutputLayerCodeType &detection_code)
2492{
2493 std::stringstream str;
2494 str << detection_code;
2495 return str.str();
2496}
2497
2498/** Formatted output of the DetectionOutputLayerInfo type.
2499 *
2500 * @param[out] os Output stream
2501 * @param[in] detection_info Type to output
2502 *
2503 * @return Modified output stream.
2504 */
2505inline ::std::ostream &operator<<(::std::ostream &os, const DetectionOutputLayerInfo &detection_info)
2506{
2507 os << "{Classes=" << detection_info.num_classes() << ","
2508 << "ShareLocation=" << detection_info.share_location() << ","
2509 << "CodeType=" << detection_info.code_type() << ","
2510 << "VarianceEncodedInTarget=" << detection_info.variance_encoded_in_target() << ","
2511 << "KeepTopK=" << detection_info.keep_top_k() << ","
2512 << "NMSThreshold=" << detection_info.nms_threshold() << ","
2513 << "Eta=" << detection_info.eta() << ","
2514 << "BackgroundLabelId=" << detection_info.background_label_id() << ","
2515 << "ConfidenceThreshold=" << detection_info.confidence_threshold() << ","
2516 << "TopK=" << detection_info.top_k() << ","
2517 << "NumLocClasses=" << detection_info.num_loc_classes()
2518 << "}";
2519
2520 return os;
2521}
2522
2523/** Formatted output of the DetectionOutputLayerInfo type.
2524 *
2525 * @param[in] detection_info Type to output
2526 *
2527 * @return Formatted string.
2528 */
2529inline std::string to_string(const DetectionOutputLayerInfo &detection_info)
2530{
2531 std::stringstream str;
2532 str << detection_info;
2533 return str.str();
2534}
Isabella Gottardia7acb3c2019-01-08 13:48:44 +00002535/** Formatted output of the DetectionPostProcessLayerInfo type.
2536 *
2537 * @param[out] os Output stream
2538 * @param[in] detection_info Type to output
2539 *
2540 * @return Modified output stream.
2541 */
2542inline ::std::ostream &operator<<(::std::ostream &os, const DetectionPostProcessLayerInfo &detection_info)
2543{
2544 os << "{MaxDetections=" << detection_info.max_detections() << ","
2545 << "MaxClassesPerDetection=" << detection_info.max_classes_per_detection() << ","
2546 << "NmsScoreThreshold=" << detection_info.nms_score_threshold() << ","
2547 << "NmsIouThreshold=" << detection_info.iou_threshold() << ","
2548 << "NumClasses=" << detection_info.num_classes() << ","
2549 << "ScaleValue_y=" << detection_info.scale_value_y() << ","
2550 << "ScaleValue_x=" << detection_info.scale_value_x() << ","
2551 << "ScaleValue_h=" << detection_info.scale_value_h() << ","
2552 << "ScaleValue_w=" << detection_info.scale_value_w() << ","
2553 << "UseRegularNms=" << detection_info.use_regular_nms() << ","
2554 << "DetectionPerClass=" << detection_info.detection_per_class()
2555 << "}";
2556
2557 return os;
2558}
2559
2560/** Formatted output of the DetectionPostProcessLayerInfo type.
2561 *
2562 * @param[in] detection_info Type to output
2563 *
2564 * @return Formatted string.
2565 */
2566inline std::string to_string(const DetectionPostProcessLayerInfo &detection_info)
2567{
2568 std::stringstream str;
2569 str << detection_info;
2570 return str.str();
2571}
Georgios Pinitasc6f95102021-03-30 10:03:01 +01002572
John Richardson8de92612018-02-22 14:09:31 +00002573/** Formatted output of the DetectionWindow type.
2574 *
2575 * @param[in] detection_window Type to output
2576 *
2577 * @return Formatted string.
2578 */
2579inline std::string to_string(const DetectionWindow &detection_window)
2580{
2581 std::stringstream str;
2582 str << detection_window;
2583 return str.str();
2584}
2585
Michalis Spyrou6c7c38e2018-08-29 16:28:11 +01002586/** Formatted output of @ref PriorBoxLayerInfo.
2587 *
2588 * @param[out] os Output stream.
2589 * @param[in] info Type to output.
2590 *
2591 * @return Modified output stream.
2592 */
2593inline ::std::ostream &operator<<(::std::ostream &os, const PriorBoxLayerInfo &info)
2594{
2595 os << "Clip:" << info.clip()
2596 << "Flip:" << info.flip()
2597 << "StepX:" << info.steps()[0]
2598 << "StepY:" << info.steps()[1]
2599 << "MinSizes:" << info.min_sizes()
2600 << "MaxSizes:" << info.max_sizes()
2601 << "ImgSizeX:" << info.img_size().x
2602 << "ImgSizeY:" << info.img_size().y
2603 << "Offset:" << info.offset()
2604 << "Variances:" << info.variances();
2605
2606 return os;
2607}
2608
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00002609/** Formatted output of the WinogradInfo type. */
2610inline ::std::ostream &operator<<(::std::ostream &os, const WinogradInfo &info)
2611{
2612 os << "{OutputTileSize=" << info.output_tile_size << ","
2613 << "KernelSize=" << info.kernel_size << ","
2614 << "PadStride=" << info.convolution_info << ","
2615 << "OutputDataLayout=" << info.output_data_layout << "}";
2616
2617 return os;
2618}
2619
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00002620inline std::string to_string(const WinogradInfo &type)
2621{
2622 std::stringstream str;
2623 str << type;
2624 return str.str();
2625}
Anthony Barbier671a11e2018-07-06 15:11:36 +01002626
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +01002627/** Convert a CLTunerMode value to a string
2628 *
2629 * @param val CLTunerMode value to be converted
2630 *
2631 * @return String representing the corresponding CLTunerMode.
2632 */
2633inline std::string to_string(const CLTunerMode val)
2634{
2635 switch(val)
2636 {
2637 case CLTunerMode::EXHAUSTIVE:
2638 {
2639 return std::string("Exhaustive");
2640 }
2641 case CLTunerMode::NORMAL:
2642 {
2643 return std::string("Normal");
2644 }
2645 case CLTunerMode::RAPID:
2646 {
2647 return std::string("Rapid");
2648 }
2649 default:
2650 {
2651 ARM_COMPUTE_ERROR("Invalid tuner mode.");
2652 return std::string("UNDEFINED");
2653 }
2654 }
2655}
SiCong Lidb4a6c12021-02-05 09:30:57 +00002656/** Converts a @ref CLGEMMKernelType to string
2657 *
2658 * @param[in] val CLGEMMKernelType value to be converted
2659 *
2660 * @return String representing the corresponding CLGEMMKernelType
2661 */
2662inline std::string to_string(CLGEMMKernelType val)
2663{
2664 switch(val)
2665 {
SiCong Lidb4a6c12021-02-05 09:30:57 +00002666 case CLGEMMKernelType::NATIVE:
2667 {
2668 return "Native";
2669 }
2670 case CLGEMMKernelType::RESHAPED_ONLY_RHS:
2671 {
2672 return "Reshaped_Only_RHS";
2673 }
2674 case CLGEMMKernelType::RESHAPED:
2675 {
2676 return "Reshaped";
2677 }
2678 default:
2679 {
2680 return "Unknown";
2681 }
2682 }
2683}
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +01002684/** [Print CLTunerMode type] **/
2685/** Formatted output of the CLTunerMode type.
2686 *
2687 * @param[out] os Output stream.
2688 * @param[in] val CLTunerMode to output.
2689 *
2690 * @return Modified output stream.
2691 */
2692inline ::std::ostream &operator<<(::std::ostream &os, const CLTunerMode &val)
2693{
2694 os << to_string(val);
2695 return os;
2696}
2697
ramelg013ae3d882021-09-12 23:07:47 +01002698/** Formatted output of the ConvolutionInfo type.
2699 *
2700 * @param[out] os Output stream.
2701 * @param[in] conv_info ConvolutionInfo to output.
2702 *
2703 * @return Modified output stream.
2704 */
2705inline ::std::ostream &operator<<(::std::ostream &os, const ConvolutionInfo &conv_info)
2706{
SiCongLi579ca842021-10-18 09:38:33 +01002707 os << "{PadStrideInfo=" << conv_info.pad_stride_info << ", "
2708 << "depth_multiplier=" << conv_info.depth_multiplier << ", "
2709 << "act_info=" << to_string(conv_info.act_info) << ", "
2710 << "dilation=" << conv_info.dilation << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002711 return os;
2712}
2713
2714/** Converts a @ref ConvolutionInfo to string
2715 *
2716 * @param[in] info ConvolutionInfo value to be converted
2717 *
2718 * @return String representing the corresponding ConvolutionInfo
2719 */
2720inline std::string to_string(const ConvolutionInfo &info)
2721{
2722 std::stringstream str;
2723 str << info;
2724 return str.str();
2725}
2726
2727/** Formatted output of the FullyConnectedLayerInfo type.
2728 *
2729 * @param[out] os Output stream.
2730 * @param[in] layer_info FullyConnectedLayerInfo to output.
2731 *
2732 * @return Modified output stream.
2733 */
2734inline ::std::ostream &operator<<(::std::ostream &os, const FullyConnectedLayerInfo &layer_info)
2735{
SiCongLi579ca842021-10-18 09:38:33 +01002736 os << "{activation_info=" << to_string(layer_info.activation_info) << ", "
2737 << "weights_trained_layout=" << layer_info.weights_trained_layout << ", "
2738 << "transpose_weights=" << layer_info.transpose_weights << ", "
2739 << "are_weights_reshaped=" << layer_info.are_weights_reshaped << ", "
2740 << "retain_internal_weights=" << layer_info.retain_internal_weights << ", "
2741 << "constant_weights=" << layer_info.transpose_weights << ", "
2742 << "fp_mixed_precision=" << layer_info.fp_mixed_precision << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002743 return os;
2744}
2745
2746/** Converts a @ref FullyConnectedLayerInfo to string
2747 *
2748 * @param[in] info FullyConnectedLayerInfo value to be converted
2749 *
2750 * @return String representing the corresponding FullyConnectedLayerInfo
2751 */
2752inline std::string to_string(const FullyConnectedLayerInfo &info)
2753{
2754 std::stringstream str;
2755 str << info;
2756 return str.str();
2757}
2758
2759/** Formatted output of the GEMMLowpOutputStageType type.
2760 *
2761 * @param[out] os Output stream.
2762 * @param[in] gemm_type GEMMLowpOutputStageType to output.
2763 *
2764 * @return Modified output stream.
2765 */
2766inline ::std::ostream &operator<<(::std::ostream &os, const GEMMLowpOutputStageType &gemm_type)
2767{
2768 switch(gemm_type)
2769 {
2770 case GEMMLowpOutputStageType::NONE:
2771 os << "NONE";
2772 break;
2773 case GEMMLowpOutputStageType::QUANTIZE_DOWN:
2774 os << "QUANTIZE_DOWN";
2775 break;
2776 case GEMMLowpOutputStageType::QUANTIZE_DOWN_FIXEDPOINT:
2777 os << "QUANTIZE_DOWN_FIXEDPOINT";
2778 break;
2779 case GEMMLowpOutputStageType::QUANTIZE_DOWN_FLOAT:
2780 os << "QUANTIZE_DOWN_FLOAT";
2781 break;
2782 default:
2783 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2784 }
2785 return os;
2786}
2787
2788/** Converts a @ref GEMMLowpOutputStageType to string
2789 *
2790 * @param[in] gemm_type GEMMLowpOutputStageType value to be converted
2791 *
2792 * @return String representing the corresponding GEMMLowpOutputStageType
2793 */
2794inline std::string to_string(const GEMMLowpOutputStageType &gemm_type)
2795{
2796 std::stringstream str;
2797 str << gemm_type;
2798 return str.str();
2799}
2800
2801/** Formatted output of the GEMMLowpOutputStageInfo type.
2802 *
2803 * @param[out] os Output stream.
2804 * @param[in] gemm_info GEMMLowpOutputStageInfo to output.
2805 *
2806 * @return Modified output stream.
2807 */
2808inline ::std::ostream &operator<<(::std::ostream &os, const GEMMLowpOutputStageInfo &gemm_info)
2809{
SiCongLi579ca842021-10-18 09:38:33 +01002810 os << "{type=" << gemm_info.type << ", "
2811 << "gemlowp_offset=" << gemm_info.gemmlowp_offset << ", "
2812 << "gemmlowp_multiplier=" << gemm_info.gemmlowp_multiplier << ", "
2813 << "gemmlowp_shift=" << gemm_info.gemmlowp_shift << ", "
2814 << "gemmlowp_min_bound=" << gemm_info.gemmlowp_min_bound << ", "
2815 << "gemmlowp_max_bound=" << gemm_info.gemmlowp_max_bound << ", "
2816 << "gemmlowp_multipliers=" << gemm_info.gemmlowp_multiplier << ", "
2817 << "gemmlowp_shifts=" << gemm_info.gemmlowp_shift << ", "
2818 << "gemmlowp_real_multiplier=" << gemm_info.gemmlowp_real_multiplier << ", "
2819 << "is_quantized_per_channel=" << gemm_info.is_quantized_per_channel << ", "
2820 << "output_data_type=" << gemm_info.output_data_type << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002821 return os;
2822}
2823
2824/** Converts a @ref GEMMLowpOutputStageInfo to string
2825 *
2826 * @param[in] gemm_info GEMMLowpOutputStageInfo value to be converted
2827 *
2828 * @return String representing the corresponding GEMMLowpOutputStageInfo
2829 */
2830inline std::string to_string(const GEMMLowpOutputStageInfo &gemm_info)
2831{
2832 std::stringstream str;
2833 str << gemm_info;
2834 return str.str();
2835}
2836
2837/** Formatted output of the Conv2dInfo type.
2838 *
2839 * @param[out] os Output stream.
2840 * @param[in] conv_info Conv2dInfo to output.
2841 *
2842 * @return Modified output stream.
2843 */
2844inline ::std::ostream &operator<<(::std::ostream &os, const Conv2dInfo &conv_info)
2845{
SiCongLi579ca842021-10-18 09:38:33 +01002846 os << "{conv_info=" << conv_info.conv_info << ", "
2847 << "dilation=" << conv_info.dilation << ", "
2848 << "act_info=" << to_string(conv_info.act_info) << ", "
2849 << "enable_fast_math=" << conv_info.enable_fast_math << ", "
2850 << "num_groups=" << conv_info.num_groups << ","
2851 << "post_ops=" << conv_info.post_ops << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002852 return os;
2853}
2854
2855/** Converts a @ref Conv2dInfo to string
2856 *
2857 * @param[in] conv_info Conv2dInfo value to be converted
2858 *
2859 * @return String representing the corresponding Conv2dInfo
2860 */
2861inline std::string to_string(const Conv2dInfo &conv_info)
2862{
2863 std::stringstream str;
2864 str << conv_info;
2865 return str.str();
2866}
2867
2868/** Formatted output of the PixelValue type.
2869 *
2870 * @param[out] os Output stream.
2871 * @param[in] pixel_value PixelValue to output.
2872 *
2873 * @return Modified output stream.
2874 */
2875inline ::std::ostream &operator<<(::std::ostream &os, const PixelValue &pixel_value)
2876{
SiCongLi579ca842021-10-18 09:38:33 +01002877 os << "{value.u64=" << pixel_value.get<uint64_t>() << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002878 return os;
2879}
2880
2881/** Converts a @ref PixelValue to string
2882 *
2883 * @param[in] pixel_value PixelValue value to be converted
2884 *
2885 * @return String representing the corresponding PixelValue
2886 */
2887inline std::string to_string(const PixelValue &pixel_value)
2888{
2889 std::stringstream str;
2890 str << pixel_value;
2891 return str.str();
2892}
2893
2894/** Formatted output of the ScaleKernelInfo type.
2895 *
2896 * @param[out] os Output stream.
2897 * @param[in] scale_info ScaleKernelInfo to output.
2898 *
2899 * @return Modified output stream.
2900 */
2901inline ::std::ostream &operator<<(::std::ostream &os, const ScaleKernelInfo &scale_info)
2902{
SiCongLi579ca842021-10-18 09:38:33 +01002903 os << "{interpolation_policy=" << scale_info.interpolation_policy << ", "
2904 << "BorderMode=" << scale_info.border_mode << ", "
2905 << "PixelValue=" << scale_info.constant_border_value << ", "
2906 << "SamplingPolicy=" << scale_info.sampling_policy << ", "
2907 << "use_padding=" << scale_info.use_padding << ", "
2908 << "align_corners=" << scale_info.align_corners << ", "
2909 << "data_layout=" << scale_info.data_layout << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002910 return os;
2911}
2912
2913/** Converts a @ref ScaleKernelInfo to string
2914 *
2915 * @param[in] scale_info ScaleKernelInfo value to be converted
2916 *
2917 * @return String representing the corresponding ScaleKernelInfo
2918 */
2919inline std::string to_string(const ScaleKernelInfo &scale_info)
2920{
2921 std::stringstream str;
2922 str << scale_info;
2923 return str.str();
2924}
2925
2926/** Formatted output of the FFTDirection type.
2927 *
2928 * @param[out] os Output stream.
2929 * @param[in] fft_dir FFTDirection to output.
2930 *
2931 * @return Modified output stream.
2932 */
2933inline ::std::ostream &operator<<(::std::ostream &os, const FFTDirection &fft_dir)
2934{
2935 switch(fft_dir)
2936 {
2937 case FFTDirection::Forward:
2938 os << "Forward";
2939 break;
2940 case FFTDirection::Inverse:
2941 os << "Inverse";
2942 break;
2943 default:
2944 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2945 }
2946 return os;
2947}
2948
2949/** Converts a @ref FFT1DInfo to string
2950 *
2951 * @param[in] fft_dir FFT1DInfo value to be converted
2952 *
2953 * @return String representing the corresponding FFT1DInfo
2954 */
2955inline std::string to_string(const FFTDirection &fft_dir)
2956{
2957 std::stringstream str;
ramelg01cbbb0382021-09-17 17:36:57 +01002958 str << "{" << fft_dir << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002959 return str.str();
2960}
2961
2962/** Formatted output of the FFT1DInfo type.
2963 *
2964 * @param[out] os Output stream.
2965 * @param[in] fft1d_info FFT1DInfo to output.
2966 *
2967 * @return Modified output stream.
2968 */
2969inline ::std::ostream &operator<<(::std::ostream &os, const FFT1DInfo &fft1d_info)
2970{
SiCongLi579ca842021-10-18 09:38:33 +01002971 os << "{axis=" << fft1d_info.axis << ", "
2972 << "direction=" << fft1d_info.direction << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002973 return os;
2974}
2975
2976/** Converts a @ref FFT1DInfo to string
2977 *
2978 * @param[in] fft1d_info FFT1DInfo value to be converted
2979 *
2980 * @return String representing the corresponding FFT1DInfo
2981 */
2982inline std::string to_string(const FFT1DInfo &fft1d_info)
2983{
2984 std::stringstream str;
2985 str << fft1d_info;
2986 return str.str();
2987}
2988
2989/** Formatted output of the FFT2DInfo type.
2990 *
2991 * @param[out] os Output stream.
2992 * @param[in] fft2d_info FFT2DInfo to output.
2993 *
2994 * @return Modified output stream.
2995 */
2996inline ::std::ostream &operator<<(::std::ostream &os, const FFT2DInfo &fft2d_info)
2997{
SiCongLi579ca842021-10-18 09:38:33 +01002998 os << "{axis=" << fft2d_info.axis0 << ", "
2999 << "axis=" << fft2d_info.axis1 << ", "
3000 << "direction=" << fft2d_info.direction << "}";
ramelg013ae3d882021-09-12 23:07:47 +01003001 return os;
3002}
3003
3004/** Converts a @ref FFT2DInfo to string
3005 *
3006 * @param[in] fft2d_info FFT2DInfo value to be converted
3007 *
3008 * @return String representing the corresponding FFT2DInfo
3009 */
3010inline std::string to_string(const FFT2DInfo &fft2d_info)
3011{
3012 std::stringstream str;
3013 str << fft2d_info;
3014 return str.str();
3015}
3016
3017/** Formatted output of the Coordinates2D type.
3018 *
3019 * @param[out] os Output stream.
3020 * @param[in] coord_2d Coordinates2D to output.
3021 *
3022 * @return Modified output stream.
3023 */
3024inline ::std::ostream &operator<<(::std::ostream &os, const Coordinates2D &coord_2d)
3025{
SiCongLi579ca842021-10-18 09:38:33 +01003026 os << "{x=" << coord_2d.x << ", "
3027 << "y=" << coord_2d.y << "}";
ramelg013ae3d882021-09-12 23:07:47 +01003028 return os;
3029}
3030
3031/** Converts a @ref Coordinates2D to string
3032 *
3033 * @param[in] coord_2d Coordinates2D value to be converted
3034 *
3035 * @return String representing the corresponding Coordinates2D
3036 */
3037inline std::string to_string(const Coordinates2D &coord_2d)
3038{
3039 std::stringstream str;
3040 str << coord_2d;
3041 return str.str();
3042}
3043
3044/** Formatted output of the FuseBatchNormalizationType type.
3045 *
3046 * @param[out] os Output stream.
3047 * @param[in] fuse_type FuseBatchNormalizationType to output.
3048 *
3049 * @return Modified output stream.
3050 */
3051inline ::std::ostream &operator<<(::std::ostream &os, const FuseBatchNormalizationType &fuse_type)
3052{
3053 switch(fuse_type)
3054 {
3055 case FuseBatchNormalizationType::CONVOLUTION:
3056 os << "CONVOLUTION";
3057 break;
3058 case FuseBatchNormalizationType::DEPTHWISECONVOLUTION:
3059 os << "DEPTHWISECONVOLUTION";
3060 break;
3061 default:
3062 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
3063 }
3064 return os;
3065}
3066
3067/** Converts a @ref FuseBatchNormalizationType to string
3068 *
3069 * @param[in] fuse_type FuseBatchNormalizationType value to be converted
3070 *
3071 * @return String representing the corresponding FuseBatchNormalizationType
3072 */
3073inline std::string to_string(const FuseBatchNormalizationType &fuse_type)
3074{
3075 std::stringstream str;
3076 str << fuse_type;
3077 return str.str();
3078}
3079
ramelg01cbbb0382021-09-17 17:36:57 +01003080/** Formatted output of the SoftmaxKernelInfo type.
3081 *
3082 * @param[out] os Output stream.
3083 * @param[in] info SoftmaxKernelInfo to output.
3084 *
3085 * @return Modified output stream.
3086 */
3087inline ::std::ostream &operator<<(::std::ostream &os, const SoftmaxKernelInfo &info)
3088{
SiCongLi579ca842021-10-18 09:38:33 +01003089 os << "{beta=" << info.beta << ", "
3090 << "is_log=" << info.is_log << ", "
3091 << "input_data_type=" << info.input_data_type << ", "
3092 << "axis=" << info.axis << "}";
ramelg01cbbb0382021-09-17 17:36:57 +01003093 return os;
3094}
3095
3096/** Converts a @ref SoftmaxKernelInfo to string
3097 *
3098 * @param[in] info SoftmaxKernelInfo value to be converted
3099 *
3100 * @return String representing the corresponding SoftmaxKernelInfo
3101 */
3102inline std::string to_string(const SoftmaxKernelInfo &info)
3103{
3104 std::stringstream str;
3105 str << info;
3106 return str.str();
3107}
3108
3109/** Formatted output of the ScaleKernelInfo type.
3110 *
3111 * @param[out] os Output stream.
3112 * @param[in] lstm_params LSTMParams to output.
3113 *
3114 * @return Modified output stream.
3115 */
3116template <typename T>
ramelg014a6d9e82021-10-02 14:34:36 +01003117::std::ostream &operator<<(::std::ostream &os, const LSTMParams<T> &lstm_params)
ramelg01cbbb0382021-09-17 17:36:57 +01003118{
ramelg014a6d9e82021-10-02 14:34:36 +01003119 os << "{input_to_input_weights=" << to_string(lstm_params.input_to_input_weights()) << ", "
3120 << "recurrent_to_input_weights=" << to_string(lstm_params.recurrent_to_input_weights()) << ", "
3121 << "cell_to_input_weights=" << to_string(lstm_params.cell_to_input_weights()) << ", "
3122 << "input_gate_bias=" << to_string(lstm_params.input_gate_bias()) << ", "
3123 << "cell_to_forget_weights=" << to_string(lstm_params.cell_to_forget_weights()) << ", "
3124 << "cell_to_output_weights=" << to_string(lstm_params.cell_to_output_weights()) << ", "
3125 << "projection_weights=" << to_string(lstm_params.projection_weights()) << ", "
3126 << "projection_bias=" << to_string(lstm_params.projection_bias()) << ", "
3127 << "input_layer_norm_weights=" << to_string(lstm_params.input_layer_norm_weights()) << ", "
3128 << "forget_layer_norm_weights=" << to_string(lstm_params.forget_layer_norm_weights()) << ", "
3129 << "cell_layer_norm_weights=" << to_string(lstm_params.cell_layer_norm_weights()) << ", "
3130 << "output_layer_norm_weights=" << to_string(lstm_params.output_layer_norm_weights()) << ", "
ramelg01cbbb0382021-09-17 17:36:57 +01003131 << "cell_clip=" << lstm_params.cell_clip() << ", "
3132 << "projection_clip=" << lstm_params.projection_clip() << ", "
3133 << "input_intermediate_scale=" << lstm_params.input_intermediate_scale() << ", "
3134 << "forget_intermediate_scale=" << lstm_params.forget_intermediate_scale() << ", "
3135 << "cell_intermediate_scale=" << lstm_params.cell_intermediate_scale() << ", "
3136 << "hidden_state_zero=" << lstm_params.hidden_state_zero() << ", "
3137 << "hidden_state_scale=" << lstm_params.hidden_state_scale() << ", "
3138 << "has_peephole_opt=" << lstm_params.has_peephole_opt() << ", "
3139 << "has_projection=" << lstm_params.has_projection() << ", "
3140 << "has_cifg_opt=" << lstm_params.has_cifg_opt() << ", "
3141 << "use_layer_norm=" << lstm_params.use_layer_norm() << "}";
3142 return os;
3143}
3144
3145/** Converts a @ref LSTMParams to string
3146 *
3147 * @param[in] lstm_params LSTMParams<T> value to be converted
3148 *
3149 * @return String representing the corresponding LSTMParams
3150 */
3151template <typename T>
ramelg014a6d9e82021-10-02 14:34:36 +01003152std::string to_string(const LSTMParams<T> &lstm_params)
ramelg01cbbb0382021-09-17 17:36:57 +01003153{
3154 std::stringstream str;
3155 str << lstm_params;
3156 return str.str();
3157}
3158
3159/** Converts a @ref LSTMParams to string
3160 *
3161 * @param[in] num uint8_t value to be converted
3162 *
3163 * @return String representing the corresponding uint8_t
3164 */
3165inline std::string to_string(const uint8_t num)
3166{
3167 // Explicity cast the uint8_t to signed integer and call the corresponding overloaded to_string() function.
3168 return ::std::to_string(static_cast<int>(num));
3169}
3170
ramelg014a6d9e82021-10-02 14:34:36 +01003171/** Available non maxima suppression types */
3172/** Formatted output of the NMSType type.
3173 *
3174 * @param[out] os Output stream.
3175 * @param[in] nms_type NMSType to output.
3176 *
3177 * @return Modified output stream.
3178 */
3179inline ::std::ostream &operator<<(::std::ostream &os, const NMSType &nms_type)
3180{
3181 switch(nms_type)
3182 {
3183 case NMSType::LINEAR:
3184 os << "LINEAR";
3185 break;
3186 case NMSType::GAUSSIAN:
3187 os << "GAUSSIAN";
3188 break;
3189 case NMSType::ORIGINAL:
3190 os << "ORIGINAL";
3191 break;
3192 default:
3193 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
3194 }
3195 return os;
3196}
3197
3198/** Converts a @ref NMSType to string
3199 *
3200 * @param[in] nms_type NMSType value to be converted
3201 *
3202 * @return String representing the corresponding NMSType
3203 */
3204inline std::string to_string(const NMSType nms_type)
3205{
3206 std::stringstream str;
3207 str << nms_type;
3208 return str.str();
3209}
3210
3211/** Formatted output of the BoxNMSLimitInfo type.
3212 *
3213 * @param[out] os Output stream.
3214 * @param[in] info BoxNMSLimitInfo to output.
3215 *
3216 * @return Modified output stream.
3217 */
3218inline ::std::ostream &operator<<(::std::ostream &os, const BoxNMSLimitInfo &info)
3219{
SiCongLi579ca842021-10-18 09:38:33 +01003220 os << "{score_thresh=" << info.score_thresh() << ", "
3221 << "nms=" << info.nms() << ", "
3222 << "detections_per_im=" << info.detections_per_im() << ", "
3223 << "soft_nms_enabled=" << info.soft_nms_enabled() << ", "
3224 << "soft_nms_min_score_thres=" << info.soft_nms_min_score_thres() << ", "
3225 << "suppress_size=" << info.suppress_size() << ", "
3226 << "min_size=" << info.min_size() << ", "
3227 << "im_width=" << info.im_width() << ", "
3228 << "im_height=" << info.im_height() << "}";
ramelg014a6d9e82021-10-02 14:34:36 +01003229 return os;
3230}
3231
3232/** Converts a @ref BoxNMSLimitInfo to string
3233 *
3234 * @param[in] info BoxNMSLimitInfo value to be converted
3235 *
3236 * @return String representing the corresponding BoxNMSLimitInfo
3237 */
3238inline std::string to_string(const BoxNMSLimitInfo &info)
3239{
3240 std::stringstream str;
3241 str << info;
3242 return str.str();
3243}
3244
Giorgio Arena945ae9e2021-10-13 11:13:04 +01003245/** Converts a @ref DimensionRoundingType to string
3246 *
3247 * @param[in] rounding_type DimensionRoundingType value to be converted
3248 *
3249 * @return String representing the corresponding DimensionRoundingType
3250 */
3251inline std::string to_string(const DimensionRoundingType &rounding_type)
3252{
3253 std::stringstream str;
3254 str << rounding_type;
3255 return str.str();
3256}
3257
Giorgio Arena945ae9e2021-10-13 11:13:04 +01003258/** Formatted output of the Conv3dInfo type.
3259 *
3260 * @param[out] os Output stream.
3261 * @param[in] conv3d_info Type to output.
3262 *
3263 * @return Modified output stream.
3264 */
3265inline ::std::ostream &operator<<(::std::ostream &os, const Conv3dInfo &conv3d_info)
3266{
3267 os << conv3d_info.stride;
3268 os << ";";
3269 os << conv3d_info.padding;
3270 os << ";";
3271 os << to_string(conv3d_info.act_info);
3272 os << ";";
3273 os << conv3d_info.dilation;
3274 os << ";";
3275 os << conv3d_info.round_type;
3276 os << ";";
3277 os << conv3d_info.enable_fast_math;
3278
3279 return os;
3280}
3281
3282/** Formatted output of the Conv3dInfo type.
3283 *
3284 * @param[in] conv3d_info Type to output.
3285 *
3286 * @return Formatted string.
3287 */
3288inline std::string to_string(const Conv3dInfo &conv3d_info)
3289{
3290 std::stringstream str;
3291 str << conv3d_info;
3292 return str.str();
3293}
3294
Ramy Elgammal91780022022-07-20 14:57:37 +01003295/** Formatted output of the arm_compute::WeightFormat type.
3296 *
3297 * @param[in] wf arm_compute::WeightFormat Type to output.
3298 *
3299 * @return Formatted string.
3300 */
3301inline std::string to_string(const WeightFormat wf)
Francesco Petrogalli553f6952022-06-30 10:22:01 +00003302{
Ramy Elgammal91780022022-07-20 14:57:37 +01003303#define __CASE_WEIGHT_FORMAT(wf) \
3304case WeightFormat::wf: \
3305 return #wf;
3306 switch(wf)
3307 {
3308 __CASE_WEIGHT_FORMAT(UNSPECIFIED)
3309 __CASE_WEIGHT_FORMAT(ANY)
3310 __CASE_WEIGHT_FORMAT(OHWI)
3311 __CASE_WEIGHT_FORMAT(OHWIo2)
3312 __CASE_WEIGHT_FORMAT(OHWIo4)
3313 __CASE_WEIGHT_FORMAT(OHWIo8)
3314 __CASE_WEIGHT_FORMAT(OHWIo16)
3315 __CASE_WEIGHT_FORMAT(OHWIo32)
3316 __CASE_WEIGHT_FORMAT(OHWIo64)
3317 __CASE_WEIGHT_FORMAT(OHWIo128)
3318 __CASE_WEIGHT_FORMAT(OHWIo4i2)
3319 __CASE_WEIGHT_FORMAT(OHWIo4i2_bf16)
3320 __CASE_WEIGHT_FORMAT(OHWIo8i2)
3321 __CASE_WEIGHT_FORMAT(OHWIo8i2_bf16)
3322 __CASE_WEIGHT_FORMAT(OHWIo16i2)
3323 __CASE_WEIGHT_FORMAT(OHWIo16i2_bf16)
3324 __CASE_WEIGHT_FORMAT(OHWIo32i2)
3325 __CASE_WEIGHT_FORMAT(OHWIo32i2_bf16)
3326 __CASE_WEIGHT_FORMAT(OHWIo64i2)
3327 __CASE_WEIGHT_FORMAT(OHWIo64i2_bf16)
3328 __CASE_WEIGHT_FORMAT(OHWIo4i4)
3329 __CASE_WEIGHT_FORMAT(OHWIo4i4_bf16)
3330 __CASE_WEIGHT_FORMAT(OHWIo8i4)
3331 __CASE_WEIGHT_FORMAT(OHWIo8i4_bf16)
3332 __CASE_WEIGHT_FORMAT(OHWIo16i4)
3333 __CASE_WEIGHT_FORMAT(OHWIo16i4_bf16)
3334 __CASE_WEIGHT_FORMAT(OHWIo32i4)
3335 __CASE_WEIGHT_FORMAT(OHWIo32i4_bf16)
3336 __CASE_WEIGHT_FORMAT(OHWIo64i4)
3337 __CASE_WEIGHT_FORMAT(OHWIo64i4_bf16)
3338 __CASE_WEIGHT_FORMAT(OHWIo2i8)
3339 __CASE_WEIGHT_FORMAT(OHWIo4i8)
3340 __CASE_WEIGHT_FORMAT(OHWIo8i8)
3341 __CASE_WEIGHT_FORMAT(OHWIo16i8)
3342 __CASE_WEIGHT_FORMAT(OHWIo32i8)
3343 __CASE_WEIGHT_FORMAT(OHWIo64i8)
3344 default:
3345 return "invalid value";
3346 }
3347#undef __CASE_WEIGHT_FORMAT
Francesco Petrogalli553f6952022-06-30 10:22:01 +00003348}
3349
Ramy Elgammal91780022022-07-20 14:57:37 +01003350/** Formatted output of the arm_compute::WeightFormat type.
3351 *
3352 * @param[out] os Output stream.
3353 * @param[in] wf WeightFormat to output.
3354 *
3355 * @return Modified output stream.
3356 */
3357inline ::std::ostream &operator<<(::std::ostream &os, const arm_compute::WeightFormat &wf)
3358{
3359 os << to_string(wf);
3360 return os;
3361}
3362
3363/** Formatted output of the std::tuple<TensorShape, TensorShape, arm_compute::WeightFormat> tuple.
3364 *
3365 * @param[in] values tuple of input and output tensor shapes and WeightFormat used.
3366 *
3367 * @return Formatted string.
3368 */
3369inline std::string to_string(const std::tuple<TensorShape, TensorShape, arm_compute::WeightFormat> values)
Francesco Petrogalli553f6952022-06-30 10:22:01 +00003370{
3371 std::stringstream str;
3372 str << "[Input shape = " << std::get<0>(values);
3373 str << ", ";
3374 str << "Expected output shape = " << std::get<1>(values);
3375
3376 str << ", ";
3377 str << "WeightFormat = " << std::get<2>(values) << "]";
3378 return str.str();
3379}
3380
Ramy Elgammal73f19af2022-10-23 11:44:49 +01003381/** Formatted output of the Padding2D type.
3382 *
3383 * @param[out] os Output stream.
3384 * @param[in] padding2d Padding info for 2D dimension shape.
3385 *
3386 * @return Modified output stream.
3387 */
3388inline ::std::ostream &operator<<(::std::ostream &os, const Padding2D &padding2d)
3389{
3390 os << padding2d.left << "," << padding2d.right << ","
3391 << padding2d.top << "," << padding2d.bottom;
3392 return os;
3393}
3394
3395/** Converts a @ref Padding2D to string
3396 *
3397 * @param[in] padding2d Padding2D value to be converted
3398 *
3399 * @return String representing the corresponding Padding2D
3400 */
3401inline std::string to_string(const Padding2D &padding2d)
3402{
3403 std::stringstream str;
3404 str << padding2d;
3405 return str.str();
3406}
3407
3408/** Formatted output of the arm_compute::experimental::dynamic_fusion::Conv2dAttributes type.
3409 *
3410 * @param[out] os Output stream.
3411 * @param[in] conv2d_attr arm_compute::experimental::dynamic_fusion::Conv2dAttributes type to output.
3412 *
3413 * @return Modified output stream.
3414 */
3415inline ::std::ostream &operator<<(::std::ostream &os, const experimental::dynamic_fusion::Conv2dAttributes &conv2d_attr)
3416{
3417 os << "Conv2dAttributes="
3418 << "["
3419 << "Padding=" << conv2d_attr.pad() << ", "
3420 << "Size2D=" << conv2d_attr.stride() << ", "
Ramy Elgammal404462a2022-11-08 02:14:46 +00003421 << "Dialation=" << conv2d_attr.dilation() << "]";
Ramy Elgammal73f19af2022-10-23 11:44:49 +01003422
3423 return os;
3424}
3425/** Formatted output of the arm_compute::experimental::dynamic_fusion::Conv2dAttributes type.
3426 *
3427 * @param[in] conv2d_attr arm_compute::experimental::dynamic_fusion::Conv2dAttributes type to output.
3428 *
3429 * @return Formatted string.
3430 */
3431inline std::string to_string(const experimental::dynamic_fusion::Conv2dAttributes &conv2d_attr)
3432{
3433 std::stringstream str;
3434 str << conv2d_attr;
3435 return str.str();
3436}
Gunes Bayir7dc02342022-11-21 21:46:50 +00003437
Gunes Bayir1dc6ff12022-12-06 20:48:31 +00003438/** Formatted output of the arm_compute::experimental::dynamic_fusion::CastAttributes type.
3439 *
3440 * @param[out] os Output stream.
3441 * @param[in] cast_attr arm_compute::experimental::dynamic_fusion::CastAttributes type to output.
3442 *
3443 * @return Modified output stream.
3444 */
3445inline ::std::ostream &operator<<(::std::ostream &os, const experimental::dynamic_fusion::CastAttributes &cast_attr)
3446{
3447 os << "CastAttributes="
3448 << "["
3449 << "Data Type=" << cast_attr.data_type() << ", "
3450 << "Convert Policy=" << cast_attr.convert_policy() << "]";
3451
3452 return os;
3453}
3454/** Formatted output of the arm_compute::experimental::dynamic_fusion::CastAttributes type.
3455 *
3456 * @param[in] cast_attr arm_compute::experimental::dynamic_fusion::CastAttributes type to output.
3457 *
3458 * @return Formatted string.
3459 */
3460inline std::string to_string(const experimental::dynamic_fusion::CastAttributes &cast_attr)
3461{
3462 std::stringstream str;
3463 str << cast_attr;
3464 return str.str();
3465}
3466
Gunes Bayir7dc02342022-11-21 21:46:50 +00003467/** Formatted output of the arm_compute::experimental::dynamic_fusion::DepthwiseConv2dAttributes type.
3468 *
3469 * @param[out] os Output stream.
3470 * @param[in] dw_conv2d_attr arm_compute::experimental::dynamic_fusion::DepthwiseConv2dAttributes type to output.
3471 *
3472 * @return Modified output stream.
3473 */
3474inline ::std::ostream &operator<<(::std::ostream &os, const experimental::dynamic_fusion::DepthwiseConv2dAttributes &dw_conv2d_attr)
3475{
3476 os << "DepthwiseConv2dAttributes="
3477 << "["
3478 << "Padding=" << dw_conv2d_attr.pad() << ", "
3479 << "Size2D=" << dw_conv2d_attr.stride() << ", "
3480 << "Depth Multiplier=" << dw_conv2d_attr.depth_multiplier() << ", "
3481 << "Dilation=" << dw_conv2d_attr.dilation() << ","
3482 << "DimensionRoundingType: " << dw_conv2d_attr.dimension_rounding_type() << "]";
3483
3484 return os;
3485}
3486/** Formatted output of the arm_compute::experimental::dynamic_fusion::DepthwiseConv2dAttributes type.
3487 *
3488 * @param[in] dw_conv2d_attr arm_compute::experimental::dynamic_fusion::DepthwiseConv2dAttributes type to output.
3489 *
3490 * @return Formatted string.
3491 */
3492inline std::string to_string(const experimental::dynamic_fusion::DepthwiseConv2dAttributes &dw_conv2d_attr)
3493{
3494 std::stringstream str;
3495 str << dw_conv2d_attr;
3496 return str.str();
3497}
3498
Jakub Sujak32741722022-11-25 16:43:18 +00003499/** Formatted output of the arm_compute::experimental::dynamic_fusion::ClampAttributes type.
3500 *
3501 * @param[out] os Output stream.
3502 * @param[in] clamp_attr arm_compute::experimental::dynamic_fusion::ClampAttributes type to output.
3503 *
3504 * @return Modified output stream.
3505 */
3506inline ::std::ostream &operator<<(::std::ostream &os, const experimental::dynamic_fusion::ClampAttributes &clamp_attr)
3507{
3508 os << "ClampAttributes="
3509 << "["
3510 << "Min value=" << clamp_attr.min_val() << ", "
3511 << "Max value=" << clamp_attr.max_val() << "]";
3512 return os;
3513}
3514/** Formatted output of the arm_compute::experimental::dynamic_fusion::ClampAttributes type.
3515 *
3516 * @param[in] clamp_attr arm_compute::experimental::dynamic_fusion::ClampAttributes type to output.
3517 *
3518 * @return Formatted string.
3519 */
3520inline std::string to_string(const experimental::dynamic_fusion::ClampAttributes &clamp_attr)
3521{
3522 std::stringstream str;
3523 str << clamp_attr;
3524 return str.str();
3525}
3526
Anthony Barbier6ff3b192017-09-04 18:44:23 +01003527} // namespace arm_compute
Anthony Barbier4dbc0a92018-08-27 13:39:47 +01003528
3529#endif /* __ARM_COMPUTE_TYPE_PRINTER_H__ */