blob: d056bfbcf44f34062cedfc58e87f80cf4524cecb [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"
Jakub Sujak8ae57142022-12-02 16:09:06 +000045#include "arm_compute/dynamic_fusion/sketch/attributes/ResizeAttributes.h"
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +010046#include "arm_compute/runtime/CL/CLTunerTypes.h"
SiCong Lidb4a6c12021-02-05 09:30:57 +000047#include "arm_compute/runtime/CL/CLTypes.h"
ramelg013ae3d882021-09-12 23:07:47 +010048#include "arm_compute/runtime/FunctionDescriptors.h"
ramelg01cbbb0382021-09-17 17:36:57 +010049#include "arm_compute/runtime/common/LSTMParams.h"
SiCongLi31778612021-11-12 17:33:45 +000050#include "support/Cast.h"
Matthew Bentham758b5ba2020-03-05 23:37:48 +000051#include "support/StringSupport.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010052#include <ostream>
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010053#include <sstream>
54#include <string>
Anthony Barbier6ff3b192017-09-04 18:44:23 +010055
56namespace arm_compute
57{
Anthony Barbierb940fd62018-06-04 14:14:32 +010058/** Formatted output if arg is not null
59 *
60 * @param[in] arg Object to print
61 *
62 * @return String representing arg.
63 */
64template <typename T>
65std::string to_string_if_not_null(T *arg)
66{
67 if(arg == nullptr)
68 {
69 return "nullptr";
70 }
71 else
72 {
73 return to_string(*arg);
74 }
75}
Anthony Barbierb4670212018-05-18 16:55:39 +010076
ramelg014a6d9e82021-10-02 14:34:36 +010077/** Fallback method: try to use std::to_string:
78 *
79 * @param[in] val Value to convert to string
80 *
81 * @return String representing val.
82 */
83template <typename T>
84inline std::string to_string(const T &val)
85{
86 return support::cpp11::to_string(val);
87}
88
ramelg01b1ba1e32021-09-25 11:53:26 +010089/** Formatted output of a vector of objects.
90 *
ramelg014a6d9e82021-10-02 14:34:36 +010091 * @note: Using the overloaded to_string() instead of overloaded operator<<(), because to_string() functions are
92 * overloaded for all types, where two or more of them can use the same operator<<(), ITensor is an example.
93 *
ramelg01b1ba1e32021-09-25 11:53:26 +010094 * @param[out] os Output stream
95 * @param[in] args Vector of objects to print
96 *
97 * @return Modified output stream.
98 */
99template <typename T>
ramelg014a6d9e82021-10-02 14:34:36 +0100100::std::ostream &operator<<(::std::ostream &os, const std::vector<T> &args)
ramelg01b1ba1e32021-09-25 11:53:26 +0100101{
102 const size_t max_print_size = 5U;
103
104 os << "[";
105 bool first = true;
106 size_t i;
107 for(i = 0; i < args.size(); ++i)
108 {
109 if(i == max_print_size)
110 {
111 break;
112 }
113 if(first)
114 {
115 first = false;
116 }
117 else
118 {
119 os << ", ";
120 }
ramelg014a6d9e82021-10-02 14:34:36 +0100121 os << to_string(args[i]);
ramelg01b1ba1e32021-09-25 11:53:26 +0100122 }
123 if(i < args.size())
124 {
125 os << ", ...";
126 }
127 os << "]";
128 return os;
129}
130
ramelg014a6d9e82021-10-02 14:34:36 +0100131/** Formatted output of a vector of objects.
132 *
133 * @param[in] args Vector of objects to print
134 *
135 * @return String representing args.
136 */
137template <typename T>
138std::string to_string(const std::vector<T> &args)
139{
140 std::stringstream str;
141 str << args;
142 return str.str();
143}
144
SiCongLi1af54162021-10-06 15:25:57 +0100145/** @name (EXPERIMENTAL_POST_OPS)
146 * @{
147 */
148/** Formmated output of the @ref experimental::PostOpType type
149 *
150 * @param[out] os Output stream.
151 * @param[in] post_op_type Type to output.
152 *
153 * @return Modified output stream.
154 */
155inline ::std::ostream &operator<<(::std::ostream &os, experimental::PostOpType post_op_type)
156{
157 os << "type=";
158 switch(post_op_type)
159 {
160 case experimental::PostOpType::Activation:
161 {
162 os << "Activation";
163 break;
164 }
165 case experimental::PostOpType::Eltwise_Add:
166 {
167 os << "Eltwise_Add";
168 break;
169 }
ramelg016049eda2021-10-29 10:52:53 +0100170 case experimental::PostOpType::Eltwise_PRelu:
171 {
172 os << "Eltwise_PRelu";
173 break;
174 }
SiCongLi1af54162021-10-06 15:25:57 +0100175 default:
176 {
177 ARM_COMPUTE_ERROR("Unsupported PostOpType");
178 break;
179 }
180 }
181 return os;
182}
183/** Converts a @ref experimental::PostOpType to string
184 *
185 * @param[in] post_op_type PostOpType value to be converted
186 *
187 * @return String representing the corresponding PostOpType
188 */
189inline std::string to_string(experimental::PostOpType post_op_type)
190{
191 std::stringstream str;
192 str << post_op_type;
193 return str.str();
194}
195/** Formatted output of the @ref experimental::IPostOp type.
196 *
197 * @param[out] os Output stream.
198 * @param[in] post_op Type to output.
199 *
200 * @return Modified output stream.
201 */
202template <typename T>
203inline ::std::ostream &operator<<(::std::ostream &os, const experimental::IPostOp<T> &post_op)
204{
205 os << "<";
206 os << post_op.type() << ",";
SiCongLieb8bd812021-10-29 15:05:49 +0100207 os << "prev_dst_pos=" << post_op.prev_dst_pos() << ",";
SiCongLi1af54162021-10-06 15:25:57 +0100208 switch(post_op.type())
209 {
210 case experimental::PostOpType::Activation:
211 {
212 const auto _post_op = utils::cast::polymorphic_downcast<const experimental::PostOpAct<T> *>(&post_op);
213 os << "act_info=" << &(_post_op->_act_info);
214 break;
215 }
216 case experimental::PostOpType::Eltwise_Add:
217 {
218 const auto _post_op = utils::cast::polymorphic_downcast<const experimental::PostOpEltwiseAdd<T> *>(&post_op);
219 os << "convert_policy=" << _post_op->_policy;
220 break;
221 }
ramelg016049eda2021-10-29 10:52:53 +0100222 case experimental::PostOpType::Eltwise_PRelu:
223 {
224 const auto _post_op = utils::cast::polymorphic_downcast<const experimental::PostOpEltwisePRelu<T> *>(&post_op);
225 os << "convert_policy=" << _post_op->_policy;
226 break;
227 }
SiCongLi1af54162021-10-06 15:25:57 +0100228 default:
229 {
230 ARM_COMPUTE_ERROR("Unsupported PostOpType");
231 break;
232 }
233 }
234 os << ">";
235 return os;
236}
237/** Converts an @ref experimental::IPostOp to string
238 *
239 * @param[in] post_op IPostOp value to be converted
240 *
241 * @return String representing the corresponding IPostOp
242 */
243template <typename T>
244inline std::string to_string(const experimental::IPostOp<T> &post_op)
245{
246 std::stringstream str;
247 str << post_op;
248 return str.str();
249}
250/** Formatted output of the @ref experimental::PostOpList type.
251 *
252 * @param[out] os Output stream.
253 * @param[in] post_ops Type to output.
254 *
255 * @return Modified output stream.
256 */
257template <typename T>
258inline ::std::ostream &operator<<(::std::ostream &os, const experimental::PostOpList<T> &post_ops)
259{
260 os << "[";
261 for(const auto &post_op : post_ops.get_list())
262 {
263 os << *post_op << ",";
264 }
265 os << "]";
266 return os;
267}
268/** Converts a @ref experimental::PostOpList to string
269 *
270 * @param[in] post_ops PostOpList value to be converted
271 *
272 * @return String representing the corresponding PostOpList
273 */
274template <typename T>
275inline std::string to_string(const experimental::PostOpList<T> &post_ops)
276{
277 std::stringstream str;
278 str << post_ops;
279 return str.str();
280}
281/** @} */ // end of group (EXPERIMENTAL_POST_OPS)
282
Alex Gildayc357c472018-03-21 13:54:09 +0000283/** Formatted output of the Dimensions type.
284 *
285 * @param[out] os Output stream.
286 * @param[in] dimensions Type to output.
287 *
288 * @return Modified output stream.
289 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100290template <typename T>
291inline ::std::ostream &operator<<(::std::ostream &os, const Dimensions<T> &dimensions)
292{
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100293 if(dimensions.num_dimensions() > 0)
294 {
295 os << dimensions[0];
296
297 for(unsigned int d = 1; d < dimensions.num_dimensions(); ++d)
298 {
Freddie Liardetdd23f2a2021-06-17 13:30:11 +0100299 os << "," << dimensions[d];
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100300 }
301 }
302
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100303 return os;
304}
305
Alex Gildayc357c472018-03-21 13:54:09 +0000306/** Formatted output of the RoundingPolicy type.
307 *
308 * @param[out] os Output stream.
309 * @param[in] rounding_policy Type to output.
310 *
311 * @return Modified output stream.
312 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100313inline ::std::ostream &operator<<(::std::ostream &os, const RoundingPolicy &rounding_policy)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100314{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100315 switch(rounding_policy)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100316 {
Anthony Barbier2a07e182017-08-04 18:20:27 +0100317 case RoundingPolicy::TO_ZERO:
318 os << "TO_ZERO";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100319 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100320 case RoundingPolicy::TO_NEAREST_UP:
321 os << "TO_NEAREST_UP";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100322 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100323 case RoundingPolicy::TO_NEAREST_EVEN:
324 os << "TO_NEAREST_EVEN";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100325 break;
326 default:
327 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
328 }
329
330 return os;
331}
332
Alex Gildayc357c472018-03-21 13:54:09 +0000333/** Formatted output of the WeightsInfo type.
334 *
335 * @param[out] os Output stream.
336 * @param[in] weights_info Type to output.
337 *
338 * @return Modified output stream.
339 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100340inline ::std::ostream &operator<<(::std::ostream &os, const WeightsInfo &weights_info)
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100341{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100342 os << weights_info.are_reshaped() << ";";
343 os << weights_info.num_kernels() << ";" << weights_info.kernel_size().first << "," << weights_info.kernel_size().second;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100344
345 return os;
346}
347
Alex Gildayc357c472018-03-21 13:54:09 +0000348/** Formatted output of the ROIPoolingInfo type.
349 *
350 * @param[out] os Output stream.
351 * @param[in] pool_info Type to output.
352 *
353 * @return Modified output stream.
354 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100355inline ::std::ostream &operator<<(::std::ostream &os, const ROIPoolingLayerInfo &pool_info)
Sanghoon Lee70f82912017-08-24 14:21:24 +0100356{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100357 os << pool_info.pooled_width() << "x" << pool_info.pooled_height() << "~" << pool_info.spatial_scale();
Georgios Pinitasd9769582017-08-03 10:19:40 +0100358 return os;
359}
360
giuros0118870812018-09-13 09:31:40 +0100361/** Formatted output of the ROIPoolingInfo type.
362 *
363 * @param[in] pool_info Type to output.
364 *
365 * @return Formatted string.
366 */
367inline std::string to_string(const ROIPoolingLayerInfo &pool_info)
368{
369 std::stringstream str;
370 str << pool_info;
371 return str.str();
372}
373
morgolockaba2f912020-05-05 16:28:19 +0100374/** Formatted output of the GEMMKernelInfo type.
375 *
376 * @param[out] os Output stream.
377 * @param[in] gemm_info Type to output.
378 *
379 * @return Modified output stream.
380 */
381inline ::std::ostream &operator<<(::std::ostream &os, const GEMMKernelInfo &gemm_info)
382{
SiCongLi579ca842021-10-18 09:38:33 +0100383 os << "( m=" << gemm_info.m;
384 os << " n=" << gemm_info.n;
385 os << " k=" << gemm_info.k;
386 os << " depth_output_gemm3d=" << gemm_info.depth_output_gemm3d;
387 os << " reinterpret_input_as_3d=" << gemm_info.reinterpret_input_as_3d;
388 os << " broadcast_bias=" << gemm_info.broadcast_bias;
389 os << " fp_mixed_precision=" << gemm_info.fp_mixed_precision;
390 os << " mult_transpose1xW_width=" << gemm_info.mult_transpose1xW_width;
391 os << " mult_interleave4x4_height=" << gemm_info.mult_interleave4x4_height;
392 os << " a_offset=" << gemm_info.a_offset;
393 os << " b_offset=" << gemm_info.b_offset;
394 os << "post_ops=" << gemm_info.post_ops;
morgolockaba2f912020-05-05 16:28:19 +0100395 os << ")";
396 return os;
397}
398
399/** Formatted output of the GEMMLHSMatrixInfo type.
400 *
401 * @param[out] os Output stream.
402 * @param[in] gemm_info Type to output.
403 *
404 * @return Modified output stream.
405 */
406inline ::std::ostream &operator<<(::std::ostream &os, const GEMMLHSMatrixInfo &gemm_info)
407{
SiCongLi579ca842021-10-18 09:38:33 +0100408 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 +0100409 return os;
410}
411
412/** Formatted output of the GEMMRHSMatrixInfo type.
413 *
414 * @param[out] os Output stream.
415 * @param[in] gemm_info Type to output.
416 *
417 * @return Modified output stream.
418 */
419inline ::std::ostream &operator<<(::std::ostream &os, const GEMMRHSMatrixInfo &gemm_info)
420{
SiCongLi579ca842021-10-18 09:38:33 +0100421 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 +0000422 gemm_info.export_to_cl_image << "})";
morgolockaba2f912020-05-05 16:28:19 +0100423 return os;
424}
425
426/** Formatted output of the GEMMRHSMatrixInfo type.
427 *
428 * @param[in] gemm_info GEMMRHSMatrixInfo to output.
429 *
430 * @return Formatted string.
431 */
432inline std::string to_string(const GEMMRHSMatrixInfo &gemm_info)
433{
434 std::stringstream str;
435 str << gemm_info;
436 return str.str();
437}
438
439/** Formatted output of the GEMMLHSMatrixInfo type.
440 *
441 * @param[in] gemm_info GEMMLHSMatrixInfo to output.
442 *
443 * @return Formatted string.
444 */
445inline std::string to_string(const GEMMLHSMatrixInfo &gemm_info)
446{
447 std::stringstream str;
448 str << gemm_info;
449 return str.str();
450}
451
452/** Formatted output of the GEMMKernelInfo type.
453 *
454 * @param[in] gemm_info GEMMKernelInfo Type to output.
455 *
456 * @return Formatted string.
457 */
458inline std::string to_string(const GEMMKernelInfo &gemm_info)
459{
460 std::stringstream str;
461 str << gemm_info;
462 return str.str();
463}
464
giuros01c04a0e82018-10-03 12:44:35 +0100465/** Formatted output of the BoundingBoxTransformInfo type.
466 *
467 * @param[out] os Output stream.
468 * @param[in] bbox_info Type to output.
469 *
470 * @return Modified output stream.
471 */
472inline ::std::ostream &operator<<(::std::ostream &os, const BoundingBoxTransformInfo &bbox_info)
473{
474 auto weights = bbox_info.weights();
SiCongLi579ca842021-10-18 09:38:33 +0100475 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 +0100476 "})";
477 return os;
478}
479
Pablo Marquez Tellod208f4f2022-07-19 12:19:46 +0100480#if defined(ARM_COMPUTE_ENABLE_BF16)
Ramy Elgammal91780022022-07-20 14:57:37 +0100481inline ::std::ostream &operator<<(::std::ostream &os, const bfloat16 &v)
Pablo Marquez Tellod208f4f2022-07-19 12:19:46 +0100482{
483 std::stringstream str;
Pablo Marquez Tello9d7b6902022-12-19 17:12:53 +0000484 str << static_cast<float>(v);
Pablo Marquez Tellod208f4f2022-07-19 12:19:46 +0100485 os << str.str();
486 return os;
487}
Ramy Elgammal91780022022-07-20 14:57:37 +0100488#endif /* defined(ARM_COMPUTE_ENABLE_BF16) */
Pablo Marquez Tellod208f4f2022-07-19 12:19:46 +0100489
giuros01c04a0e82018-10-03 12:44:35 +0100490/** Formatted output of the BoundingBoxTransformInfo type.
491 *
492 * @param[in] bbox_info Type to output.
493 *
494 * @return Formatted string.
495 */
496inline std::string to_string(const BoundingBoxTransformInfo &bbox_info)
497{
498 std::stringstream str;
499 str << bbox_info;
500 return str.str();
501}
502
Manuel Bottini5209be52019-02-13 16:34:56 +0000503/** Formatted output of the ComputeAnchorsInfo type.
504 *
505 * @param[out] os Output stream.
506 * @param[in] anchors_info Type to output.
507 *
508 * @return Modified output stream.
509 */
510inline ::std::ostream &operator<<(::std::ostream &os, const ComputeAnchorsInfo &anchors_info)
511{
512 os << "(" << anchors_info.feat_width() << "x" << anchors_info.feat_height() << ")~" << anchors_info.spatial_scale();
513 return os;
514}
515
516/** Formatted output of the ComputeAnchorsInfo type.
517 *
518 * @param[in] anchors_info Type to output.
519 *
520 * @return Formatted string.
521 */
522inline std::string to_string(const ComputeAnchorsInfo &anchors_info)
523{
524 std::stringstream str;
525 str << anchors_info;
526 return str.str();
527}
528
529/** Formatted output of the GenerateProposalsInfo type.
530 *
531 * @param[out] os Output stream.
532 * @param[in] proposals_info Type to output.
533 *
534 * @return Modified output stream.
535 */
536inline ::std::ostream &operator<<(::std::ostream &os, const GenerateProposalsInfo &proposals_info)
537{
538 os << "(" << proposals_info.im_width() << "x" << proposals_info.im_height() << ")~" << proposals_info.im_scale();
539 return os;
540}
541
542/** Formatted output of the GenerateProposalsInfo type.
543 *
544 * @param[in] proposals_info Type to output.
545 *
546 * @return Formatted string.
547 */
548inline std::string to_string(const GenerateProposalsInfo &proposals_info)
549{
550 std::stringstream str;
551 str << proposals_info;
552 return str.str();
553}
554
Alex Gildayc357c472018-03-21 13:54:09 +0000555/** Formatted output of the QuantizationInfo type.
556 *
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100557 * @param[out] os Output stream.
558 * @param[in] qinfo Type to output.
Alex Gildayc357c472018-03-21 13:54:09 +0000559 *
560 * @return Modified output stream.
561 */
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100562inline ::std::ostream &operator<<(::std::ostream &os, const QuantizationInfo &qinfo)
Chunosovd621bca2017-11-03 17:33:15 +0700563{
Georgios Pinitas3d13af82019-06-04 13:04:16 +0100564 const UniformQuantizationInfo uqinfo = qinfo.uniform();
565 os << "Scale:" << uqinfo.scale << "~";
566 os << "Offset:" << uqinfo.offset;
Chunosovd621bca2017-11-03 17:33:15 +0700567 return os;
568}
569
Alex Gildayc357c472018-03-21 13:54:09 +0000570/** Formatted output of the QuantizationInfo type.
571 *
572 * @param[in] quantization_info Type to output.
573 *
574 * @return Formatted string.
575 */
Chunosovd621bca2017-11-03 17:33:15 +0700576inline std::string to_string(const QuantizationInfo &quantization_info)
577{
578 std::stringstream str;
579 str << quantization_info;
580 return str.str();
581}
582
Alex Gildayc357c472018-03-21 13:54:09 +0000583/** Formatted output of the activation function type.
584 *
585 * @param[out] os Output stream.
586 * @param[in] act_function Type to output.
587 *
588 * @return Modified output stream.
589 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100590inline ::std::ostream &operator<<(::std::ostream &os, const ActivationLayerInfo::ActivationFunction &act_function)
591{
592 switch(act_function)
593 {
594 case ActivationLayerInfo::ActivationFunction::ABS:
595 os << "ABS";
596 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100597 case ActivationLayerInfo::ActivationFunction::LINEAR:
598 os << "LINEAR";
599 break;
600 case ActivationLayerInfo::ActivationFunction::LOGISTIC:
601 os << "LOGISTIC";
602 break;
603 case ActivationLayerInfo::ActivationFunction::RELU:
604 os << "RELU";
605 break;
Georgios Pinitas579c0492017-07-12 16:12:12 +0100606 case ActivationLayerInfo::ActivationFunction::BOUNDED_RELU:
607 os << "BOUNDED_RELU";
608 break;
609 case ActivationLayerInfo::ActivationFunction::LEAKY_RELU:
610 os << "LEAKY_RELU";
611 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100612 case ActivationLayerInfo::ActivationFunction::SOFT_RELU:
613 os << "SOFT_RELU";
614 break;
615 case ActivationLayerInfo::ActivationFunction::SQRT:
616 os << "SQRT";
617 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100618 case ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU:
619 os << "LU_BOUNDED_RELU";
Kevin Petitd9f80712017-12-06 12:18:48 +0000620 break;
Georgios Pinitasfb0fdcd2019-08-22 17:10:04 +0100621 case ActivationLayerInfo::ActivationFunction::ELU:
622 os << "ELU";
623 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100624 case ActivationLayerInfo::ActivationFunction::SQUARE:
625 os << "SQUARE";
626 break;
627 case ActivationLayerInfo::ActivationFunction::TANH:
628 os << "TANH";
629 break;
Usama Arif6a98a6e2019-05-10 17:07:27 +0100630 case ActivationLayerInfo::ActivationFunction::IDENTITY:
631 os << "IDENTITY";
632 break;
morgolock07df3d42020-02-27 11:46:28 +0000633 case ActivationLayerInfo::ActivationFunction::HARD_SWISH:
634 os << "HARD_SWISH";
635 break;
Jonathan Deakind6b8a712022-08-23 11:44:18 +0100636 case ActivationLayerInfo::ActivationFunction::SWISH:
637 os << "SWISH";
638 break;
Murray Kornelsen926f5022022-07-13 21:22:39 -0400639 case ActivationLayerInfo::ActivationFunction::GELU:
640 os << "GELU";
641 break;
morgolock07df3d42020-02-27 11:46:28 +0000642
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100643 default:
644 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
645 }
646
647 return os;
648}
649
Alex Gildayc357c472018-03-21 13:54:09 +0000650/** Formatted output of the activation function info type.
651 *
SiCongLi1af54162021-10-06 15:25:57 +0100652 * @param[in] info ActivationLayerInfo to output.
Alex Gildayc357c472018-03-21 13:54:09 +0000653 *
654 * @return Formatted string.
655 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100656inline std::string to_string(const arm_compute::ActivationLayerInfo &info)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100657{
658 std::stringstream str;
Isabella Gottardi3f217ec2018-02-12 14:59:19 +0000659 if(info.enabled())
660 {
661 str << info.activation();
662 }
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100663 return str.str();
664}
665
SiCongLi1af54162021-10-06 15:25:57 +0100666/** Formatted output of the activation function info.
ramelg013ae3d882021-09-12 23:07:47 +0100667 *
SiCongLi1af54162021-10-06 15:25:57 +0100668 * @param[out] os Output stream.
669 * @param[in] info ActivationLayerInfo to output.
ramelg013ae3d882021-09-12 23:07:47 +0100670 *
671 * @return Formatted string.
672 */
SiCongLi1af54162021-10-06 15:25:57 +0100673inline ::std::ostream &operator<<(::std::ostream &os, const ActivationLayerInfo *info)
ramelg013ae3d882021-09-12 23:07:47 +0100674{
ramelg013ae3d882021-09-12 23:07:47 +0100675 if(info != nullptr)
676 {
ramelg013ae3d882021-09-12 23:07:47 +0100677 if(info->enabled())
678 {
SiCongLi1af54162021-10-06 15:25:57 +0100679 os << info->activation();
680 os << "(";
681 os << "VAL_A=" << info->a() << ",";
682 os << "VAL_B=" << info->b();
683 os << ")";
ramelg013ae3d882021-09-12 23:07:47 +0100684 }
SiCongLi1af54162021-10-06 15:25:57 +0100685 else
686 {
687 os << "disabled";
688 }
ramelg013ae3d882021-09-12 23:07:47 +0100689 }
SiCongLi1af54162021-10-06 15:25:57 +0100690 else
691 {
692 os << "nullptr";
693 }
694 return os;
ramelg013ae3d882021-09-12 23:07:47 +0100695}
696
Alex Gildayc357c472018-03-21 13:54:09 +0000697/** Formatted output of the activation function type.
698 *
699 * @param[in] function Type to output.
700 *
701 * @return Formatted string.
702 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100703inline std::string to_string(const arm_compute::ActivationLayerInfo::ActivationFunction &function)
704{
705 std::stringstream str;
706 str << function;
707 return str.str();
708}
709
Alex Gildayc357c472018-03-21 13:54:09 +0000710/** Formatted output of the NormType type.
711 *
712 * @param[out] os Output stream.
713 * @param[in] norm_type Type to output.
714 *
715 * @return Modified output stream.
716 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100717inline ::std::ostream &operator<<(::std::ostream &os, const NormType &norm_type)
718{
719 switch(norm_type)
720 {
721 case NormType::CROSS_MAP:
722 os << "CROSS_MAP";
723 break;
724 case NormType::IN_MAP_1D:
725 os << "IN_MAP_1D";
726 break;
727 case NormType::IN_MAP_2D:
728 os << "IN_MAP_2D";
729 break;
730 default:
731 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
732 }
733
734 return os;
735}
736
Alex Gildayc357c472018-03-21 13:54:09 +0000737/** Formatted output of @ref NormalizationLayerInfo.
738 *
739 * @param[in] info Type to output.
740 *
741 * @return Formatted string.
742 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100743inline std::string to_string(const arm_compute::NormalizationLayerInfo &info)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100744{
745 std::stringstream str;
Michalis Spyroud466c2d2018-01-30 10:54:39 +0000746 str << info.type() << ":NormSize=" << info.norm_size();
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100747 return str.str();
748}
749
Alex Gildayc357c472018-03-21 13:54:09 +0000750/** Formatted output of @ref NormalizationLayerInfo.
751 *
752 * @param[out] os Output stream.
753 * @param[in] info Type to output.
754 *
755 * @return Modified output stream.
756 */
Georgios Pinitas6f669f02017-09-26 12:32:57 +0100757inline ::std::ostream &operator<<(::std::ostream &os, const NormalizationLayerInfo &info)
758{
Michalis Spyroud466c2d2018-01-30 10:54:39 +0000759 os << info.type() << ":NormSize=" << info.norm_size();
Georgios Pinitas6f669f02017-09-26 12:32:57 +0100760 return os;
761}
762
Alex Gildayc357c472018-03-21 13:54:09 +0000763/** Formatted output of the PoolingType type.
764 *
765 * @param[out] os Output stream.
766 * @param[in] pool_type Type to output.
767 *
768 * @return Modified output stream.
769 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100770inline ::std::ostream &operator<<(::std::ostream &os, const PoolingType &pool_type)
771{
772 switch(pool_type)
773 {
774 case PoolingType::AVG:
775 os << "AVG";
776 break;
777 case PoolingType::MAX:
778 os << "MAX";
779 break;
Georgios Pinitascdf51452017-08-31 14:21:36 +0100780 case PoolingType::L2:
781 os << "L2";
782 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100783 default:
784 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
785 }
786
787 return os;
788}
789
Alex Gildayc357c472018-03-21 13:54:09 +0000790/** Formatted output of @ref PoolingLayerInfo.
791 *
792 * @param[out] os Output stream.
793 * @param[in] info Type to output.
794 *
795 * @return Modified output stream.
796 */
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100797inline ::std::ostream &operator<<(::std::ostream &os, const PoolingLayerInfo &info)
798{
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +0000799 os << info.pool_type;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100800
801 return os;
802}
803
Alex Gildayc357c472018-03-21 13:54:09 +0000804/** Formatted output of @ref RoundingPolicy.
805 *
806 * @param[in] rounding_policy Type to output.
807 *
808 * @return Formatted string.
809 */
John Richardsondd715f22017-09-18 16:10:48 +0100810inline std::string to_string(const RoundingPolicy &rounding_policy)
811{
812 std::stringstream str;
813 str << rounding_policy;
814 return str.str();
815}
816
Vidhya Sudhan Loganathand646ae12018-11-19 15:18:20 +0000817/** [Print DataLayout type] **/
Alex Gildayc357c472018-03-21 13:54:09 +0000818/** Formatted output of the DataLayout type.
819 *
820 * @param[out] os Output stream.
821 * @param[in] data_layout Type to output.
822 *
823 * @return Modified output stream.
824 */
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000825inline ::std::ostream &operator<<(::std::ostream &os, const DataLayout &data_layout)
826{
827 switch(data_layout)
828 {
829 case DataLayout::UNKNOWN:
830 os << "UNKNOWN";
831 break;
832 case DataLayout::NHWC:
833 os << "NHWC";
834 break;
835 case DataLayout::NCHW:
836 os << "NCHW";
837 break;
Adnan AlSinane4563a02021-09-01 15:32:03 +0100838 case DataLayout::NDHWC:
839 os << "NDHWC";
840 break;
Giorgio Arenac9fe9fc2021-10-06 12:54:29 +0100841 case DataLayout::NCDHW:
842 os << "NCDHW";
843 break;
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000844 default:
845 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
846 }
847
848 return os;
849}
850
Alex Gildayc357c472018-03-21 13:54:09 +0000851/** Formatted output of the DataLayout type.
852 *
853 * @param[in] data_layout Type to output.
854 *
855 * @return Formatted string.
856 */
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000857inline std::string to_string(const arm_compute::DataLayout &data_layout)
858{
859 std::stringstream str;
860 str << data_layout;
861 return str.str();
862}
Vidhya Sudhan Loganathand646ae12018-11-19 15:18:20 +0000863/** [Print DataLayout type] **/
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000864
Georgios Pinitase2220552018-07-20 13:23:44 +0100865/** Formatted output of the DataLayoutDimension type.
866 *
867 * @param[out] os Output stream.
868 * @param[in] data_layout_dim Data layout dimension to print.
869 *
870 * @return Modified output stream.
871 */
872inline ::std::ostream &operator<<(::std::ostream &os, const DataLayoutDimension &data_layout_dim)
873{
874 switch(data_layout_dim)
875 {
876 case DataLayoutDimension::WIDTH:
877 os << "WIDTH";
878 break;
879 case DataLayoutDimension::HEIGHT:
880 os << "HEIGHT";
881 break;
882 case DataLayoutDimension::CHANNEL:
883 os << "CHANNEL";
884 break;
Giorgio Arenac9fe9fc2021-10-06 12:54:29 +0100885 case DataLayoutDimension::DEPTH:
886 os << "DEPTH";
887 break;
Georgios Pinitase2220552018-07-20 13:23:44 +0100888 case DataLayoutDimension::BATCHES:
889 os << "BATCHES";
890 break;
891 default:
892 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
893 }
894 return os;
895}
896
Alex Gildayc357c472018-03-21 13:54:09 +0000897/** Formatted output of the DataType type.
898 *
899 * @param[out] os Output stream.
900 * @param[in] data_type Type to output.
901 *
902 * @return Modified output stream.
903 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100904inline ::std::ostream &operator<<(::std::ostream &os, const DataType &data_type)
905{
906 switch(data_type)
907 {
908 case DataType::UNKNOWN:
909 os << "UNKNOWN";
910 break;
911 case DataType::U8:
912 os << "U8";
913 break;
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100914 case DataType::QSYMM8:
915 os << "QSYMM8";
916 break;
Chunosovd621bca2017-11-03 17:33:15 +0700917 case DataType::QASYMM8:
918 os << "QASYMM8";
919 break;
Georgios Pinitas448a81f2019-11-21 14:10:25 +0000920 case DataType::QASYMM8_SIGNED:
921 os << "QASYMM8_SIGNED";
922 break;
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100923 case DataType::QSYMM8_PER_CHANNEL:
924 os << "QSYMM8_PER_CHANNEL";
925 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100926 case DataType::S8:
927 os << "S8";
928 break;
929 case DataType::U16:
930 os << "U16";
931 break;
932 case DataType::S16:
933 os << "S16";
934 break;
Manuel Bottini3689fcd2019-06-14 17:18:12 +0100935 case DataType::QSYMM16:
936 os << "QSYMM16";
937 break;
Michele Di Giorgio35ea9a72019-08-23 12:02:06 +0100938 case DataType::QASYMM16:
939 os << "QASYMM16";
940 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100941 case DataType::U32:
942 os << "U32";
943 break;
944 case DataType::S32:
945 os << "S32";
946 break;
947 case DataType::U64:
948 os << "U64";
949 break;
950 case DataType::S64:
951 os << "S64";
952 break;
Georgios Pinitase8291ac2020-02-26 09:58:13 +0000953 case DataType::BFLOAT16:
954 os << "BFLOAT16";
955 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100956 case DataType::F16:
957 os << "F16";
958 break;
959 case DataType::F32:
960 os << "F32";
961 break;
962 case DataType::F64:
963 os << "F64";
964 break;
965 case DataType::SIZET:
966 os << "SIZET";
967 break;
968 default:
969 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
970 }
971
972 return os;
973}
974
Alex Gildayc357c472018-03-21 13:54:09 +0000975/** Formatted output of the DataType type.
976 *
977 * @param[in] data_type Type to output.
978 *
979 * @return Formatted string.
980 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100981inline std::string to_string(const arm_compute::DataType &data_type)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100982{
983 std::stringstream str;
984 str << data_type;
985 return str.str();
986}
987
Alex Gildayc357c472018-03-21 13:54:09 +0000988/** Formatted output of the Format type.
989 *
990 * @param[out] os Output stream.
991 * @param[in] format Type to output.
992 *
993 * @return Modified output stream.
994 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100995inline ::std::ostream &operator<<(::std::ostream &os, const Format &format)
996{
997 switch(format)
998 {
999 case Format::UNKNOWN:
1000 os << "UNKNOWN";
1001 break;
1002 case Format::U8:
1003 os << "U8";
1004 break;
1005 case Format::S16:
1006 os << "S16";
1007 break;
1008 case Format::U16:
1009 os << "U16";
1010 break;
1011 case Format::S32:
1012 os << "S32";
1013 break;
1014 case Format::U32:
1015 os << "U32";
1016 break;
1017 case Format::F16:
1018 os << "F16";
1019 break;
1020 case Format::F32:
1021 os << "F32";
1022 break;
1023 case Format::UV88:
1024 os << "UV88";
1025 break;
1026 case Format::RGB888:
1027 os << "RGB888";
1028 break;
1029 case Format::RGBA8888:
1030 os << "RGBA8888";
1031 break;
1032 case Format::YUV444:
1033 os << "YUV444";
1034 break;
1035 case Format::YUYV422:
1036 os << "YUYV422";
1037 break;
1038 case Format::NV12:
1039 os << "NV12";
1040 break;
1041 case Format::NV21:
1042 os << "NV21";
1043 break;
1044 case Format::IYUV:
1045 os << "IYUV";
1046 break;
1047 case Format::UYVY422:
1048 os << "UYVY422";
1049 break;
1050 default:
1051 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1052 }
1053
1054 return os;
1055}
1056
Alex Gildayc357c472018-03-21 13:54:09 +00001057/** Formatted output of the Format type.
1058 *
1059 * @param[in] format Type to output.
1060 *
1061 * @return Formatted string.
1062 */
Moritz Pflanzer7655a672017-09-23 11:57:33 +01001063inline std::string to_string(const Format &format)
1064{
1065 std::stringstream str;
1066 str << format;
1067 return str.str();
1068}
1069
Alex Gildayc357c472018-03-21 13:54:09 +00001070/** Formatted output of the Channel type.
1071 *
1072 * @param[out] os Output stream.
1073 * @param[in] channel Type to output.
1074 *
1075 * @return Modified output stream.
1076 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001077inline ::std::ostream &operator<<(::std::ostream &os, const Channel &channel)
1078{
1079 switch(channel)
1080 {
1081 case Channel::UNKNOWN:
1082 os << "UNKNOWN";
1083 break;
1084 case Channel::C0:
1085 os << "C0";
1086 break;
1087 case Channel::C1:
1088 os << "C1";
1089 break;
1090 case Channel::C2:
1091 os << "C2";
1092 break;
1093 case Channel::C3:
1094 os << "C3";
1095 break;
1096 case Channel::R:
1097 os << "R";
1098 break;
1099 case Channel::G:
1100 os << "G";
1101 break;
1102 case Channel::B:
1103 os << "B";
1104 break;
1105 case Channel::A:
1106 os << "A";
1107 break;
1108 case Channel::Y:
1109 os << "Y";
1110 break;
1111 case Channel::U:
1112 os << "U";
1113 break;
1114 case Channel::V:
1115 os << "V";
1116 break;
1117 default:
1118 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1119 }
1120
1121 return os;
1122}
1123
Alex Gildayc357c472018-03-21 13:54:09 +00001124/** Formatted output of the Channel type.
1125 *
1126 * @param[in] channel Type to output.
1127 *
1128 * @return Formatted string.
1129 */
Ioan-Cristian Szabo9414f642017-10-27 17:35:40 +01001130inline std::string to_string(const Channel &channel)
1131{
1132 std::stringstream str;
1133 str << channel;
1134 return str.str();
1135}
1136
Alex Gildayc357c472018-03-21 13:54:09 +00001137/** Formatted output of the BorderMode type.
1138 *
1139 * @param[out] os Output stream.
1140 * @param[in] mode Type to output.
1141 *
1142 * @return Modified output stream.
1143 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001144inline ::std::ostream &operator<<(::std::ostream &os, const BorderMode &mode)
1145{
1146 switch(mode)
1147 {
1148 case BorderMode::UNDEFINED:
1149 os << "UNDEFINED";
1150 break;
1151 case BorderMode::CONSTANT:
1152 os << "CONSTANT";
1153 break;
1154 case BorderMode::REPLICATE:
1155 os << "REPLICATE";
1156 break;
1157 default:
1158 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1159 }
1160
1161 return os;
1162}
1163
Alex Gildayc357c472018-03-21 13:54:09 +00001164/** Formatted output of the BorderSize type.
1165 *
1166 * @param[out] os Output stream.
1167 * @param[in] border Type to output.
1168 *
1169 * @return Modified output stream.
1170 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001171inline ::std::ostream &operator<<(::std::ostream &os, const BorderSize &border)
1172{
Moritz Pflanzerc87fbf82017-07-18 14:02:10 +01001173 os << border.top << ","
1174 << border.right << ","
1175 << border.bottom << ","
1176 << border.left;
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001177
1178 return os;
1179}
Anthony Barbier2a07e182017-08-04 18:20:27 +01001180
Giuseppe Rossinid7647d42018-07-17 18:13:13 +01001181/** Formatted output of the PaddingList type.
1182 *
1183 * @param[out] os Output stream.
1184 * @param[in] padding Type to output.
1185 *
1186 * @return Modified output stream.
1187 */
1188inline ::std::ostream &operator<<(::std::ostream &os, const PaddingList &padding)
1189{
1190 os << "{";
1191 for(auto const &p : padding)
1192 {
1193 os << "{" << p.first << "," << p.second << "}";
1194 }
1195 os << "}";
1196 return os;
1197}
1198
giuros013175fcf2018-11-21 09:59:17 +00001199/** Formatted output of the Multiples type.
1200 *
1201 * @param[out] os Output stream.
1202 * @param[in] multiples Type to output.
1203 *
1204 * @return Modified output stream.
1205 */
1206inline ::std::ostream &operator<<(::std::ostream &os, const Multiples &multiples)
1207{
1208 os << "(";
1209 for(size_t i = 0; i < multiples.size() - 1; i++)
1210 {
1211 os << multiples[i] << ", ";
1212 }
1213 os << multiples.back() << ")";
1214 return os;
1215}
1216
Alex Gildayc357c472018-03-21 13:54:09 +00001217/** Formatted output of the InterpolationPolicy type.
1218 *
1219 * @param[out] os Output stream.
1220 * @param[in] policy Type to output.
1221 *
1222 * @return Modified output stream.
1223 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001224inline ::std::ostream &operator<<(::std::ostream &os, const InterpolationPolicy &policy)
1225{
1226 switch(policy)
1227 {
1228 case InterpolationPolicy::NEAREST_NEIGHBOR:
1229 os << "NEAREST_NEIGHBOR";
1230 break;
1231 case InterpolationPolicy::BILINEAR:
1232 os << "BILINEAR";
1233 break;
1234 case InterpolationPolicy::AREA:
1235 os << "AREA";
1236 break;
1237 default:
1238 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1239 }
1240
1241 return os;
1242}
1243
Alex Gildayc357c472018-03-21 13:54:09 +00001244/** Formatted output of the SamplingPolicy type.
1245 *
1246 * @param[out] os Output stream.
1247 * @param[in] policy Type to output.
1248 *
1249 * @return Modified output stream.
1250 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +07001251inline ::std::ostream &operator<<(::std::ostream &os, const SamplingPolicy &policy)
1252{
1253 switch(policy)
1254 {
1255 case SamplingPolicy::CENTER:
1256 os << "CENTER";
1257 break;
1258 case SamplingPolicy::TOP_LEFT:
1259 os << "TOP_LEFT";
1260 break;
1261 default:
1262 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1263 }
1264
1265 return os;
1266}
1267
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001268/** Formatted output of the ITensorInfo type.
1269 *
1270 * @param[out] os Output stream.
1271 * @param[in] info Tensor information.
1272 *
1273 * @return Modified output stream.
1274 */
1275inline ::std::ostream &operator<<(std::ostream &os, const ITensorInfo *info)
1276{
Georgios Pinitasc6f95102021-03-30 10:03:01 +01001277 const DataType data_type = info->data_type();
1278 const DataLayout data_layout = info->data_layout();
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001279
1280 os << "Shape=" << info->tensor_shape() << ","
1281 << "DataLayout=" << string_from_data_layout(data_layout) << ","
ramelg014a6d9e82021-10-02 14:34:36 +01001282 << "DataType=" << string_from_data_type(data_type);
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001283
1284 if(is_data_type_quantized(data_type))
1285 {
ramelg01b1ba1e32021-09-25 11:53:26 +01001286 const QuantizationInfo qinfo = info->quantization_info();
1287 const auto scales = qinfo.scale();
1288 const auto offsets = qinfo.offset();
1289
ramelg014a6d9e82021-10-02 14:34:36 +01001290 os << ", QuantizationInfo={"
ramelg01b1ba1e32021-09-25 11:53:26 +01001291 << "scales.size=" << scales.size()
1292 << ", scale(s)=" << scales << ", ";
1293
1294 os << "offsets.size=" << offsets.size()
1295 << ", offset(s)=" << offsets << "}";
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001296 }
1297 return os;
1298}
1299
ramelg013ae3d882021-09-12 23:07:47 +01001300/** Formatted output of the const TensorInfo& type.
Alex Gildayc357c472018-03-21 13:54:09 +00001301 *
Anthony Barbier366628a2018-08-01 13:55:03 +01001302 * @param[out] os Output stream.
1303 * @param[in] info Type to output.
1304 *
1305 * @return Modified output stream.
1306 */
1307inline ::std::ostream &operator<<(::std::ostream &os, const TensorInfo &info)
1308{
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001309 os << &info;
Georgios Pinitasc6f95102021-03-30 10:03:01 +01001310 return os;
Anthony Barbier366628a2018-08-01 13:55:03 +01001311}
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001312
ramelg013ae3d882021-09-12 23:07:47 +01001313/** Formatted output of the const TensorInfo& type.
Anthony Barbier366628a2018-08-01 13:55:03 +01001314 *
Alex Gildayc357c472018-03-21 13:54:09 +00001315 * @param[in] info Type to output.
1316 *
1317 * @return Formatted string.
1318 */
Georgios Pinitas3faea252017-10-30 14:13:50 +00001319inline std::string to_string(const TensorInfo &info)
1320{
1321 std::stringstream str;
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001322 str << &info;
Georgios Pinitas3faea252017-10-30 14:13:50 +00001323 return str.str();
1324}
1325
ramelg013ae3d882021-09-12 23:07:47 +01001326/** Formatted output of the const ITensorInfo& type.
1327 *
1328 * @param[in] info Type to output.
1329 *
1330 * @return Formatted string.
1331 */
1332inline std::string to_string(const ITensorInfo &info)
1333{
1334 std::stringstream str;
1335 str << &info;
1336 return str.str();
1337}
1338
ramelg013ae3d882021-09-12 23:07:47 +01001339/** Formatted output of the const ITensorInfo* type.
1340 *
1341 * @param[in] info Type to output.
1342 *
1343 * @return Formatted string.
1344 */
Ramy Elgammale920d6a2021-08-19 22:10:30 +01001345inline std::string to_string(const ITensorInfo *info)
1346{
ramelg013ae3d882021-09-12 23:07:47 +01001347 std::string ret_str = "nullptr";
1348 if(info != nullptr)
1349 {
1350 std::stringstream str;
1351 str << info;
1352 ret_str = str.str();
1353 }
1354 return ret_str;
1355}
1356
ramelg01cbbb0382021-09-17 17:36:57 +01001357/** Formatted output of the ITensorInfo* type.
1358 *
1359 * @param[in] info Type to output.
1360 *
1361 * @return Formatted string.
1362 */
1363inline std::string to_string(ITensorInfo *info)
1364{
1365 return to_string(static_cast<const ITensorInfo *>(info));
1366}
1367
1368/** Formatted output of the ITensorInfo type obtained from const ITensor* type.
ramelg013ae3d882021-09-12 23:07:47 +01001369 *
1370 * @param[in] tensor Type to output.
1371 *
1372 * @return Formatted string.
1373 */
1374inline std::string to_string(const ITensor *tensor)
1375{
1376 std::string ret_str = "nullptr";
1377 if(tensor != nullptr)
1378 {
1379 std::stringstream str;
ramelg01cbbb0382021-09-17 17:36:57 +01001380 str << "ITensor->info(): " << tensor->info();
ramelg013ae3d882021-09-12 23:07:47 +01001381 ret_str = str.str();
1382 }
1383 return ret_str;
1384}
1385
ramelg01cbbb0382021-09-17 17:36:57 +01001386/** Formatted output of the ITensorInfo type obtained from the ITensor* type.
ramelg013ae3d882021-09-12 23:07:47 +01001387 *
1388 * @param[in] tensor Type to output.
1389 *
1390 * @return Formatted string.
1391 */
1392inline std::string to_string(ITensor *tensor)
1393{
ramelg01cbbb0382021-09-17 17:36:57 +01001394 return to_string(static_cast<const ITensor *>(tensor));
ramelg013ae3d882021-09-12 23:07:47 +01001395}
1396
ramelg01cbbb0382021-09-17 17:36:57 +01001397/** Formatted output of the ITensorInfo type obtained from the ITensor& type.
ramelg013ae3d882021-09-12 23:07:47 +01001398 *
1399 * @param[in] tensor Type to output.
1400 *
1401 * @return Formatted string.
1402 */
1403inline std::string to_string(ITensor &tensor)
1404{
Ramy Elgammale920d6a2021-08-19 22:10:30 +01001405 std::stringstream str;
ramelg01cbbb0382021-09-17 17:36:57 +01001406 str << "ITensor.info(): " << tensor.info();
Ramy Elgammale920d6a2021-08-19 22:10:30 +01001407 return str.str();
1408}
1409
ramelg01cbbb0382021-09-17 17:36:57 +01001410#ifdef ARM_COMPUTE_OPENCL_ENABLED
1411/** Formatted output of the ITensorInfo type obtained from the const ICLTensor& type.
1412 *
1413 * @param[in] cl_tensor Type to output.
1414 *
1415 * @return Formatted string.
1416 */
1417inline std::string to_string(const ICLTensor *cl_tensor)
1418{
1419 std::string ret_str = "nullptr";
1420 if(cl_tensor != nullptr)
1421 {
1422 std::stringstream str;
1423 str << "ICLTensor->info(): " << cl_tensor->info();
1424 ret_str = str.str();
1425 }
1426 return ret_str;
1427}
1428
1429/** Formatted output of the ITensorInfo type obtained from the ICLTensor& type.
1430 *
1431 * @param[in] cl_tensor Type to output.
1432 *
1433 * @return Formatted string.
1434 */
1435inline std::string to_string(ICLTensor *cl_tensor)
1436{
1437 return to_string(static_cast<const ICLTensor *>(cl_tensor));
1438}
1439#endif /* ARM_COMPUTE_OPENCL_ENABLED */
1440
Alex Gildayc357c472018-03-21 13:54:09 +00001441/** Formatted output of the Dimensions type.
1442 *
1443 * @param[in] dimensions Type to output.
1444 *
1445 * @return Formatted string.
1446 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001447template <typename T>
1448inline std::string to_string(const Dimensions<T> &dimensions)
1449{
1450 std::stringstream str;
1451 str << dimensions;
1452 return str.str();
1453}
1454
Alex Gildayc357c472018-03-21 13:54:09 +00001455/** Formatted output of the Strides type.
1456 *
1457 * @param[in] stride Type to output.
1458 *
1459 * @return Formatted string.
1460 */
John Richardsona36eae12017-09-26 16:55:59 +01001461inline std::string to_string(const Strides &stride)
1462{
1463 std::stringstream str;
1464 str << stride;
1465 return str.str();
1466}
1467
Alex Gildayc357c472018-03-21 13:54:09 +00001468/** Formatted output of the TensorShape type.
1469 *
1470 * @param[in] shape Type to output.
1471 *
1472 * @return Formatted string.
1473 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001474inline std::string to_string(const TensorShape &shape)
1475{
1476 std::stringstream str;
1477 str << shape;
1478 return str.str();
1479}
1480
Alex Gildayc357c472018-03-21 13:54:09 +00001481/** Formatted output of the Coordinates type.
1482 *
1483 * @param[in] coord Type to output.
1484 *
1485 * @return Formatted string.
1486 */
Abe Mbise925ca0f2017-10-02 19:16:33 +01001487inline std::string to_string(const Coordinates &coord)
1488{
1489 std::stringstream str;
1490 str << coord;
1491 return str.str();
1492}
1493
Anthony Barbierb940fd62018-06-04 14:14:32 +01001494/** Formatted output of the GEMMReshapeInfo type.
1495 *
1496 * @param[out] os Output stream.
1497 * @param[in] info Type to output.
1498 *
1499 * @return Modified output stream.
1500 */
1501inline ::std::ostream &operator<<(::std::ostream &os, const GEMMReshapeInfo &info)
1502{
1503 os << "{m=" << info.m() << ",";
1504 os << "n=" << info.n() << ",";
1505 os << "k=" << info.k() << ",";
1506 os << "mult_transpose1xW_width=" << info.mult_transpose1xW_width() << ",";
1507 os << "mult_interleave4x4_height=" << info.mult_interleave4x4_height();
1508 os << "}";
1509
1510 return os;
1511}
1512
1513/** Formatted output of the GEMMInfo type.
1514 *
1515 * @param[out] os Output stream.
1516 * @param[in] info Type to output.
1517 *
1518 * @return Modified output stream.
1519 */
1520inline ::std::ostream &operator<<(::std::ostream &os, const GEMMInfo &info)
1521{
1522 os << "{is_a_reshaped=" << info.is_a_reshaped() << ",";
1523 os << "is_b_reshaped=" << info.is_b_reshaped() << ",";
1524 os << "reshape_b_only_on_first_run=" << info.reshape_b_only_on_first_run() << ",";
Anthony Barbierb4670212018-05-18 16:55:39 +01001525 os << "depth_output_gemm3d=" << info.depth_output_gemm3d() << ",";
1526 os << "reinterpret_input_as_3d=" << info.reinterpret_input_as_3d() << ",";
1527 os << "retain_internal_weights=" << info.retain_internal_weights() << ",";
1528 os << "fp_mixed_precision=" << info.fp_mixed_precision() << ",";
1529 os << "broadcast_bias=" << info.broadcast_bias() << ",";
ramelg01cbbb0382021-09-17 17:36:57 +01001530 os << "pretranspose_B=" << info.pretranspose_B() << ",";
SiCongLi579ca842021-10-18 09:38:33 +01001531 os << "post_ops=" << info.post_ops() << "}";
Anthony Barbierb940fd62018-06-04 14:14:32 +01001532
1533 return os;
1534}
1535
1536/** Formatted output of the Window::Dimension type.
1537 *
1538 * @param[out] os Output stream.
1539 * @param[in] dim Type to output.
1540 *
1541 * @return Modified output stream.
1542 */
1543inline ::std::ostream &operator<<(::std::ostream &os, const Window::Dimension &dim)
1544{
1545 os << "{start=" << dim.start() << ", end=" << dim.end() << ", step=" << dim.step() << "}";
1546
1547 return os;
1548}
1549/** Formatted output of the Window type.
1550 *
1551 * @param[out] os Output stream.
1552 * @param[in] win Type to output.
1553 *
1554 * @return Modified output stream.
1555 */
1556inline ::std::ostream &operator<<(::std::ostream &os, const Window &win)
1557{
1558 os << "{";
1559 for(unsigned int i = 0; i < Coordinates::num_max_dimensions; i++)
1560 {
1561 if(i > 0)
1562 {
1563 os << ", ";
1564 }
1565 os << win[i];
1566 }
1567 os << "}";
1568
1569 return os;
1570}
1571
1572/** Formatted output of the WeightsInfo type.
1573 *
1574 * @param[in] info Type to output.
1575 *
1576 * @return Formatted string.
1577 */
1578inline std::string to_string(const WeightsInfo &info)
1579{
1580 std::stringstream str;
1581 str << info;
1582 return str.str();
1583}
1584
1585/** Formatted output of the GEMMReshapeInfo type.
1586 *
1587 * @param[in] info Type to output.
1588 *
1589 * @return Formatted string.
1590 */
1591inline std::string to_string(const GEMMReshapeInfo &info)
1592{
1593 std::stringstream str;
1594 str << info;
1595 return str.str();
1596}
1597
1598/** Formatted output of the GEMMInfo type.
1599 *
1600 * @param[in] info Type to output.
1601 *
1602 * @return Formatted string.
1603 */
1604inline std::string to_string(const GEMMInfo &info)
1605{
1606 std::stringstream str;
1607 str << info;
1608 return str.str();
1609}
1610
1611/** Formatted output of the Window::Dimension type.
1612 *
1613 * @param[in] dim Type to output.
1614 *
1615 * @return Formatted string.
1616 */
1617inline std::string to_string(const Window::Dimension &dim)
1618{
1619 std::stringstream str;
1620 str << dim;
1621 return str.str();
1622}
ramelg01cbbb0382021-09-17 17:36:57 +01001623/** Formatted output of the Window& type.
Anthony Barbierb940fd62018-06-04 14:14:32 +01001624 *
1625 * @param[in] win Type to output.
1626 *
1627 * @return Formatted string.
1628 */
1629inline std::string to_string(const Window &win)
1630{
1631 std::stringstream str;
1632 str << win;
1633 return str.str();
1634}
1635
ramelg01cbbb0382021-09-17 17:36:57 +01001636/** Formatted output of the Window* type.
1637 *
1638 * @param[in] win Type to output.
1639 *
1640 * @return Formatted string.
1641 */
1642inline std::string to_string(Window *win)
1643{
1644 std::string ret_str = "nullptr";
1645 if(win != nullptr)
1646 {
1647 std::stringstream str;
1648 str << *win;
1649 ret_str = str.str();
1650 }
1651 return ret_str;
1652}
1653
Alex Gildayc357c472018-03-21 13:54:09 +00001654/** Formatted output of the Rectangle type.
1655 *
1656 * @param[out] os Output stream.
1657 * @param[in] rect Type to output.
1658 *
1659 * @return Modified output stream.
1660 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001661inline ::std::ostream &operator<<(::std::ostream &os, const Rectangle &rect)
1662{
1663 os << rect.width << "x" << rect.height;
1664 os << "+" << rect.x << "+" << rect.y;
1665
1666 return os;
1667}
1668
Usama Arif8cf8c112019-03-14 15:36:54 +00001669/** Formatted output of the PaddingMode type.
1670 *
1671 * @param[out] os Output stream.
1672 * @param[in] mode Type to output.
1673 *
1674 * @return Modified output stream.
1675 */
1676inline ::std::ostream &operator<<(::std::ostream &os, const PaddingMode &mode)
1677{
1678 switch(mode)
1679 {
1680 case PaddingMode::CONSTANT:
1681 os << "CONSTANT";
1682 break;
1683 case PaddingMode::REFLECT:
1684 os << "REFLECT";
1685 break;
1686 case PaddingMode::SYMMETRIC:
1687 os << "SYMMETRIC";
1688 break;
1689 default:
1690 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1691 }
1692
1693 return os;
1694}
1695
1696/** Formatted output of the PaddingMode type.
1697 *
1698 * @param[in] mode Type to output.
1699 *
1700 * @return Formatted string.
1701 */
1702inline std::string to_string(const PaddingMode &mode)
1703{
1704 std::stringstream str;
1705 str << mode;
1706 return str.str();
1707}
1708
Alex Gildayc357c472018-03-21 13:54:09 +00001709/** Formatted output of the PadStrideInfo type.
1710 *
1711 * @param[out] os Output stream.
1712 * @param[in] pad_stride_info Type to output.
1713 *
1714 * @return Modified output stream.
1715 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001716inline ::std::ostream &operator<<(::std::ostream &os, const PadStrideInfo &pad_stride_info)
1717{
1718 os << pad_stride_info.stride().first << "," << pad_stride_info.stride().second;
1719 os << ";";
Jaroslaw Rzepeckia1ed41f2017-10-13 11:13:58 +01001720 os << pad_stride_info.pad_left() << "," << pad_stride_info.pad_right() << ","
1721 << pad_stride_info.pad_top() << "," << pad_stride_info.pad_bottom();
Anthony Barbier2a07e182017-08-04 18:20:27 +01001722
1723 return os;
1724}
1725
Alex Gildayc357c472018-03-21 13:54:09 +00001726/** Formatted output of the PadStrideInfo type.
1727 *
1728 * @param[in] pad_stride_info Type to output.
1729 *
1730 * @return Formatted string.
1731 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001732inline std::string to_string(const PadStrideInfo &pad_stride_info)
1733{
1734 std::stringstream str;
1735 str << pad_stride_info;
1736 return str.str();
1737}
1738
Alex Gildayc357c472018-03-21 13:54:09 +00001739/** Formatted output of the BorderMode type.
1740 *
1741 * @param[in] mode Type to output.
1742 *
1743 * @return Formatted string.
1744 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001745inline std::string to_string(const BorderMode &mode)
1746{
1747 std::stringstream str;
1748 str << mode;
1749 return str.str();
1750}
1751
Alex Gildayc357c472018-03-21 13:54:09 +00001752/** Formatted output of the BorderSize type.
1753 *
1754 * @param[in] border Type to output.
1755 *
1756 * @return Formatted string.
1757 */
John Richardsonb482ce12017-09-18 12:44:01 +01001758inline std::string to_string(const BorderSize &border)
1759{
1760 std::stringstream str;
1761 str << border;
1762 return str.str();
1763}
1764
Giuseppe Rossinid7647d42018-07-17 18:13:13 +01001765/** Formatted output of the PaddingList type.
1766 *
1767 * @param[in] padding Type to output.
1768 *
1769 * @return Formatted string.
1770 */
1771inline std::string to_string(const PaddingList &padding)
1772{
1773 std::stringstream str;
1774 str << padding;
1775 return str.str();
1776}
1777
giuros013175fcf2018-11-21 09:59:17 +00001778/** Formatted output of the Multiples type.
1779 *
1780 * @param[in] multiples Type to output.
1781 *
1782 * @return Formatted string.
1783 */
1784inline std::string to_string(const Multiples &multiples)
1785{
1786 std::stringstream str;
1787 str << multiples;
1788 return str.str();
1789}
1790
Alex Gildayc357c472018-03-21 13:54:09 +00001791/** Formatted output of the InterpolationPolicy type.
1792 *
1793 * @param[in] policy Type to output.
1794 *
1795 * @return Formatted string.
1796 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001797inline std::string to_string(const InterpolationPolicy &policy)
1798{
1799 std::stringstream str;
1800 str << policy;
1801 return str.str();
1802}
1803
Alex Gildayc357c472018-03-21 13:54:09 +00001804/** Formatted output of the SamplingPolicy type.
1805 *
1806 * @param[in] policy Type to output.
1807 *
1808 * @return Formatted string.
1809 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +07001810inline std::string to_string(const SamplingPolicy &policy)
1811{
1812 std::stringstream str;
1813 str << policy;
1814 return str.str();
1815}
1816
Alex Gildayc357c472018-03-21 13:54:09 +00001817/** Formatted output of the ConvertPolicy type.
1818 *
1819 * @param[out] os Output stream.
1820 * @param[in] policy Type to output.
1821 *
1822 * @return Modified output stream.
1823 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001824inline ::std::ostream &operator<<(::std::ostream &os, const ConvertPolicy &policy)
1825{
1826 switch(policy)
1827 {
1828 case ConvertPolicy::WRAP:
1829 os << "WRAP";
1830 break;
1831 case ConvertPolicy::SATURATE:
1832 os << "SATURATE";
1833 break;
1834 default:
1835 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1836 }
1837
1838 return os;
1839}
1840
1841inline std::string to_string(const ConvertPolicy &policy)
1842{
1843 std::stringstream str;
1844 str << policy;
1845 return str.str();
1846}
1847
giuros01164a2722018-11-20 18:34:46 +00001848/** Formatted output of the ArithmeticOperation type.
1849 *
1850 * @param[out] os Output stream.
1851 * @param[in] op Operation to output.
1852 *
1853 * @return Modified output stream.
1854 */
1855inline ::std::ostream &operator<<(::std::ostream &os, const ArithmeticOperation &op)
1856{
1857 switch(op)
1858 {
1859 case ArithmeticOperation::ADD:
1860 os << "ADD";
1861 break;
1862 case ArithmeticOperation::SUB:
1863 os << "SUB";
1864 break;
1865 case ArithmeticOperation::DIV:
1866 os << "DIV";
1867 break;
1868 case ArithmeticOperation::MAX:
1869 os << "MAX";
1870 break;
1871 case ArithmeticOperation::MIN:
1872 os << "MIN";
1873 break;
1874 case ArithmeticOperation::SQUARED_DIFF:
1875 os << "SQUARED_DIFF";
1876 break;
Usama Arif52c54f62019-05-14 10:22:36 +01001877 case ArithmeticOperation::POWER:
1878 os << "POWER";
1879 break;
Ramy Elgammal404462a2022-11-08 02:14:46 +00001880 case ArithmeticOperation::PRELU:
1881 os << "PRELU";
1882 break;
giuros01164a2722018-11-20 18:34:46 +00001883 default:
1884 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1885 }
1886
1887 return os;
1888}
1889
1890/** Formatted output of the Arithmetic Operation
1891 *
1892 * @param[in] op Type to output.
1893 *
1894 * @return Formatted string.
1895 */
1896inline std::string to_string(const ArithmeticOperation &op)
1897{
1898 std::stringstream str;
1899 str << op;
1900 return str.str();
1901}
1902
Alex Gildayc357c472018-03-21 13:54:09 +00001903/** Formatted output of the Reduction Operations.
1904 *
1905 * @param[out] os Output stream.
1906 * @param[in] op Type to output.
1907 *
1908 * @return Modified output stream.
1909 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001910inline ::std::ostream &operator<<(::std::ostream &os, const ReductionOperation &op)
1911{
1912 switch(op)
1913 {
Michalis Spyrou7e9391b2018-10-05 14:49:28 +01001914 case ReductionOperation::SUM:
1915 os << "SUM";
1916 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +01001917 case ReductionOperation::SUM_SQUARE:
1918 os << "SUM_SQUARE";
1919 break;
Michalis Spyrou7e9391b2018-10-05 14:49:28 +01001920 case ReductionOperation::MEAN_SUM:
1921 os << "MEAN_SUM";
1922 break;
Michalis Spyrou7930db42018-11-22 17:36:28 +00001923 case ReductionOperation::ARG_IDX_MAX:
1924 os << "ARG_IDX_MAX";
1925 break;
1926 case ReductionOperation::ARG_IDX_MIN:
1927 os << "ARG_IDX_MIN";
1928 break;
Manuel Bottinib412fab2018-12-10 17:40:23 +00001929 case ReductionOperation::PROD:
1930 os << "PROD";
1931 break;
Usama Arifa4a08ad2019-05-20 12:38:33 +01001932 case ReductionOperation::MIN:
1933 os << "MIN";
1934 break;
Usama Arif28f0dd92019-05-20 13:44:34 +01001935 case ReductionOperation::MAX:
1936 os << "MAX";
1937 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +01001938 default:
1939 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1940 }
1941
1942 return os;
1943}
1944
Alex Gildayc357c472018-03-21 13:54:09 +00001945/** Formatted output of the Reduction Operations.
1946 *
1947 * @param[in] op Type to output.
1948 *
1949 * @return Formatted string.
1950 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001951inline std::string to_string(const ReductionOperation &op)
1952{
1953 std::stringstream str;
1954 str << op;
1955 return str.str();
1956}
1957
Georgios Pinitas7900a9e2018-11-23 11:44:58 +00001958/** Formatted output of the Comparison Operations.
1959 *
1960 * @param[out] os Output stream.
1961 * @param[in] op Type to output.
1962 *
1963 * @return Modified output stream.
1964 */
1965inline ::std::ostream &operator<<(::std::ostream &os, const ComparisonOperation &op)
1966{
1967 switch(op)
1968 {
1969 case ComparisonOperation::Equal:
1970 os << "Equal";
1971 break;
1972 case ComparisonOperation::NotEqual:
1973 os << "NotEqual";
1974 break;
1975 case ComparisonOperation::Greater:
1976 os << "Greater";
1977 break;
1978 case ComparisonOperation::GreaterEqual:
1979 os << "GreaterEqual";
1980 break;
1981 case ComparisonOperation::Less:
1982 os << "Less";
1983 break;
1984 case ComparisonOperation::LessEqual:
1985 os << "LessEqual";
1986 break;
1987 default:
1988 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1989 }
1990
1991 return os;
1992}
1993
Michalis Spyroue9362622018-11-23 17:41:37 +00001994/** Formatted output of the Elementwise unary Operations.
1995 *
1996 * @param[out] os Output stream.
1997 * @param[in] op Type to output.
1998 *
1999 * @return Modified output stream.
2000 */
2001inline ::std::ostream &operator<<(::std::ostream &os, const ElementWiseUnary &op)
2002{
2003 switch(op)
2004 {
2005 case ElementWiseUnary::RSQRT:
2006 os << "RSQRT";
2007 break;
2008 case ElementWiseUnary::EXP:
2009 os << "EXP";
2010 break;
Usama Arifeb312ef2019-05-13 17:45:54 +01002011 case ElementWiseUnary::NEG:
2012 os << "NEG";
2013 break;
Usama Arifac33d7e2019-05-20 14:21:40 +01002014 case ElementWiseUnary::LOG:
2015 os << "LOG";
2016 break;
ramelg01b1ba1e32021-09-25 11:53:26 +01002017 case ElementWiseUnary::SIN:
2018 os << "SIN";
2019 break;
2020 case ElementWiseUnary::ABS:
2021 os << "ABS";
2022 break;
Usama Arif6a4d5422019-05-24 14:53:59 +01002023 case ElementWiseUnary::ROUND:
2024 os << "ROUND";
2025 break;
ramelg01b1ba1e32021-09-25 11:53:26 +01002026 case ElementWiseUnary::LOGICAL_NOT:
2027 os << "LOGICAL_NOT";
2028 break;
Michalis Spyroue9362622018-11-23 17:41:37 +00002029 default:
2030 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2031 }
2032
2033 return os;
2034}
2035
Georgios Pinitas7900a9e2018-11-23 11:44:58 +00002036/** Formatted output of the Comparison Operations.
2037 *
2038 * @param[in] op Type to output.
2039 *
2040 * @return Formatted string.
2041 */
2042inline std::string to_string(const ComparisonOperation &op)
2043{
2044 std::stringstream str;
2045 str << op;
2046 return str.str();
2047}
2048
Michalis Spyroue9362622018-11-23 17:41:37 +00002049/** Formatted output of the Elementwise unary Operations.
2050 *
2051 * @param[in] op Type to output.
2052 *
2053 * @return Formatted string.
2054 */
2055inline std::string to_string(const ElementWiseUnary &op)
2056{
2057 std::stringstream str;
2058 str << op;
2059 return str.str();
2060}
2061
Alex Gildayc357c472018-03-21 13:54:09 +00002062/** Formatted output of the Norm Type.
2063 *
2064 * @param[in] type Type to output.
2065 *
2066 * @return Formatted string.
2067 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01002068inline std::string to_string(const NormType &type)
2069{
2070 std::stringstream str;
2071 str << type;
2072 return str.str();
2073}
2074
Alex Gildayc357c472018-03-21 13:54:09 +00002075/** Formatted output of the Pooling Type.
2076 *
2077 * @param[in] type Type to output.
2078 *
2079 * @return Formatted string.
2080 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01002081inline std::string to_string(const PoolingType &type)
2082{
2083 std::stringstream str;
2084 str << type;
2085 return str.str();
2086}
2087
Alex Gildayc357c472018-03-21 13:54:09 +00002088/** Formatted output of the Pooling Layer Info.
2089 *
2090 * @param[in] info Type to output.
2091 *
2092 * @return Formatted string.
2093 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01002094inline std::string to_string(const PoolingLayerInfo &info)
2095{
2096 std::stringstream str;
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +00002097 str << "{Type=" << info.pool_type << ","
Sang-Hoon Park11fedda2020-01-15 14:44:04 +00002098 << "DataLayout=" << info.data_layout << ","
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +00002099 << "IsGlobalPooling=" << info.is_global_pooling;
2100 if(!info.is_global_pooling)
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00002101 {
2102 str << ","
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +00002103 << "PoolSize=" << info.pool_size.width << "," << info.pool_size.height << ","
2104 << "PadStride=" << info.pad_stride_info;
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00002105 }
2106 str << "}";
Anthony Barbier2a07e182017-08-04 18:20:27 +01002107 return str.str();
2108}
2109
ramelg0137515692022-02-26 22:06:20 +00002110/** Formatted output of the Size3D type.
2111 *
2112 * @param[out] os Output stream
2113 * @param[in] size Type to output
2114 *
2115 * @return Modified output stream.
2116 */
2117inline ::std::ostream &operator<<(::std::ostream &os, const Size3D &size)
2118{
2119 os << size.width << "x" << size.height << "x" << size.depth;
2120
2121 return os;
2122}
2123
2124/** Formatted output of the Size3D type.
2125 *
2126 * @param[in] type Type to output
2127 *
2128 * @return Formatted string.
2129 */
2130inline std::string to_string(const Size3D &type)
2131{
2132 std::stringstream str;
2133 str << type;
2134 return str.str();
2135}
2136
2137/** Formatted output of the Padding3D type.
2138 *
2139 * @param[out] os Output stream.
2140 * @param[in] padding3d Padding info for 3D spatial dimension shape.
2141 *
2142 * @return Modified output stream.
2143 */
2144inline ::std::ostream &operator<<(::std::ostream &os, const Padding3D &padding3d)
2145{
2146 os << padding3d.left << "," << padding3d.right << ","
2147 << padding3d.top << "," << padding3d.bottom << ","
2148 << padding3d.front << "," << padding3d.back;
2149 return os;
2150}
2151
2152/** Converts a @ref Padding3D to string
2153 *
2154 * @param[in] padding3d Padding3D value to be converted
2155 *
2156 * @return String representing the corresponding Padding3D
2157 */
2158inline std::string to_string(const Padding3D &padding3d)
2159{
2160 std::stringstream str;
2161 str << padding3d;
2162 return str.str();
2163}
2164
2165/** Formatted output of the DimensionRoundingType type.
2166 *
2167 * @param[out] os Output stream.
2168 * @param[in] rounding_type DimensionRoundingType Dimension rounding type when down-scaling, or compute output shape of pooling(2D or 3D).
2169 *
2170 * @return Modified output stream.
2171 */
2172inline ::std::ostream &operator<<(::std::ostream &os, const DimensionRoundingType &rounding_type)
2173{
2174 switch(rounding_type)
2175 {
2176 case DimensionRoundingType::CEIL:
2177 os << "CEIL";
2178 break;
2179 case DimensionRoundingType::FLOOR:
2180 os << "FLOOR";
2181 break;
2182 default:
2183 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2184 }
2185 return os;
2186}
2187
2188/** Formatted output of the Pooling 3d Layer Info.
2189 *
2190 * @param[out] os Output stream.
2191 * @param[in] info Pooling 3D layer info to print to output stream.
2192 *
2193 * @return Modified output stream.
2194 */
2195inline ::std::ostream &operator<<(::std::ostream &os, const Pooling3dLayerInfo &info)
2196{
2197 os << "{Type=" << info.pool_type << ","
2198 << "IsGlobalPooling=" << info.is_global_pooling;
2199 if(!info.is_global_pooling)
2200 {
2201 os << ","
2202 << "PoolSize=" << info.pool_size << ", "
2203 << "Stride=" << info.stride << ", "
2204 << "Padding=" << info.padding << ", "
2205 << "Exclude Padding=" << info.exclude_padding << ", "
2206 << "fp_mixed_precision=" << info.fp_mixed_precision << ", "
2207 << "DimensionRoundingType=" << info.round_type;
2208 }
2209 os << "}";
2210 return os;
2211}
2212
2213/** Formatted output of the Pooling 3d Layer Info.
2214 *
2215 * @param[in] info Type to output.
2216 *
2217 * @return Formatted string.
2218 */
2219inline std::string to_string(const Pooling3dLayerInfo &info)
2220{
2221 std::stringstream str;
2222 str << info;
2223 return str.str();
2224}
2225
Michalis Spyrou6c7c38e2018-08-29 16:28:11 +01002226/** Formatted output of the PriorBoxLayerInfo.
2227 *
2228 * @param[in] info Type to output.
2229 *
2230 * @return Formatted string.
2231 */
2232inline std::string to_string(const PriorBoxLayerInfo &info)
2233{
2234 std::stringstream str;
2235 str << "{";
2236 str << "Clip:" << info.clip()
2237 << "Flip:" << info.flip()
2238 << "StepX:" << info.steps()[0]
2239 << "StepY:" << info.steps()[1]
2240 << "MinSizes:" << info.min_sizes().size()
2241 << "MaxSizes:" << info.max_sizes().size()
2242 << "ImgSizeX:" << info.img_size().x
2243 << "ImgSizeY:" << info.img_size().y
2244 << "Offset:" << info.offset()
2245 << "Variances:" << info.variances().size();
2246 str << "}";
2247 return str.str();
2248}
2249
Alex Gildayc357c472018-03-21 13:54:09 +00002250/** Formatted output of the Size2D type.
2251 *
2252 * @param[out] os Output stream
2253 * @param[in] size Type to output
2254 *
2255 * @return Modified output stream.
2256 */
John Richardson25f23682017-11-27 14:35:09 +00002257inline ::std::ostream &operator<<(::std::ostream &os, const Size2D &size)
2258{
2259 os << size.width << "x" << size.height;
2260
2261 return os;
2262}
2263
Alex Gildayc357c472018-03-21 13:54:09 +00002264/** Formatted output of the Size2D type.
2265 *
2266 * @param[in] type Type to output
2267 *
2268 * @return Formatted string.
2269 */
John Richardson25f23682017-11-27 14:35:09 +00002270inline std::string to_string(const Size2D &type)
2271{
2272 std::stringstream str;
2273 str << type;
2274 return str.str();
2275}
2276
Alex Gildayc357c472018-03-21 13:54:09 +00002277/** Formatted output of the ConvolutionMethod type.
2278 *
2279 * @param[out] os Output stream
2280 * @param[in] conv_method Type to output
2281 *
2282 * @return Modified output stream.
2283 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002284inline ::std::ostream &operator<<(::std::ostream &os, const ConvolutionMethod &conv_method)
2285{
2286 switch(conv_method)
2287 {
2288 case ConvolutionMethod::GEMM:
2289 os << "GEMM";
2290 break;
2291 case ConvolutionMethod::DIRECT:
2292 os << "DIRECT";
2293 break;
2294 case ConvolutionMethod::WINOGRAD:
2295 os << "WINOGRAD";
2296 break;
SiCongLid9287352021-11-03 19:01:22 +00002297 case ConvolutionMethod::FFT:
2298 os << "FFT";
2299 break;
2300 case ConvolutionMethod::GEMM_CONV2D:
2301 os << "GEMM_CONV2D";
2302 break;
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002303 default:
2304 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2305 }
2306
2307 return os;
2308}
2309
Alex Gildayc357c472018-03-21 13:54:09 +00002310/** Formatted output of the ConvolutionMethod type.
2311 *
2312 * @param[in] conv_method Type to output
2313 *
2314 * @return Formatted string.
2315 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002316inline std::string to_string(const ConvolutionMethod &conv_method)
2317{
2318 std::stringstream str;
2319 str << conv_method;
2320 return str.str();
2321}
2322
Alex Gildayc357c472018-03-21 13:54:09 +00002323/** Formatted output of the GPUTarget type.
2324 *
2325 * @param[out] os Output stream
2326 * @param[in] gpu_target Type to output
2327 *
2328 * @return Modified output stream.
2329 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002330inline ::std::ostream &operator<<(::std::ostream &os, const GPUTarget &gpu_target)
2331{
2332 switch(gpu_target)
2333 {
2334 case GPUTarget::GPU_ARCH_MASK:
2335 os << "GPU_ARCH_MASK";
2336 break;
Gian Marco Iodice3c4d0852022-07-11 12:09:45 +01002337 case GPUTarget::GPU_GENERATION_MASK:
2338 os << "GPU_GENERATION_MASK";
2339 break;
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002340 case GPUTarget::MIDGARD:
2341 os << "MIDGARD";
2342 break;
2343 case GPUTarget::BIFROST:
2344 os << "BIFROST";
2345 break;
Georgios Pinitasd5462ff2019-07-03 19:33:57 +01002346 case GPUTarget::VALHALL:
2347 os << "VALHALL";
2348 break;
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002349 case GPUTarget::T600:
2350 os << "T600";
2351 break;
2352 case GPUTarget::T700:
2353 os << "T700";
2354 break;
2355 case GPUTarget::T800:
2356 os << "T800";
2357 break;
Michalis Spyroua9676112018-02-22 18:07:43 +00002358 case GPUTarget::G71:
2359 os << "G71";
2360 break;
2361 case GPUTarget::G72:
2362 os << "G72";
2363 break;
2364 case GPUTarget::G51:
2365 os << "G51";
2366 break;
2367 case GPUTarget::G51BIG:
2368 os << "G51BIG";
2369 break;
2370 case GPUTarget::G51LIT:
2371 os << "G51LIT";
2372 break;
Gian Marco Iodice3c4d0852022-07-11 12:09:45 +01002373 case GPUTarget::G31:
2374 os << "G31";
2375 break;
Georgios Pinitasb03f7c52018-07-12 10:49:53 +01002376 case GPUTarget::G76:
2377 os << "G76";
Michalis Spyroua9676112018-02-22 18:07:43 +00002378 break;
Gian Marco Iodice3c4d0852022-07-11 12:09:45 +01002379 case GPUTarget::G52:
2380 os << "G52";
2381 break;
2382 case GPUTarget::G52LIT:
2383 os << "G52LIT";
2384 break;
Georgios Pinitasd5462ff2019-07-03 19:33:57 +01002385 case GPUTarget::G77:
2386 os << "G77";
Michalis Spyroua9676112018-02-22 18:07:43 +00002387 break;
Gian Marco Iodice3c4d0852022-07-11 12:09:45 +01002388 case GPUTarget::G57:
2389 os << "G57";
2390 break;
Georgios Pinitas4ffc42a2020-12-01 16:28:24 +00002391 case GPUTarget::G78:
2392 os << "G78";
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002393 break;
Gian Marco Iodice3c4d0852022-07-11 12:09:45 +01002394 case GPUTarget::G68:
2395 os << "G68";
2396 break;
2397 case GPUTarget::G78AE:
2398 os << "G78AE";
Pablo Marquez Tellob1496e62021-06-25 14:49:37 +01002399 break;
Gian Marco Iodiceab2bc732022-01-19 10:06:45 +00002400 case GPUTarget::G710:
2401 os << "G710";
Georgios Pinitasd5462ff2019-07-03 19:33:57 +01002402 break;
Gian Marco Iodice3c4d0852022-07-11 12:09:45 +01002403 case GPUTarget::G610:
2404 os << "G610";
2405 break;
2406 case GPUTarget::G510:
2407 os << "G510";
2408 break;
2409 case GPUTarget::G310:
2410 os << "G310";
2411 break;
Gunes Bayir4bfc70e2021-12-10 16:17:56 +00002412 case GPUTarget::G715:
2413 os << "G715";
2414 break;
2415 case GPUTarget::G615:
2416 os << "G615";
2417 break;
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002418 default:
2419 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2420 }
2421
2422 return os;
2423}
2424
Alex Gildayc357c472018-03-21 13:54:09 +00002425/** Formatted output of the GPUTarget type.
2426 *
2427 * @param[in] gpu_target Type to output
2428 *
2429 * @return Formatted string.
2430 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002431inline std::string to_string(const GPUTarget &gpu_target)
2432{
2433 std::stringstream str;
2434 str << gpu_target;
2435 return str.str();
2436}
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00002437
John Richardson8de92612018-02-22 14:09:31 +00002438/** Formatted output of the DetectionWindow type.
2439 *
2440 * @param[out] os Output stream
2441 * @param[in] detection_window Type to output
2442 *
2443 * @return Modified output stream.
2444 */
John Richardson684cb0f2018-01-09 11:17:00 +00002445inline ::std::ostream &operator<<(::std::ostream &os, const DetectionWindow &detection_window)
2446{
2447 os << "{x=" << detection_window.x << ","
2448 << "y=" << detection_window.y << ","
2449 << "width=" << detection_window.width << ","
2450 << "height=" << detection_window.height << ","
2451 << "idx_class=" << detection_window.idx_class << ","
2452 << "score=" << detection_window.score << "}";
2453
2454 return os;
2455}
2456
Isabella Gottardi05e56442018-11-16 11:26:52 +00002457/** Formatted output of the DetectionOutputLayerCodeType type.
2458 *
2459 * @param[out] os Output stream
2460 * @param[in] detection_code Type to output
2461 *
2462 * @return Modified output stream.
2463 */
2464inline ::std::ostream &operator<<(::std::ostream &os, const DetectionOutputLayerCodeType &detection_code)
2465{
2466 switch(detection_code)
2467 {
2468 case DetectionOutputLayerCodeType::CENTER_SIZE:
2469 os << "CENTER_SIZE";
2470 break;
2471 case DetectionOutputLayerCodeType::CORNER:
2472 os << "CORNER";
2473 break;
2474 case DetectionOutputLayerCodeType::CORNER_SIZE:
2475 os << "CORNER_SIZE";
2476 break;
2477 case DetectionOutputLayerCodeType::TF_CENTER:
2478 os << "TF_CENTER";
2479 break;
2480 default:
2481 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2482 }
2483
2484 return os;
2485}
2486/** Formatted output of the DetectionOutputLayerCodeType type.
2487 *
2488 * @param[in] detection_code Type to output
2489 *
2490 * @return Formatted string.
2491 */
2492inline std::string to_string(const DetectionOutputLayerCodeType &detection_code)
2493{
2494 std::stringstream str;
2495 str << detection_code;
2496 return str.str();
2497}
2498
2499/** Formatted output of the DetectionOutputLayerInfo type.
2500 *
2501 * @param[out] os Output stream
2502 * @param[in] detection_info Type to output
2503 *
2504 * @return Modified output stream.
2505 */
2506inline ::std::ostream &operator<<(::std::ostream &os, const DetectionOutputLayerInfo &detection_info)
2507{
2508 os << "{Classes=" << detection_info.num_classes() << ","
2509 << "ShareLocation=" << detection_info.share_location() << ","
2510 << "CodeType=" << detection_info.code_type() << ","
2511 << "VarianceEncodedInTarget=" << detection_info.variance_encoded_in_target() << ","
2512 << "KeepTopK=" << detection_info.keep_top_k() << ","
2513 << "NMSThreshold=" << detection_info.nms_threshold() << ","
2514 << "Eta=" << detection_info.eta() << ","
2515 << "BackgroundLabelId=" << detection_info.background_label_id() << ","
2516 << "ConfidenceThreshold=" << detection_info.confidence_threshold() << ","
2517 << "TopK=" << detection_info.top_k() << ","
2518 << "NumLocClasses=" << detection_info.num_loc_classes()
2519 << "}";
2520
2521 return os;
2522}
2523
2524/** Formatted output of the DetectionOutputLayerInfo type.
2525 *
2526 * @param[in] detection_info Type to output
2527 *
2528 * @return Formatted string.
2529 */
2530inline std::string to_string(const DetectionOutputLayerInfo &detection_info)
2531{
2532 std::stringstream str;
2533 str << detection_info;
2534 return str.str();
2535}
Isabella Gottardia7acb3c2019-01-08 13:48:44 +00002536/** Formatted output of the DetectionPostProcessLayerInfo type.
2537 *
2538 * @param[out] os Output stream
2539 * @param[in] detection_info Type to output
2540 *
2541 * @return Modified output stream.
2542 */
2543inline ::std::ostream &operator<<(::std::ostream &os, const DetectionPostProcessLayerInfo &detection_info)
2544{
2545 os << "{MaxDetections=" << detection_info.max_detections() << ","
2546 << "MaxClassesPerDetection=" << detection_info.max_classes_per_detection() << ","
2547 << "NmsScoreThreshold=" << detection_info.nms_score_threshold() << ","
2548 << "NmsIouThreshold=" << detection_info.iou_threshold() << ","
2549 << "NumClasses=" << detection_info.num_classes() << ","
2550 << "ScaleValue_y=" << detection_info.scale_value_y() << ","
2551 << "ScaleValue_x=" << detection_info.scale_value_x() << ","
2552 << "ScaleValue_h=" << detection_info.scale_value_h() << ","
2553 << "ScaleValue_w=" << detection_info.scale_value_w() << ","
2554 << "UseRegularNms=" << detection_info.use_regular_nms() << ","
2555 << "DetectionPerClass=" << detection_info.detection_per_class()
2556 << "}";
2557
2558 return os;
2559}
2560
2561/** Formatted output of the DetectionPostProcessLayerInfo type.
2562 *
2563 * @param[in] detection_info Type to output
2564 *
2565 * @return Formatted string.
2566 */
2567inline std::string to_string(const DetectionPostProcessLayerInfo &detection_info)
2568{
2569 std::stringstream str;
2570 str << detection_info;
2571 return str.str();
2572}
Georgios Pinitasc6f95102021-03-30 10:03:01 +01002573
John Richardson8de92612018-02-22 14:09:31 +00002574/** Formatted output of the DetectionWindow type.
2575 *
2576 * @param[in] detection_window Type to output
2577 *
2578 * @return Formatted string.
2579 */
2580inline std::string to_string(const DetectionWindow &detection_window)
2581{
2582 std::stringstream str;
2583 str << detection_window;
2584 return str.str();
2585}
2586
Michalis Spyrou6c7c38e2018-08-29 16:28:11 +01002587/** Formatted output of @ref PriorBoxLayerInfo.
2588 *
2589 * @param[out] os Output stream.
2590 * @param[in] info Type to output.
2591 *
2592 * @return Modified output stream.
2593 */
2594inline ::std::ostream &operator<<(::std::ostream &os, const PriorBoxLayerInfo &info)
2595{
2596 os << "Clip:" << info.clip()
2597 << "Flip:" << info.flip()
2598 << "StepX:" << info.steps()[0]
2599 << "StepY:" << info.steps()[1]
2600 << "MinSizes:" << info.min_sizes()
2601 << "MaxSizes:" << info.max_sizes()
2602 << "ImgSizeX:" << info.img_size().x
2603 << "ImgSizeY:" << info.img_size().y
2604 << "Offset:" << info.offset()
2605 << "Variances:" << info.variances();
2606
2607 return os;
2608}
2609
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00002610/** Formatted output of the WinogradInfo type. */
2611inline ::std::ostream &operator<<(::std::ostream &os, const WinogradInfo &info)
2612{
2613 os << "{OutputTileSize=" << info.output_tile_size << ","
2614 << "KernelSize=" << info.kernel_size << ","
2615 << "PadStride=" << info.convolution_info << ","
2616 << "OutputDataLayout=" << info.output_data_layout << "}";
2617
2618 return os;
2619}
2620
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00002621inline std::string to_string(const WinogradInfo &type)
2622{
2623 std::stringstream str;
2624 str << type;
2625 return str.str();
2626}
Anthony Barbier671a11e2018-07-06 15:11:36 +01002627
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +01002628/** Convert a CLTunerMode value to a string
2629 *
2630 * @param val CLTunerMode value to be converted
2631 *
2632 * @return String representing the corresponding CLTunerMode.
2633 */
2634inline std::string to_string(const CLTunerMode val)
2635{
2636 switch(val)
2637 {
2638 case CLTunerMode::EXHAUSTIVE:
2639 {
2640 return std::string("Exhaustive");
2641 }
2642 case CLTunerMode::NORMAL:
2643 {
2644 return std::string("Normal");
2645 }
2646 case CLTunerMode::RAPID:
2647 {
2648 return std::string("Rapid");
2649 }
2650 default:
2651 {
2652 ARM_COMPUTE_ERROR("Invalid tuner mode.");
2653 return std::string("UNDEFINED");
2654 }
2655 }
2656}
SiCong Lidb4a6c12021-02-05 09:30:57 +00002657/** Converts a @ref CLGEMMKernelType to string
2658 *
2659 * @param[in] val CLGEMMKernelType value to be converted
2660 *
2661 * @return String representing the corresponding CLGEMMKernelType
2662 */
2663inline std::string to_string(CLGEMMKernelType val)
2664{
2665 switch(val)
2666 {
SiCong Lidb4a6c12021-02-05 09:30:57 +00002667 case CLGEMMKernelType::NATIVE:
2668 {
2669 return "Native";
2670 }
2671 case CLGEMMKernelType::RESHAPED_ONLY_RHS:
2672 {
2673 return "Reshaped_Only_RHS";
2674 }
2675 case CLGEMMKernelType::RESHAPED:
2676 {
2677 return "Reshaped";
2678 }
2679 default:
2680 {
2681 return "Unknown";
2682 }
2683 }
2684}
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +01002685/** [Print CLTunerMode type] **/
2686/** Formatted output of the CLTunerMode type.
2687 *
2688 * @param[out] os Output stream.
2689 * @param[in] val CLTunerMode to output.
2690 *
2691 * @return Modified output stream.
2692 */
2693inline ::std::ostream &operator<<(::std::ostream &os, const CLTunerMode &val)
2694{
2695 os << to_string(val);
2696 return os;
2697}
2698
ramelg013ae3d882021-09-12 23:07:47 +01002699/** Formatted output of the ConvolutionInfo type.
2700 *
2701 * @param[out] os Output stream.
2702 * @param[in] conv_info ConvolutionInfo to output.
2703 *
2704 * @return Modified output stream.
2705 */
2706inline ::std::ostream &operator<<(::std::ostream &os, const ConvolutionInfo &conv_info)
2707{
SiCongLi579ca842021-10-18 09:38:33 +01002708 os << "{PadStrideInfo=" << conv_info.pad_stride_info << ", "
2709 << "depth_multiplier=" << conv_info.depth_multiplier << ", "
2710 << "act_info=" << to_string(conv_info.act_info) << ", "
2711 << "dilation=" << conv_info.dilation << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002712 return os;
2713}
2714
2715/** Converts a @ref ConvolutionInfo to string
2716 *
2717 * @param[in] info ConvolutionInfo value to be converted
2718 *
2719 * @return String representing the corresponding ConvolutionInfo
2720 */
2721inline std::string to_string(const ConvolutionInfo &info)
2722{
2723 std::stringstream str;
2724 str << info;
2725 return str.str();
2726}
2727
2728/** Formatted output of the FullyConnectedLayerInfo type.
2729 *
2730 * @param[out] os Output stream.
2731 * @param[in] layer_info FullyConnectedLayerInfo to output.
2732 *
2733 * @return Modified output stream.
2734 */
2735inline ::std::ostream &operator<<(::std::ostream &os, const FullyConnectedLayerInfo &layer_info)
2736{
SiCongLi579ca842021-10-18 09:38:33 +01002737 os << "{activation_info=" << to_string(layer_info.activation_info) << ", "
2738 << "weights_trained_layout=" << layer_info.weights_trained_layout << ", "
2739 << "transpose_weights=" << layer_info.transpose_weights << ", "
2740 << "are_weights_reshaped=" << layer_info.are_weights_reshaped << ", "
2741 << "retain_internal_weights=" << layer_info.retain_internal_weights << ", "
2742 << "constant_weights=" << layer_info.transpose_weights << ", "
2743 << "fp_mixed_precision=" << layer_info.fp_mixed_precision << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002744 return os;
2745}
2746
2747/** Converts a @ref FullyConnectedLayerInfo to string
2748 *
2749 * @param[in] info FullyConnectedLayerInfo value to be converted
2750 *
2751 * @return String representing the corresponding FullyConnectedLayerInfo
2752 */
2753inline std::string to_string(const FullyConnectedLayerInfo &info)
2754{
2755 std::stringstream str;
2756 str << info;
2757 return str.str();
2758}
2759
2760/** Formatted output of the GEMMLowpOutputStageType type.
2761 *
2762 * @param[out] os Output stream.
2763 * @param[in] gemm_type GEMMLowpOutputStageType to output.
2764 *
2765 * @return Modified output stream.
2766 */
2767inline ::std::ostream &operator<<(::std::ostream &os, const GEMMLowpOutputStageType &gemm_type)
2768{
2769 switch(gemm_type)
2770 {
2771 case GEMMLowpOutputStageType::NONE:
2772 os << "NONE";
2773 break;
2774 case GEMMLowpOutputStageType::QUANTIZE_DOWN:
2775 os << "QUANTIZE_DOWN";
2776 break;
2777 case GEMMLowpOutputStageType::QUANTIZE_DOWN_FIXEDPOINT:
2778 os << "QUANTIZE_DOWN_FIXEDPOINT";
2779 break;
2780 case GEMMLowpOutputStageType::QUANTIZE_DOWN_FLOAT:
2781 os << "QUANTIZE_DOWN_FLOAT";
2782 break;
2783 default:
2784 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2785 }
2786 return os;
2787}
2788
2789/** Converts a @ref GEMMLowpOutputStageType to string
2790 *
2791 * @param[in] gemm_type GEMMLowpOutputStageType value to be converted
2792 *
2793 * @return String representing the corresponding GEMMLowpOutputStageType
2794 */
2795inline std::string to_string(const GEMMLowpOutputStageType &gemm_type)
2796{
2797 std::stringstream str;
2798 str << gemm_type;
2799 return str.str();
2800}
2801
2802/** Formatted output of the GEMMLowpOutputStageInfo type.
2803 *
2804 * @param[out] os Output stream.
2805 * @param[in] gemm_info GEMMLowpOutputStageInfo to output.
2806 *
2807 * @return Modified output stream.
2808 */
2809inline ::std::ostream &operator<<(::std::ostream &os, const GEMMLowpOutputStageInfo &gemm_info)
2810{
SiCongLi579ca842021-10-18 09:38:33 +01002811 os << "{type=" << gemm_info.type << ", "
2812 << "gemlowp_offset=" << gemm_info.gemmlowp_offset << ", "
2813 << "gemmlowp_multiplier=" << gemm_info.gemmlowp_multiplier << ", "
2814 << "gemmlowp_shift=" << gemm_info.gemmlowp_shift << ", "
2815 << "gemmlowp_min_bound=" << gemm_info.gemmlowp_min_bound << ", "
2816 << "gemmlowp_max_bound=" << gemm_info.gemmlowp_max_bound << ", "
2817 << "gemmlowp_multipliers=" << gemm_info.gemmlowp_multiplier << ", "
2818 << "gemmlowp_shifts=" << gemm_info.gemmlowp_shift << ", "
2819 << "gemmlowp_real_multiplier=" << gemm_info.gemmlowp_real_multiplier << ", "
2820 << "is_quantized_per_channel=" << gemm_info.is_quantized_per_channel << ", "
2821 << "output_data_type=" << gemm_info.output_data_type << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002822 return os;
2823}
2824
2825/** Converts a @ref GEMMLowpOutputStageInfo to string
2826 *
2827 * @param[in] gemm_info GEMMLowpOutputStageInfo value to be converted
2828 *
2829 * @return String representing the corresponding GEMMLowpOutputStageInfo
2830 */
2831inline std::string to_string(const GEMMLowpOutputStageInfo &gemm_info)
2832{
2833 std::stringstream str;
2834 str << gemm_info;
2835 return str.str();
2836}
2837
2838/** Formatted output of the Conv2dInfo type.
2839 *
2840 * @param[out] os Output stream.
2841 * @param[in] conv_info Conv2dInfo to output.
2842 *
2843 * @return Modified output stream.
2844 */
2845inline ::std::ostream &operator<<(::std::ostream &os, const Conv2dInfo &conv_info)
2846{
SiCongLi579ca842021-10-18 09:38:33 +01002847 os << "{conv_info=" << conv_info.conv_info << ", "
2848 << "dilation=" << conv_info.dilation << ", "
2849 << "act_info=" << to_string(conv_info.act_info) << ", "
2850 << "enable_fast_math=" << conv_info.enable_fast_math << ", "
2851 << "num_groups=" << conv_info.num_groups << ","
2852 << "post_ops=" << conv_info.post_ops << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002853 return os;
2854}
2855
2856/** Converts a @ref Conv2dInfo to string
2857 *
2858 * @param[in] conv_info Conv2dInfo value to be converted
2859 *
2860 * @return String representing the corresponding Conv2dInfo
2861 */
2862inline std::string to_string(const Conv2dInfo &conv_info)
2863{
2864 std::stringstream str;
2865 str << conv_info;
2866 return str.str();
2867}
2868
2869/** Formatted output of the PixelValue type.
2870 *
2871 * @param[out] os Output stream.
2872 * @param[in] pixel_value PixelValue to output.
2873 *
2874 * @return Modified output stream.
2875 */
2876inline ::std::ostream &operator<<(::std::ostream &os, const PixelValue &pixel_value)
2877{
SiCongLi579ca842021-10-18 09:38:33 +01002878 os << "{value.u64=" << pixel_value.get<uint64_t>() << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002879 return os;
2880}
2881
2882/** Converts a @ref PixelValue to string
2883 *
2884 * @param[in] pixel_value PixelValue value to be converted
2885 *
2886 * @return String representing the corresponding PixelValue
2887 */
2888inline std::string to_string(const PixelValue &pixel_value)
2889{
2890 std::stringstream str;
2891 str << pixel_value;
2892 return str.str();
2893}
2894
2895/** Formatted output of the ScaleKernelInfo type.
2896 *
2897 * @param[out] os Output stream.
2898 * @param[in] scale_info ScaleKernelInfo to output.
2899 *
2900 * @return Modified output stream.
2901 */
2902inline ::std::ostream &operator<<(::std::ostream &os, const ScaleKernelInfo &scale_info)
2903{
SiCongLi579ca842021-10-18 09:38:33 +01002904 os << "{interpolation_policy=" << scale_info.interpolation_policy << ", "
2905 << "BorderMode=" << scale_info.border_mode << ", "
2906 << "PixelValue=" << scale_info.constant_border_value << ", "
2907 << "SamplingPolicy=" << scale_info.sampling_policy << ", "
2908 << "use_padding=" << scale_info.use_padding << ", "
2909 << "align_corners=" << scale_info.align_corners << ", "
2910 << "data_layout=" << scale_info.data_layout << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002911 return os;
2912}
2913
2914/** Converts a @ref ScaleKernelInfo to string
2915 *
2916 * @param[in] scale_info ScaleKernelInfo value to be converted
2917 *
2918 * @return String representing the corresponding ScaleKernelInfo
2919 */
2920inline std::string to_string(const ScaleKernelInfo &scale_info)
2921{
2922 std::stringstream str;
2923 str << scale_info;
2924 return str.str();
2925}
2926
2927/** Formatted output of the FFTDirection type.
2928 *
2929 * @param[out] os Output stream.
2930 * @param[in] fft_dir FFTDirection to output.
2931 *
2932 * @return Modified output stream.
2933 */
2934inline ::std::ostream &operator<<(::std::ostream &os, const FFTDirection &fft_dir)
2935{
2936 switch(fft_dir)
2937 {
2938 case FFTDirection::Forward:
2939 os << "Forward";
2940 break;
2941 case FFTDirection::Inverse:
2942 os << "Inverse";
2943 break;
2944 default:
2945 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2946 }
2947 return os;
2948}
2949
2950/** Converts a @ref FFT1DInfo to string
2951 *
2952 * @param[in] fft_dir FFT1DInfo value to be converted
2953 *
2954 * @return String representing the corresponding FFT1DInfo
2955 */
2956inline std::string to_string(const FFTDirection &fft_dir)
2957{
2958 std::stringstream str;
ramelg01cbbb0382021-09-17 17:36:57 +01002959 str << "{" << fft_dir << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002960 return str.str();
2961}
2962
2963/** Formatted output of the FFT1DInfo type.
2964 *
2965 * @param[out] os Output stream.
2966 * @param[in] fft1d_info FFT1DInfo to output.
2967 *
2968 * @return Modified output stream.
2969 */
2970inline ::std::ostream &operator<<(::std::ostream &os, const FFT1DInfo &fft1d_info)
2971{
SiCongLi579ca842021-10-18 09:38:33 +01002972 os << "{axis=" << fft1d_info.axis << ", "
2973 << "direction=" << fft1d_info.direction << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002974 return os;
2975}
2976
2977/** Converts a @ref FFT1DInfo to string
2978 *
2979 * @param[in] fft1d_info FFT1DInfo value to be converted
2980 *
2981 * @return String representing the corresponding FFT1DInfo
2982 */
2983inline std::string to_string(const FFT1DInfo &fft1d_info)
2984{
2985 std::stringstream str;
2986 str << fft1d_info;
2987 return str.str();
2988}
2989
2990/** Formatted output of the FFT2DInfo type.
2991 *
2992 * @param[out] os Output stream.
2993 * @param[in] fft2d_info FFT2DInfo to output.
2994 *
2995 * @return Modified output stream.
2996 */
2997inline ::std::ostream &operator<<(::std::ostream &os, const FFT2DInfo &fft2d_info)
2998{
SiCongLi579ca842021-10-18 09:38:33 +01002999 os << "{axis=" << fft2d_info.axis0 << ", "
3000 << "axis=" << fft2d_info.axis1 << ", "
3001 << "direction=" << fft2d_info.direction << "}";
ramelg013ae3d882021-09-12 23:07:47 +01003002 return os;
3003}
3004
3005/** Converts a @ref FFT2DInfo to string
3006 *
3007 * @param[in] fft2d_info FFT2DInfo value to be converted
3008 *
3009 * @return String representing the corresponding FFT2DInfo
3010 */
3011inline std::string to_string(const FFT2DInfo &fft2d_info)
3012{
3013 std::stringstream str;
3014 str << fft2d_info;
3015 return str.str();
3016}
3017
3018/** Formatted output of the Coordinates2D type.
3019 *
3020 * @param[out] os Output stream.
3021 * @param[in] coord_2d Coordinates2D to output.
3022 *
3023 * @return Modified output stream.
3024 */
3025inline ::std::ostream &operator<<(::std::ostream &os, const Coordinates2D &coord_2d)
3026{
SiCongLi579ca842021-10-18 09:38:33 +01003027 os << "{x=" << coord_2d.x << ", "
3028 << "y=" << coord_2d.y << "}";
ramelg013ae3d882021-09-12 23:07:47 +01003029 return os;
3030}
3031
3032/** Converts a @ref Coordinates2D to string
3033 *
3034 * @param[in] coord_2d Coordinates2D value to be converted
3035 *
3036 * @return String representing the corresponding Coordinates2D
3037 */
3038inline std::string to_string(const Coordinates2D &coord_2d)
3039{
3040 std::stringstream str;
3041 str << coord_2d;
3042 return str.str();
3043}
3044
3045/** Formatted output of the FuseBatchNormalizationType type.
3046 *
3047 * @param[out] os Output stream.
3048 * @param[in] fuse_type FuseBatchNormalizationType to output.
3049 *
3050 * @return Modified output stream.
3051 */
3052inline ::std::ostream &operator<<(::std::ostream &os, const FuseBatchNormalizationType &fuse_type)
3053{
3054 switch(fuse_type)
3055 {
3056 case FuseBatchNormalizationType::CONVOLUTION:
3057 os << "CONVOLUTION";
3058 break;
3059 case FuseBatchNormalizationType::DEPTHWISECONVOLUTION:
3060 os << "DEPTHWISECONVOLUTION";
3061 break;
3062 default:
3063 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
3064 }
3065 return os;
3066}
3067
3068/** Converts a @ref FuseBatchNormalizationType to string
3069 *
3070 * @param[in] fuse_type FuseBatchNormalizationType value to be converted
3071 *
3072 * @return String representing the corresponding FuseBatchNormalizationType
3073 */
3074inline std::string to_string(const FuseBatchNormalizationType &fuse_type)
3075{
3076 std::stringstream str;
3077 str << fuse_type;
3078 return str.str();
3079}
3080
ramelg01cbbb0382021-09-17 17:36:57 +01003081/** Formatted output of the SoftmaxKernelInfo type.
3082 *
3083 * @param[out] os Output stream.
3084 * @param[in] info SoftmaxKernelInfo to output.
3085 *
3086 * @return Modified output stream.
3087 */
3088inline ::std::ostream &operator<<(::std::ostream &os, const SoftmaxKernelInfo &info)
3089{
SiCongLi579ca842021-10-18 09:38:33 +01003090 os << "{beta=" << info.beta << ", "
3091 << "is_log=" << info.is_log << ", "
3092 << "input_data_type=" << info.input_data_type << ", "
3093 << "axis=" << info.axis << "}";
ramelg01cbbb0382021-09-17 17:36:57 +01003094 return os;
3095}
3096
3097/** Converts a @ref SoftmaxKernelInfo to string
3098 *
3099 * @param[in] info SoftmaxKernelInfo value to be converted
3100 *
3101 * @return String representing the corresponding SoftmaxKernelInfo
3102 */
3103inline std::string to_string(const SoftmaxKernelInfo &info)
3104{
3105 std::stringstream str;
3106 str << info;
3107 return str.str();
3108}
3109
3110/** Formatted output of the ScaleKernelInfo type.
3111 *
3112 * @param[out] os Output stream.
3113 * @param[in] lstm_params LSTMParams to output.
3114 *
3115 * @return Modified output stream.
3116 */
3117template <typename T>
ramelg014a6d9e82021-10-02 14:34:36 +01003118::std::ostream &operator<<(::std::ostream &os, const LSTMParams<T> &lstm_params)
ramelg01cbbb0382021-09-17 17:36:57 +01003119{
ramelg014a6d9e82021-10-02 14:34:36 +01003120 os << "{input_to_input_weights=" << to_string(lstm_params.input_to_input_weights()) << ", "
3121 << "recurrent_to_input_weights=" << to_string(lstm_params.recurrent_to_input_weights()) << ", "
3122 << "cell_to_input_weights=" << to_string(lstm_params.cell_to_input_weights()) << ", "
3123 << "input_gate_bias=" << to_string(lstm_params.input_gate_bias()) << ", "
3124 << "cell_to_forget_weights=" << to_string(lstm_params.cell_to_forget_weights()) << ", "
3125 << "cell_to_output_weights=" << to_string(lstm_params.cell_to_output_weights()) << ", "
3126 << "projection_weights=" << to_string(lstm_params.projection_weights()) << ", "
3127 << "projection_bias=" << to_string(lstm_params.projection_bias()) << ", "
3128 << "input_layer_norm_weights=" << to_string(lstm_params.input_layer_norm_weights()) << ", "
3129 << "forget_layer_norm_weights=" << to_string(lstm_params.forget_layer_norm_weights()) << ", "
3130 << "cell_layer_norm_weights=" << to_string(lstm_params.cell_layer_norm_weights()) << ", "
3131 << "output_layer_norm_weights=" << to_string(lstm_params.output_layer_norm_weights()) << ", "
ramelg01cbbb0382021-09-17 17:36:57 +01003132 << "cell_clip=" << lstm_params.cell_clip() << ", "
3133 << "projection_clip=" << lstm_params.projection_clip() << ", "
3134 << "input_intermediate_scale=" << lstm_params.input_intermediate_scale() << ", "
3135 << "forget_intermediate_scale=" << lstm_params.forget_intermediate_scale() << ", "
3136 << "cell_intermediate_scale=" << lstm_params.cell_intermediate_scale() << ", "
3137 << "hidden_state_zero=" << lstm_params.hidden_state_zero() << ", "
3138 << "hidden_state_scale=" << lstm_params.hidden_state_scale() << ", "
3139 << "has_peephole_opt=" << lstm_params.has_peephole_opt() << ", "
3140 << "has_projection=" << lstm_params.has_projection() << ", "
3141 << "has_cifg_opt=" << lstm_params.has_cifg_opt() << ", "
3142 << "use_layer_norm=" << lstm_params.use_layer_norm() << "}";
3143 return os;
3144}
3145
3146/** Converts a @ref LSTMParams to string
3147 *
3148 * @param[in] lstm_params LSTMParams<T> value to be converted
3149 *
3150 * @return String representing the corresponding LSTMParams
3151 */
3152template <typename T>
ramelg014a6d9e82021-10-02 14:34:36 +01003153std::string to_string(const LSTMParams<T> &lstm_params)
ramelg01cbbb0382021-09-17 17:36:57 +01003154{
3155 std::stringstream str;
3156 str << lstm_params;
3157 return str.str();
3158}
3159
3160/** Converts a @ref LSTMParams to string
3161 *
3162 * @param[in] num uint8_t value to be converted
3163 *
3164 * @return String representing the corresponding uint8_t
3165 */
3166inline std::string to_string(const uint8_t num)
3167{
3168 // Explicity cast the uint8_t to signed integer and call the corresponding overloaded to_string() function.
3169 return ::std::to_string(static_cast<int>(num));
3170}
3171
ramelg014a6d9e82021-10-02 14:34:36 +01003172/** Available non maxima suppression types */
3173/** Formatted output of the NMSType type.
3174 *
3175 * @param[out] os Output stream.
3176 * @param[in] nms_type NMSType to output.
3177 *
3178 * @return Modified output stream.
3179 */
3180inline ::std::ostream &operator<<(::std::ostream &os, const NMSType &nms_type)
3181{
3182 switch(nms_type)
3183 {
3184 case NMSType::LINEAR:
3185 os << "LINEAR";
3186 break;
3187 case NMSType::GAUSSIAN:
3188 os << "GAUSSIAN";
3189 break;
3190 case NMSType::ORIGINAL:
3191 os << "ORIGINAL";
3192 break;
3193 default:
3194 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
3195 }
3196 return os;
3197}
3198
3199/** Converts a @ref NMSType to string
3200 *
3201 * @param[in] nms_type NMSType value to be converted
3202 *
3203 * @return String representing the corresponding NMSType
3204 */
3205inline std::string to_string(const NMSType nms_type)
3206{
3207 std::stringstream str;
3208 str << nms_type;
3209 return str.str();
3210}
3211
3212/** Formatted output of the BoxNMSLimitInfo type.
3213 *
3214 * @param[out] os Output stream.
3215 * @param[in] info BoxNMSLimitInfo to output.
3216 *
3217 * @return Modified output stream.
3218 */
3219inline ::std::ostream &operator<<(::std::ostream &os, const BoxNMSLimitInfo &info)
3220{
SiCongLi579ca842021-10-18 09:38:33 +01003221 os << "{score_thresh=" << info.score_thresh() << ", "
3222 << "nms=" << info.nms() << ", "
3223 << "detections_per_im=" << info.detections_per_im() << ", "
3224 << "soft_nms_enabled=" << info.soft_nms_enabled() << ", "
3225 << "soft_nms_min_score_thres=" << info.soft_nms_min_score_thres() << ", "
3226 << "suppress_size=" << info.suppress_size() << ", "
3227 << "min_size=" << info.min_size() << ", "
3228 << "im_width=" << info.im_width() << ", "
3229 << "im_height=" << info.im_height() << "}";
ramelg014a6d9e82021-10-02 14:34:36 +01003230 return os;
3231}
3232
3233/** Converts a @ref BoxNMSLimitInfo to string
3234 *
3235 * @param[in] info BoxNMSLimitInfo value to be converted
3236 *
3237 * @return String representing the corresponding BoxNMSLimitInfo
3238 */
3239inline std::string to_string(const BoxNMSLimitInfo &info)
3240{
3241 std::stringstream str;
3242 str << info;
3243 return str.str();
3244}
3245
Giorgio Arena945ae9e2021-10-13 11:13:04 +01003246/** Converts a @ref DimensionRoundingType to string
3247 *
3248 * @param[in] rounding_type DimensionRoundingType value to be converted
3249 *
3250 * @return String representing the corresponding DimensionRoundingType
3251 */
3252inline std::string to_string(const DimensionRoundingType &rounding_type)
3253{
3254 std::stringstream str;
3255 str << rounding_type;
3256 return str.str();
3257}
3258
Giorgio Arena945ae9e2021-10-13 11:13:04 +01003259/** Formatted output of the Conv3dInfo type.
3260 *
3261 * @param[out] os Output stream.
3262 * @param[in] conv3d_info Type to output.
3263 *
3264 * @return Modified output stream.
3265 */
3266inline ::std::ostream &operator<<(::std::ostream &os, const Conv3dInfo &conv3d_info)
3267{
3268 os << conv3d_info.stride;
3269 os << ";";
3270 os << conv3d_info.padding;
3271 os << ";";
3272 os << to_string(conv3d_info.act_info);
3273 os << ";";
3274 os << conv3d_info.dilation;
3275 os << ";";
3276 os << conv3d_info.round_type;
3277 os << ";";
3278 os << conv3d_info.enable_fast_math;
3279
3280 return os;
3281}
3282
3283/** Formatted output of the Conv3dInfo type.
3284 *
3285 * @param[in] conv3d_info Type to output.
3286 *
3287 * @return Formatted string.
3288 */
3289inline std::string to_string(const Conv3dInfo &conv3d_info)
3290{
3291 std::stringstream str;
3292 str << conv3d_info;
3293 return str.str();
3294}
3295
Ramy Elgammal91780022022-07-20 14:57:37 +01003296/** Formatted output of the arm_compute::WeightFormat type.
3297 *
3298 * @param[in] wf arm_compute::WeightFormat Type to output.
3299 *
3300 * @return Formatted string.
3301 */
3302inline std::string to_string(const WeightFormat wf)
Francesco Petrogalli553f6952022-06-30 10:22:01 +00003303{
Ramy Elgammal91780022022-07-20 14:57:37 +01003304#define __CASE_WEIGHT_FORMAT(wf) \
3305case WeightFormat::wf: \
3306 return #wf;
3307 switch(wf)
3308 {
3309 __CASE_WEIGHT_FORMAT(UNSPECIFIED)
3310 __CASE_WEIGHT_FORMAT(ANY)
3311 __CASE_WEIGHT_FORMAT(OHWI)
3312 __CASE_WEIGHT_FORMAT(OHWIo2)
3313 __CASE_WEIGHT_FORMAT(OHWIo4)
3314 __CASE_WEIGHT_FORMAT(OHWIo8)
3315 __CASE_WEIGHT_FORMAT(OHWIo16)
3316 __CASE_WEIGHT_FORMAT(OHWIo32)
3317 __CASE_WEIGHT_FORMAT(OHWIo64)
3318 __CASE_WEIGHT_FORMAT(OHWIo128)
3319 __CASE_WEIGHT_FORMAT(OHWIo4i2)
3320 __CASE_WEIGHT_FORMAT(OHWIo4i2_bf16)
3321 __CASE_WEIGHT_FORMAT(OHWIo8i2)
3322 __CASE_WEIGHT_FORMAT(OHWIo8i2_bf16)
3323 __CASE_WEIGHT_FORMAT(OHWIo16i2)
3324 __CASE_WEIGHT_FORMAT(OHWIo16i2_bf16)
3325 __CASE_WEIGHT_FORMAT(OHWIo32i2)
3326 __CASE_WEIGHT_FORMAT(OHWIo32i2_bf16)
3327 __CASE_WEIGHT_FORMAT(OHWIo64i2)
3328 __CASE_WEIGHT_FORMAT(OHWIo64i2_bf16)
3329 __CASE_WEIGHT_FORMAT(OHWIo4i4)
3330 __CASE_WEIGHT_FORMAT(OHWIo4i4_bf16)
3331 __CASE_WEIGHT_FORMAT(OHWIo8i4)
3332 __CASE_WEIGHT_FORMAT(OHWIo8i4_bf16)
3333 __CASE_WEIGHT_FORMAT(OHWIo16i4)
3334 __CASE_WEIGHT_FORMAT(OHWIo16i4_bf16)
3335 __CASE_WEIGHT_FORMAT(OHWIo32i4)
3336 __CASE_WEIGHT_FORMAT(OHWIo32i4_bf16)
3337 __CASE_WEIGHT_FORMAT(OHWIo64i4)
3338 __CASE_WEIGHT_FORMAT(OHWIo64i4_bf16)
3339 __CASE_WEIGHT_FORMAT(OHWIo2i8)
3340 __CASE_WEIGHT_FORMAT(OHWIo4i8)
3341 __CASE_WEIGHT_FORMAT(OHWIo8i8)
3342 __CASE_WEIGHT_FORMAT(OHWIo16i8)
3343 __CASE_WEIGHT_FORMAT(OHWIo32i8)
3344 __CASE_WEIGHT_FORMAT(OHWIo64i8)
3345 default:
3346 return "invalid value";
3347 }
3348#undef __CASE_WEIGHT_FORMAT
Francesco Petrogalli553f6952022-06-30 10:22:01 +00003349}
3350
Ramy Elgammal91780022022-07-20 14:57:37 +01003351/** Formatted output of the arm_compute::WeightFormat type.
3352 *
3353 * @param[out] os Output stream.
3354 * @param[in] wf WeightFormat to output.
3355 *
3356 * @return Modified output stream.
3357 */
3358inline ::std::ostream &operator<<(::std::ostream &os, const arm_compute::WeightFormat &wf)
3359{
3360 os << to_string(wf);
3361 return os;
3362}
3363
3364/** Formatted output of the std::tuple<TensorShape, TensorShape, arm_compute::WeightFormat> tuple.
3365 *
3366 * @param[in] values tuple of input and output tensor shapes and WeightFormat used.
3367 *
3368 * @return Formatted string.
3369 */
3370inline std::string to_string(const std::tuple<TensorShape, TensorShape, arm_compute::WeightFormat> values)
Francesco Petrogalli553f6952022-06-30 10:22:01 +00003371{
3372 std::stringstream str;
3373 str << "[Input shape = " << std::get<0>(values);
3374 str << ", ";
3375 str << "Expected output shape = " << std::get<1>(values);
3376
3377 str << ", ";
3378 str << "WeightFormat = " << std::get<2>(values) << "]";
3379 return str.str();
3380}
3381
Ramy Elgammal73f19af2022-10-23 11:44:49 +01003382/** Formatted output of the Padding2D type.
3383 *
3384 * @param[out] os Output stream.
3385 * @param[in] padding2d Padding info for 2D dimension shape.
3386 *
3387 * @return Modified output stream.
3388 */
3389inline ::std::ostream &operator<<(::std::ostream &os, const Padding2D &padding2d)
3390{
3391 os << padding2d.left << "," << padding2d.right << ","
3392 << padding2d.top << "," << padding2d.bottom;
3393 return os;
3394}
3395
3396/** Converts a @ref Padding2D to string
3397 *
3398 * @param[in] padding2d Padding2D value to be converted
3399 *
3400 * @return String representing the corresponding Padding2D
3401 */
3402inline std::string to_string(const Padding2D &padding2d)
3403{
3404 std::stringstream str;
3405 str << padding2d;
3406 return str.str();
3407}
3408
3409/** Formatted output of the arm_compute::experimental::dynamic_fusion::Conv2dAttributes type.
3410 *
3411 * @param[out] os Output stream.
3412 * @param[in] conv2d_attr arm_compute::experimental::dynamic_fusion::Conv2dAttributes type to output.
3413 *
3414 * @return Modified output stream.
3415 */
3416inline ::std::ostream &operator<<(::std::ostream &os, const experimental::dynamic_fusion::Conv2dAttributes &conv2d_attr)
3417{
3418 os << "Conv2dAttributes="
3419 << "["
3420 << "Padding=" << conv2d_attr.pad() << ", "
3421 << "Size2D=" << conv2d_attr.stride() << ", "
Ramy Elgammal404462a2022-11-08 02:14:46 +00003422 << "Dialation=" << conv2d_attr.dilation() << "]";
Ramy Elgammal73f19af2022-10-23 11:44:49 +01003423
3424 return os;
3425}
3426/** Formatted output of the arm_compute::experimental::dynamic_fusion::Conv2dAttributes type.
3427 *
3428 * @param[in] conv2d_attr arm_compute::experimental::dynamic_fusion::Conv2dAttributes type to output.
3429 *
3430 * @return Formatted string.
3431 */
3432inline std::string to_string(const experimental::dynamic_fusion::Conv2dAttributes &conv2d_attr)
3433{
3434 std::stringstream str;
3435 str << conv2d_attr;
3436 return str.str();
3437}
Gunes Bayir7dc02342022-11-21 21:46:50 +00003438
Gunes Bayir1dc6ff12022-12-06 20:48:31 +00003439/** Formatted output of the arm_compute::experimental::dynamic_fusion::CastAttributes type.
3440 *
3441 * @param[out] os Output stream.
3442 * @param[in] cast_attr arm_compute::experimental::dynamic_fusion::CastAttributes type to output.
3443 *
3444 * @return Modified output stream.
3445 */
3446inline ::std::ostream &operator<<(::std::ostream &os, const experimental::dynamic_fusion::CastAttributes &cast_attr)
3447{
3448 os << "CastAttributes="
3449 << "["
3450 << "Data Type=" << cast_attr.data_type() << ", "
3451 << "Convert Policy=" << cast_attr.convert_policy() << "]";
3452
3453 return os;
3454}
3455/** Formatted output of the arm_compute::experimental::dynamic_fusion::CastAttributes type.
3456 *
3457 * @param[in] cast_attr arm_compute::experimental::dynamic_fusion::CastAttributes type to output.
3458 *
3459 * @return Formatted string.
3460 */
3461inline std::string to_string(const experimental::dynamic_fusion::CastAttributes &cast_attr)
3462{
3463 std::stringstream str;
3464 str << cast_attr;
3465 return str.str();
3466}
3467
Gunes Bayir7dc02342022-11-21 21:46:50 +00003468/** Formatted output of the arm_compute::experimental::dynamic_fusion::DepthwiseConv2dAttributes type.
3469 *
3470 * @param[out] os Output stream.
3471 * @param[in] dw_conv2d_attr arm_compute::experimental::dynamic_fusion::DepthwiseConv2dAttributes type to output.
3472 *
3473 * @return Modified output stream.
3474 */
3475inline ::std::ostream &operator<<(::std::ostream &os, const experimental::dynamic_fusion::DepthwiseConv2dAttributes &dw_conv2d_attr)
3476{
3477 os << "DepthwiseConv2dAttributes="
3478 << "["
3479 << "Padding=" << dw_conv2d_attr.pad() << ", "
3480 << "Size2D=" << dw_conv2d_attr.stride() << ", "
3481 << "Depth Multiplier=" << dw_conv2d_attr.depth_multiplier() << ", "
3482 << "Dilation=" << dw_conv2d_attr.dilation() << ","
3483 << "DimensionRoundingType: " << dw_conv2d_attr.dimension_rounding_type() << "]";
3484
3485 return os;
3486}
3487/** Formatted output of the arm_compute::experimental::dynamic_fusion::DepthwiseConv2dAttributes type.
3488 *
3489 * @param[in] dw_conv2d_attr arm_compute::experimental::dynamic_fusion::DepthwiseConv2dAttributes type to output.
3490 *
3491 * @return Formatted string.
3492 */
3493inline std::string to_string(const experimental::dynamic_fusion::DepthwiseConv2dAttributes &dw_conv2d_attr)
3494{
3495 std::stringstream str;
3496 str << dw_conv2d_attr;
3497 return str.str();
3498}
3499
Jakub Sujak32741722022-11-25 16:43:18 +00003500/** Formatted output of the arm_compute::experimental::dynamic_fusion::ClampAttributes type.
3501 *
3502 * @param[out] os Output stream.
3503 * @param[in] clamp_attr arm_compute::experimental::dynamic_fusion::ClampAttributes type to output.
3504 *
3505 * @return Modified output stream.
3506 */
3507inline ::std::ostream &operator<<(::std::ostream &os, const experimental::dynamic_fusion::ClampAttributes &clamp_attr)
3508{
3509 os << "ClampAttributes="
3510 << "["
3511 << "Min value=" << clamp_attr.min_val() << ", "
3512 << "Max value=" << clamp_attr.max_val() << "]";
3513 return os;
3514}
3515/** Formatted output of the arm_compute::experimental::dynamic_fusion::ClampAttributes type.
3516 *
3517 * @param[in] clamp_attr arm_compute::experimental::dynamic_fusion::ClampAttributes type to output.
3518 *
3519 * @return Formatted string.
3520 */
3521inline std::string to_string(const experimental::dynamic_fusion::ClampAttributes &clamp_attr)
3522{
3523 std::stringstream str;
3524 str << clamp_attr;
3525 return str.str();
3526}
3527
Jakub Sujak8ae57142022-12-02 16:09:06 +00003528/** Formatted output of the arm_compute::experimental::dynamic_fusion::ResizeAttributes type.
3529 *
3530 * @param[out] os Output stream.
3531 * @param[in] resize_attr arm_compute::experimental::dynamic_fusion::ResizeAttributes type to output.
3532 *
3533 * @return Modified output stream.
3534 */
3535inline ::std::ostream &operator<<(::std::ostream &os, const experimental::dynamic_fusion::ResizeAttributes &resize_attr)
3536{
3537 os << "ResizeAttributes="
3538 << "["
3539 << "AlignCorners=" << resize_attr.align_corners() << ", "
3540 << "InterpolationPolicy=" << resize_attr.interpolation_policy() << ", "
3541 << "OutputHeight=" << resize_attr.output_height() << ", "
3542 << "OutputWidth=" << resize_attr.output_width() << ", "
3543 << "SamplingPolicy=" << resize_attr.sampling_policy() << "]";
3544 return os;
3545}
3546
3547/** Formatted output of the arm_compute::experimental::dynamic_fusion::ResizeAttributes type.
3548 *
3549 * @param[in] resize_attr arm_compute::experimental::dynamic_fusion::ResizeAttributes type to output.
3550 *
3551 * @return Formatted string.
3552 */
3553inline std::string to_string(const experimental::dynamic_fusion::ResizeAttributes &resize_attr)
3554{
3555 std::stringstream str;
3556 str << resize_attr;
3557 return str.str();
3558}
3559
Anthony Barbier6ff3b192017-09-04 18:44:23 +01003560} // namespace arm_compute
Anthony Barbier4dbc0a92018-08-27 13:39:47 +01003561
3562#endif /* __ARM_COMPUTE_TYPE_PRINTER_H__ */