blob: f55f72a4b842ba1f1d2048e9cbd9b355344ad8bf [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001/*
Gian Marco Iodiceab2bc732022-01-19 10:06:45 +00002 * Copyright (c) 2017-2022 Arm Limited.
Anthony Barbier6ff3b192017-09-04 18:44:23 +01003 *
4 * SPDX-License-Identifier: MIT
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
Anthony Barbier4dbc0a92018-08-27 13:39:47 +010024#ifndef __ARM_COMPUTE_TYPE_PRINTER_H__
25#define __ARM_COMPUTE_TYPE_PRINTER_H__
Anthony Barbier6ff3b192017-09-04 18:44:23 +010026
ramelg01cbbb0382021-09-17 17:36:57 +010027#ifdef ARM_COMPUTE_OPENCL_ENABLED
28#include "arm_compute/core/CL/ICLTensor.h"
29#endif /* ARM_COMPUTE_OPENCL_ENABLED */
30
Anthony Barbier6ff3b192017-09-04 18:44:23 +010031#include "arm_compute/core/Dimensions.h"
32#include "arm_compute/core/Error.h"
Michele Di Giorgiob8fc60f2018-04-25 11:58:07 +010033#include "arm_compute/core/GPUTarget.h"
morgolockaba2f912020-05-05 16:28:19 +010034#include "arm_compute/core/KernelDescriptors.h"
John Richardson25f23682017-11-27 14:35:09 +000035#include "arm_compute/core/Size2D.h"
John Richardsona36eae12017-09-26 16:55:59 +010036#include "arm_compute/core/Strides.h"
Georgios Pinitas3faea252017-10-30 14:13:50 +000037#include "arm_compute/core/TensorInfo.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010038#include "arm_compute/core/Types.h"
SiCongLi1af54162021-10-06 15:25:57 +010039#include "arm_compute/core/experimental/IPostOp.h"
SiCongLi31778612021-11-12 17:33:45 +000040#include "arm_compute/core/experimental/PostOps.h"
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +010041#include "arm_compute/runtime/CL/CLTunerTypes.h"
SiCong Lidb4a6c12021-02-05 09:30:57 +000042#include "arm_compute/runtime/CL/CLTypes.h"
ramelg013ae3d882021-09-12 23:07:47 +010043#include "arm_compute/runtime/FunctionDescriptors.h"
ramelg01cbbb0382021-09-17 17:36:57 +010044#include "arm_compute/runtime/common/LSTMParams.h"
SiCongLi31778612021-11-12 17:33:45 +000045#include "support/Cast.h"
Matthew Bentham758b5ba2020-03-05 23:37:48 +000046#include "support/StringSupport.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010047#include <ostream>
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010048#include <sstream>
49#include <string>
Anthony Barbier6ff3b192017-09-04 18:44:23 +010050
51namespace arm_compute
52{
Anthony Barbierb940fd62018-06-04 14:14:32 +010053/** Formatted output if arg is not null
54 *
55 * @param[in] arg Object to print
56 *
57 * @return String representing arg.
58 */
59template <typename T>
60std::string to_string_if_not_null(T *arg)
61{
62 if(arg == nullptr)
63 {
64 return "nullptr";
65 }
66 else
67 {
68 return to_string(*arg);
69 }
70}
Anthony Barbierb4670212018-05-18 16:55:39 +010071
ramelg014a6d9e82021-10-02 14:34:36 +010072/** Fallback method: try to use std::to_string:
73 *
74 * @param[in] val Value to convert to string
75 *
76 * @return String representing val.
77 */
78template <typename T>
79inline std::string to_string(const T &val)
80{
81 return support::cpp11::to_string(val);
82}
83
ramelg01b1ba1e32021-09-25 11:53:26 +010084/** Formatted output of a vector of objects.
85 *
ramelg014a6d9e82021-10-02 14:34:36 +010086 * @note: Using the overloaded to_string() instead of overloaded operator<<(), because to_string() functions are
87 * overloaded for all types, where two or more of them can use the same operator<<(), ITensor is an example.
88 *
ramelg01b1ba1e32021-09-25 11:53:26 +010089 * @param[out] os Output stream
90 * @param[in] args Vector of objects to print
91 *
92 * @return Modified output stream.
93 */
94template <typename T>
ramelg014a6d9e82021-10-02 14:34:36 +010095::std::ostream &operator<<(::std::ostream &os, const std::vector<T> &args)
ramelg01b1ba1e32021-09-25 11:53:26 +010096{
97 const size_t max_print_size = 5U;
98
99 os << "[";
100 bool first = true;
101 size_t i;
102 for(i = 0; i < args.size(); ++i)
103 {
104 if(i == max_print_size)
105 {
106 break;
107 }
108 if(first)
109 {
110 first = false;
111 }
112 else
113 {
114 os << ", ";
115 }
ramelg014a6d9e82021-10-02 14:34:36 +0100116 os << to_string(args[i]);
ramelg01b1ba1e32021-09-25 11:53:26 +0100117 }
118 if(i < args.size())
119 {
120 os << ", ...";
121 }
122 os << "]";
123 return os;
124}
125
ramelg014a6d9e82021-10-02 14:34:36 +0100126/** Formatted output of a vector of objects.
127 *
128 * @param[in] args Vector of objects to print
129 *
130 * @return String representing args.
131 */
132template <typename T>
133std::string to_string(const std::vector<T> &args)
134{
135 std::stringstream str;
136 str << args;
137 return str.str();
138}
139
SiCongLi1af54162021-10-06 15:25:57 +0100140/** @name (EXPERIMENTAL_POST_OPS)
141 * @{
142 */
143/** Formmated output of the @ref experimental::PostOpType type
144 *
145 * @param[out] os Output stream.
146 * @param[in] post_op_type Type to output.
147 *
148 * @return Modified output stream.
149 */
150inline ::std::ostream &operator<<(::std::ostream &os, experimental::PostOpType post_op_type)
151{
152 os << "type=";
153 switch(post_op_type)
154 {
155 case experimental::PostOpType::Activation:
156 {
157 os << "Activation";
158 break;
159 }
160 case experimental::PostOpType::Eltwise_Add:
161 {
162 os << "Eltwise_Add";
163 break;
164 }
ramelg016049eda2021-10-29 10:52:53 +0100165 case experimental::PostOpType::Eltwise_PRelu:
166 {
167 os << "Eltwise_PRelu";
168 break;
169 }
SiCongLi1af54162021-10-06 15:25:57 +0100170 default:
171 {
172 ARM_COMPUTE_ERROR("Unsupported PostOpType");
173 break;
174 }
175 }
176 return os;
177}
178/** Converts a @ref experimental::PostOpType to string
179 *
180 * @param[in] post_op_type PostOpType value to be converted
181 *
182 * @return String representing the corresponding PostOpType
183 */
184inline std::string to_string(experimental::PostOpType post_op_type)
185{
186 std::stringstream str;
187 str << post_op_type;
188 return str.str();
189}
190/** Formatted output of the @ref experimental::IPostOp type.
191 *
192 * @param[out] os Output stream.
193 * @param[in] post_op Type to output.
194 *
195 * @return Modified output stream.
196 */
197template <typename T>
198inline ::std::ostream &operator<<(::std::ostream &os, const experimental::IPostOp<T> &post_op)
199{
200 os << "<";
201 os << post_op.type() << ",";
SiCongLieb8bd812021-10-29 15:05:49 +0100202 os << "prev_dst_pos=" << post_op.prev_dst_pos() << ",";
SiCongLi1af54162021-10-06 15:25:57 +0100203 switch(post_op.type())
204 {
205 case experimental::PostOpType::Activation:
206 {
207 const auto _post_op = utils::cast::polymorphic_downcast<const experimental::PostOpAct<T> *>(&post_op);
208 os << "act_info=" << &(_post_op->_act_info);
209 break;
210 }
211 case experimental::PostOpType::Eltwise_Add:
212 {
213 const auto _post_op = utils::cast::polymorphic_downcast<const experimental::PostOpEltwiseAdd<T> *>(&post_op);
214 os << "convert_policy=" << _post_op->_policy;
215 break;
216 }
ramelg016049eda2021-10-29 10:52:53 +0100217 case experimental::PostOpType::Eltwise_PRelu:
218 {
219 const auto _post_op = utils::cast::polymorphic_downcast<const experimental::PostOpEltwisePRelu<T> *>(&post_op);
220 os << "convert_policy=" << _post_op->_policy;
221 break;
222 }
SiCongLi1af54162021-10-06 15:25:57 +0100223 default:
224 {
225 ARM_COMPUTE_ERROR("Unsupported PostOpType");
226 break;
227 }
228 }
229 os << ">";
230 return os;
231}
232/** Converts an @ref experimental::IPostOp to string
233 *
234 * @param[in] post_op IPostOp value to be converted
235 *
236 * @return String representing the corresponding IPostOp
237 */
238template <typename T>
239inline std::string to_string(const experimental::IPostOp<T> &post_op)
240{
241 std::stringstream str;
242 str << post_op;
243 return str.str();
244}
245/** Formatted output of the @ref experimental::PostOpList type.
246 *
247 * @param[out] os Output stream.
248 * @param[in] post_ops Type to output.
249 *
250 * @return Modified output stream.
251 */
252template <typename T>
253inline ::std::ostream &operator<<(::std::ostream &os, const experimental::PostOpList<T> &post_ops)
254{
255 os << "[";
256 for(const auto &post_op : post_ops.get_list())
257 {
258 os << *post_op << ",";
259 }
260 os << "]";
261 return os;
262}
263/** Converts a @ref experimental::PostOpList to string
264 *
265 * @param[in] post_ops PostOpList value to be converted
266 *
267 * @return String representing the corresponding PostOpList
268 */
269template <typename T>
270inline std::string to_string(const experimental::PostOpList<T> &post_ops)
271{
272 std::stringstream str;
273 str << post_ops;
274 return str.str();
275}
276/** @} */ // end of group (EXPERIMENTAL_POST_OPS)
277
Alex Gildayc357c472018-03-21 13:54:09 +0000278/** Formatted output of the Dimensions type.
279 *
280 * @param[out] os Output stream.
281 * @param[in] dimensions Type to output.
282 *
283 * @return Modified output stream.
284 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100285template <typename T>
286inline ::std::ostream &operator<<(::std::ostream &os, const Dimensions<T> &dimensions)
287{
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100288 if(dimensions.num_dimensions() > 0)
289 {
290 os << dimensions[0];
291
292 for(unsigned int d = 1; d < dimensions.num_dimensions(); ++d)
293 {
Freddie Liardetdd23f2a2021-06-17 13:30:11 +0100294 os << "," << dimensions[d];
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100295 }
296 }
297
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100298 return os;
299}
300
Alex Gildayc357c472018-03-21 13:54:09 +0000301/** Formatted output of the RoundingPolicy type.
302 *
303 * @param[out] os Output stream.
304 * @param[in] rounding_policy Type to output.
305 *
306 * @return Modified output stream.
307 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100308inline ::std::ostream &operator<<(::std::ostream &os, const RoundingPolicy &rounding_policy)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100309{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100310 switch(rounding_policy)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100311 {
Anthony Barbier2a07e182017-08-04 18:20:27 +0100312 case RoundingPolicy::TO_ZERO:
313 os << "TO_ZERO";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100314 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100315 case RoundingPolicy::TO_NEAREST_UP:
316 os << "TO_NEAREST_UP";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100317 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100318 case RoundingPolicy::TO_NEAREST_EVEN:
319 os << "TO_NEAREST_EVEN";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100320 break;
321 default:
322 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
323 }
324
325 return os;
326}
327
Alex Gildayc357c472018-03-21 13:54:09 +0000328/** Formatted output of the WeightsInfo type.
329 *
330 * @param[out] os Output stream.
331 * @param[in] weights_info Type to output.
332 *
333 * @return Modified output stream.
334 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100335inline ::std::ostream &operator<<(::std::ostream &os, const WeightsInfo &weights_info)
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100336{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100337 os << weights_info.are_reshaped() << ";";
338 os << weights_info.num_kernels() << ";" << weights_info.kernel_size().first << "," << weights_info.kernel_size().second;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100339
340 return os;
341}
342
Alex Gildayc357c472018-03-21 13:54:09 +0000343/** Formatted output of the ROIPoolingInfo type.
344 *
345 * @param[out] os Output stream.
346 * @param[in] pool_info Type to output.
347 *
348 * @return Modified output stream.
349 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100350inline ::std::ostream &operator<<(::std::ostream &os, const ROIPoolingLayerInfo &pool_info)
Sanghoon Lee70f82912017-08-24 14:21:24 +0100351{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100352 os << pool_info.pooled_width() << "x" << pool_info.pooled_height() << "~" << pool_info.spatial_scale();
Georgios Pinitasd9769582017-08-03 10:19:40 +0100353 return os;
354}
355
giuros0118870812018-09-13 09:31:40 +0100356/** Formatted output of the ROIPoolingInfo type.
357 *
358 * @param[in] pool_info Type to output.
359 *
360 * @return Formatted string.
361 */
362inline std::string to_string(const ROIPoolingLayerInfo &pool_info)
363{
364 std::stringstream str;
365 str << pool_info;
366 return str.str();
367}
368
morgolockaba2f912020-05-05 16:28:19 +0100369/** Formatted output of the GEMMKernelInfo type.
370 *
371 * @param[out] os Output stream.
372 * @param[in] gemm_info Type to output.
373 *
374 * @return Modified output stream.
375 */
376inline ::std::ostream &operator<<(::std::ostream &os, const GEMMKernelInfo &gemm_info)
377{
SiCongLi579ca842021-10-18 09:38:33 +0100378 os << "( m=" << gemm_info.m;
379 os << " n=" << gemm_info.n;
380 os << " k=" << gemm_info.k;
381 os << " depth_output_gemm3d=" << gemm_info.depth_output_gemm3d;
382 os << " reinterpret_input_as_3d=" << gemm_info.reinterpret_input_as_3d;
383 os << " broadcast_bias=" << gemm_info.broadcast_bias;
384 os << " fp_mixed_precision=" << gemm_info.fp_mixed_precision;
385 os << " mult_transpose1xW_width=" << gemm_info.mult_transpose1xW_width;
386 os << " mult_interleave4x4_height=" << gemm_info.mult_interleave4x4_height;
387 os << " a_offset=" << gemm_info.a_offset;
388 os << " b_offset=" << gemm_info.b_offset;
389 os << "post_ops=" << gemm_info.post_ops;
morgolockaba2f912020-05-05 16:28:19 +0100390 os << ")";
391 return os;
392}
393
394/** Formatted output of the GEMMLHSMatrixInfo type.
395 *
396 * @param[out] os Output stream.
397 * @param[in] gemm_info Type to output.
398 *
399 * @return Modified output stream.
400 */
401inline ::std::ostream &operator<<(::std::ostream &os, const GEMMLHSMatrixInfo &gemm_info)
402{
SiCongLi579ca842021-10-18 09:38:33 +0100403 os << "( m0=" << (unsigned int)gemm_info.m0 << " k0=" << gemm_info.k0 << " v0=" << gemm_info.v0 << " trans=" << gemm_info.transpose << " inter=" << gemm_info.interleave << "})";
morgolockaba2f912020-05-05 16:28:19 +0100404 return os;
405}
406
407/** Formatted output of the GEMMRHSMatrixInfo type.
408 *
409 * @param[out] os Output stream.
410 * @param[in] gemm_info Type to output.
411 *
412 * @return Modified output stream.
413 */
414inline ::std::ostream &operator<<(::std::ostream &os, const GEMMRHSMatrixInfo &gemm_info)
415{
SiCongLi579ca842021-10-18 09:38:33 +0100416 os << "( n0=" << (unsigned int)gemm_info.n0 << " k0=" << gemm_info.k0 << " h0=" << gemm_info.h0 << " trans=" << gemm_info.transpose << " inter=" << gemm_info.interleave << " exp_img=" <<
SiCong Lidb4a6c12021-02-05 09:30:57 +0000417 gemm_info.export_to_cl_image << "})";
morgolockaba2f912020-05-05 16:28:19 +0100418 return os;
419}
420
421/** Formatted output of the GEMMRHSMatrixInfo type.
422 *
423 * @param[in] gemm_info GEMMRHSMatrixInfo to output.
424 *
425 * @return Formatted string.
426 */
427inline std::string to_string(const GEMMRHSMatrixInfo &gemm_info)
428{
429 std::stringstream str;
430 str << gemm_info;
431 return str.str();
432}
433
434/** Formatted output of the GEMMLHSMatrixInfo type.
435 *
436 * @param[in] gemm_info GEMMLHSMatrixInfo to output.
437 *
438 * @return Formatted string.
439 */
440inline std::string to_string(const GEMMLHSMatrixInfo &gemm_info)
441{
442 std::stringstream str;
443 str << gemm_info;
444 return str.str();
445}
446
447/** Formatted output of the GEMMKernelInfo type.
448 *
449 * @param[in] gemm_info GEMMKernelInfo Type to output.
450 *
451 * @return Formatted string.
452 */
453inline std::string to_string(const GEMMKernelInfo &gemm_info)
454{
455 std::stringstream str;
456 str << gemm_info;
457 return str.str();
458}
459
giuros01c04a0e82018-10-03 12:44:35 +0100460/** Formatted output of the BoundingBoxTransformInfo type.
461 *
462 * @param[out] os Output stream.
463 * @param[in] bbox_info Type to output.
464 *
465 * @return Modified output stream.
466 */
467inline ::std::ostream &operator<<(::std::ostream &os, const BoundingBoxTransformInfo &bbox_info)
468{
469 auto weights = bbox_info.weights();
SiCongLi579ca842021-10-18 09:38:33 +0100470 os << "(" << bbox_info.img_width() << "x" << bbox_info.img_height() << ")~" << bbox_info.scale() << "(weights={" << weights[0] << ", " << weights[1] << ", " << weights[2] << ", " << weights[3] <<
giuros01c04a0e82018-10-03 12:44:35 +0100471 "})";
472 return os;
473}
474
Pablo Marquez Tellod208f4f2022-07-19 12:19:46 +0100475#if defined(ARM_COMPUTE_ENABLE_BF16)
Ramy Elgammal91780022022-07-20 14:57:37 +0100476inline ::std::ostream &operator<<(::std::ostream &os, const bfloat16 &v)
Pablo Marquez Tellod208f4f2022-07-19 12:19:46 +0100477{
478 std::stringstream str;
479 str << v;
480 os << str.str();
481 return os;
482}
Ramy Elgammal91780022022-07-20 14:57:37 +0100483#endif /* defined(ARM_COMPUTE_ENABLE_BF16) */
Pablo Marquez Tellod208f4f2022-07-19 12:19:46 +0100484
giuros01c04a0e82018-10-03 12:44:35 +0100485/** Formatted output of the BoundingBoxTransformInfo type.
486 *
487 * @param[in] bbox_info Type to output.
488 *
489 * @return Formatted string.
490 */
491inline std::string to_string(const BoundingBoxTransformInfo &bbox_info)
492{
493 std::stringstream str;
494 str << bbox_info;
495 return str.str();
496}
497
Manuel Bottini5209be52019-02-13 16:34:56 +0000498/** Formatted output of the ComputeAnchorsInfo type.
499 *
500 * @param[out] os Output stream.
501 * @param[in] anchors_info Type to output.
502 *
503 * @return Modified output stream.
504 */
505inline ::std::ostream &operator<<(::std::ostream &os, const ComputeAnchorsInfo &anchors_info)
506{
507 os << "(" << anchors_info.feat_width() << "x" << anchors_info.feat_height() << ")~" << anchors_info.spatial_scale();
508 return os;
509}
510
511/** Formatted output of the ComputeAnchorsInfo type.
512 *
513 * @param[in] anchors_info Type to output.
514 *
515 * @return Formatted string.
516 */
517inline std::string to_string(const ComputeAnchorsInfo &anchors_info)
518{
519 std::stringstream str;
520 str << anchors_info;
521 return str.str();
522}
523
524/** Formatted output of the GenerateProposalsInfo type.
525 *
526 * @param[out] os Output stream.
527 * @param[in] proposals_info Type to output.
528 *
529 * @return Modified output stream.
530 */
531inline ::std::ostream &operator<<(::std::ostream &os, const GenerateProposalsInfo &proposals_info)
532{
533 os << "(" << proposals_info.im_width() << "x" << proposals_info.im_height() << ")~" << proposals_info.im_scale();
534 return os;
535}
536
537/** Formatted output of the GenerateProposalsInfo type.
538 *
539 * @param[in] proposals_info Type to output.
540 *
541 * @return Formatted string.
542 */
543inline std::string to_string(const GenerateProposalsInfo &proposals_info)
544{
545 std::stringstream str;
546 str << proposals_info;
547 return str.str();
548}
549
Alex Gildayc357c472018-03-21 13:54:09 +0000550/** Formatted output of the QuantizationInfo type.
551 *
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100552 * @param[out] os Output stream.
553 * @param[in] qinfo Type to output.
Alex Gildayc357c472018-03-21 13:54:09 +0000554 *
555 * @return Modified output stream.
556 */
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100557inline ::std::ostream &operator<<(::std::ostream &os, const QuantizationInfo &qinfo)
Chunosovd621bca2017-11-03 17:33:15 +0700558{
Georgios Pinitas3d13af82019-06-04 13:04:16 +0100559 const UniformQuantizationInfo uqinfo = qinfo.uniform();
560 os << "Scale:" << uqinfo.scale << "~";
561 os << "Offset:" << uqinfo.offset;
Chunosovd621bca2017-11-03 17:33:15 +0700562 return os;
563}
564
Alex Gildayc357c472018-03-21 13:54:09 +0000565/** Formatted output of the QuantizationInfo type.
566 *
567 * @param[in] quantization_info Type to output.
568 *
569 * @return Formatted string.
570 */
Chunosovd621bca2017-11-03 17:33:15 +0700571inline std::string to_string(const QuantizationInfo &quantization_info)
572{
573 std::stringstream str;
574 str << quantization_info;
575 return str.str();
576}
577
Alex Gildayc357c472018-03-21 13:54:09 +0000578/** Formatted output of the activation function type.
579 *
580 * @param[out] os Output stream.
581 * @param[in] act_function Type to output.
582 *
583 * @return Modified output stream.
584 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100585inline ::std::ostream &operator<<(::std::ostream &os, const ActivationLayerInfo::ActivationFunction &act_function)
586{
587 switch(act_function)
588 {
589 case ActivationLayerInfo::ActivationFunction::ABS:
590 os << "ABS";
591 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100592 case ActivationLayerInfo::ActivationFunction::LINEAR:
593 os << "LINEAR";
594 break;
595 case ActivationLayerInfo::ActivationFunction::LOGISTIC:
596 os << "LOGISTIC";
597 break;
598 case ActivationLayerInfo::ActivationFunction::RELU:
599 os << "RELU";
600 break;
Georgios Pinitas579c0492017-07-12 16:12:12 +0100601 case ActivationLayerInfo::ActivationFunction::BOUNDED_RELU:
602 os << "BOUNDED_RELU";
603 break;
604 case ActivationLayerInfo::ActivationFunction::LEAKY_RELU:
605 os << "LEAKY_RELU";
606 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100607 case ActivationLayerInfo::ActivationFunction::SOFT_RELU:
608 os << "SOFT_RELU";
609 break;
610 case ActivationLayerInfo::ActivationFunction::SQRT:
611 os << "SQRT";
612 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100613 case ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU:
614 os << "LU_BOUNDED_RELU";
Kevin Petitd9f80712017-12-06 12:18:48 +0000615 break;
Georgios Pinitasfb0fdcd2019-08-22 17:10:04 +0100616 case ActivationLayerInfo::ActivationFunction::ELU:
617 os << "ELU";
618 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100619 case ActivationLayerInfo::ActivationFunction::SQUARE:
620 os << "SQUARE";
621 break;
622 case ActivationLayerInfo::ActivationFunction::TANH:
623 os << "TANH";
624 break;
Usama Arif6a98a6e2019-05-10 17:07:27 +0100625 case ActivationLayerInfo::ActivationFunction::IDENTITY:
626 os << "IDENTITY";
627 break;
morgolock07df3d42020-02-27 11:46:28 +0000628 case ActivationLayerInfo::ActivationFunction::HARD_SWISH:
629 os << "HARD_SWISH";
630 break;
Jonathan Deakind6b8a712022-08-23 11:44:18 +0100631 case ActivationLayerInfo::ActivationFunction::SWISH:
632 os << "SWISH";
633 break;
Murray Kornelsen926f5022022-07-13 21:22:39 -0400634 case ActivationLayerInfo::ActivationFunction::GELU:
635 os << "GELU";
636 break;
morgolock07df3d42020-02-27 11:46:28 +0000637
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100638 default:
639 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
640 }
641
642 return os;
643}
644
Alex Gildayc357c472018-03-21 13:54:09 +0000645/** Formatted output of the activation function info type.
646 *
SiCongLi1af54162021-10-06 15:25:57 +0100647 * @param[in] info ActivationLayerInfo to output.
Alex Gildayc357c472018-03-21 13:54:09 +0000648 *
649 * @return Formatted string.
650 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100651inline std::string to_string(const arm_compute::ActivationLayerInfo &info)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100652{
653 std::stringstream str;
Isabella Gottardi3f217ec2018-02-12 14:59:19 +0000654 if(info.enabled())
655 {
656 str << info.activation();
657 }
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100658 return str.str();
659}
660
SiCongLi1af54162021-10-06 15:25:57 +0100661/** Formatted output of the activation function info.
ramelg013ae3d882021-09-12 23:07:47 +0100662 *
SiCongLi1af54162021-10-06 15:25:57 +0100663 * @param[out] os Output stream.
664 * @param[in] info ActivationLayerInfo to output.
ramelg013ae3d882021-09-12 23:07:47 +0100665 *
666 * @return Formatted string.
667 */
SiCongLi1af54162021-10-06 15:25:57 +0100668inline ::std::ostream &operator<<(::std::ostream &os, const ActivationLayerInfo *info)
ramelg013ae3d882021-09-12 23:07:47 +0100669{
ramelg013ae3d882021-09-12 23:07:47 +0100670 if(info != nullptr)
671 {
ramelg013ae3d882021-09-12 23:07:47 +0100672 if(info->enabled())
673 {
SiCongLi1af54162021-10-06 15:25:57 +0100674 os << info->activation();
675 os << "(";
676 os << "VAL_A=" << info->a() << ",";
677 os << "VAL_B=" << info->b();
678 os << ")";
ramelg013ae3d882021-09-12 23:07:47 +0100679 }
SiCongLi1af54162021-10-06 15:25:57 +0100680 else
681 {
682 os << "disabled";
683 }
ramelg013ae3d882021-09-12 23:07:47 +0100684 }
SiCongLi1af54162021-10-06 15:25:57 +0100685 else
686 {
687 os << "nullptr";
688 }
689 return os;
ramelg013ae3d882021-09-12 23:07:47 +0100690}
691
Alex Gildayc357c472018-03-21 13:54:09 +0000692/** Formatted output of the activation function type.
693 *
694 * @param[in] function Type to output.
695 *
696 * @return Formatted string.
697 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100698inline std::string to_string(const arm_compute::ActivationLayerInfo::ActivationFunction &function)
699{
700 std::stringstream str;
701 str << function;
702 return str.str();
703}
704
Alex Gildayc357c472018-03-21 13:54:09 +0000705/** Formatted output of the NormType type.
706 *
707 * @param[out] os Output stream.
708 * @param[in] norm_type Type to output.
709 *
710 * @return Modified output stream.
711 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100712inline ::std::ostream &operator<<(::std::ostream &os, const NormType &norm_type)
713{
714 switch(norm_type)
715 {
716 case NormType::CROSS_MAP:
717 os << "CROSS_MAP";
718 break;
719 case NormType::IN_MAP_1D:
720 os << "IN_MAP_1D";
721 break;
722 case NormType::IN_MAP_2D:
723 os << "IN_MAP_2D";
724 break;
725 default:
726 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
727 }
728
729 return os;
730}
731
Alex Gildayc357c472018-03-21 13:54:09 +0000732/** Formatted output of @ref NormalizationLayerInfo.
733 *
734 * @param[in] info Type to output.
735 *
736 * @return Formatted string.
737 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100738inline std::string to_string(const arm_compute::NormalizationLayerInfo &info)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100739{
740 std::stringstream str;
Michalis Spyroud466c2d2018-01-30 10:54:39 +0000741 str << info.type() << ":NormSize=" << info.norm_size();
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100742 return str.str();
743}
744
Alex Gildayc357c472018-03-21 13:54:09 +0000745/** Formatted output of @ref NormalizationLayerInfo.
746 *
747 * @param[out] os Output stream.
748 * @param[in] info Type to output.
749 *
750 * @return Modified output stream.
751 */
Georgios Pinitas6f669f02017-09-26 12:32:57 +0100752inline ::std::ostream &operator<<(::std::ostream &os, const NormalizationLayerInfo &info)
753{
Michalis Spyroud466c2d2018-01-30 10:54:39 +0000754 os << info.type() << ":NormSize=" << info.norm_size();
Georgios Pinitas6f669f02017-09-26 12:32:57 +0100755 return os;
756}
757
Alex Gildayc357c472018-03-21 13:54:09 +0000758/** Formatted output of the PoolingType type.
759 *
760 * @param[out] os Output stream.
761 * @param[in] pool_type Type to output.
762 *
763 * @return Modified output stream.
764 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100765inline ::std::ostream &operator<<(::std::ostream &os, const PoolingType &pool_type)
766{
767 switch(pool_type)
768 {
769 case PoolingType::AVG:
770 os << "AVG";
771 break;
772 case PoolingType::MAX:
773 os << "MAX";
774 break;
Georgios Pinitascdf51452017-08-31 14:21:36 +0100775 case PoolingType::L2:
776 os << "L2";
777 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100778 default:
779 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
780 }
781
782 return os;
783}
784
Alex Gildayc357c472018-03-21 13:54:09 +0000785/** Formatted output of @ref PoolingLayerInfo.
786 *
787 * @param[out] os Output stream.
788 * @param[in] info Type to output.
789 *
790 * @return Modified output stream.
791 */
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100792inline ::std::ostream &operator<<(::std::ostream &os, const PoolingLayerInfo &info)
793{
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +0000794 os << info.pool_type;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100795
796 return os;
797}
798
Alex Gildayc357c472018-03-21 13:54:09 +0000799/** Formatted output of @ref RoundingPolicy.
800 *
801 * @param[in] rounding_policy Type to output.
802 *
803 * @return Formatted string.
804 */
John Richardsondd715f22017-09-18 16:10:48 +0100805inline std::string to_string(const RoundingPolicy &rounding_policy)
806{
807 std::stringstream str;
808 str << rounding_policy;
809 return str.str();
810}
811
Vidhya Sudhan Loganathand646ae12018-11-19 15:18:20 +0000812/** [Print DataLayout type] **/
Alex Gildayc357c472018-03-21 13:54:09 +0000813/** Formatted output of the DataLayout type.
814 *
815 * @param[out] os Output stream.
816 * @param[in] data_layout Type to output.
817 *
818 * @return Modified output stream.
819 */
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000820inline ::std::ostream &operator<<(::std::ostream &os, const DataLayout &data_layout)
821{
822 switch(data_layout)
823 {
824 case DataLayout::UNKNOWN:
825 os << "UNKNOWN";
826 break;
827 case DataLayout::NHWC:
828 os << "NHWC";
829 break;
830 case DataLayout::NCHW:
831 os << "NCHW";
832 break;
Adnan AlSinane4563a02021-09-01 15:32:03 +0100833 case DataLayout::NDHWC:
834 os << "NDHWC";
835 break;
Giorgio Arenac9fe9fc2021-10-06 12:54:29 +0100836 case DataLayout::NCDHW:
837 os << "NCDHW";
838 break;
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000839 default:
840 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
841 }
842
843 return os;
844}
845
Alex Gildayc357c472018-03-21 13:54:09 +0000846/** Formatted output of the DataLayout type.
847 *
848 * @param[in] data_layout Type to output.
849 *
850 * @return Formatted string.
851 */
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000852inline std::string to_string(const arm_compute::DataLayout &data_layout)
853{
854 std::stringstream str;
855 str << data_layout;
856 return str.str();
857}
Vidhya Sudhan Loganathand646ae12018-11-19 15:18:20 +0000858/** [Print DataLayout type] **/
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000859
Georgios Pinitase2220552018-07-20 13:23:44 +0100860/** Formatted output of the DataLayoutDimension type.
861 *
862 * @param[out] os Output stream.
863 * @param[in] data_layout_dim Data layout dimension to print.
864 *
865 * @return Modified output stream.
866 */
867inline ::std::ostream &operator<<(::std::ostream &os, const DataLayoutDimension &data_layout_dim)
868{
869 switch(data_layout_dim)
870 {
871 case DataLayoutDimension::WIDTH:
872 os << "WIDTH";
873 break;
874 case DataLayoutDimension::HEIGHT:
875 os << "HEIGHT";
876 break;
877 case DataLayoutDimension::CHANNEL:
878 os << "CHANNEL";
879 break;
Giorgio Arenac9fe9fc2021-10-06 12:54:29 +0100880 case DataLayoutDimension::DEPTH:
881 os << "DEPTH";
882 break;
Georgios Pinitase2220552018-07-20 13:23:44 +0100883 case DataLayoutDimension::BATCHES:
884 os << "BATCHES";
885 break;
886 default:
887 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
888 }
889 return os;
890}
891
Alex Gildayc357c472018-03-21 13:54:09 +0000892/** Formatted output of the DataType type.
893 *
894 * @param[out] os Output stream.
895 * @param[in] data_type Type to output.
896 *
897 * @return Modified output stream.
898 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100899inline ::std::ostream &operator<<(::std::ostream &os, const DataType &data_type)
900{
901 switch(data_type)
902 {
903 case DataType::UNKNOWN:
904 os << "UNKNOWN";
905 break;
906 case DataType::U8:
907 os << "U8";
908 break;
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100909 case DataType::QSYMM8:
910 os << "QSYMM8";
911 break;
Chunosovd621bca2017-11-03 17:33:15 +0700912 case DataType::QASYMM8:
913 os << "QASYMM8";
914 break;
Georgios Pinitas448a81f2019-11-21 14:10:25 +0000915 case DataType::QASYMM8_SIGNED:
916 os << "QASYMM8_SIGNED";
917 break;
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100918 case DataType::QSYMM8_PER_CHANNEL:
919 os << "QSYMM8_PER_CHANNEL";
920 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100921 case DataType::S8:
922 os << "S8";
923 break;
924 case DataType::U16:
925 os << "U16";
926 break;
927 case DataType::S16:
928 os << "S16";
929 break;
Manuel Bottini3689fcd2019-06-14 17:18:12 +0100930 case DataType::QSYMM16:
931 os << "QSYMM16";
932 break;
Michele Di Giorgio35ea9a72019-08-23 12:02:06 +0100933 case DataType::QASYMM16:
934 os << "QASYMM16";
935 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100936 case DataType::U32:
937 os << "U32";
938 break;
939 case DataType::S32:
940 os << "S32";
941 break;
942 case DataType::U64:
943 os << "U64";
944 break;
945 case DataType::S64:
946 os << "S64";
947 break;
Georgios Pinitase8291ac2020-02-26 09:58:13 +0000948 case DataType::BFLOAT16:
949 os << "BFLOAT16";
950 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100951 case DataType::F16:
952 os << "F16";
953 break;
954 case DataType::F32:
955 os << "F32";
956 break;
957 case DataType::F64:
958 os << "F64";
959 break;
960 case DataType::SIZET:
961 os << "SIZET";
962 break;
963 default:
964 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
965 }
966
967 return os;
968}
969
Alex Gildayc357c472018-03-21 13:54:09 +0000970/** Formatted output of the DataType type.
971 *
972 * @param[in] data_type Type to output.
973 *
974 * @return Formatted string.
975 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100976inline std::string to_string(const arm_compute::DataType &data_type)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100977{
978 std::stringstream str;
979 str << data_type;
980 return str.str();
981}
982
Alex Gildayc357c472018-03-21 13:54:09 +0000983/** Formatted output of the Format type.
984 *
985 * @param[out] os Output stream.
986 * @param[in] format Type to output.
987 *
988 * @return Modified output stream.
989 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100990inline ::std::ostream &operator<<(::std::ostream &os, const Format &format)
991{
992 switch(format)
993 {
994 case Format::UNKNOWN:
995 os << "UNKNOWN";
996 break;
997 case Format::U8:
998 os << "U8";
999 break;
1000 case Format::S16:
1001 os << "S16";
1002 break;
1003 case Format::U16:
1004 os << "U16";
1005 break;
1006 case Format::S32:
1007 os << "S32";
1008 break;
1009 case Format::U32:
1010 os << "U32";
1011 break;
1012 case Format::F16:
1013 os << "F16";
1014 break;
1015 case Format::F32:
1016 os << "F32";
1017 break;
1018 case Format::UV88:
1019 os << "UV88";
1020 break;
1021 case Format::RGB888:
1022 os << "RGB888";
1023 break;
1024 case Format::RGBA8888:
1025 os << "RGBA8888";
1026 break;
1027 case Format::YUV444:
1028 os << "YUV444";
1029 break;
1030 case Format::YUYV422:
1031 os << "YUYV422";
1032 break;
1033 case Format::NV12:
1034 os << "NV12";
1035 break;
1036 case Format::NV21:
1037 os << "NV21";
1038 break;
1039 case Format::IYUV:
1040 os << "IYUV";
1041 break;
1042 case Format::UYVY422:
1043 os << "UYVY422";
1044 break;
1045 default:
1046 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1047 }
1048
1049 return os;
1050}
1051
Alex Gildayc357c472018-03-21 13:54:09 +00001052/** Formatted output of the Format type.
1053 *
1054 * @param[in] format Type to output.
1055 *
1056 * @return Formatted string.
1057 */
Moritz Pflanzer7655a672017-09-23 11:57:33 +01001058inline std::string to_string(const Format &format)
1059{
1060 std::stringstream str;
1061 str << format;
1062 return str.str();
1063}
1064
Alex Gildayc357c472018-03-21 13:54:09 +00001065/** Formatted output of the Channel type.
1066 *
1067 * @param[out] os Output stream.
1068 * @param[in] channel Type to output.
1069 *
1070 * @return Modified output stream.
1071 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001072inline ::std::ostream &operator<<(::std::ostream &os, const Channel &channel)
1073{
1074 switch(channel)
1075 {
1076 case Channel::UNKNOWN:
1077 os << "UNKNOWN";
1078 break;
1079 case Channel::C0:
1080 os << "C0";
1081 break;
1082 case Channel::C1:
1083 os << "C1";
1084 break;
1085 case Channel::C2:
1086 os << "C2";
1087 break;
1088 case Channel::C3:
1089 os << "C3";
1090 break;
1091 case Channel::R:
1092 os << "R";
1093 break;
1094 case Channel::G:
1095 os << "G";
1096 break;
1097 case Channel::B:
1098 os << "B";
1099 break;
1100 case Channel::A:
1101 os << "A";
1102 break;
1103 case Channel::Y:
1104 os << "Y";
1105 break;
1106 case Channel::U:
1107 os << "U";
1108 break;
1109 case Channel::V:
1110 os << "V";
1111 break;
1112 default:
1113 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1114 }
1115
1116 return os;
1117}
1118
Alex Gildayc357c472018-03-21 13:54:09 +00001119/** Formatted output of the Channel type.
1120 *
1121 * @param[in] channel Type to output.
1122 *
1123 * @return Formatted string.
1124 */
Ioan-Cristian Szabo9414f642017-10-27 17:35:40 +01001125inline std::string to_string(const Channel &channel)
1126{
1127 std::stringstream str;
1128 str << channel;
1129 return str.str();
1130}
1131
Alex Gildayc357c472018-03-21 13:54:09 +00001132/** Formatted output of the BorderMode type.
1133 *
1134 * @param[out] os Output stream.
1135 * @param[in] mode Type to output.
1136 *
1137 * @return Modified output stream.
1138 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001139inline ::std::ostream &operator<<(::std::ostream &os, const BorderMode &mode)
1140{
1141 switch(mode)
1142 {
1143 case BorderMode::UNDEFINED:
1144 os << "UNDEFINED";
1145 break;
1146 case BorderMode::CONSTANT:
1147 os << "CONSTANT";
1148 break;
1149 case BorderMode::REPLICATE:
1150 os << "REPLICATE";
1151 break;
1152 default:
1153 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1154 }
1155
1156 return os;
1157}
1158
Alex Gildayc357c472018-03-21 13:54:09 +00001159/** Formatted output of the BorderSize type.
1160 *
1161 * @param[out] os Output stream.
1162 * @param[in] border Type to output.
1163 *
1164 * @return Modified output stream.
1165 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001166inline ::std::ostream &operator<<(::std::ostream &os, const BorderSize &border)
1167{
Moritz Pflanzerc87fbf82017-07-18 14:02:10 +01001168 os << border.top << ","
1169 << border.right << ","
1170 << border.bottom << ","
1171 << border.left;
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001172
1173 return os;
1174}
Anthony Barbier2a07e182017-08-04 18:20:27 +01001175
Giuseppe Rossinid7647d42018-07-17 18:13:13 +01001176/** Formatted output of the PaddingList type.
1177 *
1178 * @param[out] os Output stream.
1179 * @param[in] padding Type to output.
1180 *
1181 * @return Modified output stream.
1182 */
1183inline ::std::ostream &operator<<(::std::ostream &os, const PaddingList &padding)
1184{
1185 os << "{";
1186 for(auto const &p : padding)
1187 {
1188 os << "{" << p.first << "," << p.second << "}";
1189 }
1190 os << "}";
1191 return os;
1192}
1193
giuros013175fcf2018-11-21 09:59:17 +00001194/** Formatted output of the Multiples type.
1195 *
1196 * @param[out] os Output stream.
1197 * @param[in] multiples Type to output.
1198 *
1199 * @return Modified output stream.
1200 */
1201inline ::std::ostream &operator<<(::std::ostream &os, const Multiples &multiples)
1202{
1203 os << "(";
1204 for(size_t i = 0; i < multiples.size() - 1; i++)
1205 {
1206 os << multiples[i] << ", ";
1207 }
1208 os << multiples.back() << ")";
1209 return os;
1210}
1211
Alex Gildayc357c472018-03-21 13:54:09 +00001212/** Formatted output of the InterpolationPolicy type.
1213 *
1214 * @param[out] os Output stream.
1215 * @param[in] policy Type to output.
1216 *
1217 * @return Modified output stream.
1218 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001219inline ::std::ostream &operator<<(::std::ostream &os, const InterpolationPolicy &policy)
1220{
1221 switch(policy)
1222 {
1223 case InterpolationPolicy::NEAREST_NEIGHBOR:
1224 os << "NEAREST_NEIGHBOR";
1225 break;
1226 case InterpolationPolicy::BILINEAR:
1227 os << "BILINEAR";
1228 break;
1229 case InterpolationPolicy::AREA:
1230 os << "AREA";
1231 break;
1232 default:
1233 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1234 }
1235
1236 return os;
1237}
1238
Alex Gildayc357c472018-03-21 13:54:09 +00001239/** Formatted output of the SamplingPolicy type.
1240 *
1241 * @param[out] os Output stream.
1242 * @param[in] policy Type to output.
1243 *
1244 * @return Modified output stream.
1245 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +07001246inline ::std::ostream &operator<<(::std::ostream &os, const SamplingPolicy &policy)
1247{
1248 switch(policy)
1249 {
1250 case SamplingPolicy::CENTER:
1251 os << "CENTER";
1252 break;
1253 case SamplingPolicy::TOP_LEFT:
1254 os << "TOP_LEFT";
1255 break;
1256 default:
1257 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1258 }
1259
1260 return os;
1261}
1262
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001263/** Formatted output of the ITensorInfo type.
1264 *
1265 * @param[out] os Output stream.
1266 * @param[in] info Tensor information.
1267 *
1268 * @return Modified output stream.
1269 */
1270inline ::std::ostream &operator<<(std::ostream &os, const ITensorInfo *info)
1271{
Georgios Pinitasc6f95102021-03-30 10:03:01 +01001272 const DataType data_type = info->data_type();
1273 const DataLayout data_layout = info->data_layout();
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001274
1275 os << "Shape=" << info->tensor_shape() << ","
1276 << "DataLayout=" << string_from_data_layout(data_layout) << ","
ramelg014a6d9e82021-10-02 14:34:36 +01001277 << "DataType=" << string_from_data_type(data_type);
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001278
1279 if(is_data_type_quantized(data_type))
1280 {
ramelg01b1ba1e32021-09-25 11:53:26 +01001281 const QuantizationInfo qinfo = info->quantization_info();
1282 const auto scales = qinfo.scale();
1283 const auto offsets = qinfo.offset();
1284
ramelg014a6d9e82021-10-02 14:34:36 +01001285 os << ", QuantizationInfo={"
ramelg01b1ba1e32021-09-25 11:53:26 +01001286 << "scales.size=" << scales.size()
1287 << ", scale(s)=" << scales << ", ";
1288
1289 os << "offsets.size=" << offsets.size()
1290 << ", offset(s)=" << offsets << "}";
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001291 }
1292 return os;
1293}
1294
ramelg013ae3d882021-09-12 23:07:47 +01001295/** Formatted output of the const TensorInfo& type.
Alex Gildayc357c472018-03-21 13:54:09 +00001296 *
Anthony Barbier366628a2018-08-01 13:55:03 +01001297 * @param[out] os Output stream.
1298 * @param[in] info Type to output.
1299 *
1300 * @return Modified output stream.
1301 */
1302inline ::std::ostream &operator<<(::std::ostream &os, const TensorInfo &info)
1303{
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001304 os << &info;
Georgios Pinitasc6f95102021-03-30 10:03:01 +01001305 return os;
Anthony Barbier366628a2018-08-01 13:55:03 +01001306}
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001307
ramelg013ae3d882021-09-12 23:07:47 +01001308/** Formatted output of the const TensorInfo& type.
Anthony Barbier366628a2018-08-01 13:55:03 +01001309 *
Alex Gildayc357c472018-03-21 13:54:09 +00001310 * @param[in] info Type to output.
1311 *
1312 * @return Formatted string.
1313 */
Georgios Pinitas3faea252017-10-30 14:13:50 +00001314inline std::string to_string(const TensorInfo &info)
1315{
1316 std::stringstream str;
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001317 str << &info;
Georgios Pinitas3faea252017-10-30 14:13:50 +00001318 return str.str();
1319}
1320
ramelg013ae3d882021-09-12 23:07:47 +01001321/** Formatted output of the const ITensorInfo& type.
1322 *
1323 * @param[in] info Type to output.
1324 *
1325 * @return Formatted string.
1326 */
1327inline std::string to_string(const ITensorInfo &info)
1328{
1329 std::stringstream str;
1330 str << &info;
1331 return str.str();
1332}
1333
ramelg013ae3d882021-09-12 23:07:47 +01001334/** Formatted output of the const ITensorInfo* type.
1335 *
1336 * @param[in] info Type to output.
1337 *
1338 * @return Formatted string.
1339 */
Ramy Elgammale920d6a2021-08-19 22:10:30 +01001340inline std::string to_string(const ITensorInfo *info)
1341{
ramelg013ae3d882021-09-12 23:07:47 +01001342 std::string ret_str = "nullptr";
1343 if(info != nullptr)
1344 {
1345 std::stringstream str;
1346 str << info;
1347 ret_str = str.str();
1348 }
1349 return ret_str;
1350}
1351
ramelg01cbbb0382021-09-17 17:36:57 +01001352/** Formatted output of the ITensorInfo* type.
1353 *
1354 * @param[in] info Type to output.
1355 *
1356 * @return Formatted string.
1357 */
1358inline std::string to_string(ITensorInfo *info)
1359{
1360 return to_string(static_cast<const ITensorInfo *>(info));
1361}
1362
1363/** Formatted output of the ITensorInfo type obtained from const ITensor* type.
ramelg013ae3d882021-09-12 23:07:47 +01001364 *
1365 * @param[in] tensor Type to output.
1366 *
1367 * @return Formatted string.
1368 */
1369inline std::string to_string(const ITensor *tensor)
1370{
1371 std::string ret_str = "nullptr";
1372 if(tensor != nullptr)
1373 {
1374 std::stringstream str;
ramelg01cbbb0382021-09-17 17:36:57 +01001375 str << "ITensor->info(): " << tensor->info();
ramelg013ae3d882021-09-12 23:07:47 +01001376 ret_str = str.str();
1377 }
1378 return ret_str;
1379}
1380
ramelg01cbbb0382021-09-17 17:36:57 +01001381/** Formatted output of the ITensorInfo type obtained from the ITensor* type.
ramelg013ae3d882021-09-12 23:07:47 +01001382 *
1383 * @param[in] tensor Type to output.
1384 *
1385 * @return Formatted string.
1386 */
1387inline std::string to_string(ITensor *tensor)
1388{
ramelg01cbbb0382021-09-17 17:36:57 +01001389 return to_string(static_cast<const ITensor *>(tensor));
ramelg013ae3d882021-09-12 23:07:47 +01001390}
1391
ramelg01cbbb0382021-09-17 17:36:57 +01001392/** Formatted output of the ITensorInfo type obtained from the ITensor& type.
ramelg013ae3d882021-09-12 23:07:47 +01001393 *
1394 * @param[in] tensor Type to output.
1395 *
1396 * @return Formatted string.
1397 */
1398inline std::string to_string(ITensor &tensor)
1399{
Ramy Elgammale920d6a2021-08-19 22:10:30 +01001400 std::stringstream str;
ramelg01cbbb0382021-09-17 17:36:57 +01001401 str << "ITensor.info(): " << tensor.info();
Ramy Elgammale920d6a2021-08-19 22:10:30 +01001402 return str.str();
1403}
1404
ramelg01cbbb0382021-09-17 17:36:57 +01001405#ifdef ARM_COMPUTE_OPENCL_ENABLED
1406/** Formatted output of the ITensorInfo type obtained from the const ICLTensor& type.
1407 *
1408 * @param[in] cl_tensor Type to output.
1409 *
1410 * @return Formatted string.
1411 */
1412inline std::string to_string(const ICLTensor *cl_tensor)
1413{
1414 std::string ret_str = "nullptr";
1415 if(cl_tensor != nullptr)
1416 {
1417 std::stringstream str;
1418 str << "ICLTensor->info(): " << cl_tensor->info();
1419 ret_str = str.str();
1420 }
1421 return ret_str;
1422}
1423
1424/** Formatted output of the ITensorInfo type obtained from the ICLTensor& type.
1425 *
1426 * @param[in] cl_tensor Type to output.
1427 *
1428 * @return Formatted string.
1429 */
1430inline std::string to_string(ICLTensor *cl_tensor)
1431{
1432 return to_string(static_cast<const ICLTensor *>(cl_tensor));
1433}
1434#endif /* ARM_COMPUTE_OPENCL_ENABLED */
1435
Alex Gildayc357c472018-03-21 13:54:09 +00001436/** Formatted output of the Dimensions type.
1437 *
1438 * @param[in] dimensions Type to output.
1439 *
1440 * @return Formatted string.
1441 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001442template <typename T>
1443inline std::string to_string(const Dimensions<T> &dimensions)
1444{
1445 std::stringstream str;
1446 str << dimensions;
1447 return str.str();
1448}
1449
Alex Gildayc357c472018-03-21 13:54:09 +00001450/** Formatted output of the Strides type.
1451 *
1452 * @param[in] stride Type to output.
1453 *
1454 * @return Formatted string.
1455 */
John Richardsona36eae12017-09-26 16:55:59 +01001456inline std::string to_string(const Strides &stride)
1457{
1458 std::stringstream str;
1459 str << stride;
1460 return str.str();
1461}
1462
Alex Gildayc357c472018-03-21 13:54:09 +00001463/** Formatted output of the TensorShape type.
1464 *
1465 * @param[in] shape Type to output.
1466 *
1467 * @return Formatted string.
1468 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001469inline std::string to_string(const TensorShape &shape)
1470{
1471 std::stringstream str;
1472 str << shape;
1473 return str.str();
1474}
1475
Alex Gildayc357c472018-03-21 13:54:09 +00001476/** Formatted output of the Coordinates type.
1477 *
1478 * @param[in] coord Type to output.
1479 *
1480 * @return Formatted string.
1481 */
Abe Mbise925ca0f2017-10-02 19:16:33 +01001482inline std::string to_string(const Coordinates &coord)
1483{
1484 std::stringstream str;
1485 str << coord;
1486 return str.str();
1487}
1488
Anthony Barbierb940fd62018-06-04 14:14:32 +01001489/** Formatted output of the GEMMReshapeInfo type.
1490 *
1491 * @param[out] os Output stream.
1492 * @param[in] info Type to output.
1493 *
1494 * @return Modified output stream.
1495 */
1496inline ::std::ostream &operator<<(::std::ostream &os, const GEMMReshapeInfo &info)
1497{
1498 os << "{m=" << info.m() << ",";
1499 os << "n=" << info.n() << ",";
1500 os << "k=" << info.k() << ",";
1501 os << "mult_transpose1xW_width=" << info.mult_transpose1xW_width() << ",";
1502 os << "mult_interleave4x4_height=" << info.mult_interleave4x4_height();
1503 os << "}";
1504
1505 return os;
1506}
1507
1508/** Formatted output of the GEMMInfo type.
1509 *
1510 * @param[out] os Output stream.
1511 * @param[in] info Type to output.
1512 *
1513 * @return Modified output stream.
1514 */
1515inline ::std::ostream &operator<<(::std::ostream &os, const GEMMInfo &info)
1516{
1517 os << "{is_a_reshaped=" << info.is_a_reshaped() << ",";
1518 os << "is_b_reshaped=" << info.is_b_reshaped() << ",";
1519 os << "reshape_b_only_on_first_run=" << info.reshape_b_only_on_first_run() << ",";
Anthony Barbierb4670212018-05-18 16:55:39 +01001520 os << "depth_output_gemm3d=" << info.depth_output_gemm3d() << ",";
1521 os << "reinterpret_input_as_3d=" << info.reinterpret_input_as_3d() << ",";
1522 os << "retain_internal_weights=" << info.retain_internal_weights() << ",";
1523 os << "fp_mixed_precision=" << info.fp_mixed_precision() << ",";
1524 os << "broadcast_bias=" << info.broadcast_bias() << ",";
ramelg01cbbb0382021-09-17 17:36:57 +01001525 os << "pretranspose_B=" << info.pretranspose_B() << ",";
SiCongLi579ca842021-10-18 09:38:33 +01001526 os << "post_ops=" << info.post_ops() << "}";
Anthony Barbierb940fd62018-06-04 14:14:32 +01001527
1528 return os;
1529}
1530
1531/** Formatted output of the Window::Dimension type.
1532 *
1533 * @param[out] os Output stream.
1534 * @param[in] dim Type to output.
1535 *
1536 * @return Modified output stream.
1537 */
1538inline ::std::ostream &operator<<(::std::ostream &os, const Window::Dimension &dim)
1539{
1540 os << "{start=" << dim.start() << ", end=" << dim.end() << ", step=" << dim.step() << "}";
1541
1542 return os;
1543}
1544/** Formatted output of the Window type.
1545 *
1546 * @param[out] os Output stream.
1547 * @param[in] win Type to output.
1548 *
1549 * @return Modified output stream.
1550 */
1551inline ::std::ostream &operator<<(::std::ostream &os, const Window &win)
1552{
1553 os << "{";
1554 for(unsigned int i = 0; i < Coordinates::num_max_dimensions; i++)
1555 {
1556 if(i > 0)
1557 {
1558 os << ", ";
1559 }
1560 os << win[i];
1561 }
1562 os << "}";
1563
1564 return os;
1565}
1566
1567/** Formatted output of the WeightsInfo type.
1568 *
1569 * @param[in] info Type to output.
1570 *
1571 * @return Formatted string.
1572 */
1573inline std::string to_string(const WeightsInfo &info)
1574{
1575 std::stringstream str;
1576 str << info;
1577 return str.str();
1578}
1579
1580/** Formatted output of the GEMMReshapeInfo type.
1581 *
1582 * @param[in] info Type to output.
1583 *
1584 * @return Formatted string.
1585 */
1586inline std::string to_string(const GEMMReshapeInfo &info)
1587{
1588 std::stringstream str;
1589 str << info;
1590 return str.str();
1591}
1592
1593/** Formatted output of the GEMMInfo type.
1594 *
1595 * @param[in] info Type to output.
1596 *
1597 * @return Formatted string.
1598 */
1599inline std::string to_string(const GEMMInfo &info)
1600{
1601 std::stringstream str;
1602 str << info;
1603 return str.str();
1604}
1605
1606/** Formatted output of the Window::Dimension type.
1607 *
1608 * @param[in] dim Type to output.
1609 *
1610 * @return Formatted string.
1611 */
1612inline std::string to_string(const Window::Dimension &dim)
1613{
1614 std::stringstream str;
1615 str << dim;
1616 return str.str();
1617}
ramelg01cbbb0382021-09-17 17:36:57 +01001618/** Formatted output of the Window& type.
Anthony Barbierb940fd62018-06-04 14:14:32 +01001619 *
1620 * @param[in] win Type to output.
1621 *
1622 * @return Formatted string.
1623 */
1624inline std::string to_string(const Window &win)
1625{
1626 std::stringstream str;
1627 str << win;
1628 return str.str();
1629}
1630
ramelg01cbbb0382021-09-17 17:36:57 +01001631/** Formatted output of the Window* type.
1632 *
1633 * @param[in] win Type to output.
1634 *
1635 * @return Formatted string.
1636 */
1637inline std::string to_string(Window *win)
1638{
1639 std::string ret_str = "nullptr";
1640 if(win != nullptr)
1641 {
1642 std::stringstream str;
1643 str << *win;
1644 ret_str = str.str();
1645 }
1646 return ret_str;
1647}
1648
Alex Gildayc357c472018-03-21 13:54:09 +00001649/** Formatted output of the Rectangle type.
1650 *
1651 * @param[out] os Output stream.
1652 * @param[in] rect Type to output.
1653 *
1654 * @return Modified output stream.
1655 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001656inline ::std::ostream &operator<<(::std::ostream &os, const Rectangle &rect)
1657{
1658 os << rect.width << "x" << rect.height;
1659 os << "+" << rect.x << "+" << rect.y;
1660
1661 return os;
1662}
1663
Usama Arif8cf8c112019-03-14 15:36:54 +00001664/** Formatted output of the PaddingMode type.
1665 *
1666 * @param[out] os Output stream.
1667 * @param[in] mode Type to output.
1668 *
1669 * @return Modified output stream.
1670 */
1671inline ::std::ostream &operator<<(::std::ostream &os, const PaddingMode &mode)
1672{
1673 switch(mode)
1674 {
1675 case PaddingMode::CONSTANT:
1676 os << "CONSTANT";
1677 break;
1678 case PaddingMode::REFLECT:
1679 os << "REFLECT";
1680 break;
1681 case PaddingMode::SYMMETRIC:
1682 os << "SYMMETRIC";
1683 break;
1684 default:
1685 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1686 }
1687
1688 return os;
1689}
1690
1691/** Formatted output of the PaddingMode type.
1692 *
1693 * @param[in] mode Type to output.
1694 *
1695 * @return Formatted string.
1696 */
1697inline std::string to_string(const PaddingMode &mode)
1698{
1699 std::stringstream str;
1700 str << mode;
1701 return str.str();
1702}
1703
Alex Gildayc357c472018-03-21 13:54:09 +00001704/** Formatted output of the PadStrideInfo type.
1705 *
1706 * @param[out] os Output stream.
1707 * @param[in] pad_stride_info Type to output.
1708 *
1709 * @return Modified output stream.
1710 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001711inline ::std::ostream &operator<<(::std::ostream &os, const PadStrideInfo &pad_stride_info)
1712{
1713 os << pad_stride_info.stride().first << "," << pad_stride_info.stride().second;
1714 os << ";";
Jaroslaw Rzepeckia1ed41f2017-10-13 11:13:58 +01001715 os << pad_stride_info.pad_left() << "," << pad_stride_info.pad_right() << ","
1716 << pad_stride_info.pad_top() << "," << pad_stride_info.pad_bottom();
Anthony Barbier2a07e182017-08-04 18:20:27 +01001717
1718 return os;
1719}
1720
Alex Gildayc357c472018-03-21 13:54:09 +00001721/** Formatted output of the PadStrideInfo type.
1722 *
1723 * @param[in] pad_stride_info Type to output.
1724 *
1725 * @return Formatted string.
1726 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001727inline std::string to_string(const PadStrideInfo &pad_stride_info)
1728{
1729 std::stringstream str;
1730 str << pad_stride_info;
1731 return str.str();
1732}
1733
Alex Gildayc357c472018-03-21 13:54:09 +00001734/** Formatted output of the BorderMode type.
1735 *
1736 * @param[in] mode Type to output.
1737 *
1738 * @return Formatted string.
1739 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001740inline std::string to_string(const BorderMode &mode)
1741{
1742 std::stringstream str;
1743 str << mode;
1744 return str.str();
1745}
1746
Alex Gildayc357c472018-03-21 13:54:09 +00001747/** Formatted output of the BorderSize type.
1748 *
1749 * @param[in] border Type to output.
1750 *
1751 * @return Formatted string.
1752 */
John Richardsonb482ce12017-09-18 12:44:01 +01001753inline std::string to_string(const BorderSize &border)
1754{
1755 std::stringstream str;
1756 str << border;
1757 return str.str();
1758}
1759
Giuseppe Rossinid7647d42018-07-17 18:13:13 +01001760/** Formatted output of the PaddingList type.
1761 *
1762 * @param[in] padding Type to output.
1763 *
1764 * @return Formatted string.
1765 */
1766inline std::string to_string(const PaddingList &padding)
1767{
1768 std::stringstream str;
1769 str << padding;
1770 return str.str();
1771}
1772
giuros013175fcf2018-11-21 09:59:17 +00001773/** Formatted output of the Multiples type.
1774 *
1775 * @param[in] multiples Type to output.
1776 *
1777 * @return Formatted string.
1778 */
1779inline std::string to_string(const Multiples &multiples)
1780{
1781 std::stringstream str;
1782 str << multiples;
1783 return str.str();
1784}
1785
Alex Gildayc357c472018-03-21 13:54:09 +00001786/** Formatted output of the InterpolationPolicy type.
1787 *
1788 * @param[in] policy Type to output.
1789 *
1790 * @return Formatted string.
1791 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001792inline std::string to_string(const InterpolationPolicy &policy)
1793{
1794 std::stringstream str;
1795 str << policy;
1796 return str.str();
1797}
1798
Alex Gildayc357c472018-03-21 13:54:09 +00001799/** Formatted output of the SamplingPolicy type.
1800 *
1801 * @param[in] policy Type to output.
1802 *
1803 * @return Formatted string.
1804 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +07001805inline std::string to_string(const SamplingPolicy &policy)
1806{
1807 std::stringstream str;
1808 str << policy;
1809 return str.str();
1810}
1811
Alex Gildayc357c472018-03-21 13:54:09 +00001812/** Formatted output of the ConvertPolicy type.
1813 *
1814 * @param[out] os Output stream.
1815 * @param[in] policy Type to output.
1816 *
1817 * @return Modified output stream.
1818 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001819inline ::std::ostream &operator<<(::std::ostream &os, const ConvertPolicy &policy)
1820{
1821 switch(policy)
1822 {
1823 case ConvertPolicy::WRAP:
1824 os << "WRAP";
1825 break;
1826 case ConvertPolicy::SATURATE:
1827 os << "SATURATE";
1828 break;
1829 default:
1830 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1831 }
1832
1833 return os;
1834}
1835
1836inline std::string to_string(const ConvertPolicy &policy)
1837{
1838 std::stringstream str;
1839 str << policy;
1840 return str.str();
1841}
1842
giuros01164a2722018-11-20 18:34:46 +00001843/** Formatted output of the ArithmeticOperation type.
1844 *
1845 * @param[out] os Output stream.
1846 * @param[in] op Operation to output.
1847 *
1848 * @return Modified output stream.
1849 */
1850inline ::std::ostream &operator<<(::std::ostream &os, const ArithmeticOperation &op)
1851{
1852 switch(op)
1853 {
1854 case ArithmeticOperation::ADD:
1855 os << "ADD";
1856 break;
1857 case ArithmeticOperation::SUB:
1858 os << "SUB";
1859 break;
1860 case ArithmeticOperation::DIV:
1861 os << "DIV";
1862 break;
1863 case ArithmeticOperation::MAX:
1864 os << "MAX";
1865 break;
1866 case ArithmeticOperation::MIN:
1867 os << "MIN";
1868 break;
1869 case ArithmeticOperation::SQUARED_DIFF:
1870 os << "SQUARED_DIFF";
1871 break;
Usama Arif52c54f62019-05-14 10:22:36 +01001872 case ArithmeticOperation::POWER:
1873 os << "POWER";
1874 break;
giuros01164a2722018-11-20 18:34:46 +00001875 default:
1876 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1877 }
1878
1879 return os;
1880}
1881
1882/** Formatted output of the Arithmetic Operation
1883 *
1884 * @param[in] op Type to output.
1885 *
1886 * @return Formatted string.
1887 */
1888inline std::string to_string(const ArithmeticOperation &op)
1889{
1890 std::stringstream str;
1891 str << op;
1892 return str.str();
1893}
1894
Alex Gildayc357c472018-03-21 13:54:09 +00001895/** Formatted output of the Reduction Operations.
1896 *
1897 * @param[out] os Output stream.
1898 * @param[in] op Type to output.
1899 *
1900 * @return Modified output stream.
1901 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001902inline ::std::ostream &operator<<(::std::ostream &os, const ReductionOperation &op)
1903{
1904 switch(op)
1905 {
Michalis Spyrou7e9391b2018-10-05 14:49:28 +01001906 case ReductionOperation::SUM:
1907 os << "SUM";
1908 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +01001909 case ReductionOperation::SUM_SQUARE:
1910 os << "SUM_SQUARE";
1911 break;
Michalis Spyrou7e9391b2018-10-05 14:49:28 +01001912 case ReductionOperation::MEAN_SUM:
1913 os << "MEAN_SUM";
1914 break;
Michalis Spyrou7930db42018-11-22 17:36:28 +00001915 case ReductionOperation::ARG_IDX_MAX:
1916 os << "ARG_IDX_MAX";
1917 break;
1918 case ReductionOperation::ARG_IDX_MIN:
1919 os << "ARG_IDX_MIN";
1920 break;
Manuel Bottinib412fab2018-12-10 17:40:23 +00001921 case ReductionOperation::PROD:
1922 os << "PROD";
1923 break;
Usama Arifa4a08ad2019-05-20 12:38:33 +01001924 case ReductionOperation::MIN:
1925 os << "MIN";
1926 break;
Usama Arif28f0dd92019-05-20 13:44:34 +01001927 case ReductionOperation::MAX:
1928 os << "MAX";
1929 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +01001930 default:
1931 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1932 }
1933
1934 return os;
1935}
1936
Alex Gildayc357c472018-03-21 13:54:09 +00001937/** Formatted output of the Reduction Operations.
1938 *
1939 * @param[in] op Type to output.
1940 *
1941 * @return Formatted string.
1942 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001943inline std::string to_string(const ReductionOperation &op)
1944{
1945 std::stringstream str;
1946 str << op;
1947 return str.str();
1948}
1949
Georgios Pinitas7900a9e2018-11-23 11:44:58 +00001950/** Formatted output of the Comparison Operations.
1951 *
1952 * @param[out] os Output stream.
1953 * @param[in] op Type to output.
1954 *
1955 * @return Modified output stream.
1956 */
1957inline ::std::ostream &operator<<(::std::ostream &os, const ComparisonOperation &op)
1958{
1959 switch(op)
1960 {
1961 case ComparisonOperation::Equal:
1962 os << "Equal";
1963 break;
1964 case ComparisonOperation::NotEqual:
1965 os << "NotEqual";
1966 break;
1967 case ComparisonOperation::Greater:
1968 os << "Greater";
1969 break;
1970 case ComparisonOperation::GreaterEqual:
1971 os << "GreaterEqual";
1972 break;
1973 case ComparisonOperation::Less:
1974 os << "Less";
1975 break;
1976 case ComparisonOperation::LessEqual:
1977 os << "LessEqual";
1978 break;
1979 default:
1980 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1981 }
1982
1983 return os;
1984}
1985
Michalis Spyroue9362622018-11-23 17:41:37 +00001986/** Formatted output of the Elementwise unary Operations.
1987 *
1988 * @param[out] os Output stream.
1989 * @param[in] op Type to output.
1990 *
1991 * @return Modified output stream.
1992 */
1993inline ::std::ostream &operator<<(::std::ostream &os, const ElementWiseUnary &op)
1994{
1995 switch(op)
1996 {
1997 case ElementWiseUnary::RSQRT:
1998 os << "RSQRT";
1999 break;
2000 case ElementWiseUnary::EXP:
2001 os << "EXP";
2002 break;
Usama Arifeb312ef2019-05-13 17:45:54 +01002003 case ElementWiseUnary::NEG:
2004 os << "NEG";
2005 break;
Usama Arifac33d7e2019-05-20 14:21:40 +01002006 case ElementWiseUnary::LOG:
2007 os << "LOG";
2008 break;
ramelg01b1ba1e32021-09-25 11:53:26 +01002009 case ElementWiseUnary::SIN:
2010 os << "SIN";
2011 break;
2012 case ElementWiseUnary::ABS:
2013 os << "ABS";
2014 break;
Usama Arif6a4d5422019-05-24 14:53:59 +01002015 case ElementWiseUnary::ROUND:
2016 os << "ROUND";
2017 break;
ramelg01b1ba1e32021-09-25 11:53:26 +01002018 case ElementWiseUnary::LOGICAL_NOT:
2019 os << "LOGICAL_NOT";
2020 break;
Michalis Spyroue9362622018-11-23 17:41:37 +00002021 default:
2022 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2023 }
2024
2025 return os;
2026}
2027
Georgios Pinitas7900a9e2018-11-23 11:44:58 +00002028/** Formatted output of the Comparison Operations.
2029 *
2030 * @param[in] op Type to output.
2031 *
2032 * @return Formatted string.
2033 */
2034inline std::string to_string(const ComparisonOperation &op)
2035{
2036 std::stringstream str;
2037 str << op;
2038 return str.str();
2039}
2040
Michalis Spyroue9362622018-11-23 17:41:37 +00002041/** Formatted output of the Elementwise unary Operations.
2042 *
2043 * @param[in] op Type to output.
2044 *
2045 * @return Formatted string.
2046 */
2047inline std::string to_string(const ElementWiseUnary &op)
2048{
2049 std::stringstream str;
2050 str << op;
2051 return str.str();
2052}
2053
Alex Gildayc357c472018-03-21 13:54:09 +00002054/** Formatted output of the Norm Type.
2055 *
2056 * @param[in] type Type to output.
2057 *
2058 * @return Formatted string.
2059 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01002060inline std::string to_string(const NormType &type)
2061{
2062 std::stringstream str;
2063 str << type;
2064 return str.str();
2065}
2066
Alex Gildayc357c472018-03-21 13:54:09 +00002067/** Formatted output of the Pooling Type.
2068 *
2069 * @param[in] type Type to output.
2070 *
2071 * @return Formatted string.
2072 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01002073inline std::string to_string(const PoolingType &type)
2074{
2075 std::stringstream str;
2076 str << type;
2077 return str.str();
2078}
2079
Alex Gildayc357c472018-03-21 13:54:09 +00002080/** Formatted output of the Pooling Layer Info.
2081 *
2082 * @param[in] info Type to output.
2083 *
2084 * @return Formatted string.
2085 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01002086inline std::string to_string(const PoolingLayerInfo &info)
2087{
2088 std::stringstream str;
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +00002089 str << "{Type=" << info.pool_type << ","
Sang-Hoon Park11fedda2020-01-15 14:44:04 +00002090 << "DataLayout=" << info.data_layout << ","
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +00002091 << "IsGlobalPooling=" << info.is_global_pooling;
2092 if(!info.is_global_pooling)
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00002093 {
2094 str << ","
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +00002095 << "PoolSize=" << info.pool_size.width << "," << info.pool_size.height << ","
2096 << "PadStride=" << info.pad_stride_info;
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00002097 }
2098 str << "}";
Anthony Barbier2a07e182017-08-04 18:20:27 +01002099 return str.str();
2100}
2101
ramelg0137515692022-02-26 22:06:20 +00002102/** Formatted output of the Size3D type.
2103 *
2104 * @param[out] os Output stream
2105 * @param[in] size Type to output
2106 *
2107 * @return Modified output stream.
2108 */
2109inline ::std::ostream &operator<<(::std::ostream &os, const Size3D &size)
2110{
2111 os << size.width << "x" << size.height << "x" << size.depth;
2112
2113 return os;
2114}
2115
2116/** Formatted output of the Size3D type.
2117 *
2118 * @param[in] type Type to output
2119 *
2120 * @return Formatted string.
2121 */
2122inline std::string to_string(const Size3D &type)
2123{
2124 std::stringstream str;
2125 str << type;
2126 return str.str();
2127}
2128
2129/** Formatted output of the Padding3D type.
2130 *
2131 * @param[out] os Output stream.
2132 * @param[in] padding3d Padding info for 3D spatial dimension shape.
2133 *
2134 * @return Modified output stream.
2135 */
2136inline ::std::ostream &operator<<(::std::ostream &os, const Padding3D &padding3d)
2137{
2138 os << padding3d.left << "," << padding3d.right << ","
2139 << padding3d.top << "," << padding3d.bottom << ","
2140 << padding3d.front << "," << padding3d.back;
2141 return os;
2142}
2143
2144/** Converts a @ref Padding3D to string
2145 *
2146 * @param[in] padding3d Padding3D value to be converted
2147 *
2148 * @return String representing the corresponding Padding3D
2149 */
2150inline std::string to_string(const Padding3D &padding3d)
2151{
2152 std::stringstream str;
2153 str << padding3d;
2154 return str.str();
2155}
2156
2157/** Formatted output of the DimensionRoundingType type.
2158 *
2159 * @param[out] os Output stream.
2160 * @param[in] rounding_type DimensionRoundingType Dimension rounding type when down-scaling, or compute output shape of pooling(2D or 3D).
2161 *
2162 * @return Modified output stream.
2163 */
2164inline ::std::ostream &operator<<(::std::ostream &os, const DimensionRoundingType &rounding_type)
2165{
2166 switch(rounding_type)
2167 {
2168 case DimensionRoundingType::CEIL:
2169 os << "CEIL";
2170 break;
2171 case DimensionRoundingType::FLOOR:
2172 os << "FLOOR";
2173 break;
2174 default:
2175 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2176 }
2177 return os;
2178}
2179
2180/** Formatted output of the Pooling 3d Layer Info.
2181 *
2182 * @param[out] os Output stream.
2183 * @param[in] info Pooling 3D layer info to print to output stream.
2184 *
2185 * @return Modified output stream.
2186 */
2187inline ::std::ostream &operator<<(::std::ostream &os, const Pooling3dLayerInfo &info)
2188{
2189 os << "{Type=" << info.pool_type << ","
2190 << "IsGlobalPooling=" << info.is_global_pooling;
2191 if(!info.is_global_pooling)
2192 {
2193 os << ","
2194 << "PoolSize=" << info.pool_size << ", "
2195 << "Stride=" << info.stride << ", "
2196 << "Padding=" << info.padding << ", "
2197 << "Exclude Padding=" << info.exclude_padding << ", "
2198 << "fp_mixed_precision=" << info.fp_mixed_precision << ", "
2199 << "DimensionRoundingType=" << info.round_type;
2200 }
2201 os << "}";
2202 return os;
2203}
2204
2205/** Formatted output of the Pooling 3d Layer Info.
2206 *
2207 * @param[in] info Type to output.
2208 *
2209 * @return Formatted string.
2210 */
2211inline std::string to_string(const Pooling3dLayerInfo &info)
2212{
2213 std::stringstream str;
2214 str << info;
2215 return str.str();
2216}
2217
Michalis Spyrou6c7c38e2018-08-29 16:28:11 +01002218/** Formatted output of the PriorBoxLayerInfo.
2219 *
2220 * @param[in] info Type to output.
2221 *
2222 * @return Formatted string.
2223 */
2224inline std::string to_string(const PriorBoxLayerInfo &info)
2225{
2226 std::stringstream str;
2227 str << "{";
2228 str << "Clip:" << info.clip()
2229 << "Flip:" << info.flip()
2230 << "StepX:" << info.steps()[0]
2231 << "StepY:" << info.steps()[1]
2232 << "MinSizes:" << info.min_sizes().size()
2233 << "MaxSizes:" << info.max_sizes().size()
2234 << "ImgSizeX:" << info.img_size().x
2235 << "ImgSizeY:" << info.img_size().y
2236 << "Offset:" << info.offset()
2237 << "Variances:" << info.variances().size();
2238 str << "}";
2239 return str.str();
2240}
2241
Alex Gildayc357c472018-03-21 13:54:09 +00002242/** Formatted output of the Size2D type.
2243 *
2244 * @param[out] os Output stream
2245 * @param[in] size Type to output
2246 *
2247 * @return Modified output stream.
2248 */
John Richardson25f23682017-11-27 14:35:09 +00002249inline ::std::ostream &operator<<(::std::ostream &os, const Size2D &size)
2250{
2251 os << size.width << "x" << size.height;
2252
2253 return os;
2254}
2255
Alex Gildayc357c472018-03-21 13:54:09 +00002256/** Formatted output of the Size2D type.
2257 *
2258 * @param[in] type Type to output
2259 *
2260 * @return Formatted string.
2261 */
John Richardson25f23682017-11-27 14:35:09 +00002262inline std::string to_string(const Size2D &type)
2263{
2264 std::stringstream str;
2265 str << type;
2266 return str.str();
2267}
2268
Alex Gildayc357c472018-03-21 13:54:09 +00002269/** Formatted output of the ConvolutionMethod type.
2270 *
2271 * @param[out] os Output stream
2272 * @param[in] conv_method Type to output
2273 *
2274 * @return Modified output stream.
2275 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002276inline ::std::ostream &operator<<(::std::ostream &os, const ConvolutionMethod &conv_method)
2277{
2278 switch(conv_method)
2279 {
2280 case ConvolutionMethod::GEMM:
2281 os << "GEMM";
2282 break;
2283 case ConvolutionMethod::DIRECT:
2284 os << "DIRECT";
2285 break;
2286 case ConvolutionMethod::WINOGRAD:
2287 os << "WINOGRAD";
2288 break;
SiCongLid9287352021-11-03 19:01:22 +00002289 case ConvolutionMethod::FFT:
2290 os << "FFT";
2291 break;
2292 case ConvolutionMethod::GEMM_CONV2D:
2293 os << "GEMM_CONV2D";
2294 break;
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002295 default:
2296 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2297 }
2298
2299 return os;
2300}
2301
Alex Gildayc357c472018-03-21 13:54:09 +00002302/** Formatted output of the ConvolutionMethod type.
2303 *
2304 * @param[in] conv_method Type to output
2305 *
2306 * @return Formatted string.
2307 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002308inline std::string to_string(const ConvolutionMethod &conv_method)
2309{
2310 std::stringstream str;
2311 str << conv_method;
2312 return str.str();
2313}
2314
Alex Gildayc357c472018-03-21 13:54:09 +00002315/** Formatted output of the GPUTarget type.
2316 *
2317 * @param[out] os Output stream
2318 * @param[in] gpu_target Type to output
2319 *
2320 * @return Modified output stream.
2321 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002322inline ::std::ostream &operator<<(::std::ostream &os, const GPUTarget &gpu_target)
2323{
2324 switch(gpu_target)
2325 {
2326 case GPUTarget::GPU_ARCH_MASK:
2327 os << "GPU_ARCH_MASK";
2328 break;
Gian Marco Iodice3c4d0852022-07-11 12:09:45 +01002329 case GPUTarget::GPU_GENERATION_MASK:
2330 os << "GPU_GENERATION_MASK";
2331 break;
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002332 case GPUTarget::MIDGARD:
2333 os << "MIDGARD";
2334 break;
2335 case GPUTarget::BIFROST:
2336 os << "BIFROST";
2337 break;
Georgios Pinitasd5462ff2019-07-03 19:33:57 +01002338 case GPUTarget::VALHALL:
2339 os << "VALHALL";
2340 break;
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002341 case GPUTarget::T600:
2342 os << "T600";
2343 break;
2344 case GPUTarget::T700:
2345 os << "T700";
2346 break;
2347 case GPUTarget::T800:
2348 os << "T800";
2349 break;
Michalis Spyroua9676112018-02-22 18:07:43 +00002350 case GPUTarget::G71:
2351 os << "G71";
2352 break;
2353 case GPUTarget::G72:
2354 os << "G72";
2355 break;
2356 case GPUTarget::G51:
2357 os << "G51";
2358 break;
2359 case GPUTarget::G51BIG:
2360 os << "G51BIG";
2361 break;
2362 case GPUTarget::G51LIT:
2363 os << "G51LIT";
2364 break;
Gian Marco Iodice3c4d0852022-07-11 12:09:45 +01002365 case GPUTarget::G31:
2366 os << "G31";
2367 break;
Georgios Pinitasb03f7c52018-07-12 10:49:53 +01002368 case GPUTarget::G76:
2369 os << "G76";
Michalis Spyroua9676112018-02-22 18:07:43 +00002370 break;
Gian Marco Iodice3c4d0852022-07-11 12:09:45 +01002371 case GPUTarget::G52:
2372 os << "G52";
2373 break;
2374 case GPUTarget::G52LIT:
2375 os << "G52LIT";
2376 break;
Georgios Pinitasd5462ff2019-07-03 19:33:57 +01002377 case GPUTarget::G77:
2378 os << "G77";
Michalis Spyroua9676112018-02-22 18:07:43 +00002379 break;
Gian Marco Iodice3c4d0852022-07-11 12:09:45 +01002380 case GPUTarget::G57:
2381 os << "G57";
2382 break;
Georgios Pinitas4ffc42a2020-12-01 16:28:24 +00002383 case GPUTarget::G78:
2384 os << "G78";
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002385 break;
Gian Marco Iodice3c4d0852022-07-11 12:09:45 +01002386 case GPUTarget::G68:
2387 os << "G68";
2388 break;
2389 case GPUTarget::G78AE:
2390 os << "G78AE";
Pablo Marquez Tellob1496e62021-06-25 14:49:37 +01002391 break;
Gian Marco Iodiceab2bc732022-01-19 10:06:45 +00002392 case GPUTarget::G710:
2393 os << "G710";
Georgios Pinitasd5462ff2019-07-03 19:33:57 +01002394 break;
Gian Marco Iodice3c4d0852022-07-11 12:09:45 +01002395 case GPUTarget::G610:
2396 os << "G610";
2397 break;
2398 case GPUTarget::G510:
2399 os << "G510";
2400 break;
2401 case GPUTarget::G310:
2402 os << "G310";
2403 break;
Gunes Bayir4bfc70e2021-12-10 16:17:56 +00002404 case GPUTarget::G715:
2405 os << "G715";
2406 break;
2407 case GPUTarget::G615:
2408 os << "G615";
2409 break;
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002410 default:
2411 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2412 }
2413
2414 return os;
2415}
2416
Alex Gildayc357c472018-03-21 13:54:09 +00002417/** Formatted output of the GPUTarget type.
2418 *
2419 * @param[in] gpu_target Type to output
2420 *
2421 * @return Formatted string.
2422 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002423inline std::string to_string(const GPUTarget &gpu_target)
2424{
2425 std::stringstream str;
2426 str << gpu_target;
2427 return str.str();
2428}
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00002429
John Richardson8de92612018-02-22 14:09:31 +00002430/** Formatted output of the DetectionWindow type.
2431 *
2432 * @param[out] os Output stream
2433 * @param[in] detection_window Type to output
2434 *
2435 * @return Modified output stream.
2436 */
John Richardson684cb0f2018-01-09 11:17:00 +00002437inline ::std::ostream &operator<<(::std::ostream &os, const DetectionWindow &detection_window)
2438{
2439 os << "{x=" << detection_window.x << ","
2440 << "y=" << detection_window.y << ","
2441 << "width=" << detection_window.width << ","
2442 << "height=" << detection_window.height << ","
2443 << "idx_class=" << detection_window.idx_class << ","
2444 << "score=" << detection_window.score << "}";
2445
2446 return os;
2447}
2448
Isabella Gottardi05e56442018-11-16 11:26:52 +00002449/** Formatted output of the DetectionOutputLayerCodeType type.
2450 *
2451 * @param[out] os Output stream
2452 * @param[in] detection_code Type to output
2453 *
2454 * @return Modified output stream.
2455 */
2456inline ::std::ostream &operator<<(::std::ostream &os, const DetectionOutputLayerCodeType &detection_code)
2457{
2458 switch(detection_code)
2459 {
2460 case DetectionOutputLayerCodeType::CENTER_SIZE:
2461 os << "CENTER_SIZE";
2462 break;
2463 case DetectionOutputLayerCodeType::CORNER:
2464 os << "CORNER";
2465 break;
2466 case DetectionOutputLayerCodeType::CORNER_SIZE:
2467 os << "CORNER_SIZE";
2468 break;
2469 case DetectionOutputLayerCodeType::TF_CENTER:
2470 os << "TF_CENTER";
2471 break;
2472 default:
2473 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2474 }
2475
2476 return os;
2477}
2478/** Formatted output of the DetectionOutputLayerCodeType type.
2479 *
2480 * @param[in] detection_code Type to output
2481 *
2482 * @return Formatted string.
2483 */
2484inline std::string to_string(const DetectionOutputLayerCodeType &detection_code)
2485{
2486 std::stringstream str;
2487 str << detection_code;
2488 return str.str();
2489}
2490
2491/** Formatted output of the DetectionOutputLayerInfo type.
2492 *
2493 * @param[out] os Output stream
2494 * @param[in] detection_info Type to output
2495 *
2496 * @return Modified output stream.
2497 */
2498inline ::std::ostream &operator<<(::std::ostream &os, const DetectionOutputLayerInfo &detection_info)
2499{
2500 os << "{Classes=" << detection_info.num_classes() << ","
2501 << "ShareLocation=" << detection_info.share_location() << ","
2502 << "CodeType=" << detection_info.code_type() << ","
2503 << "VarianceEncodedInTarget=" << detection_info.variance_encoded_in_target() << ","
2504 << "KeepTopK=" << detection_info.keep_top_k() << ","
2505 << "NMSThreshold=" << detection_info.nms_threshold() << ","
2506 << "Eta=" << detection_info.eta() << ","
2507 << "BackgroundLabelId=" << detection_info.background_label_id() << ","
2508 << "ConfidenceThreshold=" << detection_info.confidence_threshold() << ","
2509 << "TopK=" << detection_info.top_k() << ","
2510 << "NumLocClasses=" << detection_info.num_loc_classes()
2511 << "}";
2512
2513 return os;
2514}
2515
2516/** Formatted output of the DetectionOutputLayerInfo type.
2517 *
2518 * @param[in] detection_info Type to output
2519 *
2520 * @return Formatted string.
2521 */
2522inline std::string to_string(const DetectionOutputLayerInfo &detection_info)
2523{
2524 std::stringstream str;
2525 str << detection_info;
2526 return str.str();
2527}
Isabella Gottardia7acb3c2019-01-08 13:48:44 +00002528/** Formatted output of the DetectionPostProcessLayerInfo type.
2529 *
2530 * @param[out] os Output stream
2531 * @param[in] detection_info Type to output
2532 *
2533 * @return Modified output stream.
2534 */
2535inline ::std::ostream &operator<<(::std::ostream &os, const DetectionPostProcessLayerInfo &detection_info)
2536{
2537 os << "{MaxDetections=" << detection_info.max_detections() << ","
2538 << "MaxClassesPerDetection=" << detection_info.max_classes_per_detection() << ","
2539 << "NmsScoreThreshold=" << detection_info.nms_score_threshold() << ","
2540 << "NmsIouThreshold=" << detection_info.iou_threshold() << ","
2541 << "NumClasses=" << detection_info.num_classes() << ","
2542 << "ScaleValue_y=" << detection_info.scale_value_y() << ","
2543 << "ScaleValue_x=" << detection_info.scale_value_x() << ","
2544 << "ScaleValue_h=" << detection_info.scale_value_h() << ","
2545 << "ScaleValue_w=" << detection_info.scale_value_w() << ","
2546 << "UseRegularNms=" << detection_info.use_regular_nms() << ","
2547 << "DetectionPerClass=" << detection_info.detection_per_class()
2548 << "}";
2549
2550 return os;
2551}
2552
2553/** Formatted output of the DetectionPostProcessLayerInfo type.
2554 *
2555 * @param[in] detection_info Type to output
2556 *
2557 * @return Formatted string.
2558 */
2559inline std::string to_string(const DetectionPostProcessLayerInfo &detection_info)
2560{
2561 std::stringstream str;
2562 str << detection_info;
2563 return str.str();
2564}
Georgios Pinitasc6f95102021-03-30 10:03:01 +01002565
John Richardson8de92612018-02-22 14:09:31 +00002566/** Formatted output of the DetectionWindow type.
2567 *
2568 * @param[in] detection_window Type to output
2569 *
2570 * @return Formatted string.
2571 */
2572inline std::string to_string(const DetectionWindow &detection_window)
2573{
2574 std::stringstream str;
2575 str << detection_window;
2576 return str.str();
2577}
2578
Michalis Spyrou6c7c38e2018-08-29 16:28:11 +01002579/** Formatted output of @ref PriorBoxLayerInfo.
2580 *
2581 * @param[out] os Output stream.
2582 * @param[in] info Type to output.
2583 *
2584 * @return Modified output stream.
2585 */
2586inline ::std::ostream &operator<<(::std::ostream &os, const PriorBoxLayerInfo &info)
2587{
2588 os << "Clip:" << info.clip()
2589 << "Flip:" << info.flip()
2590 << "StepX:" << info.steps()[0]
2591 << "StepY:" << info.steps()[1]
2592 << "MinSizes:" << info.min_sizes()
2593 << "MaxSizes:" << info.max_sizes()
2594 << "ImgSizeX:" << info.img_size().x
2595 << "ImgSizeY:" << info.img_size().y
2596 << "Offset:" << info.offset()
2597 << "Variances:" << info.variances();
2598
2599 return os;
2600}
2601
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00002602/** Formatted output of the WinogradInfo type. */
2603inline ::std::ostream &operator<<(::std::ostream &os, const WinogradInfo &info)
2604{
2605 os << "{OutputTileSize=" << info.output_tile_size << ","
2606 << "KernelSize=" << info.kernel_size << ","
2607 << "PadStride=" << info.convolution_info << ","
2608 << "OutputDataLayout=" << info.output_data_layout << "}";
2609
2610 return os;
2611}
2612
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00002613inline std::string to_string(const WinogradInfo &type)
2614{
2615 std::stringstream str;
2616 str << type;
2617 return str.str();
2618}
Anthony Barbier671a11e2018-07-06 15:11:36 +01002619
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +01002620/** Convert a CLTunerMode value to a string
2621 *
2622 * @param val CLTunerMode value to be converted
2623 *
2624 * @return String representing the corresponding CLTunerMode.
2625 */
2626inline std::string to_string(const CLTunerMode val)
2627{
2628 switch(val)
2629 {
2630 case CLTunerMode::EXHAUSTIVE:
2631 {
2632 return std::string("Exhaustive");
2633 }
2634 case CLTunerMode::NORMAL:
2635 {
2636 return std::string("Normal");
2637 }
2638 case CLTunerMode::RAPID:
2639 {
2640 return std::string("Rapid");
2641 }
2642 default:
2643 {
2644 ARM_COMPUTE_ERROR("Invalid tuner mode.");
2645 return std::string("UNDEFINED");
2646 }
2647 }
2648}
SiCong Lidb4a6c12021-02-05 09:30:57 +00002649/** Converts a @ref CLGEMMKernelType to string
2650 *
2651 * @param[in] val CLGEMMKernelType value to be converted
2652 *
2653 * @return String representing the corresponding CLGEMMKernelType
2654 */
2655inline std::string to_string(CLGEMMKernelType val)
2656{
2657 switch(val)
2658 {
SiCong Lidb4a6c12021-02-05 09:30:57 +00002659 case CLGEMMKernelType::NATIVE:
2660 {
2661 return "Native";
2662 }
2663 case CLGEMMKernelType::RESHAPED_ONLY_RHS:
2664 {
2665 return "Reshaped_Only_RHS";
2666 }
2667 case CLGEMMKernelType::RESHAPED:
2668 {
2669 return "Reshaped";
2670 }
2671 default:
2672 {
2673 return "Unknown";
2674 }
2675 }
2676}
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +01002677/** [Print CLTunerMode type] **/
2678/** Formatted output of the CLTunerMode type.
2679 *
2680 * @param[out] os Output stream.
2681 * @param[in] val CLTunerMode to output.
2682 *
2683 * @return Modified output stream.
2684 */
2685inline ::std::ostream &operator<<(::std::ostream &os, const CLTunerMode &val)
2686{
2687 os << to_string(val);
2688 return os;
2689}
2690
ramelg013ae3d882021-09-12 23:07:47 +01002691/** Formatted output of the ConvolutionInfo type.
2692 *
2693 * @param[out] os Output stream.
2694 * @param[in] conv_info ConvolutionInfo to output.
2695 *
2696 * @return Modified output stream.
2697 */
2698inline ::std::ostream &operator<<(::std::ostream &os, const ConvolutionInfo &conv_info)
2699{
SiCongLi579ca842021-10-18 09:38:33 +01002700 os << "{PadStrideInfo=" << conv_info.pad_stride_info << ", "
2701 << "depth_multiplier=" << conv_info.depth_multiplier << ", "
2702 << "act_info=" << to_string(conv_info.act_info) << ", "
2703 << "dilation=" << conv_info.dilation << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002704 return os;
2705}
2706
2707/** Converts a @ref ConvolutionInfo to string
2708 *
2709 * @param[in] info ConvolutionInfo value to be converted
2710 *
2711 * @return String representing the corresponding ConvolutionInfo
2712 */
2713inline std::string to_string(const ConvolutionInfo &info)
2714{
2715 std::stringstream str;
2716 str << info;
2717 return str.str();
2718}
2719
2720/** Formatted output of the FullyConnectedLayerInfo type.
2721 *
2722 * @param[out] os Output stream.
2723 * @param[in] layer_info FullyConnectedLayerInfo to output.
2724 *
2725 * @return Modified output stream.
2726 */
2727inline ::std::ostream &operator<<(::std::ostream &os, const FullyConnectedLayerInfo &layer_info)
2728{
SiCongLi579ca842021-10-18 09:38:33 +01002729 os << "{activation_info=" << to_string(layer_info.activation_info) << ", "
2730 << "weights_trained_layout=" << layer_info.weights_trained_layout << ", "
2731 << "transpose_weights=" << layer_info.transpose_weights << ", "
2732 << "are_weights_reshaped=" << layer_info.are_weights_reshaped << ", "
2733 << "retain_internal_weights=" << layer_info.retain_internal_weights << ", "
2734 << "constant_weights=" << layer_info.transpose_weights << ", "
2735 << "fp_mixed_precision=" << layer_info.fp_mixed_precision << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002736 return os;
2737}
2738
2739/** Converts a @ref FullyConnectedLayerInfo to string
2740 *
2741 * @param[in] info FullyConnectedLayerInfo value to be converted
2742 *
2743 * @return String representing the corresponding FullyConnectedLayerInfo
2744 */
2745inline std::string to_string(const FullyConnectedLayerInfo &info)
2746{
2747 std::stringstream str;
2748 str << info;
2749 return str.str();
2750}
2751
2752/** Formatted output of the GEMMLowpOutputStageType type.
2753 *
2754 * @param[out] os Output stream.
2755 * @param[in] gemm_type GEMMLowpOutputStageType to output.
2756 *
2757 * @return Modified output stream.
2758 */
2759inline ::std::ostream &operator<<(::std::ostream &os, const GEMMLowpOutputStageType &gemm_type)
2760{
2761 switch(gemm_type)
2762 {
2763 case GEMMLowpOutputStageType::NONE:
2764 os << "NONE";
2765 break;
2766 case GEMMLowpOutputStageType::QUANTIZE_DOWN:
2767 os << "QUANTIZE_DOWN";
2768 break;
2769 case GEMMLowpOutputStageType::QUANTIZE_DOWN_FIXEDPOINT:
2770 os << "QUANTIZE_DOWN_FIXEDPOINT";
2771 break;
2772 case GEMMLowpOutputStageType::QUANTIZE_DOWN_FLOAT:
2773 os << "QUANTIZE_DOWN_FLOAT";
2774 break;
2775 default:
2776 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2777 }
2778 return os;
2779}
2780
2781/** Converts a @ref GEMMLowpOutputStageType to string
2782 *
2783 * @param[in] gemm_type GEMMLowpOutputStageType value to be converted
2784 *
2785 * @return String representing the corresponding GEMMLowpOutputStageType
2786 */
2787inline std::string to_string(const GEMMLowpOutputStageType &gemm_type)
2788{
2789 std::stringstream str;
2790 str << gemm_type;
2791 return str.str();
2792}
2793
2794/** Formatted output of the GEMMLowpOutputStageInfo type.
2795 *
2796 * @param[out] os Output stream.
2797 * @param[in] gemm_info GEMMLowpOutputStageInfo to output.
2798 *
2799 * @return Modified output stream.
2800 */
2801inline ::std::ostream &operator<<(::std::ostream &os, const GEMMLowpOutputStageInfo &gemm_info)
2802{
SiCongLi579ca842021-10-18 09:38:33 +01002803 os << "{type=" << gemm_info.type << ", "
2804 << "gemlowp_offset=" << gemm_info.gemmlowp_offset << ", "
2805 << "gemmlowp_multiplier=" << gemm_info.gemmlowp_multiplier << ", "
2806 << "gemmlowp_shift=" << gemm_info.gemmlowp_shift << ", "
2807 << "gemmlowp_min_bound=" << gemm_info.gemmlowp_min_bound << ", "
2808 << "gemmlowp_max_bound=" << gemm_info.gemmlowp_max_bound << ", "
2809 << "gemmlowp_multipliers=" << gemm_info.gemmlowp_multiplier << ", "
2810 << "gemmlowp_shifts=" << gemm_info.gemmlowp_shift << ", "
2811 << "gemmlowp_real_multiplier=" << gemm_info.gemmlowp_real_multiplier << ", "
2812 << "is_quantized_per_channel=" << gemm_info.is_quantized_per_channel << ", "
2813 << "output_data_type=" << gemm_info.output_data_type << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002814 return os;
2815}
2816
2817/** Converts a @ref GEMMLowpOutputStageInfo to string
2818 *
2819 * @param[in] gemm_info GEMMLowpOutputStageInfo value to be converted
2820 *
2821 * @return String representing the corresponding GEMMLowpOutputStageInfo
2822 */
2823inline std::string to_string(const GEMMLowpOutputStageInfo &gemm_info)
2824{
2825 std::stringstream str;
2826 str << gemm_info;
2827 return str.str();
2828}
2829
2830/** Formatted output of the Conv2dInfo type.
2831 *
2832 * @param[out] os Output stream.
2833 * @param[in] conv_info Conv2dInfo to output.
2834 *
2835 * @return Modified output stream.
2836 */
2837inline ::std::ostream &operator<<(::std::ostream &os, const Conv2dInfo &conv_info)
2838{
SiCongLi579ca842021-10-18 09:38:33 +01002839 os << "{conv_info=" << conv_info.conv_info << ", "
2840 << "dilation=" << conv_info.dilation << ", "
2841 << "act_info=" << to_string(conv_info.act_info) << ", "
2842 << "enable_fast_math=" << conv_info.enable_fast_math << ", "
2843 << "num_groups=" << conv_info.num_groups << ","
2844 << "post_ops=" << conv_info.post_ops << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002845 return os;
2846}
2847
2848/** Converts a @ref Conv2dInfo to string
2849 *
2850 * @param[in] conv_info Conv2dInfo value to be converted
2851 *
2852 * @return String representing the corresponding Conv2dInfo
2853 */
2854inline std::string to_string(const Conv2dInfo &conv_info)
2855{
2856 std::stringstream str;
2857 str << conv_info;
2858 return str.str();
2859}
2860
2861/** Formatted output of the PixelValue type.
2862 *
2863 * @param[out] os Output stream.
2864 * @param[in] pixel_value PixelValue to output.
2865 *
2866 * @return Modified output stream.
2867 */
2868inline ::std::ostream &operator<<(::std::ostream &os, const PixelValue &pixel_value)
2869{
SiCongLi579ca842021-10-18 09:38:33 +01002870 os << "{value.u64=" << pixel_value.get<uint64_t>() << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002871 return os;
2872}
2873
2874/** Converts a @ref PixelValue to string
2875 *
2876 * @param[in] pixel_value PixelValue value to be converted
2877 *
2878 * @return String representing the corresponding PixelValue
2879 */
2880inline std::string to_string(const PixelValue &pixel_value)
2881{
2882 std::stringstream str;
2883 str << pixel_value;
2884 return str.str();
2885}
2886
2887/** Formatted output of the ScaleKernelInfo type.
2888 *
2889 * @param[out] os Output stream.
2890 * @param[in] scale_info ScaleKernelInfo to output.
2891 *
2892 * @return Modified output stream.
2893 */
2894inline ::std::ostream &operator<<(::std::ostream &os, const ScaleKernelInfo &scale_info)
2895{
SiCongLi579ca842021-10-18 09:38:33 +01002896 os << "{interpolation_policy=" << scale_info.interpolation_policy << ", "
2897 << "BorderMode=" << scale_info.border_mode << ", "
2898 << "PixelValue=" << scale_info.constant_border_value << ", "
2899 << "SamplingPolicy=" << scale_info.sampling_policy << ", "
2900 << "use_padding=" << scale_info.use_padding << ", "
2901 << "align_corners=" << scale_info.align_corners << ", "
2902 << "data_layout=" << scale_info.data_layout << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002903 return os;
2904}
2905
2906/** Converts a @ref ScaleKernelInfo to string
2907 *
2908 * @param[in] scale_info ScaleKernelInfo value to be converted
2909 *
2910 * @return String representing the corresponding ScaleKernelInfo
2911 */
2912inline std::string to_string(const ScaleKernelInfo &scale_info)
2913{
2914 std::stringstream str;
2915 str << scale_info;
2916 return str.str();
2917}
2918
2919/** Formatted output of the FFTDirection type.
2920 *
2921 * @param[out] os Output stream.
2922 * @param[in] fft_dir FFTDirection to output.
2923 *
2924 * @return Modified output stream.
2925 */
2926inline ::std::ostream &operator<<(::std::ostream &os, const FFTDirection &fft_dir)
2927{
2928 switch(fft_dir)
2929 {
2930 case FFTDirection::Forward:
2931 os << "Forward";
2932 break;
2933 case FFTDirection::Inverse:
2934 os << "Inverse";
2935 break;
2936 default:
2937 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2938 }
2939 return os;
2940}
2941
2942/** Converts a @ref FFT1DInfo to string
2943 *
2944 * @param[in] fft_dir FFT1DInfo value to be converted
2945 *
2946 * @return String representing the corresponding FFT1DInfo
2947 */
2948inline std::string to_string(const FFTDirection &fft_dir)
2949{
2950 std::stringstream str;
ramelg01cbbb0382021-09-17 17:36:57 +01002951 str << "{" << fft_dir << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002952 return str.str();
2953}
2954
2955/** Formatted output of the FFT1DInfo type.
2956 *
2957 * @param[out] os Output stream.
2958 * @param[in] fft1d_info FFT1DInfo to output.
2959 *
2960 * @return Modified output stream.
2961 */
2962inline ::std::ostream &operator<<(::std::ostream &os, const FFT1DInfo &fft1d_info)
2963{
SiCongLi579ca842021-10-18 09:38:33 +01002964 os << "{axis=" << fft1d_info.axis << ", "
2965 << "direction=" << fft1d_info.direction << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002966 return os;
2967}
2968
2969/** Converts a @ref FFT1DInfo to string
2970 *
2971 * @param[in] fft1d_info FFT1DInfo value to be converted
2972 *
2973 * @return String representing the corresponding FFT1DInfo
2974 */
2975inline std::string to_string(const FFT1DInfo &fft1d_info)
2976{
2977 std::stringstream str;
2978 str << fft1d_info;
2979 return str.str();
2980}
2981
2982/** Formatted output of the FFT2DInfo type.
2983 *
2984 * @param[out] os Output stream.
2985 * @param[in] fft2d_info FFT2DInfo to output.
2986 *
2987 * @return Modified output stream.
2988 */
2989inline ::std::ostream &operator<<(::std::ostream &os, const FFT2DInfo &fft2d_info)
2990{
SiCongLi579ca842021-10-18 09:38:33 +01002991 os << "{axis=" << fft2d_info.axis0 << ", "
2992 << "axis=" << fft2d_info.axis1 << ", "
2993 << "direction=" << fft2d_info.direction << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002994 return os;
2995}
2996
2997/** Converts a @ref FFT2DInfo to string
2998 *
2999 * @param[in] fft2d_info FFT2DInfo value to be converted
3000 *
3001 * @return String representing the corresponding FFT2DInfo
3002 */
3003inline std::string to_string(const FFT2DInfo &fft2d_info)
3004{
3005 std::stringstream str;
3006 str << fft2d_info;
3007 return str.str();
3008}
3009
3010/** Formatted output of the Coordinates2D type.
3011 *
3012 * @param[out] os Output stream.
3013 * @param[in] coord_2d Coordinates2D to output.
3014 *
3015 * @return Modified output stream.
3016 */
3017inline ::std::ostream &operator<<(::std::ostream &os, const Coordinates2D &coord_2d)
3018{
SiCongLi579ca842021-10-18 09:38:33 +01003019 os << "{x=" << coord_2d.x << ", "
3020 << "y=" << coord_2d.y << "}";
ramelg013ae3d882021-09-12 23:07:47 +01003021 return os;
3022}
3023
3024/** Converts a @ref Coordinates2D to string
3025 *
3026 * @param[in] coord_2d Coordinates2D value to be converted
3027 *
3028 * @return String representing the corresponding Coordinates2D
3029 */
3030inline std::string to_string(const Coordinates2D &coord_2d)
3031{
3032 std::stringstream str;
3033 str << coord_2d;
3034 return str.str();
3035}
3036
3037/** Formatted output of the FuseBatchNormalizationType type.
3038 *
3039 * @param[out] os Output stream.
3040 * @param[in] fuse_type FuseBatchNormalizationType to output.
3041 *
3042 * @return Modified output stream.
3043 */
3044inline ::std::ostream &operator<<(::std::ostream &os, const FuseBatchNormalizationType &fuse_type)
3045{
3046 switch(fuse_type)
3047 {
3048 case FuseBatchNormalizationType::CONVOLUTION:
3049 os << "CONVOLUTION";
3050 break;
3051 case FuseBatchNormalizationType::DEPTHWISECONVOLUTION:
3052 os << "DEPTHWISECONVOLUTION";
3053 break;
3054 default:
3055 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
3056 }
3057 return os;
3058}
3059
3060/** Converts a @ref FuseBatchNormalizationType to string
3061 *
3062 * @param[in] fuse_type FuseBatchNormalizationType value to be converted
3063 *
3064 * @return String representing the corresponding FuseBatchNormalizationType
3065 */
3066inline std::string to_string(const FuseBatchNormalizationType &fuse_type)
3067{
3068 std::stringstream str;
3069 str << fuse_type;
3070 return str.str();
3071}
3072
ramelg01cbbb0382021-09-17 17:36:57 +01003073/** Formatted output of the SoftmaxKernelInfo type.
3074 *
3075 * @param[out] os Output stream.
3076 * @param[in] info SoftmaxKernelInfo to output.
3077 *
3078 * @return Modified output stream.
3079 */
3080inline ::std::ostream &operator<<(::std::ostream &os, const SoftmaxKernelInfo &info)
3081{
SiCongLi579ca842021-10-18 09:38:33 +01003082 os << "{beta=" << info.beta << ", "
3083 << "is_log=" << info.is_log << ", "
3084 << "input_data_type=" << info.input_data_type << ", "
3085 << "axis=" << info.axis << "}";
ramelg01cbbb0382021-09-17 17:36:57 +01003086 return os;
3087}
3088
3089/** Converts a @ref SoftmaxKernelInfo to string
3090 *
3091 * @param[in] info SoftmaxKernelInfo value to be converted
3092 *
3093 * @return String representing the corresponding SoftmaxKernelInfo
3094 */
3095inline std::string to_string(const SoftmaxKernelInfo &info)
3096{
3097 std::stringstream str;
3098 str << info;
3099 return str.str();
3100}
3101
3102/** Formatted output of the ScaleKernelInfo type.
3103 *
3104 * @param[out] os Output stream.
3105 * @param[in] lstm_params LSTMParams to output.
3106 *
3107 * @return Modified output stream.
3108 */
3109template <typename T>
ramelg014a6d9e82021-10-02 14:34:36 +01003110::std::ostream &operator<<(::std::ostream &os, const LSTMParams<T> &lstm_params)
ramelg01cbbb0382021-09-17 17:36:57 +01003111{
ramelg014a6d9e82021-10-02 14:34:36 +01003112 os << "{input_to_input_weights=" << to_string(lstm_params.input_to_input_weights()) << ", "
3113 << "recurrent_to_input_weights=" << to_string(lstm_params.recurrent_to_input_weights()) << ", "
3114 << "cell_to_input_weights=" << to_string(lstm_params.cell_to_input_weights()) << ", "
3115 << "input_gate_bias=" << to_string(lstm_params.input_gate_bias()) << ", "
3116 << "cell_to_forget_weights=" << to_string(lstm_params.cell_to_forget_weights()) << ", "
3117 << "cell_to_output_weights=" << to_string(lstm_params.cell_to_output_weights()) << ", "
3118 << "projection_weights=" << to_string(lstm_params.projection_weights()) << ", "
3119 << "projection_bias=" << to_string(lstm_params.projection_bias()) << ", "
3120 << "input_layer_norm_weights=" << to_string(lstm_params.input_layer_norm_weights()) << ", "
3121 << "forget_layer_norm_weights=" << to_string(lstm_params.forget_layer_norm_weights()) << ", "
3122 << "cell_layer_norm_weights=" << to_string(lstm_params.cell_layer_norm_weights()) << ", "
3123 << "output_layer_norm_weights=" << to_string(lstm_params.output_layer_norm_weights()) << ", "
ramelg01cbbb0382021-09-17 17:36:57 +01003124 << "cell_clip=" << lstm_params.cell_clip() << ", "
3125 << "projection_clip=" << lstm_params.projection_clip() << ", "
3126 << "input_intermediate_scale=" << lstm_params.input_intermediate_scale() << ", "
3127 << "forget_intermediate_scale=" << lstm_params.forget_intermediate_scale() << ", "
3128 << "cell_intermediate_scale=" << lstm_params.cell_intermediate_scale() << ", "
3129 << "hidden_state_zero=" << lstm_params.hidden_state_zero() << ", "
3130 << "hidden_state_scale=" << lstm_params.hidden_state_scale() << ", "
3131 << "has_peephole_opt=" << lstm_params.has_peephole_opt() << ", "
3132 << "has_projection=" << lstm_params.has_projection() << ", "
3133 << "has_cifg_opt=" << lstm_params.has_cifg_opt() << ", "
3134 << "use_layer_norm=" << lstm_params.use_layer_norm() << "}";
3135 return os;
3136}
3137
3138/** Converts a @ref LSTMParams to string
3139 *
3140 * @param[in] lstm_params LSTMParams<T> value to be converted
3141 *
3142 * @return String representing the corresponding LSTMParams
3143 */
3144template <typename T>
ramelg014a6d9e82021-10-02 14:34:36 +01003145std::string to_string(const LSTMParams<T> &lstm_params)
ramelg01cbbb0382021-09-17 17:36:57 +01003146{
3147 std::stringstream str;
3148 str << lstm_params;
3149 return str.str();
3150}
3151
3152/** Converts a @ref LSTMParams to string
3153 *
3154 * @param[in] num uint8_t value to be converted
3155 *
3156 * @return String representing the corresponding uint8_t
3157 */
3158inline std::string to_string(const uint8_t num)
3159{
3160 // Explicity cast the uint8_t to signed integer and call the corresponding overloaded to_string() function.
3161 return ::std::to_string(static_cast<int>(num));
3162}
3163
ramelg014a6d9e82021-10-02 14:34:36 +01003164/** Available non maxima suppression types */
3165/** Formatted output of the NMSType type.
3166 *
3167 * @param[out] os Output stream.
3168 * @param[in] nms_type NMSType to output.
3169 *
3170 * @return Modified output stream.
3171 */
3172inline ::std::ostream &operator<<(::std::ostream &os, const NMSType &nms_type)
3173{
3174 switch(nms_type)
3175 {
3176 case NMSType::LINEAR:
3177 os << "LINEAR";
3178 break;
3179 case NMSType::GAUSSIAN:
3180 os << "GAUSSIAN";
3181 break;
3182 case NMSType::ORIGINAL:
3183 os << "ORIGINAL";
3184 break;
3185 default:
3186 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
3187 }
3188 return os;
3189}
3190
3191/** Converts a @ref NMSType to string
3192 *
3193 * @param[in] nms_type NMSType value to be converted
3194 *
3195 * @return String representing the corresponding NMSType
3196 */
3197inline std::string to_string(const NMSType nms_type)
3198{
3199 std::stringstream str;
3200 str << nms_type;
3201 return str.str();
3202}
3203
3204/** Formatted output of the BoxNMSLimitInfo type.
3205 *
3206 * @param[out] os Output stream.
3207 * @param[in] info BoxNMSLimitInfo to output.
3208 *
3209 * @return Modified output stream.
3210 */
3211inline ::std::ostream &operator<<(::std::ostream &os, const BoxNMSLimitInfo &info)
3212{
SiCongLi579ca842021-10-18 09:38:33 +01003213 os << "{score_thresh=" << info.score_thresh() << ", "
3214 << "nms=" << info.nms() << ", "
3215 << "detections_per_im=" << info.detections_per_im() << ", "
3216 << "soft_nms_enabled=" << info.soft_nms_enabled() << ", "
3217 << "soft_nms_min_score_thres=" << info.soft_nms_min_score_thres() << ", "
3218 << "suppress_size=" << info.suppress_size() << ", "
3219 << "min_size=" << info.min_size() << ", "
3220 << "im_width=" << info.im_width() << ", "
3221 << "im_height=" << info.im_height() << "}";
ramelg014a6d9e82021-10-02 14:34:36 +01003222 return os;
3223}
3224
3225/** Converts a @ref BoxNMSLimitInfo to string
3226 *
3227 * @param[in] info BoxNMSLimitInfo value to be converted
3228 *
3229 * @return String representing the corresponding BoxNMSLimitInfo
3230 */
3231inline std::string to_string(const BoxNMSLimitInfo &info)
3232{
3233 std::stringstream str;
3234 str << info;
3235 return str.str();
3236}
3237
Giorgio Arena945ae9e2021-10-13 11:13:04 +01003238/** Converts a @ref DimensionRoundingType to string
3239 *
3240 * @param[in] rounding_type DimensionRoundingType value to be converted
3241 *
3242 * @return String representing the corresponding DimensionRoundingType
3243 */
3244inline std::string to_string(const DimensionRoundingType &rounding_type)
3245{
3246 std::stringstream str;
3247 str << rounding_type;
3248 return str.str();
3249}
3250
Giorgio Arena945ae9e2021-10-13 11:13:04 +01003251/** Formatted output of the Conv3dInfo type.
3252 *
3253 * @param[out] os Output stream.
3254 * @param[in] conv3d_info Type to output.
3255 *
3256 * @return Modified output stream.
3257 */
3258inline ::std::ostream &operator<<(::std::ostream &os, const Conv3dInfo &conv3d_info)
3259{
3260 os << conv3d_info.stride;
3261 os << ";";
3262 os << conv3d_info.padding;
3263 os << ";";
3264 os << to_string(conv3d_info.act_info);
3265 os << ";";
3266 os << conv3d_info.dilation;
3267 os << ";";
3268 os << conv3d_info.round_type;
3269 os << ";";
3270 os << conv3d_info.enable_fast_math;
3271
3272 return os;
3273}
3274
3275/** Formatted output of the Conv3dInfo type.
3276 *
3277 * @param[in] conv3d_info Type to output.
3278 *
3279 * @return Formatted string.
3280 */
3281inline std::string to_string(const Conv3dInfo &conv3d_info)
3282{
3283 std::stringstream str;
3284 str << conv3d_info;
3285 return str.str();
3286}
3287
Ramy Elgammal91780022022-07-20 14:57:37 +01003288/** Formatted output of the arm_compute::WeightFormat type.
3289 *
3290 * @param[in] wf arm_compute::WeightFormat Type to output.
3291 *
3292 * @return Formatted string.
3293 */
3294inline std::string to_string(const WeightFormat wf)
Francesco Petrogalli553f6952022-06-30 10:22:01 +00003295{
Ramy Elgammal91780022022-07-20 14:57:37 +01003296#define __CASE_WEIGHT_FORMAT(wf) \
3297case WeightFormat::wf: \
3298 return #wf;
3299 switch(wf)
3300 {
3301 __CASE_WEIGHT_FORMAT(UNSPECIFIED)
3302 __CASE_WEIGHT_FORMAT(ANY)
3303 __CASE_WEIGHT_FORMAT(OHWI)
3304 __CASE_WEIGHT_FORMAT(OHWIo2)
3305 __CASE_WEIGHT_FORMAT(OHWIo4)
3306 __CASE_WEIGHT_FORMAT(OHWIo8)
3307 __CASE_WEIGHT_FORMAT(OHWIo16)
3308 __CASE_WEIGHT_FORMAT(OHWIo32)
3309 __CASE_WEIGHT_FORMAT(OHWIo64)
3310 __CASE_WEIGHT_FORMAT(OHWIo128)
3311 __CASE_WEIGHT_FORMAT(OHWIo4i2)
3312 __CASE_WEIGHT_FORMAT(OHWIo4i2_bf16)
3313 __CASE_WEIGHT_FORMAT(OHWIo8i2)
3314 __CASE_WEIGHT_FORMAT(OHWIo8i2_bf16)
3315 __CASE_WEIGHT_FORMAT(OHWIo16i2)
3316 __CASE_WEIGHT_FORMAT(OHWIo16i2_bf16)
3317 __CASE_WEIGHT_FORMAT(OHWIo32i2)
3318 __CASE_WEIGHT_FORMAT(OHWIo32i2_bf16)
3319 __CASE_WEIGHT_FORMAT(OHWIo64i2)
3320 __CASE_WEIGHT_FORMAT(OHWIo64i2_bf16)
3321 __CASE_WEIGHT_FORMAT(OHWIo4i4)
3322 __CASE_WEIGHT_FORMAT(OHWIo4i4_bf16)
3323 __CASE_WEIGHT_FORMAT(OHWIo8i4)
3324 __CASE_WEIGHT_FORMAT(OHWIo8i4_bf16)
3325 __CASE_WEIGHT_FORMAT(OHWIo16i4)
3326 __CASE_WEIGHT_FORMAT(OHWIo16i4_bf16)
3327 __CASE_WEIGHT_FORMAT(OHWIo32i4)
3328 __CASE_WEIGHT_FORMAT(OHWIo32i4_bf16)
3329 __CASE_WEIGHT_FORMAT(OHWIo64i4)
3330 __CASE_WEIGHT_FORMAT(OHWIo64i4_bf16)
3331 __CASE_WEIGHT_FORMAT(OHWIo2i8)
3332 __CASE_WEIGHT_FORMAT(OHWIo4i8)
3333 __CASE_WEIGHT_FORMAT(OHWIo8i8)
3334 __CASE_WEIGHT_FORMAT(OHWIo16i8)
3335 __CASE_WEIGHT_FORMAT(OHWIo32i8)
3336 __CASE_WEIGHT_FORMAT(OHWIo64i8)
3337 default:
3338 return "invalid value";
3339 }
3340#undef __CASE_WEIGHT_FORMAT
Francesco Petrogalli553f6952022-06-30 10:22:01 +00003341}
3342
Ramy Elgammal91780022022-07-20 14:57:37 +01003343/** Formatted output of the arm_compute::WeightFormat type.
3344 *
3345 * @param[out] os Output stream.
3346 * @param[in] wf WeightFormat to output.
3347 *
3348 * @return Modified output stream.
3349 */
3350inline ::std::ostream &operator<<(::std::ostream &os, const arm_compute::WeightFormat &wf)
3351{
3352 os << to_string(wf);
3353 return os;
3354}
3355
3356/** Formatted output of the std::tuple<TensorShape, TensorShape, arm_compute::WeightFormat> tuple.
3357 *
3358 * @param[in] values tuple of input and output tensor shapes and WeightFormat used.
3359 *
3360 * @return Formatted string.
3361 */
3362inline std::string to_string(const std::tuple<TensorShape, TensorShape, arm_compute::WeightFormat> values)
Francesco Petrogalli553f6952022-06-30 10:22:01 +00003363{
3364 std::stringstream str;
3365 str << "[Input shape = " << std::get<0>(values);
3366 str << ", ";
3367 str << "Expected output shape = " << std::get<1>(values);
3368
3369 str << ", ";
3370 str << "WeightFormat = " << std::get<2>(values) << "]";
3371 return str.str();
3372}
3373
Anthony Barbier6ff3b192017-09-04 18:44:23 +01003374} // namespace arm_compute
Anthony Barbier4dbc0a92018-08-27 13:39:47 +01003375
3376#endif /* __ARM_COMPUTE_TYPE_PRINTER_H__ */