blob: 61f0eb9cec532314a63e72ef061c220fc8a85a95 [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001/*
Pablo Marquez Tello6bcdc572023-01-11 09:54:00 +00002 * Copyright (c) 2017-2023 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"
Gunes Bayir1dc6ff12022-12-06 20:48:31 +000041#include "arm_compute/dynamic_fusion/sketch/attributes/CastAttributes.h"
Jakub Sujak32741722022-11-25 16:43:18 +000042#include "arm_compute/dynamic_fusion/sketch/attributes/ClampAttributes.h"
SiCong Li5a63d1e2023-01-06 16:28:57 +000043#include "arm_compute/dynamic_fusion/sketch/attributes/Conv2dAttributes.h"
Gunes Bayir7dc02342022-11-21 21:46:50 +000044#include "arm_compute/dynamic_fusion/sketch/attributes/DepthwiseConv2dAttributes.h"
Mohammed Suhail Munshia18d85c2023-01-03 10:16:16 +000045#include "arm_compute/dynamic_fusion/sketch/attributes/Pool2dAttributes.h"
Jakub Sujak8ae57142022-12-02 16:09:06 +000046#include "arm_compute/dynamic_fusion/sketch/attributes/ResizeAttributes.h"
Gunes Bayiraecb5d92022-12-18 21:31:29 +000047#include "arm_compute/dynamic_fusion/sketch/attributes/SoftmaxAttributes.h"
Mohammed Suhail Munshia18d85c2023-01-03 10:16:16 +000048#include "arm_compute/dynamic_fusion/sketch/gpu/operators/GpuPool2d.h"
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +010049#include "arm_compute/runtime/CL/CLTunerTypes.h"
SiCong Lidb4a6c12021-02-05 09:30:57 +000050#include "arm_compute/runtime/CL/CLTypes.h"
ramelg013ae3d882021-09-12 23:07:47 +010051#include "arm_compute/runtime/FunctionDescriptors.h"
ramelg01cbbb0382021-09-17 17:36:57 +010052#include "arm_compute/runtime/common/LSTMParams.h"
SiCongLi31778612021-11-12 17:33:45 +000053#include "support/Cast.h"
Matthew Bentham758b5ba2020-03-05 23:37:48 +000054#include "support/StringSupport.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010055#include <ostream>
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010056#include <sstream>
57#include <string>
Anthony Barbier6ff3b192017-09-04 18:44:23 +010058
59namespace arm_compute
60{
Anthony Barbierb940fd62018-06-04 14:14:32 +010061/** Formatted output if arg is not null
62 *
63 * @param[in] arg Object to print
64 *
65 * @return String representing arg.
66 */
67template <typename T>
68std::string to_string_if_not_null(T *arg)
69{
70 if(arg == nullptr)
71 {
72 return "nullptr";
73 }
74 else
75 {
76 return to_string(*arg);
77 }
78}
Anthony Barbierb4670212018-05-18 16:55:39 +010079
ramelg014a6d9e82021-10-02 14:34:36 +010080/** Fallback method: try to use std::to_string:
81 *
82 * @param[in] val Value to convert to string
83 *
84 * @return String representing val.
85 */
86template <typename T>
87inline std::string to_string(const T &val)
88{
89 return support::cpp11::to_string(val);
90}
91
ramelg01b1ba1e32021-09-25 11:53:26 +010092/** Formatted output of a vector of objects.
93 *
ramelg014a6d9e82021-10-02 14:34:36 +010094 * @note: Using the overloaded to_string() instead of overloaded operator<<(), because to_string() functions are
95 * overloaded for all types, where two or more of them can use the same operator<<(), ITensor is an example.
96 *
ramelg01b1ba1e32021-09-25 11:53:26 +010097 * @param[out] os Output stream
98 * @param[in] args Vector of objects to print
99 *
100 * @return Modified output stream.
101 */
102template <typename T>
ramelg014a6d9e82021-10-02 14:34:36 +0100103::std::ostream &operator<<(::std::ostream &os, const std::vector<T> &args)
ramelg01b1ba1e32021-09-25 11:53:26 +0100104{
105 const size_t max_print_size = 5U;
106
107 os << "[";
108 bool first = true;
109 size_t i;
110 for(i = 0; i < args.size(); ++i)
111 {
112 if(i == max_print_size)
113 {
114 break;
115 }
116 if(first)
117 {
118 first = false;
119 }
120 else
121 {
122 os << ", ";
123 }
ramelg014a6d9e82021-10-02 14:34:36 +0100124 os << to_string(args[i]);
ramelg01b1ba1e32021-09-25 11:53:26 +0100125 }
126 if(i < args.size())
127 {
128 os << ", ...";
129 }
130 os << "]";
131 return os;
132}
133
ramelg014a6d9e82021-10-02 14:34:36 +0100134/** Formatted output of a vector of objects.
135 *
136 * @param[in] args Vector of objects to print
137 *
138 * @return String representing args.
139 */
140template <typename T>
141std::string to_string(const std::vector<T> &args)
142{
143 std::stringstream str;
144 str << args;
145 return str.str();
146}
147
SiCongLi1af54162021-10-06 15:25:57 +0100148/** @name (EXPERIMENTAL_POST_OPS)
149 * @{
150 */
151/** Formmated output of the @ref experimental::PostOpType type
152 *
153 * @param[out] os Output stream.
154 * @param[in] post_op_type Type to output.
155 *
156 * @return Modified output stream.
157 */
158inline ::std::ostream &operator<<(::std::ostream &os, experimental::PostOpType post_op_type)
159{
160 os << "type=";
161 switch(post_op_type)
162 {
163 case experimental::PostOpType::Activation:
164 {
165 os << "Activation";
166 break;
167 }
168 case experimental::PostOpType::Eltwise_Add:
169 {
170 os << "Eltwise_Add";
171 break;
172 }
ramelg016049eda2021-10-29 10:52:53 +0100173 case experimental::PostOpType::Eltwise_PRelu:
174 {
175 os << "Eltwise_PRelu";
176 break;
177 }
SiCongLi1af54162021-10-06 15:25:57 +0100178 default:
179 {
180 ARM_COMPUTE_ERROR("Unsupported PostOpType");
181 break;
182 }
183 }
184 return os;
185}
186/** Converts a @ref experimental::PostOpType to string
187 *
188 * @param[in] post_op_type PostOpType value to be converted
189 *
190 * @return String representing the corresponding PostOpType
191 */
192inline std::string to_string(experimental::PostOpType post_op_type)
193{
194 std::stringstream str;
195 str << post_op_type;
196 return str.str();
197}
198/** Formatted output of the @ref experimental::IPostOp type.
199 *
200 * @param[out] os Output stream.
201 * @param[in] post_op Type to output.
202 *
203 * @return Modified output stream.
204 */
205template <typename T>
206inline ::std::ostream &operator<<(::std::ostream &os, const experimental::IPostOp<T> &post_op)
207{
208 os << "<";
209 os << post_op.type() << ",";
SiCongLieb8bd812021-10-29 15:05:49 +0100210 os << "prev_dst_pos=" << post_op.prev_dst_pos() << ",";
SiCongLi1af54162021-10-06 15:25:57 +0100211 switch(post_op.type())
212 {
213 case experimental::PostOpType::Activation:
214 {
215 const auto _post_op = utils::cast::polymorphic_downcast<const experimental::PostOpAct<T> *>(&post_op);
216 os << "act_info=" << &(_post_op->_act_info);
217 break;
218 }
219 case experimental::PostOpType::Eltwise_Add:
220 {
221 const auto _post_op = utils::cast::polymorphic_downcast<const experimental::PostOpEltwiseAdd<T> *>(&post_op);
222 os << "convert_policy=" << _post_op->_policy;
223 break;
224 }
ramelg016049eda2021-10-29 10:52:53 +0100225 case experimental::PostOpType::Eltwise_PRelu:
226 {
227 const auto _post_op = utils::cast::polymorphic_downcast<const experimental::PostOpEltwisePRelu<T> *>(&post_op);
228 os << "convert_policy=" << _post_op->_policy;
229 break;
230 }
SiCongLi1af54162021-10-06 15:25:57 +0100231 default:
232 {
233 ARM_COMPUTE_ERROR("Unsupported PostOpType");
234 break;
235 }
236 }
237 os << ">";
238 return os;
239}
240/** Converts an @ref experimental::IPostOp to string
241 *
242 * @param[in] post_op IPostOp value to be converted
243 *
244 * @return String representing the corresponding IPostOp
245 */
246template <typename T>
247inline std::string to_string(const experimental::IPostOp<T> &post_op)
248{
249 std::stringstream str;
250 str << post_op;
251 return str.str();
252}
253/** Formatted output of the @ref experimental::PostOpList type.
254 *
255 * @param[out] os Output stream.
256 * @param[in] post_ops Type to output.
257 *
258 * @return Modified output stream.
259 */
260template <typename T>
261inline ::std::ostream &operator<<(::std::ostream &os, const experimental::PostOpList<T> &post_ops)
262{
263 os << "[";
264 for(const auto &post_op : post_ops.get_list())
265 {
266 os << *post_op << ",";
267 }
268 os << "]";
269 return os;
270}
271/** Converts a @ref experimental::PostOpList to string
272 *
273 * @param[in] post_ops PostOpList value to be converted
274 *
275 * @return String representing the corresponding PostOpList
276 */
277template <typename T>
278inline std::string to_string(const experimental::PostOpList<T> &post_ops)
279{
280 std::stringstream str;
281 str << post_ops;
282 return str.str();
283}
284/** @} */ // end of group (EXPERIMENTAL_POST_OPS)
285
Alex Gildayc357c472018-03-21 13:54:09 +0000286/** Formatted output of the Dimensions type.
287 *
288 * @param[out] os Output stream.
289 * @param[in] dimensions Type to output.
290 *
291 * @return Modified output stream.
292 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100293template <typename T>
294inline ::std::ostream &operator<<(::std::ostream &os, const Dimensions<T> &dimensions)
295{
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100296 if(dimensions.num_dimensions() > 0)
297 {
298 os << dimensions[0];
299
300 for(unsigned int d = 1; d < dimensions.num_dimensions(); ++d)
301 {
Freddie Liardetdd23f2a2021-06-17 13:30:11 +0100302 os << "," << dimensions[d];
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100303 }
304 }
305
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100306 return os;
307}
308
Alex Gildayc357c472018-03-21 13:54:09 +0000309/** Formatted output of the RoundingPolicy type.
310 *
311 * @param[out] os Output stream.
312 * @param[in] rounding_policy Type to output.
313 *
314 * @return Modified output stream.
315 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100316inline ::std::ostream &operator<<(::std::ostream &os, const RoundingPolicy &rounding_policy)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100317{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100318 switch(rounding_policy)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100319 {
Anthony Barbier2a07e182017-08-04 18:20:27 +0100320 case RoundingPolicy::TO_ZERO:
321 os << "TO_ZERO";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100322 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100323 case RoundingPolicy::TO_NEAREST_UP:
324 os << "TO_NEAREST_UP";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100325 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100326 case RoundingPolicy::TO_NEAREST_EVEN:
327 os << "TO_NEAREST_EVEN";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100328 break;
329 default:
330 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
331 }
332
333 return os;
334}
335
Alex Gildayc357c472018-03-21 13:54:09 +0000336/** Formatted output of the WeightsInfo type.
337 *
338 * @param[out] os Output stream.
339 * @param[in] weights_info Type to output.
340 *
341 * @return Modified output stream.
342 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100343inline ::std::ostream &operator<<(::std::ostream &os, const WeightsInfo &weights_info)
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100344{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100345 os << weights_info.are_reshaped() << ";";
346 os << weights_info.num_kernels() << ";" << weights_info.kernel_size().first << "," << weights_info.kernel_size().second;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100347
348 return os;
349}
350
Alex Gildayc357c472018-03-21 13:54:09 +0000351/** Formatted output of the ROIPoolingInfo type.
352 *
353 * @param[out] os Output stream.
354 * @param[in] pool_info Type to output.
355 *
356 * @return Modified output stream.
357 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100358inline ::std::ostream &operator<<(::std::ostream &os, const ROIPoolingLayerInfo &pool_info)
Sanghoon Lee70f82912017-08-24 14:21:24 +0100359{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100360 os << pool_info.pooled_width() << "x" << pool_info.pooled_height() << "~" << pool_info.spatial_scale();
Georgios Pinitasd9769582017-08-03 10:19:40 +0100361 return os;
362}
363
giuros0118870812018-09-13 09:31:40 +0100364/** Formatted output of the ROIPoolingInfo type.
365 *
366 * @param[in] pool_info Type to output.
367 *
368 * @return Formatted string.
369 */
370inline std::string to_string(const ROIPoolingLayerInfo &pool_info)
371{
372 std::stringstream str;
373 str << pool_info;
374 return str.str();
375}
376
morgolockaba2f912020-05-05 16:28:19 +0100377/** Formatted output of the GEMMKernelInfo type.
378 *
379 * @param[out] os Output stream.
380 * @param[in] gemm_info Type to output.
381 *
382 * @return Modified output stream.
383 */
384inline ::std::ostream &operator<<(::std::ostream &os, const GEMMKernelInfo &gemm_info)
385{
SiCongLi579ca842021-10-18 09:38:33 +0100386 os << "( m=" << gemm_info.m;
387 os << " n=" << gemm_info.n;
388 os << " k=" << gemm_info.k;
389 os << " depth_output_gemm3d=" << gemm_info.depth_output_gemm3d;
390 os << " reinterpret_input_as_3d=" << gemm_info.reinterpret_input_as_3d;
391 os << " broadcast_bias=" << gemm_info.broadcast_bias;
392 os << " fp_mixed_precision=" << gemm_info.fp_mixed_precision;
393 os << " mult_transpose1xW_width=" << gemm_info.mult_transpose1xW_width;
394 os << " mult_interleave4x4_height=" << gemm_info.mult_interleave4x4_height;
395 os << " a_offset=" << gemm_info.a_offset;
396 os << " b_offset=" << gemm_info.b_offset;
397 os << "post_ops=" << gemm_info.post_ops;
morgolockaba2f912020-05-05 16:28:19 +0100398 os << ")";
399 return os;
400}
401
402/** Formatted output of the GEMMLHSMatrixInfo type.
403 *
404 * @param[out] os Output stream.
405 * @param[in] gemm_info Type to output.
406 *
407 * @return Modified output stream.
408 */
409inline ::std::ostream &operator<<(::std::ostream &os, const GEMMLHSMatrixInfo &gemm_info)
410{
SiCongLi579ca842021-10-18 09:38:33 +0100411 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 +0100412 return os;
413}
414
415/** Formatted output of the GEMMRHSMatrixInfo type.
416 *
417 * @param[out] os Output stream.
418 * @param[in] gemm_info Type to output.
419 *
420 * @return Modified output stream.
421 */
422inline ::std::ostream &operator<<(::std::ostream &os, const GEMMRHSMatrixInfo &gemm_info)
423{
SiCongLi579ca842021-10-18 09:38:33 +0100424 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 +0000425 gemm_info.export_to_cl_image << "})";
morgolockaba2f912020-05-05 16:28:19 +0100426 return os;
427}
428
429/** Formatted output of the GEMMRHSMatrixInfo type.
430 *
431 * @param[in] gemm_info GEMMRHSMatrixInfo to output.
432 *
433 * @return Formatted string.
434 */
435inline std::string to_string(const GEMMRHSMatrixInfo &gemm_info)
436{
437 std::stringstream str;
438 str << gemm_info;
439 return str.str();
440}
441
442/** Formatted output of the GEMMLHSMatrixInfo type.
443 *
444 * @param[in] gemm_info GEMMLHSMatrixInfo to output.
445 *
446 * @return Formatted string.
447 */
448inline std::string to_string(const GEMMLHSMatrixInfo &gemm_info)
449{
450 std::stringstream str;
451 str << gemm_info;
452 return str.str();
453}
454
455/** Formatted output of the GEMMKernelInfo type.
456 *
457 * @param[in] gemm_info GEMMKernelInfo Type to output.
458 *
459 * @return Formatted string.
460 */
461inline std::string to_string(const GEMMKernelInfo &gemm_info)
462{
463 std::stringstream str;
464 str << gemm_info;
465 return str.str();
466}
467
giuros01c04a0e82018-10-03 12:44:35 +0100468/** Formatted output of the BoundingBoxTransformInfo type.
469 *
470 * @param[out] os Output stream.
471 * @param[in] bbox_info Type to output.
472 *
473 * @return Modified output stream.
474 */
475inline ::std::ostream &operator<<(::std::ostream &os, const BoundingBoxTransformInfo &bbox_info)
476{
477 auto weights = bbox_info.weights();
SiCongLi579ca842021-10-18 09:38:33 +0100478 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 +0100479 "})";
480 return os;
481}
482
Pablo Marquez Tellod208f4f2022-07-19 12:19:46 +0100483#if defined(ARM_COMPUTE_ENABLE_BF16)
Ramy Elgammal91780022022-07-20 14:57:37 +0100484inline ::std::ostream &operator<<(::std::ostream &os, const bfloat16 &v)
Pablo Marquez Tellod208f4f2022-07-19 12:19:46 +0100485{
486 std::stringstream str;
Pablo Marquez Tello6bcdc572023-01-11 09:54:00 +0000487 str << v;
Pablo Marquez Tellod208f4f2022-07-19 12:19:46 +0100488 os << str.str();
489 return os;
490}
Ramy Elgammal91780022022-07-20 14:57:37 +0100491#endif /* defined(ARM_COMPUTE_ENABLE_BF16) */
Pablo Marquez Tellod208f4f2022-07-19 12:19:46 +0100492
giuros01c04a0e82018-10-03 12:44:35 +0100493/** Formatted output of the BoundingBoxTransformInfo type.
494 *
495 * @param[in] bbox_info Type to output.
496 *
497 * @return Formatted string.
498 */
499inline std::string to_string(const BoundingBoxTransformInfo &bbox_info)
500{
501 std::stringstream str;
502 str << bbox_info;
503 return str.str();
504}
505
Manuel Bottini5209be52019-02-13 16:34:56 +0000506/** Formatted output of the ComputeAnchorsInfo type.
507 *
508 * @param[out] os Output stream.
509 * @param[in] anchors_info Type to output.
510 *
511 * @return Modified output stream.
512 */
513inline ::std::ostream &operator<<(::std::ostream &os, const ComputeAnchorsInfo &anchors_info)
514{
515 os << "(" << anchors_info.feat_width() << "x" << anchors_info.feat_height() << ")~" << anchors_info.spatial_scale();
516 return os;
517}
518
519/** Formatted output of the ComputeAnchorsInfo type.
520 *
521 * @param[in] anchors_info Type to output.
522 *
523 * @return Formatted string.
524 */
525inline std::string to_string(const ComputeAnchorsInfo &anchors_info)
526{
527 std::stringstream str;
528 str << anchors_info;
529 return str.str();
530}
531
532/** Formatted output of the GenerateProposalsInfo type.
533 *
534 * @param[out] os Output stream.
535 * @param[in] proposals_info Type to output.
536 *
537 * @return Modified output stream.
538 */
539inline ::std::ostream &operator<<(::std::ostream &os, const GenerateProposalsInfo &proposals_info)
540{
541 os << "(" << proposals_info.im_width() << "x" << proposals_info.im_height() << ")~" << proposals_info.im_scale();
542 return os;
543}
544
545/** Formatted output of the GenerateProposalsInfo type.
546 *
547 * @param[in] proposals_info Type to output.
548 *
549 * @return Formatted string.
550 */
551inline std::string to_string(const GenerateProposalsInfo &proposals_info)
552{
553 std::stringstream str;
554 str << proposals_info;
555 return str.str();
556}
557
Alex Gildayc357c472018-03-21 13:54:09 +0000558/** Formatted output of the QuantizationInfo type.
559 *
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100560 * @param[out] os Output stream.
561 * @param[in] qinfo Type to output.
Alex Gildayc357c472018-03-21 13:54:09 +0000562 *
563 * @return Modified output stream.
564 */
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100565inline ::std::ostream &operator<<(::std::ostream &os, const QuantizationInfo &qinfo)
Chunosovd621bca2017-11-03 17:33:15 +0700566{
Georgios Pinitas3d13af82019-06-04 13:04:16 +0100567 const UniformQuantizationInfo uqinfo = qinfo.uniform();
568 os << "Scale:" << uqinfo.scale << "~";
569 os << "Offset:" << uqinfo.offset;
Chunosovd621bca2017-11-03 17:33:15 +0700570 return os;
571}
572
Alex Gildayc357c472018-03-21 13:54:09 +0000573/** Formatted output of the QuantizationInfo type.
574 *
575 * @param[in] quantization_info Type to output.
576 *
577 * @return Formatted string.
578 */
Chunosovd621bca2017-11-03 17:33:15 +0700579inline std::string to_string(const QuantizationInfo &quantization_info)
580{
581 std::stringstream str;
582 str << quantization_info;
583 return str.str();
584}
585
Alex Gildayc357c472018-03-21 13:54:09 +0000586/** Formatted output of the activation function type.
587 *
588 * @param[out] os Output stream.
589 * @param[in] act_function Type to output.
590 *
591 * @return Modified output stream.
592 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100593inline ::std::ostream &operator<<(::std::ostream &os, const ActivationLayerInfo::ActivationFunction &act_function)
594{
595 switch(act_function)
596 {
597 case ActivationLayerInfo::ActivationFunction::ABS:
598 os << "ABS";
599 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100600 case ActivationLayerInfo::ActivationFunction::LINEAR:
601 os << "LINEAR";
602 break;
603 case ActivationLayerInfo::ActivationFunction::LOGISTIC:
604 os << "LOGISTIC";
605 break;
606 case ActivationLayerInfo::ActivationFunction::RELU:
607 os << "RELU";
608 break;
Georgios Pinitas579c0492017-07-12 16:12:12 +0100609 case ActivationLayerInfo::ActivationFunction::BOUNDED_RELU:
610 os << "BOUNDED_RELU";
611 break;
612 case ActivationLayerInfo::ActivationFunction::LEAKY_RELU:
613 os << "LEAKY_RELU";
614 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100615 case ActivationLayerInfo::ActivationFunction::SOFT_RELU:
616 os << "SOFT_RELU";
617 break;
618 case ActivationLayerInfo::ActivationFunction::SQRT:
619 os << "SQRT";
620 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100621 case ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU:
622 os << "LU_BOUNDED_RELU";
Kevin Petitd9f80712017-12-06 12:18:48 +0000623 break;
Georgios Pinitasfb0fdcd2019-08-22 17:10:04 +0100624 case ActivationLayerInfo::ActivationFunction::ELU:
625 os << "ELU";
626 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100627 case ActivationLayerInfo::ActivationFunction::SQUARE:
628 os << "SQUARE";
629 break;
630 case ActivationLayerInfo::ActivationFunction::TANH:
631 os << "TANH";
632 break;
Usama Arif6a98a6e2019-05-10 17:07:27 +0100633 case ActivationLayerInfo::ActivationFunction::IDENTITY:
634 os << "IDENTITY";
635 break;
morgolock07df3d42020-02-27 11:46:28 +0000636 case ActivationLayerInfo::ActivationFunction::HARD_SWISH:
637 os << "HARD_SWISH";
638 break;
Jonathan Deakind6b8a712022-08-23 11:44:18 +0100639 case ActivationLayerInfo::ActivationFunction::SWISH:
640 os << "SWISH";
641 break;
Murray Kornelsen926f5022022-07-13 21:22:39 -0400642 case ActivationLayerInfo::ActivationFunction::GELU:
643 os << "GELU";
644 break;
morgolock07df3d42020-02-27 11:46:28 +0000645
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100646 default:
647 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
648 }
649
650 return os;
651}
652
Alex Gildayc357c472018-03-21 13:54:09 +0000653/** Formatted output of the activation function info type.
654 *
SiCongLi1af54162021-10-06 15:25:57 +0100655 * @param[in] info ActivationLayerInfo to output.
Alex Gildayc357c472018-03-21 13:54:09 +0000656 *
657 * @return Formatted string.
658 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100659inline std::string to_string(const arm_compute::ActivationLayerInfo &info)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100660{
661 std::stringstream str;
Isabella Gottardi3f217ec2018-02-12 14:59:19 +0000662 if(info.enabled())
663 {
664 str << info.activation();
665 }
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100666 return str.str();
667}
668
SiCongLi1af54162021-10-06 15:25:57 +0100669/** Formatted output of the activation function info.
ramelg013ae3d882021-09-12 23:07:47 +0100670 *
SiCongLi1af54162021-10-06 15:25:57 +0100671 * @param[out] os Output stream.
672 * @param[in] info ActivationLayerInfo to output.
ramelg013ae3d882021-09-12 23:07:47 +0100673 *
674 * @return Formatted string.
675 */
SiCongLi1af54162021-10-06 15:25:57 +0100676inline ::std::ostream &operator<<(::std::ostream &os, const ActivationLayerInfo *info)
ramelg013ae3d882021-09-12 23:07:47 +0100677{
ramelg013ae3d882021-09-12 23:07:47 +0100678 if(info != nullptr)
679 {
ramelg013ae3d882021-09-12 23:07:47 +0100680 if(info->enabled())
681 {
SiCongLi1af54162021-10-06 15:25:57 +0100682 os << info->activation();
683 os << "(";
684 os << "VAL_A=" << info->a() << ",";
685 os << "VAL_B=" << info->b();
686 os << ")";
ramelg013ae3d882021-09-12 23:07:47 +0100687 }
SiCongLi1af54162021-10-06 15:25:57 +0100688 else
689 {
690 os << "disabled";
691 }
ramelg013ae3d882021-09-12 23:07:47 +0100692 }
SiCongLi1af54162021-10-06 15:25:57 +0100693 else
694 {
695 os << "nullptr";
696 }
697 return os;
ramelg013ae3d882021-09-12 23:07:47 +0100698}
699
Alex Gildayc357c472018-03-21 13:54:09 +0000700/** Formatted output of the activation function type.
701 *
702 * @param[in] function Type to output.
703 *
704 * @return Formatted string.
705 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100706inline std::string to_string(const arm_compute::ActivationLayerInfo::ActivationFunction &function)
707{
708 std::stringstream str;
709 str << function;
710 return str.str();
711}
712
Alex Gildayc357c472018-03-21 13:54:09 +0000713/** Formatted output of the NormType type.
714 *
715 * @param[out] os Output stream.
716 * @param[in] norm_type Type to output.
717 *
718 * @return Modified output stream.
719 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100720inline ::std::ostream &operator<<(::std::ostream &os, const NormType &norm_type)
721{
722 switch(norm_type)
723 {
724 case NormType::CROSS_MAP:
725 os << "CROSS_MAP";
726 break;
727 case NormType::IN_MAP_1D:
728 os << "IN_MAP_1D";
729 break;
730 case NormType::IN_MAP_2D:
731 os << "IN_MAP_2D";
732 break;
733 default:
734 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
735 }
736
737 return os;
738}
739
Alex Gildayc357c472018-03-21 13:54:09 +0000740/** Formatted output of @ref NormalizationLayerInfo.
741 *
742 * @param[in] info Type to output.
743 *
744 * @return Formatted string.
745 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100746inline std::string to_string(const arm_compute::NormalizationLayerInfo &info)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100747{
748 std::stringstream str;
Michalis Spyroud466c2d2018-01-30 10:54:39 +0000749 str << info.type() << ":NormSize=" << info.norm_size();
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100750 return str.str();
751}
752
Alex Gildayc357c472018-03-21 13:54:09 +0000753/** Formatted output of @ref NormalizationLayerInfo.
754 *
755 * @param[out] os Output stream.
756 * @param[in] info Type to output.
757 *
758 * @return Modified output stream.
759 */
Georgios Pinitas6f669f02017-09-26 12:32:57 +0100760inline ::std::ostream &operator<<(::std::ostream &os, const NormalizationLayerInfo &info)
761{
Michalis Spyroud466c2d2018-01-30 10:54:39 +0000762 os << info.type() << ":NormSize=" << info.norm_size();
Georgios Pinitas6f669f02017-09-26 12:32:57 +0100763 return os;
764}
765
Alex Gildayc357c472018-03-21 13:54:09 +0000766/** Formatted output of the PoolingType type.
767 *
768 * @param[out] os Output stream.
769 * @param[in] pool_type Type to output.
770 *
771 * @return Modified output stream.
772 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100773inline ::std::ostream &operator<<(::std::ostream &os, const PoolingType &pool_type)
774{
775 switch(pool_type)
776 {
777 case PoolingType::AVG:
778 os << "AVG";
779 break;
780 case PoolingType::MAX:
781 os << "MAX";
782 break;
Georgios Pinitascdf51452017-08-31 14:21:36 +0100783 case PoolingType::L2:
784 os << "L2";
785 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100786 default:
787 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
788 }
789
790 return os;
791}
792
Alex Gildayc357c472018-03-21 13:54:09 +0000793/** Formatted output of @ref PoolingLayerInfo.
794 *
795 * @param[out] os Output stream.
796 * @param[in] info Type to output.
797 *
798 * @return Modified output stream.
799 */
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100800inline ::std::ostream &operator<<(::std::ostream &os, const PoolingLayerInfo &info)
801{
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +0000802 os << info.pool_type;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100803
804 return os;
805}
806
Alex Gildayc357c472018-03-21 13:54:09 +0000807/** Formatted output of @ref RoundingPolicy.
808 *
809 * @param[in] rounding_policy Type to output.
810 *
811 * @return Formatted string.
812 */
John Richardsondd715f22017-09-18 16:10:48 +0100813inline std::string to_string(const RoundingPolicy &rounding_policy)
814{
815 std::stringstream str;
816 str << rounding_policy;
817 return str.str();
818}
819
Vidhya Sudhan Loganathand646ae12018-11-19 15:18:20 +0000820/** [Print DataLayout type] **/
Alex Gildayc357c472018-03-21 13:54:09 +0000821/** Formatted output of the DataLayout type.
822 *
823 * @param[out] os Output stream.
824 * @param[in] data_layout Type to output.
825 *
826 * @return Modified output stream.
827 */
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000828inline ::std::ostream &operator<<(::std::ostream &os, const DataLayout &data_layout)
829{
830 switch(data_layout)
831 {
832 case DataLayout::UNKNOWN:
833 os << "UNKNOWN";
834 break;
835 case DataLayout::NHWC:
836 os << "NHWC";
837 break;
838 case DataLayout::NCHW:
839 os << "NCHW";
840 break;
Adnan AlSinane4563a02021-09-01 15:32:03 +0100841 case DataLayout::NDHWC:
842 os << "NDHWC";
843 break;
Giorgio Arenac9fe9fc2021-10-06 12:54:29 +0100844 case DataLayout::NCDHW:
845 os << "NCDHW";
846 break;
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000847 default:
848 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
849 }
850
851 return os;
852}
853
Alex Gildayc357c472018-03-21 13:54:09 +0000854/** Formatted output of the DataLayout type.
855 *
856 * @param[in] data_layout Type to output.
857 *
858 * @return Formatted string.
859 */
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000860inline std::string to_string(const arm_compute::DataLayout &data_layout)
861{
862 std::stringstream str;
863 str << data_layout;
864 return str.str();
865}
Vidhya Sudhan Loganathand646ae12018-11-19 15:18:20 +0000866/** [Print DataLayout type] **/
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000867
Georgios Pinitase2220552018-07-20 13:23:44 +0100868/** Formatted output of the DataLayoutDimension type.
869 *
870 * @param[out] os Output stream.
871 * @param[in] data_layout_dim Data layout dimension to print.
872 *
873 * @return Modified output stream.
874 */
875inline ::std::ostream &operator<<(::std::ostream &os, const DataLayoutDimension &data_layout_dim)
876{
877 switch(data_layout_dim)
878 {
879 case DataLayoutDimension::WIDTH:
880 os << "WIDTH";
881 break;
882 case DataLayoutDimension::HEIGHT:
883 os << "HEIGHT";
884 break;
885 case DataLayoutDimension::CHANNEL:
886 os << "CHANNEL";
887 break;
Giorgio Arenac9fe9fc2021-10-06 12:54:29 +0100888 case DataLayoutDimension::DEPTH:
889 os << "DEPTH";
890 break;
Georgios Pinitase2220552018-07-20 13:23:44 +0100891 case DataLayoutDimension::BATCHES:
892 os << "BATCHES";
893 break;
894 default:
895 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
896 }
897 return os;
898}
899
Alex Gildayc357c472018-03-21 13:54:09 +0000900/** Formatted output of the DataType type.
901 *
902 * @param[out] os Output stream.
903 * @param[in] data_type Type to output.
904 *
905 * @return Modified output stream.
906 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100907inline ::std::ostream &operator<<(::std::ostream &os, const DataType &data_type)
908{
909 switch(data_type)
910 {
911 case DataType::UNKNOWN:
912 os << "UNKNOWN";
913 break;
914 case DataType::U8:
915 os << "U8";
916 break;
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100917 case DataType::QSYMM8:
918 os << "QSYMM8";
919 break;
Chunosovd621bca2017-11-03 17:33:15 +0700920 case DataType::QASYMM8:
921 os << "QASYMM8";
922 break;
Georgios Pinitas448a81f2019-11-21 14:10:25 +0000923 case DataType::QASYMM8_SIGNED:
924 os << "QASYMM8_SIGNED";
925 break;
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100926 case DataType::QSYMM8_PER_CHANNEL:
927 os << "QSYMM8_PER_CHANNEL";
928 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100929 case DataType::S8:
930 os << "S8";
931 break;
932 case DataType::U16:
933 os << "U16";
934 break;
935 case DataType::S16:
936 os << "S16";
937 break;
Manuel Bottini3689fcd2019-06-14 17:18:12 +0100938 case DataType::QSYMM16:
939 os << "QSYMM16";
940 break;
Michele Di Giorgio35ea9a72019-08-23 12:02:06 +0100941 case DataType::QASYMM16:
942 os << "QASYMM16";
943 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100944 case DataType::U32:
945 os << "U32";
946 break;
947 case DataType::S32:
948 os << "S32";
949 break;
950 case DataType::U64:
951 os << "U64";
952 break;
953 case DataType::S64:
954 os << "S64";
955 break;
Georgios Pinitase8291ac2020-02-26 09:58:13 +0000956 case DataType::BFLOAT16:
957 os << "BFLOAT16";
958 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100959 case DataType::F16:
960 os << "F16";
961 break;
962 case DataType::F32:
963 os << "F32";
964 break;
965 case DataType::F64:
966 os << "F64";
967 break;
968 case DataType::SIZET:
969 os << "SIZET";
970 break;
971 default:
972 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
973 }
974
975 return os;
976}
977
Alex Gildayc357c472018-03-21 13:54:09 +0000978/** Formatted output of the DataType type.
979 *
980 * @param[in] data_type Type to output.
981 *
982 * @return Formatted string.
983 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100984inline std::string to_string(const arm_compute::DataType &data_type)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100985{
986 std::stringstream str;
987 str << data_type;
988 return str.str();
989}
990
Alex Gildayc357c472018-03-21 13:54:09 +0000991/** Formatted output of the Format type.
992 *
993 * @param[out] os Output stream.
994 * @param[in] format Type to output.
995 *
996 * @return Modified output stream.
997 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100998inline ::std::ostream &operator<<(::std::ostream &os, const Format &format)
999{
1000 switch(format)
1001 {
1002 case Format::UNKNOWN:
1003 os << "UNKNOWN";
1004 break;
1005 case Format::U8:
1006 os << "U8";
1007 break;
1008 case Format::S16:
1009 os << "S16";
1010 break;
1011 case Format::U16:
1012 os << "U16";
1013 break;
1014 case Format::S32:
1015 os << "S32";
1016 break;
1017 case Format::U32:
1018 os << "U32";
1019 break;
1020 case Format::F16:
1021 os << "F16";
1022 break;
1023 case Format::F32:
1024 os << "F32";
1025 break;
1026 case Format::UV88:
1027 os << "UV88";
1028 break;
1029 case Format::RGB888:
1030 os << "RGB888";
1031 break;
1032 case Format::RGBA8888:
1033 os << "RGBA8888";
1034 break;
1035 case Format::YUV444:
1036 os << "YUV444";
1037 break;
1038 case Format::YUYV422:
1039 os << "YUYV422";
1040 break;
1041 case Format::NV12:
1042 os << "NV12";
1043 break;
1044 case Format::NV21:
1045 os << "NV21";
1046 break;
1047 case Format::IYUV:
1048 os << "IYUV";
1049 break;
1050 case Format::UYVY422:
1051 os << "UYVY422";
1052 break;
1053 default:
1054 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1055 }
1056
1057 return os;
1058}
1059
Alex Gildayc357c472018-03-21 13:54:09 +00001060/** Formatted output of the Format type.
1061 *
1062 * @param[in] format Type to output.
1063 *
1064 * @return Formatted string.
1065 */
Moritz Pflanzer7655a672017-09-23 11:57:33 +01001066inline std::string to_string(const Format &format)
1067{
1068 std::stringstream str;
1069 str << format;
1070 return str.str();
1071}
1072
Alex Gildayc357c472018-03-21 13:54:09 +00001073/** Formatted output of the Channel type.
1074 *
1075 * @param[out] os Output stream.
1076 * @param[in] channel Type to output.
1077 *
1078 * @return Modified output stream.
1079 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001080inline ::std::ostream &operator<<(::std::ostream &os, const Channel &channel)
1081{
1082 switch(channel)
1083 {
1084 case Channel::UNKNOWN:
1085 os << "UNKNOWN";
1086 break;
1087 case Channel::C0:
1088 os << "C0";
1089 break;
1090 case Channel::C1:
1091 os << "C1";
1092 break;
1093 case Channel::C2:
1094 os << "C2";
1095 break;
1096 case Channel::C3:
1097 os << "C3";
1098 break;
1099 case Channel::R:
1100 os << "R";
1101 break;
1102 case Channel::G:
1103 os << "G";
1104 break;
1105 case Channel::B:
1106 os << "B";
1107 break;
1108 case Channel::A:
1109 os << "A";
1110 break;
1111 case Channel::Y:
1112 os << "Y";
1113 break;
1114 case Channel::U:
1115 os << "U";
1116 break;
1117 case Channel::V:
1118 os << "V";
1119 break;
1120 default:
1121 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1122 }
1123
1124 return os;
1125}
1126
Alex Gildayc357c472018-03-21 13:54:09 +00001127/** Formatted output of the Channel type.
1128 *
1129 * @param[in] channel Type to output.
1130 *
1131 * @return Formatted string.
1132 */
Ioan-Cristian Szabo9414f642017-10-27 17:35:40 +01001133inline std::string to_string(const Channel &channel)
1134{
1135 std::stringstream str;
1136 str << channel;
1137 return str.str();
1138}
1139
Alex Gildayc357c472018-03-21 13:54:09 +00001140/** Formatted output of the BorderMode type.
1141 *
1142 * @param[out] os Output stream.
1143 * @param[in] mode Type to output.
1144 *
1145 * @return Modified output stream.
1146 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001147inline ::std::ostream &operator<<(::std::ostream &os, const BorderMode &mode)
1148{
1149 switch(mode)
1150 {
1151 case BorderMode::UNDEFINED:
1152 os << "UNDEFINED";
1153 break;
1154 case BorderMode::CONSTANT:
1155 os << "CONSTANT";
1156 break;
1157 case BorderMode::REPLICATE:
1158 os << "REPLICATE";
1159 break;
1160 default:
1161 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1162 }
1163
1164 return os;
1165}
1166
Alex Gildayc357c472018-03-21 13:54:09 +00001167/** Formatted output of the BorderSize type.
1168 *
1169 * @param[out] os Output stream.
1170 * @param[in] border Type to output.
1171 *
1172 * @return Modified output stream.
1173 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001174inline ::std::ostream &operator<<(::std::ostream &os, const BorderSize &border)
1175{
Moritz Pflanzerc87fbf82017-07-18 14:02:10 +01001176 os << border.top << ","
1177 << border.right << ","
1178 << border.bottom << ","
1179 << border.left;
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001180
1181 return os;
1182}
Anthony Barbier2a07e182017-08-04 18:20:27 +01001183
Giuseppe Rossinid7647d42018-07-17 18:13:13 +01001184/** Formatted output of the PaddingList type.
1185 *
1186 * @param[out] os Output stream.
1187 * @param[in] padding Type to output.
1188 *
1189 * @return Modified output stream.
1190 */
1191inline ::std::ostream &operator<<(::std::ostream &os, const PaddingList &padding)
1192{
1193 os << "{";
1194 for(auto const &p : padding)
1195 {
1196 os << "{" << p.first << "," << p.second << "}";
1197 }
1198 os << "}";
1199 return os;
1200}
1201
giuros013175fcf2018-11-21 09:59:17 +00001202/** Formatted output of the Multiples type.
1203 *
1204 * @param[out] os Output stream.
1205 * @param[in] multiples Type to output.
1206 *
1207 * @return Modified output stream.
1208 */
1209inline ::std::ostream &operator<<(::std::ostream &os, const Multiples &multiples)
1210{
1211 os << "(";
1212 for(size_t i = 0; i < multiples.size() - 1; i++)
1213 {
1214 os << multiples[i] << ", ";
1215 }
1216 os << multiples.back() << ")";
1217 return os;
1218}
1219
Alex Gildayc357c472018-03-21 13:54:09 +00001220/** Formatted output of the InterpolationPolicy type.
1221 *
1222 * @param[out] os Output stream.
1223 * @param[in] policy Type to output.
1224 *
1225 * @return Modified output stream.
1226 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001227inline ::std::ostream &operator<<(::std::ostream &os, const InterpolationPolicy &policy)
1228{
1229 switch(policy)
1230 {
1231 case InterpolationPolicy::NEAREST_NEIGHBOR:
1232 os << "NEAREST_NEIGHBOR";
1233 break;
1234 case InterpolationPolicy::BILINEAR:
1235 os << "BILINEAR";
1236 break;
1237 case InterpolationPolicy::AREA:
1238 os << "AREA";
1239 break;
1240 default:
1241 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1242 }
1243
1244 return os;
1245}
1246
Alex Gildayc357c472018-03-21 13:54:09 +00001247/** Formatted output of the SamplingPolicy type.
1248 *
1249 * @param[out] os Output stream.
1250 * @param[in] policy Type to output.
1251 *
1252 * @return Modified output stream.
1253 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +07001254inline ::std::ostream &operator<<(::std::ostream &os, const SamplingPolicy &policy)
1255{
1256 switch(policy)
1257 {
1258 case SamplingPolicy::CENTER:
1259 os << "CENTER";
1260 break;
1261 case SamplingPolicy::TOP_LEFT:
1262 os << "TOP_LEFT";
1263 break;
1264 default:
1265 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1266 }
1267
1268 return os;
1269}
1270
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001271/** Formatted output of the ITensorInfo type.
1272 *
1273 * @param[out] os Output stream.
1274 * @param[in] info Tensor information.
1275 *
1276 * @return Modified output stream.
1277 */
1278inline ::std::ostream &operator<<(std::ostream &os, const ITensorInfo *info)
1279{
Georgios Pinitasc6f95102021-03-30 10:03:01 +01001280 const DataType data_type = info->data_type();
1281 const DataLayout data_layout = info->data_layout();
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001282
1283 os << "Shape=" << info->tensor_shape() << ","
1284 << "DataLayout=" << string_from_data_layout(data_layout) << ","
ramelg014a6d9e82021-10-02 14:34:36 +01001285 << "DataType=" << string_from_data_type(data_type);
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001286
1287 if(is_data_type_quantized(data_type))
1288 {
ramelg01b1ba1e32021-09-25 11:53:26 +01001289 const QuantizationInfo qinfo = info->quantization_info();
1290 const auto scales = qinfo.scale();
1291 const auto offsets = qinfo.offset();
1292
ramelg014a6d9e82021-10-02 14:34:36 +01001293 os << ", QuantizationInfo={"
ramelg01b1ba1e32021-09-25 11:53:26 +01001294 << "scales.size=" << scales.size()
1295 << ", scale(s)=" << scales << ", ";
1296
1297 os << "offsets.size=" << offsets.size()
1298 << ", offset(s)=" << offsets << "}";
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001299 }
1300 return os;
1301}
1302
ramelg013ae3d882021-09-12 23:07:47 +01001303/** Formatted output of the const TensorInfo& type.
Alex Gildayc357c472018-03-21 13:54:09 +00001304 *
Anthony Barbier366628a2018-08-01 13:55:03 +01001305 * @param[out] os Output stream.
1306 * @param[in] info Type to output.
1307 *
1308 * @return Modified output stream.
1309 */
1310inline ::std::ostream &operator<<(::std::ostream &os, const TensorInfo &info)
1311{
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001312 os << &info;
Georgios Pinitasc6f95102021-03-30 10:03:01 +01001313 return os;
Anthony Barbier366628a2018-08-01 13:55:03 +01001314}
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001315
ramelg013ae3d882021-09-12 23:07:47 +01001316/** Formatted output of the const TensorInfo& type.
Anthony Barbier366628a2018-08-01 13:55:03 +01001317 *
Alex Gildayc357c472018-03-21 13:54:09 +00001318 * @param[in] info Type to output.
1319 *
1320 * @return Formatted string.
1321 */
Georgios Pinitas3faea252017-10-30 14:13:50 +00001322inline std::string to_string(const TensorInfo &info)
1323{
1324 std::stringstream str;
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001325 str << &info;
Georgios Pinitas3faea252017-10-30 14:13:50 +00001326 return str.str();
1327}
1328
ramelg013ae3d882021-09-12 23:07:47 +01001329/** Formatted output of the const ITensorInfo& type.
1330 *
1331 * @param[in] info Type to output.
1332 *
1333 * @return Formatted string.
1334 */
1335inline std::string to_string(const ITensorInfo &info)
1336{
1337 std::stringstream str;
1338 str << &info;
1339 return str.str();
1340}
1341
ramelg013ae3d882021-09-12 23:07:47 +01001342/** Formatted output of the const ITensorInfo* type.
1343 *
1344 * @param[in] info Type to output.
1345 *
1346 * @return Formatted string.
1347 */
Ramy Elgammale920d6a2021-08-19 22:10:30 +01001348inline std::string to_string(const ITensorInfo *info)
1349{
ramelg013ae3d882021-09-12 23:07:47 +01001350 std::string ret_str = "nullptr";
1351 if(info != nullptr)
1352 {
1353 std::stringstream str;
1354 str << info;
1355 ret_str = str.str();
1356 }
1357 return ret_str;
1358}
1359
ramelg01cbbb0382021-09-17 17:36:57 +01001360/** Formatted output of the ITensorInfo* type.
1361 *
1362 * @param[in] info Type to output.
1363 *
1364 * @return Formatted string.
1365 */
1366inline std::string to_string(ITensorInfo *info)
1367{
1368 return to_string(static_cast<const ITensorInfo *>(info));
1369}
1370
1371/** Formatted output of the ITensorInfo type obtained from const ITensor* type.
ramelg013ae3d882021-09-12 23:07:47 +01001372 *
1373 * @param[in] tensor Type to output.
1374 *
1375 * @return Formatted string.
1376 */
1377inline std::string to_string(const ITensor *tensor)
1378{
1379 std::string ret_str = "nullptr";
1380 if(tensor != nullptr)
1381 {
1382 std::stringstream str;
ramelg01cbbb0382021-09-17 17:36:57 +01001383 str << "ITensor->info(): " << tensor->info();
ramelg013ae3d882021-09-12 23:07:47 +01001384 ret_str = str.str();
1385 }
1386 return ret_str;
1387}
1388
ramelg01cbbb0382021-09-17 17:36:57 +01001389/** Formatted output of the ITensorInfo type obtained from the ITensor* type.
ramelg013ae3d882021-09-12 23:07:47 +01001390 *
1391 * @param[in] tensor Type to output.
1392 *
1393 * @return Formatted string.
1394 */
1395inline std::string to_string(ITensor *tensor)
1396{
ramelg01cbbb0382021-09-17 17:36:57 +01001397 return to_string(static_cast<const ITensor *>(tensor));
ramelg013ae3d882021-09-12 23:07:47 +01001398}
1399
ramelg01cbbb0382021-09-17 17:36:57 +01001400/** Formatted output of the ITensorInfo type obtained from the ITensor& type.
ramelg013ae3d882021-09-12 23:07:47 +01001401 *
1402 * @param[in] tensor Type to output.
1403 *
1404 * @return Formatted string.
1405 */
1406inline std::string to_string(ITensor &tensor)
1407{
Ramy Elgammale920d6a2021-08-19 22:10:30 +01001408 std::stringstream str;
ramelg01cbbb0382021-09-17 17:36:57 +01001409 str << "ITensor.info(): " << tensor.info();
Ramy Elgammale920d6a2021-08-19 22:10:30 +01001410 return str.str();
1411}
1412
ramelg01cbbb0382021-09-17 17:36:57 +01001413#ifdef ARM_COMPUTE_OPENCL_ENABLED
1414/** Formatted output of the ITensorInfo type obtained from the const ICLTensor& type.
1415 *
1416 * @param[in] cl_tensor Type to output.
1417 *
1418 * @return Formatted string.
1419 */
1420inline std::string to_string(const ICLTensor *cl_tensor)
1421{
1422 std::string ret_str = "nullptr";
1423 if(cl_tensor != nullptr)
1424 {
1425 std::stringstream str;
1426 str << "ICLTensor->info(): " << cl_tensor->info();
1427 ret_str = str.str();
1428 }
1429 return ret_str;
1430}
1431
1432/** Formatted output of the ITensorInfo type obtained from the ICLTensor& type.
1433 *
1434 * @param[in] cl_tensor Type to output.
1435 *
1436 * @return Formatted string.
1437 */
1438inline std::string to_string(ICLTensor *cl_tensor)
1439{
1440 return to_string(static_cast<const ICLTensor *>(cl_tensor));
1441}
1442#endif /* ARM_COMPUTE_OPENCL_ENABLED */
1443
Alex Gildayc357c472018-03-21 13:54:09 +00001444/** Formatted output of the Dimensions type.
1445 *
1446 * @param[in] dimensions Type to output.
1447 *
1448 * @return Formatted string.
1449 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001450template <typename T>
1451inline std::string to_string(const Dimensions<T> &dimensions)
1452{
1453 std::stringstream str;
1454 str << dimensions;
1455 return str.str();
1456}
1457
Alex Gildayc357c472018-03-21 13:54:09 +00001458/** Formatted output of the Strides type.
1459 *
1460 * @param[in] stride Type to output.
1461 *
1462 * @return Formatted string.
1463 */
John Richardsona36eae12017-09-26 16:55:59 +01001464inline std::string to_string(const Strides &stride)
1465{
1466 std::stringstream str;
1467 str << stride;
1468 return str.str();
1469}
1470
Alex Gildayc357c472018-03-21 13:54:09 +00001471/** Formatted output of the TensorShape type.
1472 *
1473 * @param[in] shape Type to output.
1474 *
1475 * @return Formatted string.
1476 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001477inline std::string to_string(const TensorShape &shape)
1478{
1479 std::stringstream str;
1480 str << shape;
1481 return str.str();
1482}
1483
Alex Gildayc357c472018-03-21 13:54:09 +00001484/** Formatted output of the Coordinates type.
1485 *
1486 * @param[in] coord Type to output.
1487 *
1488 * @return Formatted string.
1489 */
Abe Mbise925ca0f2017-10-02 19:16:33 +01001490inline std::string to_string(const Coordinates &coord)
1491{
1492 std::stringstream str;
1493 str << coord;
1494 return str.str();
1495}
1496
Anthony Barbierb940fd62018-06-04 14:14:32 +01001497/** Formatted output of the GEMMReshapeInfo type.
1498 *
1499 * @param[out] os Output stream.
1500 * @param[in] info Type to output.
1501 *
1502 * @return Modified output stream.
1503 */
1504inline ::std::ostream &operator<<(::std::ostream &os, const GEMMReshapeInfo &info)
1505{
1506 os << "{m=" << info.m() << ",";
1507 os << "n=" << info.n() << ",";
1508 os << "k=" << info.k() << ",";
1509 os << "mult_transpose1xW_width=" << info.mult_transpose1xW_width() << ",";
1510 os << "mult_interleave4x4_height=" << info.mult_interleave4x4_height();
1511 os << "}";
1512
1513 return os;
1514}
1515
1516/** Formatted output of the GEMMInfo type.
1517 *
1518 * @param[out] os Output stream.
1519 * @param[in] info Type to output.
1520 *
1521 * @return Modified output stream.
1522 */
1523inline ::std::ostream &operator<<(::std::ostream &os, const GEMMInfo &info)
1524{
1525 os << "{is_a_reshaped=" << info.is_a_reshaped() << ",";
1526 os << "is_b_reshaped=" << info.is_b_reshaped() << ",";
1527 os << "reshape_b_only_on_first_run=" << info.reshape_b_only_on_first_run() << ",";
Anthony Barbierb4670212018-05-18 16:55:39 +01001528 os << "depth_output_gemm3d=" << info.depth_output_gemm3d() << ",";
1529 os << "reinterpret_input_as_3d=" << info.reinterpret_input_as_3d() << ",";
1530 os << "retain_internal_weights=" << info.retain_internal_weights() << ",";
1531 os << "fp_mixed_precision=" << info.fp_mixed_precision() << ",";
1532 os << "broadcast_bias=" << info.broadcast_bias() << ",";
ramelg01cbbb0382021-09-17 17:36:57 +01001533 os << "pretranspose_B=" << info.pretranspose_B() << ",";
SiCongLi579ca842021-10-18 09:38:33 +01001534 os << "post_ops=" << info.post_ops() << "}";
Anthony Barbierb940fd62018-06-04 14:14:32 +01001535
1536 return os;
1537}
1538
1539/** Formatted output of the Window::Dimension type.
1540 *
1541 * @param[out] os Output stream.
1542 * @param[in] dim Type to output.
1543 *
1544 * @return Modified output stream.
1545 */
1546inline ::std::ostream &operator<<(::std::ostream &os, const Window::Dimension &dim)
1547{
1548 os << "{start=" << dim.start() << ", end=" << dim.end() << ", step=" << dim.step() << "}";
1549
1550 return os;
1551}
1552/** Formatted output of the Window type.
1553 *
1554 * @param[out] os Output stream.
1555 * @param[in] win Type to output.
1556 *
1557 * @return Modified output stream.
1558 */
1559inline ::std::ostream &operator<<(::std::ostream &os, const Window &win)
1560{
1561 os << "{";
1562 for(unsigned int i = 0; i < Coordinates::num_max_dimensions; i++)
1563 {
1564 if(i > 0)
1565 {
1566 os << ", ";
1567 }
1568 os << win[i];
1569 }
1570 os << "}";
1571
1572 return os;
1573}
1574
1575/** Formatted output of the WeightsInfo type.
1576 *
1577 * @param[in] info Type to output.
1578 *
1579 * @return Formatted string.
1580 */
1581inline std::string to_string(const WeightsInfo &info)
1582{
1583 std::stringstream str;
1584 str << info;
1585 return str.str();
1586}
1587
1588/** Formatted output of the GEMMReshapeInfo type.
1589 *
1590 * @param[in] info Type to output.
1591 *
1592 * @return Formatted string.
1593 */
1594inline std::string to_string(const GEMMReshapeInfo &info)
1595{
1596 std::stringstream str;
1597 str << info;
1598 return str.str();
1599}
1600
1601/** Formatted output of the GEMMInfo type.
1602 *
1603 * @param[in] info Type to output.
1604 *
1605 * @return Formatted string.
1606 */
1607inline std::string to_string(const GEMMInfo &info)
1608{
1609 std::stringstream str;
1610 str << info;
1611 return str.str();
1612}
1613
1614/** Formatted output of the Window::Dimension type.
1615 *
1616 * @param[in] dim Type to output.
1617 *
1618 * @return Formatted string.
1619 */
1620inline std::string to_string(const Window::Dimension &dim)
1621{
1622 std::stringstream str;
1623 str << dim;
1624 return str.str();
1625}
ramelg01cbbb0382021-09-17 17:36:57 +01001626/** Formatted output of the Window& type.
Anthony Barbierb940fd62018-06-04 14:14:32 +01001627 *
1628 * @param[in] win Type to output.
1629 *
1630 * @return Formatted string.
1631 */
1632inline std::string to_string(const Window &win)
1633{
1634 std::stringstream str;
1635 str << win;
1636 return str.str();
1637}
1638
ramelg01cbbb0382021-09-17 17:36:57 +01001639/** Formatted output of the Window* type.
1640 *
1641 * @param[in] win Type to output.
1642 *
1643 * @return Formatted string.
1644 */
1645inline std::string to_string(Window *win)
1646{
1647 std::string ret_str = "nullptr";
1648 if(win != nullptr)
1649 {
1650 std::stringstream str;
1651 str << *win;
1652 ret_str = str.str();
1653 }
1654 return ret_str;
1655}
1656
Alex Gildayc357c472018-03-21 13:54:09 +00001657/** Formatted output of the Rectangle type.
1658 *
1659 * @param[out] os Output stream.
1660 * @param[in] rect Type to output.
1661 *
1662 * @return Modified output stream.
1663 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001664inline ::std::ostream &operator<<(::std::ostream &os, const Rectangle &rect)
1665{
1666 os << rect.width << "x" << rect.height;
1667 os << "+" << rect.x << "+" << rect.y;
1668
1669 return os;
1670}
1671
Usama Arif8cf8c112019-03-14 15:36:54 +00001672/** Formatted output of the PaddingMode type.
1673 *
1674 * @param[out] os Output stream.
1675 * @param[in] mode Type to output.
1676 *
1677 * @return Modified output stream.
1678 */
1679inline ::std::ostream &operator<<(::std::ostream &os, const PaddingMode &mode)
1680{
1681 switch(mode)
1682 {
1683 case PaddingMode::CONSTANT:
1684 os << "CONSTANT";
1685 break;
1686 case PaddingMode::REFLECT:
1687 os << "REFLECT";
1688 break;
1689 case PaddingMode::SYMMETRIC:
1690 os << "SYMMETRIC";
1691 break;
1692 default:
1693 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1694 }
1695
1696 return os;
1697}
1698
1699/** Formatted output of the PaddingMode type.
1700 *
1701 * @param[in] mode Type to output.
1702 *
1703 * @return Formatted string.
1704 */
1705inline std::string to_string(const PaddingMode &mode)
1706{
1707 std::stringstream str;
1708 str << mode;
1709 return str.str();
1710}
1711
Alex Gildayc357c472018-03-21 13:54:09 +00001712/** Formatted output of the PadStrideInfo type.
1713 *
1714 * @param[out] os Output stream.
1715 * @param[in] pad_stride_info Type to output.
1716 *
1717 * @return Modified output stream.
1718 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001719inline ::std::ostream &operator<<(::std::ostream &os, const PadStrideInfo &pad_stride_info)
1720{
1721 os << pad_stride_info.stride().first << "," << pad_stride_info.stride().second;
1722 os << ";";
Jaroslaw Rzepeckia1ed41f2017-10-13 11:13:58 +01001723 os << pad_stride_info.pad_left() << "," << pad_stride_info.pad_right() << ","
1724 << pad_stride_info.pad_top() << "," << pad_stride_info.pad_bottom();
Anthony Barbier2a07e182017-08-04 18:20:27 +01001725
1726 return os;
1727}
1728
Alex Gildayc357c472018-03-21 13:54:09 +00001729/** Formatted output of the PadStrideInfo type.
1730 *
1731 * @param[in] pad_stride_info Type to output.
1732 *
1733 * @return Formatted string.
1734 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001735inline std::string to_string(const PadStrideInfo &pad_stride_info)
1736{
1737 std::stringstream str;
1738 str << pad_stride_info;
1739 return str.str();
1740}
1741
Alex Gildayc357c472018-03-21 13:54:09 +00001742/** Formatted output of the BorderMode type.
1743 *
1744 * @param[in] mode Type to output.
1745 *
1746 * @return Formatted string.
1747 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001748inline std::string to_string(const BorderMode &mode)
1749{
1750 std::stringstream str;
1751 str << mode;
1752 return str.str();
1753}
1754
Alex Gildayc357c472018-03-21 13:54:09 +00001755/** Formatted output of the BorderSize type.
1756 *
1757 * @param[in] border Type to output.
1758 *
1759 * @return Formatted string.
1760 */
John Richardsonb482ce12017-09-18 12:44:01 +01001761inline std::string to_string(const BorderSize &border)
1762{
1763 std::stringstream str;
1764 str << border;
1765 return str.str();
1766}
1767
Giuseppe Rossinid7647d42018-07-17 18:13:13 +01001768/** Formatted output of the PaddingList type.
1769 *
1770 * @param[in] padding Type to output.
1771 *
1772 * @return Formatted string.
1773 */
1774inline std::string to_string(const PaddingList &padding)
1775{
1776 std::stringstream str;
1777 str << padding;
1778 return str.str();
1779}
1780
giuros013175fcf2018-11-21 09:59:17 +00001781/** Formatted output of the Multiples type.
1782 *
1783 * @param[in] multiples Type to output.
1784 *
1785 * @return Formatted string.
1786 */
1787inline std::string to_string(const Multiples &multiples)
1788{
1789 std::stringstream str;
1790 str << multiples;
1791 return str.str();
1792}
1793
Alex Gildayc357c472018-03-21 13:54:09 +00001794/** Formatted output of the InterpolationPolicy type.
1795 *
1796 * @param[in] policy Type to output.
1797 *
1798 * @return Formatted string.
1799 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001800inline std::string to_string(const InterpolationPolicy &policy)
1801{
1802 std::stringstream str;
1803 str << policy;
1804 return str.str();
1805}
1806
Alex Gildayc357c472018-03-21 13:54:09 +00001807/** Formatted output of the SamplingPolicy type.
1808 *
1809 * @param[in] policy Type to output.
1810 *
1811 * @return Formatted string.
1812 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +07001813inline std::string to_string(const SamplingPolicy &policy)
1814{
1815 std::stringstream str;
1816 str << policy;
1817 return str.str();
1818}
1819
Alex Gildayc357c472018-03-21 13:54:09 +00001820/** Formatted output of the ConvertPolicy type.
1821 *
1822 * @param[out] os Output stream.
1823 * @param[in] policy Type to output.
1824 *
1825 * @return Modified output stream.
1826 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001827inline ::std::ostream &operator<<(::std::ostream &os, const ConvertPolicy &policy)
1828{
1829 switch(policy)
1830 {
1831 case ConvertPolicy::WRAP:
1832 os << "WRAP";
1833 break;
1834 case ConvertPolicy::SATURATE:
1835 os << "SATURATE";
1836 break;
1837 default:
1838 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1839 }
1840
1841 return os;
1842}
1843
1844inline std::string to_string(const ConvertPolicy &policy)
1845{
1846 std::stringstream str;
1847 str << policy;
1848 return str.str();
1849}
1850
giuros01164a2722018-11-20 18:34:46 +00001851/** Formatted output of the ArithmeticOperation type.
1852 *
1853 * @param[out] os Output stream.
1854 * @param[in] op Operation to output.
1855 *
1856 * @return Modified output stream.
1857 */
1858inline ::std::ostream &operator<<(::std::ostream &os, const ArithmeticOperation &op)
1859{
1860 switch(op)
1861 {
1862 case ArithmeticOperation::ADD:
1863 os << "ADD";
1864 break;
1865 case ArithmeticOperation::SUB:
1866 os << "SUB";
1867 break;
1868 case ArithmeticOperation::DIV:
1869 os << "DIV";
1870 break;
1871 case ArithmeticOperation::MAX:
1872 os << "MAX";
1873 break;
1874 case ArithmeticOperation::MIN:
1875 os << "MIN";
1876 break;
1877 case ArithmeticOperation::SQUARED_DIFF:
1878 os << "SQUARED_DIFF";
1879 break;
Usama Arif52c54f62019-05-14 10:22:36 +01001880 case ArithmeticOperation::POWER:
1881 os << "POWER";
1882 break;
Ramy Elgammal404462a2022-11-08 02:14:46 +00001883 case ArithmeticOperation::PRELU:
1884 os << "PRELU";
1885 break;
giuros01164a2722018-11-20 18:34:46 +00001886 default:
1887 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1888 }
1889
1890 return os;
1891}
1892
1893/** Formatted output of the Arithmetic Operation
1894 *
1895 * @param[in] op Type to output.
1896 *
1897 * @return Formatted string.
1898 */
1899inline std::string to_string(const ArithmeticOperation &op)
1900{
1901 std::stringstream str;
1902 str << op;
1903 return str.str();
1904}
1905
Alex Gildayc357c472018-03-21 13:54:09 +00001906/** Formatted output of the Reduction Operations.
1907 *
1908 * @param[out] os Output stream.
1909 * @param[in] op Type to output.
1910 *
1911 * @return Modified output stream.
1912 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001913inline ::std::ostream &operator<<(::std::ostream &os, const ReductionOperation &op)
1914{
1915 switch(op)
1916 {
Michalis Spyrou7e9391b2018-10-05 14:49:28 +01001917 case ReductionOperation::SUM:
1918 os << "SUM";
1919 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +01001920 case ReductionOperation::SUM_SQUARE:
1921 os << "SUM_SQUARE";
1922 break;
Michalis Spyrou7e9391b2018-10-05 14:49:28 +01001923 case ReductionOperation::MEAN_SUM:
1924 os << "MEAN_SUM";
1925 break;
Michalis Spyrou7930db42018-11-22 17:36:28 +00001926 case ReductionOperation::ARG_IDX_MAX:
1927 os << "ARG_IDX_MAX";
1928 break;
1929 case ReductionOperation::ARG_IDX_MIN:
1930 os << "ARG_IDX_MIN";
1931 break;
Manuel Bottinib412fab2018-12-10 17:40:23 +00001932 case ReductionOperation::PROD:
1933 os << "PROD";
1934 break;
Usama Arifa4a08ad2019-05-20 12:38:33 +01001935 case ReductionOperation::MIN:
1936 os << "MIN";
1937 break;
Usama Arif28f0dd92019-05-20 13:44:34 +01001938 case ReductionOperation::MAX:
1939 os << "MAX";
1940 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +01001941 default:
1942 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1943 }
1944
1945 return os;
1946}
1947
Alex Gildayc357c472018-03-21 13:54:09 +00001948/** Formatted output of the Reduction Operations.
1949 *
1950 * @param[in] op Type to output.
1951 *
1952 * @return Formatted string.
1953 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001954inline std::string to_string(const ReductionOperation &op)
1955{
1956 std::stringstream str;
1957 str << op;
1958 return str.str();
1959}
1960
Georgios Pinitas7900a9e2018-11-23 11:44:58 +00001961/** Formatted output of the Comparison Operations.
1962 *
1963 * @param[out] os Output stream.
1964 * @param[in] op Type to output.
1965 *
1966 * @return Modified output stream.
1967 */
1968inline ::std::ostream &operator<<(::std::ostream &os, const ComparisonOperation &op)
1969{
1970 switch(op)
1971 {
1972 case ComparisonOperation::Equal:
1973 os << "Equal";
1974 break;
1975 case ComparisonOperation::NotEqual:
1976 os << "NotEqual";
1977 break;
1978 case ComparisonOperation::Greater:
1979 os << "Greater";
1980 break;
1981 case ComparisonOperation::GreaterEqual:
1982 os << "GreaterEqual";
1983 break;
1984 case ComparisonOperation::Less:
1985 os << "Less";
1986 break;
1987 case ComparisonOperation::LessEqual:
1988 os << "LessEqual";
1989 break;
1990 default:
1991 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1992 }
1993
1994 return os;
1995}
1996
Michalis Spyroue9362622018-11-23 17:41:37 +00001997/** Formatted output of the Elementwise unary Operations.
1998 *
1999 * @param[out] os Output stream.
2000 * @param[in] op Type to output.
2001 *
2002 * @return Modified output stream.
2003 */
2004inline ::std::ostream &operator<<(::std::ostream &os, const ElementWiseUnary &op)
2005{
2006 switch(op)
2007 {
2008 case ElementWiseUnary::RSQRT:
2009 os << "RSQRT";
2010 break;
2011 case ElementWiseUnary::EXP:
2012 os << "EXP";
2013 break;
Usama Arifeb312ef2019-05-13 17:45:54 +01002014 case ElementWiseUnary::NEG:
2015 os << "NEG";
2016 break;
Usama Arifac33d7e2019-05-20 14:21:40 +01002017 case ElementWiseUnary::LOG:
2018 os << "LOG";
2019 break;
ramelg01b1ba1e32021-09-25 11:53:26 +01002020 case ElementWiseUnary::SIN:
2021 os << "SIN";
2022 break;
2023 case ElementWiseUnary::ABS:
2024 os << "ABS";
2025 break;
Usama Arif6a4d5422019-05-24 14:53:59 +01002026 case ElementWiseUnary::ROUND:
2027 os << "ROUND";
2028 break;
ramelg01b1ba1e32021-09-25 11:53:26 +01002029 case ElementWiseUnary::LOGICAL_NOT:
2030 os << "LOGICAL_NOT";
2031 break;
Michalis Spyroue9362622018-11-23 17:41:37 +00002032 default:
2033 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2034 }
2035
2036 return os;
2037}
2038
Georgios Pinitas7900a9e2018-11-23 11:44:58 +00002039/** Formatted output of the Comparison Operations.
2040 *
2041 * @param[in] op Type to output.
2042 *
2043 * @return Formatted string.
2044 */
2045inline std::string to_string(const ComparisonOperation &op)
2046{
2047 std::stringstream str;
2048 str << op;
2049 return str.str();
2050}
2051
Michalis Spyroue9362622018-11-23 17:41:37 +00002052/** Formatted output of the Elementwise unary Operations.
2053 *
2054 * @param[in] op Type to output.
2055 *
2056 * @return Formatted string.
2057 */
2058inline std::string to_string(const ElementWiseUnary &op)
2059{
2060 std::stringstream str;
2061 str << op;
2062 return str.str();
2063}
2064
Alex Gildayc357c472018-03-21 13:54:09 +00002065/** Formatted output of the Norm Type.
2066 *
2067 * @param[in] type Type to output.
2068 *
2069 * @return Formatted string.
2070 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01002071inline std::string to_string(const NormType &type)
2072{
2073 std::stringstream str;
2074 str << type;
2075 return str.str();
2076}
2077
Alex Gildayc357c472018-03-21 13:54:09 +00002078/** Formatted output of the Pooling Type.
2079 *
2080 * @param[in] type Type to output.
2081 *
2082 * @return Formatted string.
2083 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01002084inline std::string to_string(const PoolingType &type)
2085{
2086 std::stringstream str;
2087 str << type;
2088 return str.str();
2089}
2090
Alex Gildayc357c472018-03-21 13:54:09 +00002091/** Formatted output of the Pooling Layer Info.
2092 *
2093 * @param[in] info Type to output.
2094 *
2095 * @return Formatted string.
2096 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01002097inline std::string to_string(const PoolingLayerInfo &info)
2098{
2099 std::stringstream str;
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +00002100 str << "{Type=" << info.pool_type << ","
Sang-Hoon Park11fedda2020-01-15 14:44:04 +00002101 << "DataLayout=" << info.data_layout << ","
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +00002102 << "IsGlobalPooling=" << info.is_global_pooling;
2103 if(!info.is_global_pooling)
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00002104 {
2105 str << ","
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +00002106 << "PoolSize=" << info.pool_size.width << "," << info.pool_size.height << ","
2107 << "PadStride=" << info.pad_stride_info;
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00002108 }
2109 str << "}";
Anthony Barbier2a07e182017-08-04 18:20:27 +01002110 return str.str();
2111}
2112
ramelg0137515692022-02-26 22:06:20 +00002113/** Formatted output of the Size3D type.
2114 *
2115 * @param[out] os Output stream
2116 * @param[in] size Type to output
2117 *
2118 * @return Modified output stream.
2119 */
2120inline ::std::ostream &operator<<(::std::ostream &os, const Size3D &size)
2121{
2122 os << size.width << "x" << size.height << "x" << size.depth;
2123
2124 return os;
2125}
2126
2127/** Formatted output of the Size3D type.
2128 *
2129 * @param[in] type Type to output
2130 *
2131 * @return Formatted string.
2132 */
2133inline std::string to_string(const Size3D &type)
2134{
2135 std::stringstream str;
2136 str << type;
2137 return str.str();
2138}
2139
2140/** Formatted output of the Padding3D type.
2141 *
2142 * @param[out] os Output stream.
2143 * @param[in] padding3d Padding info for 3D spatial dimension shape.
2144 *
2145 * @return Modified output stream.
2146 */
2147inline ::std::ostream &operator<<(::std::ostream &os, const Padding3D &padding3d)
2148{
2149 os << padding3d.left << "," << padding3d.right << ","
2150 << padding3d.top << "," << padding3d.bottom << ","
2151 << padding3d.front << "," << padding3d.back;
2152 return os;
2153}
2154
2155/** Converts a @ref Padding3D to string
2156 *
2157 * @param[in] padding3d Padding3D value to be converted
2158 *
2159 * @return String representing the corresponding Padding3D
2160 */
2161inline std::string to_string(const Padding3D &padding3d)
2162{
2163 std::stringstream str;
2164 str << padding3d;
2165 return str.str();
2166}
2167
2168/** Formatted output of the DimensionRoundingType type.
2169 *
2170 * @param[out] os Output stream.
2171 * @param[in] rounding_type DimensionRoundingType Dimension rounding type when down-scaling, or compute output shape of pooling(2D or 3D).
2172 *
2173 * @return Modified output stream.
2174 */
2175inline ::std::ostream &operator<<(::std::ostream &os, const DimensionRoundingType &rounding_type)
2176{
2177 switch(rounding_type)
2178 {
2179 case DimensionRoundingType::CEIL:
2180 os << "CEIL";
2181 break;
2182 case DimensionRoundingType::FLOOR:
2183 os << "FLOOR";
2184 break;
2185 default:
2186 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2187 }
2188 return os;
2189}
2190
2191/** Formatted output of the Pooling 3d Layer Info.
2192 *
2193 * @param[out] os Output stream.
2194 * @param[in] info Pooling 3D layer info to print to output stream.
2195 *
2196 * @return Modified output stream.
2197 */
2198inline ::std::ostream &operator<<(::std::ostream &os, const Pooling3dLayerInfo &info)
2199{
2200 os << "{Type=" << info.pool_type << ","
2201 << "IsGlobalPooling=" << info.is_global_pooling;
2202 if(!info.is_global_pooling)
2203 {
2204 os << ","
2205 << "PoolSize=" << info.pool_size << ", "
2206 << "Stride=" << info.stride << ", "
2207 << "Padding=" << info.padding << ", "
2208 << "Exclude Padding=" << info.exclude_padding << ", "
2209 << "fp_mixed_precision=" << info.fp_mixed_precision << ", "
2210 << "DimensionRoundingType=" << info.round_type;
2211 }
2212 os << "}";
2213 return os;
2214}
2215
2216/** Formatted output of the Pooling 3d Layer Info.
2217 *
2218 * @param[in] info Type to output.
2219 *
2220 * @return Formatted string.
2221 */
2222inline std::string to_string(const Pooling3dLayerInfo &info)
2223{
2224 std::stringstream str;
2225 str << info;
2226 return str.str();
2227}
2228
Michalis Spyrou6c7c38e2018-08-29 16:28:11 +01002229/** Formatted output of the PriorBoxLayerInfo.
2230 *
2231 * @param[in] info Type to output.
2232 *
2233 * @return Formatted string.
2234 */
2235inline std::string to_string(const PriorBoxLayerInfo &info)
2236{
2237 std::stringstream str;
2238 str << "{";
2239 str << "Clip:" << info.clip()
2240 << "Flip:" << info.flip()
2241 << "StepX:" << info.steps()[0]
2242 << "StepY:" << info.steps()[1]
2243 << "MinSizes:" << info.min_sizes().size()
2244 << "MaxSizes:" << info.max_sizes().size()
2245 << "ImgSizeX:" << info.img_size().x
2246 << "ImgSizeY:" << info.img_size().y
2247 << "Offset:" << info.offset()
2248 << "Variances:" << info.variances().size();
2249 str << "}";
2250 return str.str();
2251}
2252
Alex Gildayc357c472018-03-21 13:54:09 +00002253/** Formatted output of the Size2D type.
2254 *
2255 * @param[out] os Output stream
2256 * @param[in] size Type to output
2257 *
2258 * @return Modified output stream.
2259 */
John Richardson25f23682017-11-27 14:35:09 +00002260inline ::std::ostream &operator<<(::std::ostream &os, const Size2D &size)
2261{
2262 os << size.width << "x" << size.height;
2263
2264 return os;
2265}
2266
Alex Gildayc357c472018-03-21 13:54:09 +00002267/** Formatted output of the Size2D type.
2268 *
2269 * @param[in] type Type to output
2270 *
2271 * @return Formatted string.
2272 */
John Richardson25f23682017-11-27 14:35:09 +00002273inline std::string to_string(const Size2D &type)
2274{
2275 std::stringstream str;
2276 str << type;
2277 return str.str();
2278}
2279
Alex Gildayc357c472018-03-21 13:54:09 +00002280/** Formatted output of the ConvolutionMethod type.
2281 *
2282 * @param[out] os Output stream
2283 * @param[in] conv_method Type to output
2284 *
2285 * @return Modified output stream.
2286 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002287inline ::std::ostream &operator<<(::std::ostream &os, const ConvolutionMethod &conv_method)
2288{
2289 switch(conv_method)
2290 {
2291 case ConvolutionMethod::GEMM:
2292 os << "GEMM";
2293 break;
2294 case ConvolutionMethod::DIRECT:
2295 os << "DIRECT";
2296 break;
2297 case ConvolutionMethod::WINOGRAD:
2298 os << "WINOGRAD";
2299 break;
SiCongLid9287352021-11-03 19:01:22 +00002300 case ConvolutionMethod::FFT:
2301 os << "FFT";
2302 break;
2303 case ConvolutionMethod::GEMM_CONV2D:
2304 os << "GEMM_CONV2D";
2305 break;
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002306 default:
2307 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2308 }
2309
2310 return os;
2311}
2312
Alex Gildayc357c472018-03-21 13:54:09 +00002313/** Formatted output of the ConvolutionMethod type.
2314 *
2315 * @param[in] conv_method Type to output
2316 *
2317 * @return Formatted string.
2318 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002319inline std::string to_string(const ConvolutionMethod &conv_method)
2320{
2321 std::stringstream str;
2322 str << conv_method;
2323 return str.str();
2324}
2325
Alex Gildayc357c472018-03-21 13:54:09 +00002326/** Formatted output of the GPUTarget type.
2327 *
2328 * @param[out] os Output stream
2329 * @param[in] gpu_target Type to output
2330 *
2331 * @return Modified output stream.
2332 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002333inline ::std::ostream &operator<<(::std::ostream &os, const GPUTarget &gpu_target)
2334{
2335 switch(gpu_target)
2336 {
2337 case GPUTarget::GPU_ARCH_MASK:
2338 os << "GPU_ARCH_MASK";
2339 break;
Gian Marco Iodice3c4d0852022-07-11 12:09:45 +01002340 case GPUTarget::GPU_GENERATION_MASK:
2341 os << "GPU_GENERATION_MASK";
2342 break;
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002343 case GPUTarget::MIDGARD:
2344 os << "MIDGARD";
2345 break;
2346 case GPUTarget::BIFROST:
2347 os << "BIFROST";
2348 break;
Georgios Pinitasd5462ff2019-07-03 19:33:57 +01002349 case GPUTarget::VALHALL:
2350 os << "VALHALL";
2351 break;
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002352 case GPUTarget::T600:
2353 os << "T600";
2354 break;
2355 case GPUTarget::T700:
2356 os << "T700";
2357 break;
2358 case GPUTarget::T800:
2359 os << "T800";
2360 break;
Michalis Spyroua9676112018-02-22 18:07:43 +00002361 case GPUTarget::G71:
2362 os << "G71";
2363 break;
2364 case GPUTarget::G72:
2365 os << "G72";
2366 break;
2367 case GPUTarget::G51:
2368 os << "G51";
2369 break;
2370 case GPUTarget::G51BIG:
2371 os << "G51BIG";
2372 break;
2373 case GPUTarget::G51LIT:
2374 os << "G51LIT";
2375 break;
Gian Marco Iodice3c4d0852022-07-11 12:09:45 +01002376 case GPUTarget::G31:
2377 os << "G31";
2378 break;
Georgios Pinitasb03f7c52018-07-12 10:49:53 +01002379 case GPUTarget::G76:
2380 os << "G76";
Michalis Spyroua9676112018-02-22 18:07:43 +00002381 break;
Gian Marco Iodice3c4d0852022-07-11 12:09:45 +01002382 case GPUTarget::G52:
2383 os << "G52";
2384 break;
2385 case GPUTarget::G52LIT:
2386 os << "G52LIT";
2387 break;
Georgios Pinitasd5462ff2019-07-03 19:33:57 +01002388 case GPUTarget::G77:
2389 os << "G77";
Michalis Spyroua9676112018-02-22 18:07:43 +00002390 break;
Gian Marco Iodice3c4d0852022-07-11 12:09:45 +01002391 case GPUTarget::G57:
2392 os << "G57";
2393 break;
Georgios Pinitas4ffc42a2020-12-01 16:28:24 +00002394 case GPUTarget::G78:
2395 os << "G78";
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002396 break;
Gian Marco Iodice3c4d0852022-07-11 12:09:45 +01002397 case GPUTarget::G68:
2398 os << "G68";
2399 break;
2400 case GPUTarget::G78AE:
2401 os << "G78AE";
Pablo Marquez Tellob1496e62021-06-25 14:49:37 +01002402 break;
Gian Marco Iodiceab2bc732022-01-19 10:06:45 +00002403 case GPUTarget::G710:
2404 os << "G710";
Georgios Pinitasd5462ff2019-07-03 19:33:57 +01002405 break;
Gian Marco Iodice3c4d0852022-07-11 12:09:45 +01002406 case GPUTarget::G610:
2407 os << "G610";
2408 break;
2409 case GPUTarget::G510:
2410 os << "G510";
2411 break;
2412 case GPUTarget::G310:
2413 os << "G310";
2414 break;
Gunes Bayir4bfc70e2021-12-10 16:17:56 +00002415 case GPUTarget::G715:
2416 os << "G715";
2417 break;
2418 case GPUTarget::G615:
2419 os << "G615";
2420 break;
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002421 default:
2422 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2423 }
2424
2425 return os;
2426}
2427
Alex Gildayc357c472018-03-21 13:54:09 +00002428/** Formatted output of the GPUTarget type.
2429 *
2430 * @param[in] gpu_target Type to output
2431 *
2432 * @return Formatted string.
2433 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002434inline std::string to_string(const GPUTarget &gpu_target)
2435{
2436 std::stringstream str;
2437 str << gpu_target;
2438 return str.str();
2439}
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00002440
John Richardson8de92612018-02-22 14:09:31 +00002441/** Formatted output of the DetectionWindow type.
2442 *
2443 * @param[out] os Output stream
2444 * @param[in] detection_window Type to output
2445 *
2446 * @return Modified output stream.
2447 */
John Richardson684cb0f2018-01-09 11:17:00 +00002448inline ::std::ostream &operator<<(::std::ostream &os, const DetectionWindow &detection_window)
2449{
2450 os << "{x=" << detection_window.x << ","
2451 << "y=" << detection_window.y << ","
2452 << "width=" << detection_window.width << ","
2453 << "height=" << detection_window.height << ","
2454 << "idx_class=" << detection_window.idx_class << ","
2455 << "score=" << detection_window.score << "}";
2456
2457 return os;
2458}
2459
Isabella Gottardi05e56442018-11-16 11:26:52 +00002460/** Formatted output of the DetectionOutputLayerCodeType type.
2461 *
2462 * @param[out] os Output stream
2463 * @param[in] detection_code Type to output
2464 *
2465 * @return Modified output stream.
2466 */
2467inline ::std::ostream &operator<<(::std::ostream &os, const DetectionOutputLayerCodeType &detection_code)
2468{
2469 switch(detection_code)
2470 {
2471 case DetectionOutputLayerCodeType::CENTER_SIZE:
2472 os << "CENTER_SIZE";
2473 break;
2474 case DetectionOutputLayerCodeType::CORNER:
2475 os << "CORNER";
2476 break;
2477 case DetectionOutputLayerCodeType::CORNER_SIZE:
2478 os << "CORNER_SIZE";
2479 break;
2480 case DetectionOutputLayerCodeType::TF_CENTER:
2481 os << "TF_CENTER";
2482 break;
2483 default:
2484 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2485 }
2486
2487 return os;
2488}
2489/** Formatted output of the DetectionOutputLayerCodeType type.
2490 *
2491 * @param[in] detection_code Type to output
2492 *
2493 * @return Formatted string.
2494 */
2495inline std::string to_string(const DetectionOutputLayerCodeType &detection_code)
2496{
2497 std::stringstream str;
2498 str << detection_code;
2499 return str.str();
2500}
2501
2502/** Formatted output of the DetectionOutputLayerInfo type.
2503 *
2504 * @param[out] os Output stream
2505 * @param[in] detection_info Type to output
2506 *
2507 * @return Modified output stream.
2508 */
2509inline ::std::ostream &operator<<(::std::ostream &os, const DetectionOutputLayerInfo &detection_info)
2510{
2511 os << "{Classes=" << detection_info.num_classes() << ","
2512 << "ShareLocation=" << detection_info.share_location() << ","
2513 << "CodeType=" << detection_info.code_type() << ","
2514 << "VarianceEncodedInTarget=" << detection_info.variance_encoded_in_target() << ","
2515 << "KeepTopK=" << detection_info.keep_top_k() << ","
2516 << "NMSThreshold=" << detection_info.nms_threshold() << ","
2517 << "Eta=" << detection_info.eta() << ","
2518 << "BackgroundLabelId=" << detection_info.background_label_id() << ","
2519 << "ConfidenceThreshold=" << detection_info.confidence_threshold() << ","
2520 << "TopK=" << detection_info.top_k() << ","
2521 << "NumLocClasses=" << detection_info.num_loc_classes()
2522 << "}";
2523
2524 return os;
2525}
2526
2527/** Formatted output of the DetectionOutputLayerInfo type.
2528 *
2529 * @param[in] detection_info Type to output
2530 *
2531 * @return Formatted string.
2532 */
2533inline std::string to_string(const DetectionOutputLayerInfo &detection_info)
2534{
2535 std::stringstream str;
2536 str << detection_info;
2537 return str.str();
2538}
Isabella Gottardia7acb3c2019-01-08 13:48:44 +00002539/** Formatted output of the DetectionPostProcessLayerInfo type.
2540 *
2541 * @param[out] os Output stream
2542 * @param[in] detection_info Type to output
2543 *
2544 * @return Modified output stream.
2545 */
2546inline ::std::ostream &operator<<(::std::ostream &os, const DetectionPostProcessLayerInfo &detection_info)
2547{
2548 os << "{MaxDetections=" << detection_info.max_detections() << ","
2549 << "MaxClassesPerDetection=" << detection_info.max_classes_per_detection() << ","
2550 << "NmsScoreThreshold=" << detection_info.nms_score_threshold() << ","
2551 << "NmsIouThreshold=" << detection_info.iou_threshold() << ","
2552 << "NumClasses=" << detection_info.num_classes() << ","
2553 << "ScaleValue_y=" << detection_info.scale_value_y() << ","
2554 << "ScaleValue_x=" << detection_info.scale_value_x() << ","
2555 << "ScaleValue_h=" << detection_info.scale_value_h() << ","
2556 << "ScaleValue_w=" << detection_info.scale_value_w() << ","
2557 << "UseRegularNms=" << detection_info.use_regular_nms() << ","
2558 << "DetectionPerClass=" << detection_info.detection_per_class()
2559 << "}";
2560
2561 return os;
2562}
2563
2564/** Formatted output of the DetectionPostProcessLayerInfo type.
2565 *
2566 * @param[in] detection_info Type to output
2567 *
2568 * @return Formatted string.
2569 */
2570inline std::string to_string(const DetectionPostProcessLayerInfo &detection_info)
2571{
2572 std::stringstream str;
2573 str << detection_info;
2574 return str.str();
2575}
Georgios Pinitasc6f95102021-03-30 10:03:01 +01002576
John Richardson8de92612018-02-22 14:09:31 +00002577/** Formatted output of the DetectionWindow type.
2578 *
2579 * @param[in] detection_window Type to output
2580 *
2581 * @return Formatted string.
2582 */
2583inline std::string to_string(const DetectionWindow &detection_window)
2584{
2585 std::stringstream str;
2586 str << detection_window;
2587 return str.str();
2588}
2589
Michalis Spyrou6c7c38e2018-08-29 16:28:11 +01002590/** Formatted output of @ref PriorBoxLayerInfo.
2591 *
2592 * @param[out] os Output stream.
2593 * @param[in] info Type to output.
2594 *
2595 * @return Modified output stream.
2596 */
2597inline ::std::ostream &operator<<(::std::ostream &os, const PriorBoxLayerInfo &info)
2598{
2599 os << "Clip:" << info.clip()
2600 << "Flip:" << info.flip()
2601 << "StepX:" << info.steps()[0]
2602 << "StepY:" << info.steps()[1]
2603 << "MinSizes:" << info.min_sizes()
2604 << "MaxSizes:" << info.max_sizes()
2605 << "ImgSizeX:" << info.img_size().x
2606 << "ImgSizeY:" << info.img_size().y
2607 << "Offset:" << info.offset()
2608 << "Variances:" << info.variances();
2609
2610 return os;
2611}
2612
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00002613/** Formatted output of the WinogradInfo type. */
2614inline ::std::ostream &operator<<(::std::ostream &os, const WinogradInfo &info)
2615{
2616 os << "{OutputTileSize=" << info.output_tile_size << ","
2617 << "KernelSize=" << info.kernel_size << ","
2618 << "PadStride=" << info.convolution_info << ","
2619 << "OutputDataLayout=" << info.output_data_layout << "}";
2620
2621 return os;
2622}
2623
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00002624inline std::string to_string(const WinogradInfo &type)
2625{
2626 std::stringstream str;
2627 str << type;
2628 return str.str();
2629}
Anthony Barbier671a11e2018-07-06 15:11:36 +01002630
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +01002631/** Convert a CLTunerMode value to a string
2632 *
2633 * @param val CLTunerMode value to be converted
2634 *
2635 * @return String representing the corresponding CLTunerMode.
2636 */
2637inline std::string to_string(const CLTunerMode val)
2638{
2639 switch(val)
2640 {
2641 case CLTunerMode::EXHAUSTIVE:
2642 {
2643 return std::string("Exhaustive");
2644 }
2645 case CLTunerMode::NORMAL:
2646 {
2647 return std::string("Normal");
2648 }
2649 case CLTunerMode::RAPID:
2650 {
2651 return std::string("Rapid");
2652 }
2653 default:
2654 {
2655 ARM_COMPUTE_ERROR("Invalid tuner mode.");
2656 return std::string("UNDEFINED");
2657 }
2658 }
2659}
SiCong Lidb4a6c12021-02-05 09:30:57 +00002660/** Converts a @ref CLGEMMKernelType to string
2661 *
2662 * @param[in] val CLGEMMKernelType value to be converted
2663 *
2664 * @return String representing the corresponding CLGEMMKernelType
2665 */
2666inline std::string to_string(CLGEMMKernelType val)
2667{
2668 switch(val)
2669 {
SiCong Lidb4a6c12021-02-05 09:30:57 +00002670 case CLGEMMKernelType::NATIVE:
2671 {
2672 return "Native";
2673 }
2674 case CLGEMMKernelType::RESHAPED_ONLY_RHS:
2675 {
2676 return "Reshaped_Only_RHS";
2677 }
2678 case CLGEMMKernelType::RESHAPED:
2679 {
2680 return "Reshaped";
2681 }
2682 default:
2683 {
2684 return "Unknown";
2685 }
2686 }
2687}
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +01002688/** [Print CLTunerMode type] **/
2689/** Formatted output of the CLTunerMode type.
2690 *
2691 * @param[out] os Output stream.
2692 * @param[in] val CLTunerMode to output.
2693 *
2694 * @return Modified output stream.
2695 */
2696inline ::std::ostream &operator<<(::std::ostream &os, const CLTunerMode &val)
2697{
2698 os << to_string(val);
2699 return os;
2700}
2701
ramelg013ae3d882021-09-12 23:07:47 +01002702/** Formatted output of the ConvolutionInfo type.
2703 *
2704 * @param[out] os Output stream.
2705 * @param[in] conv_info ConvolutionInfo to output.
2706 *
2707 * @return Modified output stream.
2708 */
2709inline ::std::ostream &operator<<(::std::ostream &os, const ConvolutionInfo &conv_info)
2710{
SiCongLi579ca842021-10-18 09:38:33 +01002711 os << "{PadStrideInfo=" << conv_info.pad_stride_info << ", "
2712 << "depth_multiplier=" << conv_info.depth_multiplier << ", "
2713 << "act_info=" << to_string(conv_info.act_info) << ", "
2714 << "dilation=" << conv_info.dilation << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002715 return os;
2716}
2717
2718/** Converts a @ref ConvolutionInfo to string
2719 *
2720 * @param[in] info ConvolutionInfo value to be converted
2721 *
2722 * @return String representing the corresponding ConvolutionInfo
2723 */
2724inline std::string to_string(const ConvolutionInfo &info)
2725{
2726 std::stringstream str;
2727 str << info;
2728 return str.str();
2729}
2730
2731/** Formatted output of the FullyConnectedLayerInfo type.
2732 *
2733 * @param[out] os Output stream.
2734 * @param[in] layer_info FullyConnectedLayerInfo to output.
2735 *
2736 * @return Modified output stream.
2737 */
2738inline ::std::ostream &operator<<(::std::ostream &os, const FullyConnectedLayerInfo &layer_info)
2739{
SiCongLi579ca842021-10-18 09:38:33 +01002740 os << "{activation_info=" << to_string(layer_info.activation_info) << ", "
2741 << "weights_trained_layout=" << layer_info.weights_trained_layout << ", "
2742 << "transpose_weights=" << layer_info.transpose_weights << ", "
2743 << "are_weights_reshaped=" << layer_info.are_weights_reshaped << ", "
2744 << "retain_internal_weights=" << layer_info.retain_internal_weights << ", "
2745 << "constant_weights=" << layer_info.transpose_weights << ", "
2746 << "fp_mixed_precision=" << layer_info.fp_mixed_precision << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002747 return os;
2748}
2749
2750/** Converts a @ref FullyConnectedLayerInfo to string
2751 *
2752 * @param[in] info FullyConnectedLayerInfo value to be converted
2753 *
2754 * @return String representing the corresponding FullyConnectedLayerInfo
2755 */
2756inline std::string to_string(const FullyConnectedLayerInfo &info)
2757{
2758 std::stringstream str;
2759 str << info;
2760 return str.str();
2761}
2762
2763/** Formatted output of the GEMMLowpOutputStageType type.
2764 *
2765 * @param[out] os Output stream.
2766 * @param[in] gemm_type GEMMLowpOutputStageType to output.
2767 *
2768 * @return Modified output stream.
2769 */
2770inline ::std::ostream &operator<<(::std::ostream &os, const GEMMLowpOutputStageType &gemm_type)
2771{
2772 switch(gemm_type)
2773 {
2774 case GEMMLowpOutputStageType::NONE:
2775 os << "NONE";
2776 break;
2777 case GEMMLowpOutputStageType::QUANTIZE_DOWN:
2778 os << "QUANTIZE_DOWN";
2779 break;
2780 case GEMMLowpOutputStageType::QUANTIZE_DOWN_FIXEDPOINT:
2781 os << "QUANTIZE_DOWN_FIXEDPOINT";
2782 break;
2783 case GEMMLowpOutputStageType::QUANTIZE_DOWN_FLOAT:
2784 os << "QUANTIZE_DOWN_FLOAT";
2785 break;
2786 default:
2787 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2788 }
2789 return os;
2790}
2791
2792/** Converts a @ref GEMMLowpOutputStageType to string
2793 *
2794 * @param[in] gemm_type GEMMLowpOutputStageType value to be converted
2795 *
2796 * @return String representing the corresponding GEMMLowpOutputStageType
2797 */
2798inline std::string to_string(const GEMMLowpOutputStageType &gemm_type)
2799{
2800 std::stringstream str;
2801 str << gemm_type;
2802 return str.str();
2803}
2804
2805/** Formatted output of the GEMMLowpOutputStageInfo type.
2806 *
2807 * @param[out] os Output stream.
2808 * @param[in] gemm_info GEMMLowpOutputStageInfo to output.
2809 *
2810 * @return Modified output stream.
2811 */
2812inline ::std::ostream &operator<<(::std::ostream &os, const GEMMLowpOutputStageInfo &gemm_info)
2813{
SiCongLi579ca842021-10-18 09:38:33 +01002814 os << "{type=" << gemm_info.type << ", "
2815 << "gemlowp_offset=" << gemm_info.gemmlowp_offset << ", "
2816 << "gemmlowp_multiplier=" << gemm_info.gemmlowp_multiplier << ", "
2817 << "gemmlowp_shift=" << gemm_info.gemmlowp_shift << ", "
2818 << "gemmlowp_min_bound=" << gemm_info.gemmlowp_min_bound << ", "
2819 << "gemmlowp_max_bound=" << gemm_info.gemmlowp_max_bound << ", "
2820 << "gemmlowp_multipliers=" << gemm_info.gemmlowp_multiplier << ", "
2821 << "gemmlowp_shifts=" << gemm_info.gemmlowp_shift << ", "
2822 << "gemmlowp_real_multiplier=" << gemm_info.gemmlowp_real_multiplier << ", "
2823 << "is_quantized_per_channel=" << gemm_info.is_quantized_per_channel << ", "
2824 << "output_data_type=" << gemm_info.output_data_type << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002825 return os;
2826}
2827
2828/** Converts a @ref GEMMLowpOutputStageInfo to string
2829 *
2830 * @param[in] gemm_info GEMMLowpOutputStageInfo value to be converted
2831 *
2832 * @return String representing the corresponding GEMMLowpOutputStageInfo
2833 */
2834inline std::string to_string(const GEMMLowpOutputStageInfo &gemm_info)
2835{
2836 std::stringstream str;
2837 str << gemm_info;
2838 return str.str();
2839}
2840
2841/** Formatted output of the Conv2dInfo type.
2842 *
2843 * @param[out] os Output stream.
2844 * @param[in] conv_info Conv2dInfo to output.
2845 *
2846 * @return Modified output stream.
2847 */
2848inline ::std::ostream &operator<<(::std::ostream &os, const Conv2dInfo &conv_info)
2849{
SiCongLi579ca842021-10-18 09:38:33 +01002850 os << "{conv_info=" << conv_info.conv_info << ", "
2851 << "dilation=" << conv_info.dilation << ", "
2852 << "act_info=" << to_string(conv_info.act_info) << ", "
2853 << "enable_fast_math=" << conv_info.enable_fast_math << ", "
2854 << "num_groups=" << conv_info.num_groups << ","
2855 << "post_ops=" << conv_info.post_ops << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002856 return os;
2857}
2858
2859/** Converts a @ref Conv2dInfo to string
2860 *
2861 * @param[in] conv_info Conv2dInfo value to be converted
2862 *
2863 * @return String representing the corresponding Conv2dInfo
2864 */
2865inline std::string to_string(const Conv2dInfo &conv_info)
2866{
2867 std::stringstream str;
2868 str << conv_info;
2869 return str.str();
2870}
2871
2872/** Formatted output of the PixelValue type.
2873 *
2874 * @param[out] os Output stream.
2875 * @param[in] pixel_value PixelValue to output.
2876 *
2877 * @return Modified output stream.
2878 */
2879inline ::std::ostream &operator<<(::std::ostream &os, const PixelValue &pixel_value)
2880{
SiCongLi579ca842021-10-18 09:38:33 +01002881 os << "{value.u64=" << pixel_value.get<uint64_t>() << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002882 return os;
2883}
2884
2885/** Converts a @ref PixelValue to string
2886 *
2887 * @param[in] pixel_value PixelValue value to be converted
2888 *
2889 * @return String representing the corresponding PixelValue
2890 */
2891inline std::string to_string(const PixelValue &pixel_value)
2892{
2893 std::stringstream str;
2894 str << pixel_value;
2895 return str.str();
2896}
2897
2898/** Formatted output of the ScaleKernelInfo type.
2899 *
2900 * @param[out] os Output stream.
2901 * @param[in] scale_info ScaleKernelInfo to output.
2902 *
2903 * @return Modified output stream.
2904 */
2905inline ::std::ostream &operator<<(::std::ostream &os, const ScaleKernelInfo &scale_info)
2906{
SiCongLi579ca842021-10-18 09:38:33 +01002907 os << "{interpolation_policy=" << scale_info.interpolation_policy << ", "
2908 << "BorderMode=" << scale_info.border_mode << ", "
2909 << "PixelValue=" << scale_info.constant_border_value << ", "
2910 << "SamplingPolicy=" << scale_info.sampling_policy << ", "
2911 << "use_padding=" << scale_info.use_padding << ", "
2912 << "align_corners=" << scale_info.align_corners << ", "
2913 << "data_layout=" << scale_info.data_layout << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002914 return os;
2915}
2916
2917/** Converts a @ref ScaleKernelInfo to string
2918 *
2919 * @param[in] scale_info ScaleKernelInfo value to be converted
2920 *
2921 * @return String representing the corresponding ScaleKernelInfo
2922 */
2923inline std::string to_string(const ScaleKernelInfo &scale_info)
2924{
2925 std::stringstream str;
2926 str << scale_info;
2927 return str.str();
2928}
2929
2930/** Formatted output of the FFTDirection type.
2931 *
2932 * @param[out] os Output stream.
2933 * @param[in] fft_dir FFTDirection to output.
2934 *
2935 * @return Modified output stream.
2936 */
2937inline ::std::ostream &operator<<(::std::ostream &os, const FFTDirection &fft_dir)
2938{
2939 switch(fft_dir)
2940 {
2941 case FFTDirection::Forward:
2942 os << "Forward";
2943 break;
2944 case FFTDirection::Inverse:
2945 os << "Inverse";
2946 break;
2947 default:
2948 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2949 }
2950 return os;
2951}
2952
2953/** Converts a @ref FFT1DInfo to string
2954 *
2955 * @param[in] fft_dir FFT1DInfo value to be converted
2956 *
2957 * @return String representing the corresponding FFT1DInfo
2958 */
2959inline std::string to_string(const FFTDirection &fft_dir)
2960{
2961 std::stringstream str;
ramelg01cbbb0382021-09-17 17:36:57 +01002962 str << "{" << fft_dir << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002963 return str.str();
2964}
2965
2966/** Formatted output of the FFT1DInfo type.
2967 *
2968 * @param[out] os Output stream.
2969 * @param[in] fft1d_info FFT1DInfo to output.
2970 *
2971 * @return Modified output stream.
2972 */
2973inline ::std::ostream &operator<<(::std::ostream &os, const FFT1DInfo &fft1d_info)
2974{
SiCongLi579ca842021-10-18 09:38:33 +01002975 os << "{axis=" << fft1d_info.axis << ", "
2976 << "direction=" << fft1d_info.direction << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002977 return os;
2978}
2979
2980/** Converts a @ref FFT1DInfo to string
2981 *
2982 * @param[in] fft1d_info FFT1DInfo value to be converted
2983 *
2984 * @return String representing the corresponding FFT1DInfo
2985 */
2986inline std::string to_string(const FFT1DInfo &fft1d_info)
2987{
2988 std::stringstream str;
2989 str << fft1d_info;
2990 return str.str();
2991}
2992
2993/** Formatted output of the FFT2DInfo type.
2994 *
2995 * @param[out] os Output stream.
2996 * @param[in] fft2d_info FFT2DInfo to output.
2997 *
2998 * @return Modified output stream.
2999 */
3000inline ::std::ostream &operator<<(::std::ostream &os, const FFT2DInfo &fft2d_info)
3001{
SiCongLi579ca842021-10-18 09:38:33 +01003002 os << "{axis=" << fft2d_info.axis0 << ", "
3003 << "axis=" << fft2d_info.axis1 << ", "
3004 << "direction=" << fft2d_info.direction << "}";
ramelg013ae3d882021-09-12 23:07:47 +01003005 return os;
3006}
3007
3008/** Converts a @ref FFT2DInfo to string
3009 *
3010 * @param[in] fft2d_info FFT2DInfo value to be converted
3011 *
3012 * @return String representing the corresponding FFT2DInfo
3013 */
3014inline std::string to_string(const FFT2DInfo &fft2d_info)
3015{
3016 std::stringstream str;
3017 str << fft2d_info;
3018 return str.str();
3019}
3020
3021/** Formatted output of the Coordinates2D type.
3022 *
3023 * @param[out] os Output stream.
3024 * @param[in] coord_2d Coordinates2D to output.
3025 *
3026 * @return Modified output stream.
3027 */
3028inline ::std::ostream &operator<<(::std::ostream &os, const Coordinates2D &coord_2d)
3029{
SiCongLi579ca842021-10-18 09:38:33 +01003030 os << "{x=" << coord_2d.x << ", "
3031 << "y=" << coord_2d.y << "}";
ramelg013ae3d882021-09-12 23:07:47 +01003032 return os;
3033}
3034
3035/** Converts a @ref Coordinates2D to string
3036 *
3037 * @param[in] coord_2d Coordinates2D value to be converted
3038 *
3039 * @return String representing the corresponding Coordinates2D
3040 */
3041inline std::string to_string(const Coordinates2D &coord_2d)
3042{
3043 std::stringstream str;
3044 str << coord_2d;
3045 return str.str();
3046}
3047
3048/** Formatted output of the FuseBatchNormalizationType type.
3049 *
3050 * @param[out] os Output stream.
3051 * @param[in] fuse_type FuseBatchNormalizationType to output.
3052 *
3053 * @return Modified output stream.
3054 */
3055inline ::std::ostream &operator<<(::std::ostream &os, const FuseBatchNormalizationType &fuse_type)
3056{
3057 switch(fuse_type)
3058 {
3059 case FuseBatchNormalizationType::CONVOLUTION:
3060 os << "CONVOLUTION";
3061 break;
3062 case FuseBatchNormalizationType::DEPTHWISECONVOLUTION:
3063 os << "DEPTHWISECONVOLUTION";
3064 break;
3065 default:
3066 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
3067 }
3068 return os;
3069}
3070
3071/** Converts a @ref FuseBatchNormalizationType to string
3072 *
3073 * @param[in] fuse_type FuseBatchNormalizationType value to be converted
3074 *
3075 * @return String representing the corresponding FuseBatchNormalizationType
3076 */
3077inline std::string to_string(const FuseBatchNormalizationType &fuse_type)
3078{
3079 std::stringstream str;
3080 str << fuse_type;
3081 return str.str();
3082}
3083
ramelg01cbbb0382021-09-17 17:36:57 +01003084/** Formatted output of the SoftmaxKernelInfo type.
3085 *
3086 * @param[out] os Output stream.
3087 * @param[in] info SoftmaxKernelInfo to output.
3088 *
3089 * @return Modified output stream.
3090 */
3091inline ::std::ostream &operator<<(::std::ostream &os, const SoftmaxKernelInfo &info)
3092{
SiCongLi579ca842021-10-18 09:38:33 +01003093 os << "{beta=" << info.beta << ", "
3094 << "is_log=" << info.is_log << ", "
3095 << "input_data_type=" << info.input_data_type << ", "
3096 << "axis=" << info.axis << "}";
ramelg01cbbb0382021-09-17 17:36:57 +01003097 return os;
3098}
3099
3100/** Converts a @ref SoftmaxKernelInfo to string
3101 *
3102 * @param[in] info SoftmaxKernelInfo value to be converted
3103 *
3104 * @return String representing the corresponding SoftmaxKernelInfo
3105 */
3106inline std::string to_string(const SoftmaxKernelInfo &info)
3107{
3108 std::stringstream str;
3109 str << info;
3110 return str.str();
3111}
3112
3113/** Formatted output of the ScaleKernelInfo type.
3114 *
3115 * @param[out] os Output stream.
3116 * @param[in] lstm_params LSTMParams to output.
3117 *
3118 * @return Modified output stream.
3119 */
3120template <typename T>
ramelg014a6d9e82021-10-02 14:34:36 +01003121::std::ostream &operator<<(::std::ostream &os, const LSTMParams<T> &lstm_params)
ramelg01cbbb0382021-09-17 17:36:57 +01003122{
ramelg014a6d9e82021-10-02 14:34:36 +01003123 os << "{input_to_input_weights=" << to_string(lstm_params.input_to_input_weights()) << ", "
3124 << "recurrent_to_input_weights=" << to_string(lstm_params.recurrent_to_input_weights()) << ", "
3125 << "cell_to_input_weights=" << to_string(lstm_params.cell_to_input_weights()) << ", "
3126 << "input_gate_bias=" << to_string(lstm_params.input_gate_bias()) << ", "
3127 << "cell_to_forget_weights=" << to_string(lstm_params.cell_to_forget_weights()) << ", "
3128 << "cell_to_output_weights=" << to_string(lstm_params.cell_to_output_weights()) << ", "
3129 << "projection_weights=" << to_string(lstm_params.projection_weights()) << ", "
3130 << "projection_bias=" << to_string(lstm_params.projection_bias()) << ", "
3131 << "input_layer_norm_weights=" << to_string(lstm_params.input_layer_norm_weights()) << ", "
3132 << "forget_layer_norm_weights=" << to_string(lstm_params.forget_layer_norm_weights()) << ", "
3133 << "cell_layer_norm_weights=" << to_string(lstm_params.cell_layer_norm_weights()) << ", "
3134 << "output_layer_norm_weights=" << to_string(lstm_params.output_layer_norm_weights()) << ", "
ramelg01cbbb0382021-09-17 17:36:57 +01003135 << "cell_clip=" << lstm_params.cell_clip() << ", "
3136 << "projection_clip=" << lstm_params.projection_clip() << ", "
3137 << "input_intermediate_scale=" << lstm_params.input_intermediate_scale() << ", "
3138 << "forget_intermediate_scale=" << lstm_params.forget_intermediate_scale() << ", "
3139 << "cell_intermediate_scale=" << lstm_params.cell_intermediate_scale() << ", "
3140 << "hidden_state_zero=" << lstm_params.hidden_state_zero() << ", "
3141 << "hidden_state_scale=" << lstm_params.hidden_state_scale() << ", "
3142 << "has_peephole_opt=" << lstm_params.has_peephole_opt() << ", "
3143 << "has_projection=" << lstm_params.has_projection() << ", "
3144 << "has_cifg_opt=" << lstm_params.has_cifg_opt() << ", "
3145 << "use_layer_norm=" << lstm_params.use_layer_norm() << "}";
3146 return os;
3147}
3148
3149/** Converts a @ref LSTMParams to string
3150 *
3151 * @param[in] lstm_params LSTMParams<T> value to be converted
3152 *
3153 * @return String representing the corresponding LSTMParams
3154 */
3155template <typename T>
ramelg014a6d9e82021-10-02 14:34:36 +01003156std::string to_string(const LSTMParams<T> &lstm_params)
ramelg01cbbb0382021-09-17 17:36:57 +01003157{
3158 std::stringstream str;
3159 str << lstm_params;
3160 return str.str();
3161}
3162
3163/** Converts a @ref LSTMParams to string
3164 *
3165 * @param[in] num uint8_t value to be converted
3166 *
3167 * @return String representing the corresponding uint8_t
3168 */
3169inline std::string to_string(const uint8_t num)
3170{
3171 // Explicity cast the uint8_t to signed integer and call the corresponding overloaded to_string() function.
3172 return ::std::to_string(static_cast<int>(num));
3173}
3174
ramelg014a6d9e82021-10-02 14:34:36 +01003175/** Available non maxima suppression types */
3176/** Formatted output of the NMSType type.
3177 *
3178 * @param[out] os Output stream.
3179 * @param[in] nms_type NMSType to output.
3180 *
3181 * @return Modified output stream.
3182 */
3183inline ::std::ostream &operator<<(::std::ostream &os, const NMSType &nms_type)
3184{
3185 switch(nms_type)
3186 {
3187 case NMSType::LINEAR:
3188 os << "LINEAR";
3189 break;
3190 case NMSType::GAUSSIAN:
3191 os << "GAUSSIAN";
3192 break;
3193 case NMSType::ORIGINAL:
3194 os << "ORIGINAL";
3195 break;
3196 default:
3197 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
3198 }
3199 return os;
3200}
3201
3202/** Converts a @ref NMSType to string
3203 *
3204 * @param[in] nms_type NMSType value to be converted
3205 *
3206 * @return String representing the corresponding NMSType
3207 */
3208inline std::string to_string(const NMSType nms_type)
3209{
3210 std::stringstream str;
3211 str << nms_type;
3212 return str.str();
3213}
3214
3215/** Formatted output of the BoxNMSLimitInfo type.
3216 *
3217 * @param[out] os Output stream.
3218 * @param[in] info BoxNMSLimitInfo to output.
3219 *
3220 * @return Modified output stream.
3221 */
3222inline ::std::ostream &operator<<(::std::ostream &os, const BoxNMSLimitInfo &info)
3223{
SiCongLi579ca842021-10-18 09:38:33 +01003224 os << "{score_thresh=" << info.score_thresh() << ", "
3225 << "nms=" << info.nms() << ", "
3226 << "detections_per_im=" << info.detections_per_im() << ", "
3227 << "soft_nms_enabled=" << info.soft_nms_enabled() << ", "
3228 << "soft_nms_min_score_thres=" << info.soft_nms_min_score_thres() << ", "
3229 << "suppress_size=" << info.suppress_size() << ", "
3230 << "min_size=" << info.min_size() << ", "
3231 << "im_width=" << info.im_width() << ", "
3232 << "im_height=" << info.im_height() << "}";
ramelg014a6d9e82021-10-02 14:34:36 +01003233 return os;
3234}
3235
3236/** Converts a @ref BoxNMSLimitInfo to string
3237 *
3238 * @param[in] info BoxNMSLimitInfo value to be converted
3239 *
3240 * @return String representing the corresponding BoxNMSLimitInfo
3241 */
3242inline std::string to_string(const BoxNMSLimitInfo &info)
3243{
3244 std::stringstream str;
3245 str << info;
3246 return str.str();
3247}
3248
Giorgio Arena945ae9e2021-10-13 11:13:04 +01003249/** Converts a @ref DimensionRoundingType to string
3250 *
3251 * @param[in] rounding_type DimensionRoundingType value to be converted
3252 *
3253 * @return String representing the corresponding DimensionRoundingType
3254 */
3255inline std::string to_string(const DimensionRoundingType &rounding_type)
3256{
3257 std::stringstream str;
3258 str << rounding_type;
3259 return str.str();
3260}
3261
Giorgio Arena945ae9e2021-10-13 11:13:04 +01003262/** Formatted output of the Conv3dInfo type.
3263 *
3264 * @param[out] os Output stream.
3265 * @param[in] conv3d_info Type to output.
3266 *
3267 * @return Modified output stream.
3268 */
3269inline ::std::ostream &operator<<(::std::ostream &os, const Conv3dInfo &conv3d_info)
3270{
3271 os << conv3d_info.stride;
3272 os << ";";
3273 os << conv3d_info.padding;
3274 os << ";";
3275 os << to_string(conv3d_info.act_info);
3276 os << ";";
3277 os << conv3d_info.dilation;
3278 os << ";";
3279 os << conv3d_info.round_type;
3280 os << ";";
3281 os << conv3d_info.enable_fast_math;
3282
3283 return os;
3284}
3285
3286/** Formatted output of the Conv3dInfo type.
3287 *
3288 * @param[in] conv3d_info Type to output.
3289 *
3290 * @return Formatted string.
3291 */
3292inline std::string to_string(const Conv3dInfo &conv3d_info)
3293{
3294 std::stringstream str;
3295 str << conv3d_info;
3296 return str.str();
3297}
3298
Ramy Elgammal91780022022-07-20 14:57:37 +01003299/** Formatted output of the arm_compute::WeightFormat type.
3300 *
3301 * @param[in] wf arm_compute::WeightFormat Type to output.
3302 *
3303 * @return Formatted string.
3304 */
3305inline std::string to_string(const WeightFormat wf)
Francesco Petrogalli553f6952022-06-30 10:22:01 +00003306{
Ramy Elgammal91780022022-07-20 14:57:37 +01003307#define __CASE_WEIGHT_FORMAT(wf) \
3308case WeightFormat::wf: \
3309 return #wf;
3310 switch(wf)
3311 {
3312 __CASE_WEIGHT_FORMAT(UNSPECIFIED)
3313 __CASE_WEIGHT_FORMAT(ANY)
3314 __CASE_WEIGHT_FORMAT(OHWI)
3315 __CASE_WEIGHT_FORMAT(OHWIo2)
3316 __CASE_WEIGHT_FORMAT(OHWIo4)
3317 __CASE_WEIGHT_FORMAT(OHWIo8)
3318 __CASE_WEIGHT_FORMAT(OHWIo16)
3319 __CASE_WEIGHT_FORMAT(OHWIo32)
3320 __CASE_WEIGHT_FORMAT(OHWIo64)
3321 __CASE_WEIGHT_FORMAT(OHWIo128)
3322 __CASE_WEIGHT_FORMAT(OHWIo4i2)
3323 __CASE_WEIGHT_FORMAT(OHWIo4i2_bf16)
3324 __CASE_WEIGHT_FORMAT(OHWIo8i2)
3325 __CASE_WEIGHT_FORMAT(OHWIo8i2_bf16)
3326 __CASE_WEIGHT_FORMAT(OHWIo16i2)
3327 __CASE_WEIGHT_FORMAT(OHWIo16i2_bf16)
3328 __CASE_WEIGHT_FORMAT(OHWIo32i2)
3329 __CASE_WEIGHT_FORMAT(OHWIo32i2_bf16)
3330 __CASE_WEIGHT_FORMAT(OHWIo64i2)
3331 __CASE_WEIGHT_FORMAT(OHWIo64i2_bf16)
3332 __CASE_WEIGHT_FORMAT(OHWIo4i4)
3333 __CASE_WEIGHT_FORMAT(OHWIo4i4_bf16)
3334 __CASE_WEIGHT_FORMAT(OHWIo8i4)
3335 __CASE_WEIGHT_FORMAT(OHWIo8i4_bf16)
3336 __CASE_WEIGHT_FORMAT(OHWIo16i4)
3337 __CASE_WEIGHT_FORMAT(OHWIo16i4_bf16)
3338 __CASE_WEIGHT_FORMAT(OHWIo32i4)
3339 __CASE_WEIGHT_FORMAT(OHWIo32i4_bf16)
3340 __CASE_WEIGHT_FORMAT(OHWIo64i4)
3341 __CASE_WEIGHT_FORMAT(OHWIo64i4_bf16)
3342 __CASE_WEIGHT_FORMAT(OHWIo2i8)
3343 __CASE_WEIGHT_FORMAT(OHWIo4i8)
3344 __CASE_WEIGHT_FORMAT(OHWIo8i8)
3345 __CASE_WEIGHT_FORMAT(OHWIo16i8)
3346 __CASE_WEIGHT_FORMAT(OHWIo32i8)
3347 __CASE_WEIGHT_FORMAT(OHWIo64i8)
3348 default:
3349 return "invalid value";
3350 }
3351#undef __CASE_WEIGHT_FORMAT
Francesco Petrogalli553f6952022-06-30 10:22:01 +00003352}
3353
Ramy Elgammal91780022022-07-20 14:57:37 +01003354/** Formatted output of the arm_compute::WeightFormat type.
3355 *
3356 * @param[out] os Output stream.
3357 * @param[in] wf WeightFormat to output.
3358 *
3359 * @return Modified output stream.
3360 */
3361inline ::std::ostream &operator<<(::std::ostream &os, const arm_compute::WeightFormat &wf)
3362{
3363 os << to_string(wf);
3364 return os;
3365}
3366
3367/** Formatted output of the std::tuple<TensorShape, TensorShape, arm_compute::WeightFormat> tuple.
3368 *
3369 * @param[in] values tuple of input and output tensor shapes and WeightFormat used.
3370 *
3371 * @return Formatted string.
3372 */
3373inline std::string to_string(const std::tuple<TensorShape, TensorShape, arm_compute::WeightFormat> values)
Francesco Petrogalli553f6952022-06-30 10:22:01 +00003374{
3375 std::stringstream str;
3376 str << "[Input shape = " << std::get<0>(values);
3377 str << ", ";
3378 str << "Expected output shape = " << std::get<1>(values);
3379
3380 str << ", ";
3381 str << "WeightFormat = " << std::get<2>(values) << "]";
3382 return str.str();
3383}
3384
Ramy Elgammal73f19af2022-10-23 11:44:49 +01003385/** Formatted output of the Padding2D type.
3386 *
3387 * @param[out] os Output stream.
3388 * @param[in] padding2d Padding info for 2D dimension shape.
3389 *
3390 * @return Modified output stream.
3391 */
3392inline ::std::ostream &operator<<(::std::ostream &os, const Padding2D &padding2d)
3393{
3394 os << padding2d.left << "," << padding2d.right << ","
3395 << padding2d.top << "," << padding2d.bottom;
3396 return os;
3397}
3398
3399/** Converts a @ref Padding2D to string
3400 *
3401 * @param[in] padding2d Padding2D value to be converted
3402 *
3403 * @return String representing the corresponding Padding2D
3404 */
3405inline std::string to_string(const Padding2D &padding2d)
3406{
3407 std::stringstream str;
3408 str << padding2d;
3409 return str.str();
3410}
3411
Mohammed Suhail Munshia18d85c2023-01-03 10:16:16 +00003412/** Formatted output of the arm_compute::experimental::dynamic_fusion::Pool2dAttributes type.
3413 *
3414 * @param[out] os Output stream.
3415 * @param[in] pool2d_attr arm_compute::experimental::dynamic_fusion::Pool2dAttributes type to output.
3416 *
3417 * @return Modified output stream.
3418 */
3419inline ::std::ostream &operator<<(::std::ostream &os, const experimental::dynamic_fusion::Pool2dAttributes &pool2d_attr)
3420{
3421 os << "Pool2dAttributes="
3422 << "["
3423 << "PoolingType=" << pool2d_attr.pool_type() << ","
3424 << "PoolSize=" << pool2d_attr.pool_size() << ","
3425 << "Padding=" << pool2d_attr.pad() << ","
3426 << "Stride=" << pool2d_attr.stride() << ","
3427 << "ExcludePadding" << pool2d_attr.exclude_padding() << "]";
3428
3429 return os;
3430}
3431
3432/** Formatted output of the arm_compute::experimental::dynamic_fusion::Pool2dAttributes type.
3433 *
3434 * @param[in] pool2d_attr arm_compute::experimental::dynamic_fusion::Pool2dAttributes type to output.
3435 *
3436 * @return Formatted string.
3437 */
3438inline std::string to_string(const experimental::dynamic_fusion::Pool2dAttributes &pool2d_attr)
3439{
3440 std::stringstream str;
3441 str << pool2d_attr;
3442 return str.str();
3443}
3444
3445/** Formatted output of the arm_compute::experimental::dynamic_fusion::GpuPool2dSettings type
3446 *
3447 * @param[out] os Output stream
3448 * @param[in] settings arm_compute::dynamic_fusion::GpuPool2dSettings type to output
3449 */
3450inline ::std::ostream &operator<<(::std::ostream &os, const experimental::dynamic_fusion::GpuPool2dSettings &settings)
3451{
3452 os << "Settings="
3453 << "["
3454 << "FPMixedPrecision=" << settings.mixed_precision() << "]";
3455 return os;
3456}
3457
3458/** Formatted output of the arm_compute::experimental::dynamic_fusion::GpuPool2dSettings type.
3459 *
3460 * @param[in] settings arm_compute::experimental::dynamic_fusion::GpuPool2dSettings type to output.
3461 *
3462 * @return Formatted string.
3463 */
3464inline std::string to_string(const experimental::dynamic_fusion::GpuPool2dSettings &settings)
3465{
3466 std::stringstream str;
3467 str << settings;
3468 return str.str();
3469}
3470
Ramy Elgammal73f19af2022-10-23 11:44:49 +01003471/** Formatted output of the arm_compute::experimental::dynamic_fusion::Conv2dAttributes type.
3472 *
3473 * @param[out] os Output stream.
3474 * @param[in] conv2d_attr arm_compute::experimental::dynamic_fusion::Conv2dAttributes type to output.
3475 *
3476 * @return Modified output stream.
3477 */
3478inline ::std::ostream &operator<<(::std::ostream &os, const experimental::dynamic_fusion::Conv2dAttributes &conv2d_attr)
3479{
3480 os << "Conv2dAttributes="
3481 << "["
3482 << "Padding=" << conv2d_attr.pad() << ", "
3483 << "Size2D=" << conv2d_attr.stride() << ", "
Ramy Elgammal404462a2022-11-08 02:14:46 +00003484 << "Dialation=" << conv2d_attr.dilation() << "]";
Ramy Elgammal73f19af2022-10-23 11:44:49 +01003485
3486 return os;
3487}
Mohammed Suhail Munshia18d85c2023-01-03 10:16:16 +00003488
Ramy Elgammal73f19af2022-10-23 11:44:49 +01003489/** Formatted output of the arm_compute::experimental::dynamic_fusion::Conv2dAttributes type.
3490 *
3491 * @param[in] conv2d_attr arm_compute::experimental::dynamic_fusion::Conv2dAttributes type to output.
3492 *
3493 * @return Formatted string.
3494 */
3495inline std::string to_string(const experimental::dynamic_fusion::Conv2dAttributes &conv2d_attr)
3496{
3497 std::stringstream str;
3498 str << conv2d_attr;
3499 return str.str();
3500}
Gunes Bayir7dc02342022-11-21 21:46:50 +00003501
Gunes Bayir1dc6ff12022-12-06 20:48:31 +00003502/** Formatted output of the arm_compute::experimental::dynamic_fusion::CastAttributes type.
3503 *
3504 * @param[out] os Output stream.
3505 * @param[in] cast_attr arm_compute::experimental::dynamic_fusion::CastAttributes type to output.
3506 *
3507 * @return Modified output stream.
3508 */
3509inline ::std::ostream &operator<<(::std::ostream &os, const experimental::dynamic_fusion::CastAttributes &cast_attr)
3510{
3511 os << "CastAttributes="
3512 << "["
3513 << "Data Type=" << cast_attr.data_type() << ", "
3514 << "Convert Policy=" << cast_attr.convert_policy() << "]";
3515
3516 return os;
3517}
3518/** Formatted output of the arm_compute::experimental::dynamic_fusion::CastAttributes type.
3519 *
3520 * @param[in] cast_attr arm_compute::experimental::dynamic_fusion::CastAttributes type to output.
3521 *
3522 * @return Formatted string.
3523 */
3524inline std::string to_string(const experimental::dynamic_fusion::CastAttributes &cast_attr)
3525{
3526 std::stringstream str;
3527 str << cast_attr;
3528 return str.str();
3529}
3530
Gunes Bayir7dc02342022-11-21 21:46:50 +00003531/** Formatted output of the arm_compute::experimental::dynamic_fusion::DepthwiseConv2dAttributes type.
3532 *
3533 * @param[out] os Output stream.
3534 * @param[in] dw_conv2d_attr arm_compute::experimental::dynamic_fusion::DepthwiseConv2dAttributes type to output.
3535 *
3536 * @return Modified output stream.
3537 */
3538inline ::std::ostream &operator<<(::std::ostream &os, const experimental::dynamic_fusion::DepthwiseConv2dAttributes &dw_conv2d_attr)
3539{
3540 os << "DepthwiseConv2dAttributes="
3541 << "["
3542 << "Padding=" << dw_conv2d_attr.pad() << ", "
3543 << "Size2D=" << dw_conv2d_attr.stride() << ", "
3544 << "Depth Multiplier=" << dw_conv2d_attr.depth_multiplier() << ", "
3545 << "Dilation=" << dw_conv2d_attr.dilation() << ","
3546 << "DimensionRoundingType: " << dw_conv2d_attr.dimension_rounding_type() << "]";
3547
3548 return os;
3549}
3550/** Formatted output of the arm_compute::experimental::dynamic_fusion::DepthwiseConv2dAttributes type.
3551 *
3552 * @param[in] dw_conv2d_attr arm_compute::experimental::dynamic_fusion::DepthwiseConv2dAttributes type to output.
3553 *
3554 * @return Formatted string.
3555 */
3556inline std::string to_string(const experimental::dynamic_fusion::DepthwiseConv2dAttributes &dw_conv2d_attr)
3557{
3558 std::stringstream str;
3559 str << dw_conv2d_attr;
3560 return str.str();
3561}
3562
Jakub Sujak32741722022-11-25 16:43:18 +00003563/** Formatted output of the arm_compute::experimental::dynamic_fusion::ClampAttributes type.
3564 *
3565 * @param[out] os Output stream.
3566 * @param[in] clamp_attr arm_compute::experimental::dynamic_fusion::ClampAttributes type to output.
3567 *
3568 * @return Modified output stream.
3569 */
3570inline ::std::ostream &operator<<(::std::ostream &os, const experimental::dynamic_fusion::ClampAttributes &clamp_attr)
3571{
3572 os << "ClampAttributes="
3573 << "["
3574 << "Min value=" << clamp_attr.min_val() << ", "
3575 << "Max value=" << clamp_attr.max_val() << "]";
3576 return os;
3577}
3578/** Formatted output of the arm_compute::experimental::dynamic_fusion::ClampAttributes type.
3579 *
3580 * @param[in] clamp_attr arm_compute::experimental::dynamic_fusion::ClampAttributes type to output.
3581 *
3582 * @return Formatted string.
3583 */
3584inline std::string to_string(const experimental::dynamic_fusion::ClampAttributes &clamp_attr)
3585{
3586 std::stringstream str;
3587 str << clamp_attr;
3588 return str.str();
3589}
3590
Jakub Sujak8ae57142022-12-02 16:09:06 +00003591/** Formatted output of the arm_compute::experimental::dynamic_fusion::ResizeAttributes type.
3592 *
3593 * @param[out] os Output stream.
3594 * @param[in] resize_attr arm_compute::experimental::dynamic_fusion::ResizeAttributes type to output.
3595 *
3596 * @return Modified output stream.
3597 */
3598inline ::std::ostream &operator<<(::std::ostream &os, const experimental::dynamic_fusion::ResizeAttributes &resize_attr)
3599{
3600 os << "ResizeAttributes="
3601 << "["
3602 << "AlignCorners=" << resize_attr.align_corners() << ", "
3603 << "InterpolationPolicy=" << resize_attr.interpolation_policy() << ", "
3604 << "OutputHeight=" << resize_attr.output_height() << ", "
3605 << "OutputWidth=" << resize_attr.output_width() << ", "
3606 << "SamplingPolicy=" << resize_attr.sampling_policy() << "]";
3607 return os;
3608}
3609
3610/** Formatted output of the arm_compute::experimental::dynamic_fusion::ResizeAttributes type.
3611 *
3612 * @param[in] resize_attr arm_compute::experimental::dynamic_fusion::ResizeAttributes type to output.
3613 *
3614 * @return Formatted string.
3615 */
3616inline std::string to_string(const experimental::dynamic_fusion::ResizeAttributes &resize_attr)
3617{
3618 std::stringstream str;
3619 str << resize_attr;
3620 return str.str();
3621}
3622
Gunes Bayiraecb5d92022-12-18 21:31:29 +00003623/** Formatted output of the arm_compute::experimental::dynamic_fusion::SoftmaxAttributes type.
3624 *
3625 * @param[out] os Output stream.
3626 * @param[in] softmax_attr arm_compute::experimental::dynamic_fusion::SoftmaxAttributes type to output.
3627 *
3628 * @return Modified output stream.
3629 */
3630inline ::std::ostream &operator<<(::std::ostream &os, const experimental::dynamic_fusion::SoftmaxAttributes &softmax_attr)
3631{
3632 os << "SofmtaxAttributes="
3633 << "["
3634 << "Beta=" << softmax_attr.beta() << ", "
3635 << "Is Log Softmax=" << softmax_attr.is_log_softmax() << ", "
3636 << "Axis=" << softmax_attr.axis() << "]";
3637 return os;
3638}
3639/** Formatted output of the arm_compute::experimental::dynamic_fusion::SoftmaxAttributes type.
3640 *
3641 * @param[in] softmax_attr arm_compute::experimental::dynamic_fusion::SoftmaxAttributes type to output.
3642 *
3643 * @return Formatted string.
3644 */
3645inline std::string to_string(const experimental::dynamic_fusion::SoftmaxAttributes &softmax_attr)
3646{
3647 std::stringstream str;
3648 str << softmax_attr;
3649 return str.str();
3650}
3651
Anthony Barbier6ff3b192017-09-04 18:44:23 +01003652} // namespace arm_compute
Anthony Barbier4dbc0a92018-08-27 13:39:47 +01003653
3654#endif /* __ARM_COMPUTE_TYPE_PRINTER_H__ */