blob: fe7f13a19e723d04812c402787a78ae66de4e1f9 [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;
631
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100632 default:
633 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
634 }
635
636 return os;
637}
638
Alex Gildayc357c472018-03-21 13:54:09 +0000639/** Formatted output of the activation function info type.
640 *
SiCongLi1af54162021-10-06 15:25:57 +0100641 * @param[in] info ActivationLayerInfo to output.
Alex Gildayc357c472018-03-21 13:54:09 +0000642 *
643 * @return Formatted string.
644 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100645inline std::string to_string(const arm_compute::ActivationLayerInfo &info)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100646{
647 std::stringstream str;
Isabella Gottardi3f217ec2018-02-12 14:59:19 +0000648 if(info.enabled())
649 {
650 str << info.activation();
651 }
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100652 return str.str();
653}
654
SiCongLi1af54162021-10-06 15:25:57 +0100655/** Formatted output of the activation function info.
ramelg013ae3d882021-09-12 23:07:47 +0100656 *
SiCongLi1af54162021-10-06 15:25:57 +0100657 * @param[out] os Output stream.
658 * @param[in] info ActivationLayerInfo to output.
ramelg013ae3d882021-09-12 23:07:47 +0100659 *
660 * @return Formatted string.
661 */
SiCongLi1af54162021-10-06 15:25:57 +0100662inline ::std::ostream &operator<<(::std::ostream &os, const ActivationLayerInfo *info)
ramelg013ae3d882021-09-12 23:07:47 +0100663{
ramelg013ae3d882021-09-12 23:07:47 +0100664 if(info != nullptr)
665 {
ramelg013ae3d882021-09-12 23:07:47 +0100666 if(info->enabled())
667 {
SiCongLi1af54162021-10-06 15:25:57 +0100668 os << info->activation();
669 os << "(";
670 os << "VAL_A=" << info->a() << ",";
671 os << "VAL_B=" << info->b();
672 os << ")";
ramelg013ae3d882021-09-12 23:07:47 +0100673 }
SiCongLi1af54162021-10-06 15:25:57 +0100674 else
675 {
676 os << "disabled";
677 }
ramelg013ae3d882021-09-12 23:07:47 +0100678 }
SiCongLi1af54162021-10-06 15:25:57 +0100679 else
680 {
681 os << "nullptr";
682 }
683 return os;
ramelg013ae3d882021-09-12 23:07:47 +0100684}
685
Alex Gildayc357c472018-03-21 13:54:09 +0000686/** Formatted output of the activation function type.
687 *
688 * @param[in] function Type to output.
689 *
690 * @return Formatted string.
691 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100692inline std::string to_string(const arm_compute::ActivationLayerInfo::ActivationFunction &function)
693{
694 std::stringstream str;
695 str << function;
696 return str.str();
697}
698
Alex Gildayc357c472018-03-21 13:54:09 +0000699/** Formatted output of the NormType type.
700 *
701 * @param[out] os Output stream.
702 * @param[in] norm_type Type to output.
703 *
704 * @return Modified output stream.
705 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100706inline ::std::ostream &operator<<(::std::ostream &os, const NormType &norm_type)
707{
708 switch(norm_type)
709 {
710 case NormType::CROSS_MAP:
711 os << "CROSS_MAP";
712 break;
713 case NormType::IN_MAP_1D:
714 os << "IN_MAP_1D";
715 break;
716 case NormType::IN_MAP_2D:
717 os << "IN_MAP_2D";
718 break;
719 default:
720 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
721 }
722
723 return os;
724}
725
Alex Gildayc357c472018-03-21 13:54:09 +0000726/** Formatted output of @ref NormalizationLayerInfo.
727 *
728 * @param[in] info Type to output.
729 *
730 * @return Formatted string.
731 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100732inline std::string to_string(const arm_compute::NormalizationLayerInfo &info)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100733{
734 std::stringstream str;
Michalis Spyroud466c2d2018-01-30 10:54:39 +0000735 str << info.type() << ":NormSize=" << info.norm_size();
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100736 return str.str();
737}
738
Alex Gildayc357c472018-03-21 13:54:09 +0000739/** Formatted output of @ref NormalizationLayerInfo.
740 *
741 * @param[out] os Output stream.
742 * @param[in] info Type to output.
743 *
744 * @return Modified output stream.
745 */
Georgios Pinitas6f669f02017-09-26 12:32:57 +0100746inline ::std::ostream &operator<<(::std::ostream &os, const NormalizationLayerInfo &info)
747{
Michalis Spyroud466c2d2018-01-30 10:54:39 +0000748 os << info.type() << ":NormSize=" << info.norm_size();
Georgios Pinitas6f669f02017-09-26 12:32:57 +0100749 return os;
750}
751
Alex Gildayc357c472018-03-21 13:54:09 +0000752/** Formatted output of the PoolingType type.
753 *
754 * @param[out] os Output stream.
755 * @param[in] pool_type Type to output.
756 *
757 * @return Modified output stream.
758 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100759inline ::std::ostream &operator<<(::std::ostream &os, const PoolingType &pool_type)
760{
761 switch(pool_type)
762 {
763 case PoolingType::AVG:
764 os << "AVG";
765 break;
766 case PoolingType::MAX:
767 os << "MAX";
768 break;
Georgios Pinitascdf51452017-08-31 14:21:36 +0100769 case PoolingType::L2:
770 os << "L2";
771 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100772 default:
773 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
774 }
775
776 return os;
777}
778
Alex Gildayc357c472018-03-21 13:54:09 +0000779/** Formatted output of @ref PoolingLayerInfo.
780 *
781 * @param[out] os Output stream.
782 * @param[in] info Type to output.
783 *
784 * @return Modified output stream.
785 */
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100786inline ::std::ostream &operator<<(::std::ostream &os, const PoolingLayerInfo &info)
787{
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +0000788 os << info.pool_type;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100789
790 return os;
791}
792
Alex Gildayc357c472018-03-21 13:54:09 +0000793/** Formatted output of @ref RoundingPolicy.
794 *
795 * @param[in] rounding_policy Type to output.
796 *
797 * @return Formatted string.
798 */
John Richardsondd715f22017-09-18 16:10:48 +0100799inline std::string to_string(const RoundingPolicy &rounding_policy)
800{
801 std::stringstream str;
802 str << rounding_policy;
803 return str.str();
804}
805
Vidhya Sudhan Loganathand646ae12018-11-19 15:18:20 +0000806/** [Print DataLayout type] **/
Alex Gildayc357c472018-03-21 13:54:09 +0000807/** Formatted output of the DataLayout type.
808 *
809 * @param[out] os Output stream.
810 * @param[in] data_layout Type to output.
811 *
812 * @return Modified output stream.
813 */
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000814inline ::std::ostream &operator<<(::std::ostream &os, const DataLayout &data_layout)
815{
816 switch(data_layout)
817 {
818 case DataLayout::UNKNOWN:
819 os << "UNKNOWN";
820 break;
821 case DataLayout::NHWC:
822 os << "NHWC";
823 break;
824 case DataLayout::NCHW:
825 os << "NCHW";
826 break;
Adnan AlSinane4563a02021-09-01 15:32:03 +0100827 case DataLayout::NDHWC:
828 os << "NDHWC";
829 break;
Giorgio Arenac9fe9fc2021-10-06 12:54:29 +0100830 case DataLayout::NCDHW:
831 os << "NCDHW";
832 break;
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000833 default:
834 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
835 }
836
837 return os;
838}
839
Alex Gildayc357c472018-03-21 13:54:09 +0000840/** Formatted output of the DataLayout type.
841 *
842 * @param[in] data_layout Type to output.
843 *
844 * @return Formatted string.
845 */
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000846inline std::string to_string(const arm_compute::DataLayout &data_layout)
847{
848 std::stringstream str;
849 str << data_layout;
850 return str.str();
851}
Vidhya Sudhan Loganathand646ae12018-11-19 15:18:20 +0000852/** [Print DataLayout type] **/
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000853
Georgios Pinitase2220552018-07-20 13:23:44 +0100854/** Formatted output of the DataLayoutDimension type.
855 *
856 * @param[out] os Output stream.
857 * @param[in] data_layout_dim Data layout dimension to print.
858 *
859 * @return Modified output stream.
860 */
861inline ::std::ostream &operator<<(::std::ostream &os, const DataLayoutDimension &data_layout_dim)
862{
863 switch(data_layout_dim)
864 {
865 case DataLayoutDimension::WIDTH:
866 os << "WIDTH";
867 break;
868 case DataLayoutDimension::HEIGHT:
869 os << "HEIGHT";
870 break;
871 case DataLayoutDimension::CHANNEL:
872 os << "CHANNEL";
873 break;
Giorgio Arenac9fe9fc2021-10-06 12:54:29 +0100874 case DataLayoutDimension::DEPTH:
875 os << "DEPTH";
876 break;
Georgios Pinitase2220552018-07-20 13:23:44 +0100877 case DataLayoutDimension::BATCHES:
878 os << "BATCHES";
879 break;
880 default:
881 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
882 }
883 return os;
884}
885
Alex Gildayc357c472018-03-21 13:54:09 +0000886/** Formatted output of the DataType type.
887 *
888 * @param[out] os Output stream.
889 * @param[in] data_type Type to output.
890 *
891 * @return Modified output stream.
892 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100893inline ::std::ostream &operator<<(::std::ostream &os, const DataType &data_type)
894{
895 switch(data_type)
896 {
897 case DataType::UNKNOWN:
898 os << "UNKNOWN";
899 break;
900 case DataType::U8:
901 os << "U8";
902 break;
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100903 case DataType::QSYMM8:
904 os << "QSYMM8";
905 break;
Chunosovd621bca2017-11-03 17:33:15 +0700906 case DataType::QASYMM8:
907 os << "QASYMM8";
908 break;
Georgios Pinitas448a81f2019-11-21 14:10:25 +0000909 case DataType::QASYMM8_SIGNED:
910 os << "QASYMM8_SIGNED";
911 break;
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100912 case DataType::QSYMM8_PER_CHANNEL:
913 os << "QSYMM8_PER_CHANNEL";
914 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100915 case DataType::S8:
916 os << "S8";
917 break;
918 case DataType::U16:
919 os << "U16";
920 break;
921 case DataType::S16:
922 os << "S16";
923 break;
Manuel Bottini3689fcd2019-06-14 17:18:12 +0100924 case DataType::QSYMM16:
925 os << "QSYMM16";
926 break;
Michele Di Giorgio35ea9a72019-08-23 12:02:06 +0100927 case DataType::QASYMM16:
928 os << "QASYMM16";
929 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100930 case DataType::U32:
931 os << "U32";
932 break;
933 case DataType::S32:
934 os << "S32";
935 break;
936 case DataType::U64:
937 os << "U64";
938 break;
939 case DataType::S64:
940 os << "S64";
941 break;
Georgios Pinitase8291ac2020-02-26 09:58:13 +0000942 case DataType::BFLOAT16:
943 os << "BFLOAT16";
944 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100945 case DataType::F16:
946 os << "F16";
947 break;
948 case DataType::F32:
949 os << "F32";
950 break;
951 case DataType::F64:
952 os << "F64";
953 break;
954 case DataType::SIZET:
955 os << "SIZET";
956 break;
957 default:
958 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
959 }
960
961 return os;
962}
963
Alex Gildayc357c472018-03-21 13:54:09 +0000964/** Formatted output of the DataType type.
965 *
966 * @param[in] data_type Type to output.
967 *
968 * @return Formatted string.
969 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100970inline std::string to_string(const arm_compute::DataType &data_type)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100971{
972 std::stringstream str;
973 str << data_type;
974 return str.str();
975}
976
Alex Gildayc357c472018-03-21 13:54:09 +0000977/** Formatted output of the Format type.
978 *
979 * @param[out] os Output stream.
980 * @param[in] format Type to output.
981 *
982 * @return Modified output stream.
983 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100984inline ::std::ostream &operator<<(::std::ostream &os, const Format &format)
985{
986 switch(format)
987 {
988 case Format::UNKNOWN:
989 os << "UNKNOWN";
990 break;
991 case Format::U8:
992 os << "U8";
993 break;
994 case Format::S16:
995 os << "S16";
996 break;
997 case Format::U16:
998 os << "U16";
999 break;
1000 case Format::S32:
1001 os << "S32";
1002 break;
1003 case Format::U32:
1004 os << "U32";
1005 break;
1006 case Format::F16:
1007 os << "F16";
1008 break;
1009 case Format::F32:
1010 os << "F32";
1011 break;
1012 case Format::UV88:
1013 os << "UV88";
1014 break;
1015 case Format::RGB888:
1016 os << "RGB888";
1017 break;
1018 case Format::RGBA8888:
1019 os << "RGBA8888";
1020 break;
1021 case Format::YUV444:
1022 os << "YUV444";
1023 break;
1024 case Format::YUYV422:
1025 os << "YUYV422";
1026 break;
1027 case Format::NV12:
1028 os << "NV12";
1029 break;
1030 case Format::NV21:
1031 os << "NV21";
1032 break;
1033 case Format::IYUV:
1034 os << "IYUV";
1035 break;
1036 case Format::UYVY422:
1037 os << "UYVY422";
1038 break;
1039 default:
1040 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1041 }
1042
1043 return os;
1044}
1045
Alex Gildayc357c472018-03-21 13:54:09 +00001046/** Formatted output of the Format type.
1047 *
1048 * @param[in] format Type to output.
1049 *
1050 * @return Formatted string.
1051 */
Moritz Pflanzer7655a672017-09-23 11:57:33 +01001052inline std::string to_string(const Format &format)
1053{
1054 std::stringstream str;
1055 str << format;
1056 return str.str();
1057}
1058
Alex Gildayc357c472018-03-21 13:54:09 +00001059/** Formatted output of the Channel type.
1060 *
1061 * @param[out] os Output stream.
1062 * @param[in] channel Type to output.
1063 *
1064 * @return Modified output stream.
1065 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001066inline ::std::ostream &operator<<(::std::ostream &os, const Channel &channel)
1067{
1068 switch(channel)
1069 {
1070 case Channel::UNKNOWN:
1071 os << "UNKNOWN";
1072 break;
1073 case Channel::C0:
1074 os << "C0";
1075 break;
1076 case Channel::C1:
1077 os << "C1";
1078 break;
1079 case Channel::C2:
1080 os << "C2";
1081 break;
1082 case Channel::C3:
1083 os << "C3";
1084 break;
1085 case Channel::R:
1086 os << "R";
1087 break;
1088 case Channel::G:
1089 os << "G";
1090 break;
1091 case Channel::B:
1092 os << "B";
1093 break;
1094 case Channel::A:
1095 os << "A";
1096 break;
1097 case Channel::Y:
1098 os << "Y";
1099 break;
1100 case Channel::U:
1101 os << "U";
1102 break;
1103 case Channel::V:
1104 os << "V";
1105 break;
1106 default:
1107 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1108 }
1109
1110 return os;
1111}
1112
Alex Gildayc357c472018-03-21 13:54:09 +00001113/** Formatted output of the Channel type.
1114 *
1115 * @param[in] channel Type to output.
1116 *
1117 * @return Formatted string.
1118 */
Ioan-Cristian Szabo9414f642017-10-27 17:35:40 +01001119inline std::string to_string(const Channel &channel)
1120{
1121 std::stringstream str;
1122 str << channel;
1123 return str.str();
1124}
1125
Alex Gildayc357c472018-03-21 13:54:09 +00001126/** Formatted output of the BorderMode type.
1127 *
1128 * @param[out] os Output stream.
1129 * @param[in] mode Type to output.
1130 *
1131 * @return Modified output stream.
1132 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001133inline ::std::ostream &operator<<(::std::ostream &os, const BorderMode &mode)
1134{
1135 switch(mode)
1136 {
1137 case BorderMode::UNDEFINED:
1138 os << "UNDEFINED";
1139 break;
1140 case BorderMode::CONSTANT:
1141 os << "CONSTANT";
1142 break;
1143 case BorderMode::REPLICATE:
1144 os << "REPLICATE";
1145 break;
1146 default:
1147 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1148 }
1149
1150 return os;
1151}
1152
Alex Gildayc357c472018-03-21 13:54:09 +00001153/** Formatted output of the BorderSize type.
1154 *
1155 * @param[out] os Output stream.
1156 * @param[in] border Type to output.
1157 *
1158 * @return Modified output stream.
1159 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001160inline ::std::ostream &operator<<(::std::ostream &os, const BorderSize &border)
1161{
Moritz Pflanzerc87fbf82017-07-18 14:02:10 +01001162 os << border.top << ","
1163 << border.right << ","
1164 << border.bottom << ","
1165 << border.left;
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001166
1167 return os;
1168}
Anthony Barbier2a07e182017-08-04 18:20:27 +01001169
Giuseppe Rossinid7647d42018-07-17 18:13:13 +01001170/** Formatted output of the PaddingList type.
1171 *
1172 * @param[out] os Output stream.
1173 * @param[in] padding Type to output.
1174 *
1175 * @return Modified output stream.
1176 */
1177inline ::std::ostream &operator<<(::std::ostream &os, const PaddingList &padding)
1178{
1179 os << "{";
1180 for(auto const &p : padding)
1181 {
1182 os << "{" << p.first << "," << p.second << "}";
1183 }
1184 os << "}";
1185 return os;
1186}
1187
giuros013175fcf2018-11-21 09:59:17 +00001188/** Formatted output of the Multiples type.
1189 *
1190 * @param[out] os Output stream.
1191 * @param[in] multiples Type to output.
1192 *
1193 * @return Modified output stream.
1194 */
1195inline ::std::ostream &operator<<(::std::ostream &os, const Multiples &multiples)
1196{
1197 os << "(";
1198 for(size_t i = 0; i < multiples.size() - 1; i++)
1199 {
1200 os << multiples[i] << ", ";
1201 }
1202 os << multiples.back() << ")";
1203 return os;
1204}
1205
Alex Gildayc357c472018-03-21 13:54:09 +00001206/** Formatted output of the InterpolationPolicy type.
1207 *
1208 * @param[out] os Output stream.
1209 * @param[in] policy Type to output.
1210 *
1211 * @return Modified output stream.
1212 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001213inline ::std::ostream &operator<<(::std::ostream &os, const InterpolationPolicy &policy)
1214{
1215 switch(policy)
1216 {
1217 case InterpolationPolicy::NEAREST_NEIGHBOR:
1218 os << "NEAREST_NEIGHBOR";
1219 break;
1220 case InterpolationPolicy::BILINEAR:
1221 os << "BILINEAR";
1222 break;
1223 case InterpolationPolicy::AREA:
1224 os << "AREA";
1225 break;
1226 default:
1227 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1228 }
1229
1230 return os;
1231}
1232
Alex Gildayc357c472018-03-21 13:54:09 +00001233/** Formatted output of the SamplingPolicy type.
1234 *
1235 * @param[out] os Output stream.
1236 * @param[in] policy Type to output.
1237 *
1238 * @return Modified output stream.
1239 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +07001240inline ::std::ostream &operator<<(::std::ostream &os, const SamplingPolicy &policy)
1241{
1242 switch(policy)
1243 {
1244 case SamplingPolicy::CENTER:
1245 os << "CENTER";
1246 break;
1247 case SamplingPolicy::TOP_LEFT:
1248 os << "TOP_LEFT";
1249 break;
1250 default:
1251 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1252 }
1253
1254 return os;
1255}
1256
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001257/** Formatted output of the ITensorInfo type.
1258 *
1259 * @param[out] os Output stream.
1260 * @param[in] info Tensor information.
1261 *
1262 * @return Modified output stream.
1263 */
1264inline ::std::ostream &operator<<(std::ostream &os, const ITensorInfo *info)
1265{
Georgios Pinitasc6f95102021-03-30 10:03:01 +01001266 const DataType data_type = info->data_type();
1267 const DataLayout data_layout = info->data_layout();
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001268
1269 os << "Shape=" << info->tensor_shape() << ","
1270 << "DataLayout=" << string_from_data_layout(data_layout) << ","
ramelg014a6d9e82021-10-02 14:34:36 +01001271 << "DataType=" << string_from_data_type(data_type);
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001272
1273 if(is_data_type_quantized(data_type))
1274 {
ramelg01b1ba1e32021-09-25 11:53:26 +01001275 const QuantizationInfo qinfo = info->quantization_info();
1276 const auto scales = qinfo.scale();
1277 const auto offsets = qinfo.offset();
1278
ramelg014a6d9e82021-10-02 14:34:36 +01001279 os << ", QuantizationInfo={"
ramelg01b1ba1e32021-09-25 11:53:26 +01001280 << "scales.size=" << scales.size()
1281 << ", scale(s)=" << scales << ", ";
1282
1283 os << "offsets.size=" << offsets.size()
1284 << ", offset(s)=" << offsets << "}";
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001285 }
1286 return os;
1287}
1288
ramelg013ae3d882021-09-12 23:07:47 +01001289/** Formatted output of the const TensorInfo& type.
Alex Gildayc357c472018-03-21 13:54:09 +00001290 *
Anthony Barbier366628a2018-08-01 13:55:03 +01001291 * @param[out] os Output stream.
1292 * @param[in] info Type to output.
1293 *
1294 * @return Modified output stream.
1295 */
1296inline ::std::ostream &operator<<(::std::ostream &os, const TensorInfo &info)
1297{
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001298 os << &info;
Georgios Pinitasc6f95102021-03-30 10:03:01 +01001299 return os;
Anthony Barbier366628a2018-08-01 13:55:03 +01001300}
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001301
ramelg013ae3d882021-09-12 23:07:47 +01001302/** Formatted output of the const TensorInfo& type.
Anthony Barbier366628a2018-08-01 13:55:03 +01001303 *
Alex Gildayc357c472018-03-21 13:54:09 +00001304 * @param[in] info Type to output.
1305 *
1306 * @return Formatted string.
1307 */
Georgios Pinitas3faea252017-10-30 14:13:50 +00001308inline std::string to_string(const TensorInfo &info)
1309{
1310 std::stringstream str;
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001311 str << &info;
Georgios Pinitas3faea252017-10-30 14:13:50 +00001312 return str.str();
1313}
1314
ramelg013ae3d882021-09-12 23:07:47 +01001315/** Formatted output of the const ITensorInfo& type.
1316 *
1317 * @param[in] info Type to output.
1318 *
1319 * @return Formatted string.
1320 */
1321inline std::string to_string(const ITensorInfo &info)
1322{
1323 std::stringstream str;
1324 str << &info;
1325 return str.str();
1326}
1327
ramelg013ae3d882021-09-12 23:07:47 +01001328/** Formatted output of the const ITensorInfo* type.
1329 *
1330 * @param[in] info Type to output.
1331 *
1332 * @return Formatted string.
1333 */
Ramy Elgammale920d6a2021-08-19 22:10:30 +01001334inline std::string to_string(const ITensorInfo *info)
1335{
ramelg013ae3d882021-09-12 23:07:47 +01001336 std::string ret_str = "nullptr";
1337 if(info != nullptr)
1338 {
1339 std::stringstream str;
1340 str << info;
1341 ret_str = str.str();
1342 }
1343 return ret_str;
1344}
1345
ramelg01cbbb0382021-09-17 17:36:57 +01001346/** Formatted output of the ITensorInfo* type.
1347 *
1348 * @param[in] info Type to output.
1349 *
1350 * @return Formatted string.
1351 */
1352inline std::string to_string(ITensorInfo *info)
1353{
1354 return to_string(static_cast<const ITensorInfo *>(info));
1355}
1356
1357/** Formatted output of the ITensorInfo type obtained from const ITensor* type.
ramelg013ae3d882021-09-12 23:07:47 +01001358 *
1359 * @param[in] tensor Type to output.
1360 *
1361 * @return Formatted string.
1362 */
1363inline std::string to_string(const ITensor *tensor)
1364{
1365 std::string ret_str = "nullptr";
1366 if(tensor != nullptr)
1367 {
1368 std::stringstream str;
ramelg01cbbb0382021-09-17 17:36:57 +01001369 str << "ITensor->info(): " << tensor->info();
ramelg013ae3d882021-09-12 23:07:47 +01001370 ret_str = str.str();
1371 }
1372 return ret_str;
1373}
1374
ramelg01cbbb0382021-09-17 17:36:57 +01001375/** Formatted output of the ITensorInfo type obtained from the ITensor* type.
ramelg013ae3d882021-09-12 23:07:47 +01001376 *
1377 * @param[in] tensor Type to output.
1378 *
1379 * @return Formatted string.
1380 */
1381inline std::string to_string(ITensor *tensor)
1382{
ramelg01cbbb0382021-09-17 17:36:57 +01001383 return to_string(static_cast<const ITensor *>(tensor));
ramelg013ae3d882021-09-12 23:07:47 +01001384}
1385
ramelg01cbbb0382021-09-17 17:36:57 +01001386/** Formatted output of the ITensorInfo type obtained from the ITensor& type.
ramelg013ae3d882021-09-12 23:07:47 +01001387 *
1388 * @param[in] tensor Type to output.
1389 *
1390 * @return Formatted string.
1391 */
1392inline std::string to_string(ITensor &tensor)
1393{
Ramy Elgammale920d6a2021-08-19 22:10:30 +01001394 std::stringstream str;
ramelg01cbbb0382021-09-17 17:36:57 +01001395 str << "ITensor.info(): " << tensor.info();
Ramy Elgammale920d6a2021-08-19 22:10:30 +01001396 return str.str();
1397}
1398
ramelg01cbbb0382021-09-17 17:36:57 +01001399#ifdef ARM_COMPUTE_OPENCL_ENABLED
1400/** Formatted output of the ITensorInfo type obtained from the const ICLTensor& type.
1401 *
1402 * @param[in] cl_tensor Type to output.
1403 *
1404 * @return Formatted string.
1405 */
1406inline std::string to_string(const ICLTensor *cl_tensor)
1407{
1408 std::string ret_str = "nullptr";
1409 if(cl_tensor != nullptr)
1410 {
1411 std::stringstream str;
1412 str << "ICLTensor->info(): " << cl_tensor->info();
1413 ret_str = str.str();
1414 }
1415 return ret_str;
1416}
1417
1418/** Formatted output of the ITensorInfo type obtained from the ICLTensor& type.
1419 *
1420 * @param[in] cl_tensor Type to output.
1421 *
1422 * @return Formatted string.
1423 */
1424inline std::string to_string(ICLTensor *cl_tensor)
1425{
1426 return to_string(static_cast<const ICLTensor *>(cl_tensor));
1427}
1428#endif /* ARM_COMPUTE_OPENCL_ENABLED */
1429
Alex Gildayc357c472018-03-21 13:54:09 +00001430/** Formatted output of the Dimensions type.
1431 *
1432 * @param[in] dimensions Type to output.
1433 *
1434 * @return Formatted string.
1435 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001436template <typename T>
1437inline std::string to_string(const Dimensions<T> &dimensions)
1438{
1439 std::stringstream str;
1440 str << dimensions;
1441 return str.str();
1442}
1443
Alex Gildayc357c472018-03-21 13:54:09 +00001444/** Formatted output of the Strides type.
1445 *
1446 * @param[in] stride Type to output.
1447 *
1448 * @return Formatted string.
1449 */
John Richardsona36eae12017-09-26 16:55:59 +01001450inline std::string to_string(const Strides &stride)
1451{
1452 std::stringstream str;
1453 str << stride;
1454 return str.str();
1455}
1456
Alex Gildayc357c472018-03-21 13:54:09 +00001457/** Formatted output of the TensorShape type.
1458 *
1459 * @param[in] shape Type to output.
1460 *
1461 * @return Formatted string.
1462 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001463inline std::string to_string(const TensorShape &shape)
1464{
1465 std::stringstream str;
1466 str << shape;
1467 return str.str();
1468}
1469
Alex Gildayc357c472018-03-21 13:54:09 +00001470/** Formatted output of the Coordinates type.
1471 *
1472 * @param[in] coord Type to output.
1473 *
1474 * @return Formatted string.
1475 */
Abe Mbise925ca0f2017-10-02 19:16:33 +01001476inline std::string to_string(const Coordinates &coord)
1477{
1478 std::stringstream str;
1479 str << coord;
1480 return str.str();
1481}
1482
Anthony Barbierb940fd62018-06-04 14:14:32 +01001483/** Formatted output of the GEMMReshapeInfo type.
1484 *
1485 * @param[out] os Output stream.
1486 * @param[in] info Type to output.
1487 *
1488 * @return Modified output stream.
1489 */
1490inline ::std::ostream &operator<<(::std::ostream &os, const GEMMReshapeInfo &info)
1491{
1492 os << "{m=" << info.m() << ",";
1493 os << "n=" << info.n() << ",";
1494 os << "k=" << info.k() << ",";
1495 os << "mult_transpose1xW_width=" << info.mult_transpose1xW_width() << ",";
1496 os << "mult_interleave4x4_height=" << info.mult_interleave4x4_height();
1497 os << "}";
1498
1499 return os;
1500}
1501
1502/** Formatted output of the GEMMInfo type.
1503 *
1504 * @param[out] os Output stream.
1505 * @param[in] info Type to output.
1506 *
1507 * @return Modified output stream.
1508 */
1509inline ::std::ostream &operator<<(::std::ostream &os, const GEMMInfo &info)
1510{
1511 os << "{is_a_reshaped=" << info.is_a_reshaped() << ",";
1512 os << "is_b_reshaped=" << info.is_b_reshaped() << ",";
1513 os << "reshape_b_only_on_first_run=" << info.reshape_b_only_on_first_run() << ",";
Anthony Barbierb4670212018-05-18 16:55:39 +01001514 os << "depth_output_gemm3d=" << info.depth_output_gemm3d() << ",";
1515 os << "reinterpret_input_as_3d=" << info.reinterpret_input_as_3d() << ",";
1516 os << "retain_internal_weights=" << info.retain_internal_weights() << ",";
1517 os << "fp_mixed_precision=" << info.fp_mixed_precision() << ",";
1518 os << "broadcast_bias=" << info.broadcast_bias() << ",";
ramelg01cbbb0382021-09-17 17:36:57 +01001519 os << "pretranspose_B=" << info.pretranspose_B() << ",";
SiCongLi579ca842021-10-18 09:38:33 +01001520 os << "post_ops=" << info.post_ops() << "}";
Anthony Barbierb940fd62018-06-04 14:14:32 +01001521
1522 return os;
1523}
1524
1525/** Formatted output of the Window::Dimension type.
1526 *
1527 * @param[out] os Output stream.
1528 * @param[in] dim Type to output.
1529 *
1530 * @return Modified output stream.
1531 */
1532inline ::std::ostream &operator<<(::std::ostream &os, const Window::Dimension &dim)
1533{
1534 os << "{start=" << dim.start() << ", end=" << dim.end() << ", step=" << dim.step() << "}";
1535
1536 return os;
1537}
1538/** Formatted output of the Window type.
1539 *
1540 * @param[out] os Output stream.
1541 * @param[in] win Type to output.
1542 *
1543 * @return Modified output stream.
1544 */
1545inline ::std::ostream &operator<<(::std::ostream &os, const Window &win)
1546{
1547 os << "{";
1548 for(unsigned int i = 0; i < Coordinates::num_max_dimensions; i++)
1549 {
1550 if(i > 0)
1551 {
1552 os << ", ";
1553 }
1554 os << win[i];
1555 }
1556 os << "}";
1557
1558 return os;
1559}
1560
1561/** Formatted output of the WeightsInfo type.
1562 *
1563 * @param[in] info Type to output.
1564 *
1565 * @return Formatted string.
1566 */
1567inline std::string to_string(const WeightsInfo &info)
1568{
1569 std::stringstream str;
1570 str << info;
1571 return str.str();
1572}
1573
1574/** Formatted output of the GEMMReshapeInfo type.
1575 *
1576 * @param[in] info Type to output.
1577 *
1578 * @return Formatted string.
1579 */
1580inline std::string to_string(const GEMMReshapeInfo &info)
1581{
1582 std::stringstream str;
1583 str << info;
1584 return str.str();
1585}
1586
1587/** Formatted output of the GEMMInfo type.
1588 *
1589 * @param[in] info Type to output.
1590 *
1591 * @return Formatted string.
1592 */
1593inline std::string to_string(const GEMMInfo &info)
1594{
1595 std::stringstream str;
1596 str << info;
1597 return str.str();
1598}
1599
1600/** Formatted output of the Window::Dimension type.
1601 *
1602 * @param[in] dim Type to output.
1603 *
1604 * @return Formatted string.
1605 */
1606inline std::string to_string(const Window::Dimension &dim)
1607{
1608 std::stringstream str;
1609 str << dim;
1610 return str.str();
1611}
ramelg01cbbb0382021-09-17 17:36:57 +01001612/** Formatted output of the Window& type.
Anthony Barbierb940fd62018-06-04 14:14:32 +01001613 *
1614 * @param[in] win Type to output.
1615 *
1616 * @return Formatted string.
1617 */
1618inline std::string to_string(const Window &win)
1619{
1620 std::stringstream str;
1621 str << win;
1622 return str.str();
1623}
1624
ramelg01cbbb0382021-09-17 17:36:57 +01001625/** Formatted output of the Window* type.
1626 *
1627 * @param[in] win Type to output.
1628 *
1629 * @return Formatted string.
1630 */
1631inline std::string to_string(Window *win)
1632{
1633 std::string ret_str = "nullptr";
1634 if(win != nullptr)
1635 {
1636 std::stringstream str;
1637 str << *win;
1638 ret_str = str.str();
1639 }
1640 return ret_str;
1641}
1642
Alex Gildayc357c472018-03-21 13:54:09 +00001643/** Formatted output of the Rectangle type.
1644 *
1645 * @param[out] os Output stream.
1646 * @param[in] rect Type to output.
1647 *
1648 * @return Modified output stream.
1649 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001650inline ::std::ostream &operator<<(::std::ostream &os, const Rectangle &rect)
1651{
1652 os << rect.width << "x" << rect.height;
1653 os << "+" << rect.x << "+" << rect.y;
1654
1655 return os;
1656}
1657
Usama Arif8cf8c112019-03-14 15:36:54 +00001658/** Formatted output of the PaddingMode type.
1659 *
1660 * @param[out] os Output stream.
1661 * @param[in] mode Type to output.
1662 *
1663 * @return Modified output stream.
1664 */
1665inline ::std::ostream &operator<<(::std::ostream &os, const PaddingMode &mode)
1666{
1667 switch(mode)
1668 {
1669 case PaddingMode::CONSTANT:
1670 os << "CONSTANT";
1671 break;
1672 case PaddingMode::REFLECT:
1673 os << "REFLECT";
1674 break;
1675 case PaddingMode::SYMMETRIC:
1676 os << "SYMMETRIC";
1677 break;
1678 default:
1679 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1680 }
1681
1682 return os;
1683}
1684
1685/** Formatted output of the PaddingMode type.
1686 *
1687 * @param[in] mode Type to output.
1688 *
1689 * @return Formatted string.
1690 */
1691inline std::string to_string(const PaddingMode &mode)
1692{
1693 std::stringstream str;
1694 str << mode;
1695 return str.str();
1696}
1697
Alex Gildayc357c472018-03-21 13:54:09 +00001698/** Formatted output of the PadStrideInfo type.
1699 *
1700 * @param[out] os Output stream.
1701 * @param[in] pad_stride_info Type to output.
1702 *
1703 * @return Modified output stream.
1704 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001705inline ::std::ostream &operator<<(::std::ostream &os, const PadStrideInfo &pad_stride_info)
1706{
1707 os << pad_stride_info.stride().first << "," << pad_stride_info.stride().second;
1708 os << ";";
Jaroslaw Rzepeckia1ed41f2017-10-13 11:13:58 +01001709 os << pad_stride_info.pad_left() << "," << pad_stride_info.pad_right() << ","
1710 << pad_stride_info.pad_top() << "," << pad_stride_info.pad_bottom();
Anthony Barbier2a07e182017-08-04 18:20:27 +01001711
1712 return os;
1713}
1714
Alex Gildayc357c472018-03-21 13:54:09 +00001715/** Formatted output of the PadStrideInfo type.
1716 *
1717 * @param[in] pad_stride_info Type to output.
1718 *
1719 * @return Formatted string.
1720 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001721inline std::string to_string(const PadStrideInfo &pad_stride_info)
1722{
1723 std::stringstream str;
1724 str << pad_stride_info;
1725 return str.str();
1726}
1727
Alex Gildayc357c472018-03-21 13:54:09 +00001728/** Formatted output of the BorderMode type.
1729 *
1730 * @param[in] mode Type to output.
1731 *
1732 * @return Formatted string.
1733 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001734inline std::string to_string(const BorderMode &mode)
1735{
1736 std::stringstream str;
1737 str << mode;
1738 return str.str();
1739}
1740
Alex Gildayc357c472018-03-21 13:54:09 +00001741/** Formatted output of the BorderSize type.
1742 *
1743 * @param[in] border Type to output.
1744 *
1745 * @return Formatted string.
1746 */
John Richardsonb482ce12017-09-18 12:44:01 +01001747inline std::string to_string(const BorderSize &border)
1748{
1749 std::stringstream str;
1750 str << border;
1751 return str.str();
1752}
1753
Giuseppe Rossinid7647d42018-07-17 18:13:13 +01001754/** Formatted output of the PaddingList type.
1755 *
1756 * @param[in] padding Type to output.
1757 *
1758 * @return Formatted string.
1759 */
1760inline std::string to_string(const PaddingList &padding)
1761{
1762 std::stringstream str;
1763 str << padding;
1764 return str.str();
1765}
1766
giuros013175fcf2018-11-21 09:59:17 +00001767/** Formatted output of the Multiples type.
1768 *
1769 * @param[in] multiples Type to output.
1770 *
1771 * @return Formatted string.
1772 */
1773inline std::string to_string(const Multiples &multiples)
1774{
1775 std::stringstream str;
1776 str << multiples;
1777 return str.str();
1778}
1779
Alex Gildayc357c472018-03-21 13:54:09 +00001780/** Formatted output of the InterpolationPolicy type.
1781 *
1782 * @param[in] policy Type to output.
1783 *
1784 * @return Formatted string.
1785 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001786inline std::string to_string(const InterpolationPolicy &policy)
1787{
1788 std::stringstream str;
1789 str << policy;
1790 return str.str();
1791}
1792
Alex Gildayc357c472018-03-21 13:54:09 +00001793/** Formatted output of the SamplingPolicy type.
1794 *
1795 * @param[in] policy Type to output.
1796 *
1797 * @return Formatted string.
1798 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +07001799inline std::string to_string(const SamplingPolicy &policy)
1800{
1801 std::stringstream str;
1802 str << policy;
1803 return str.str();
1804}
1805
Alex Gildayc357c472018-03-21 13:54:09 +00001806/** Formatted output of the ConvertPolicy type.
1807 *
1808 * @param[out] os Output stream.
1809 * @param[in] policy Type to output.
1810 *
1811 * @return Modified output stream.
1812 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001813inline ::std::ostream &operator<<(::std::ostream &os, const ConvertPolicy &policy)
1814{
1815 switch(policy)
1816 {
1817 case ConvertPolicy::WRAP:
1818 os << "WRAP";
1819 break;
1820 case ConvertPolicy::SATURATE:
1821 os << "SATURATE";
1822 break;
1823 default:
1824 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1825 }
1826
1827 return os;
1828}
1829
1830inline std::string to_string(const ConvertPolicy &policy)
1831{
1832 std::stringstream str;
1833 str << policy;
1834 return str.str();
1835}
1836
giuros01164a2722018-11-20 18:34:46 +00001837/** Formatted output of the ArithmeticOperation type.
1838 *
1839 * @param[out] os Output stream.
1840 * @param[in] op Operation to output.
1841 *
1842 * @return Modified output stream.
1843 */
1844inline ::std::ostream &operator<<(::std::ostream &os, const ArithmeticOperation &op)
1845{
1846 switch(op)
1847 {
1848 case ArithmeticOperation::ADD:
1849 os << "ADD";
1850 break;
1851 case ArithmeticOperation::SUB:
1852 os << "SUB";
1853 break;
1854 case ArithmeticOperation::DIV:
1855 os << "DIV";
1856 break;
1857 case ArithmeticOperation::MAX:
1858 os << "MAX";
1859 break;
1860 case ArithmeticOperation::MIN:
1861 os << "MIN";
1862 break;
1863 case ArithmeticOperation::SQUARED_DIFF:
1864 os << "SQUARED_DIFF";
1865 break;
Usama Arif52c54f62019-05-14 10:22:36 +01001866 case ArithmeticOperation::POWER:
1867 os << "POWER";
1868 break;
giuros01164a2722018-11-20 18:34:46 +00001869 default:
1870 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1871 }
1872
1873 return os;
1874}
1875
1876/** Formatted output of the Arithmetic Operation
1877 *
1878 * @param[in] op Type to output.
1879 *
1880 * @return Formatted string.
1881 */
1882inline std::string to_string(const ArithmeticOperation &op)
1883{
1884 std::stringstream str;
1885 str << op;
1886 return str.str();
1887}
1888
Alex Gildayc357c472018-03-21 13:54:09 +00001889/** Formatted output of the Reduction Operations.
1890 *
1891 * @param[out] os Output stream.
1892 * @param[in] op Type to output.
1893 *
1894 * @return Modified output stream.
1895 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001896inline ::std::ostream &operator<<(::std::ostream &os, const ReductionOperation &op)
1897{
1898 switch(op)
1899 {
Michalis Spyrou7e9391b2018-10-05 14:49:28 +01001900 case ReductionOperation::SUM:
1901 os << "SUM";
1902 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +01001903 case ReductionOperation::SUM_SQUARE:
1904 os << "SUM_SQUARE";
1905 break;
Michalis Spyrou7e9391b2018-10-05 14:49:28 +01001906 case ReductionOperation::MEAN_SUM:
1907 os << "MEAN_SUM";
1908 break;
Michalis Spyrou7930db42018-11-22 17:36:28 +00001909 case ReductionOperation::ARG_IDX_MAX:
1910 os << "ARG_IDX_MAX";
1911 break;
1912 case ReductionOperation::ARG_IDX_MIN:
1913 os << "ARG_IDX_MIN";
1914 break;
Manuel Bottinib412fab2018-12-10 17:40:23 +00001915 case ReductionOperation::PROD:
1916 os << "PROD";
1917 break;
Usama Arifa4a08ad2019-05-20 12:38:33 +01001918 case ReductionOperation::MIN:
1919 os << "MIN";
1920 break;
Usama Arif28f0dd92019-05-20 13:44:34 +01001921 case ReductionOperation::MAX:
1922 os << "MAX";
1923 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +01001924 default:
1925 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1926 }
1927
1928 return os;
1929}
1930
Alex Gildayc357c472018-03-21 13:54:09 +00001931/** Formatted output of the Reduction Operations.
1932 *
1933 * @param[in] op Type to output.
1934 *
1935 * @return Formatted string.
1936 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001937inline std::string to_string(const ReductionOperation &op)
1938{
1939 std::stringstream str;
1940 str << op;
1941 return str.str();
1942}
1943
Georgios Pinitas7900a9e2018-11-23 11:44:58 +00001944/** Formatted output of the Comparison Operations.
1945 *
1946 * @param[out] os Output stream.
1947 * @param[in] op Type to output.
1948 *
1949 * @return Modified output stream.
1950 */
1951inline ::std::ostream &operator<<(::std::ostream &os, const ComparisonOperation &op)
1952{
1953 switch(op)
1954 {
1955 case ComparisonOperation::Equal:
1956 os << "Equal";
1957 break;
1958 case ComparisonOperation::NotEqual:
1959 os << "NotEqual";
1960 break;
1961 case ComparisonOperation::Greater:
1962 os << "Greater";
1963 break;
1964 case ComparisonOperation::GreaterEqual:
1965 os << "GreaterEqual";
1966 break;
1967 case ComparisonOperation::Less:
1968 os << "Less";
1969 break;
1970 case ComparisonOperation::LessEqual:
1971 os << "LessEqual";
1972 break;
1973 default:
1974 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1975 }
1976
1977 return os;
1978}
1979
Michalis Spyroue9362622018-11-23 17:41:37 +00001980/** Formatted output of the Elementwise unary Operations.
1981 *
1982 * @param[out] os Output stream.
1983 * @param[in] op Type to output.
1984 *
1985 * @return Modified output stream.
1986 */
1987inline ::std::ostream &operator<<(::std::ostream &os, const ElementWiseUnary &op)
1988{
1989 switch(op)
1990 {
1991 case ElementWiseUnary::RSQRT:
1992 os << "RSQRT";
1993 break;
1994 case ElementWiseUnary::EXP:
1995 os << "EXP";
1996 break;
Usama Arifeb312ef2019-05-13 17:45:54 +01001997 case ElementWiseUnary::NEG:
1998 os << "NEG";
1999 break;
Usama Arifac33d7e2019-05-20 14:21:40 +01002000 case ElementWiseUnary::LOG:
2001 os << "LOG";
2002 break;
ramelg01b1ba1e32021-09-25 11:53:26 +01002003 case ElementWiseUnary::SIN:
2004 os << "SIN";
2005 break;
2006 case ElementWiseUnary::ABS:
2007 os << "ABS";
2008 break;
Usama Arif6a4d5422019-05-24 14:53:59 +01002009 case ElementWiseUnary::ROUND:
2010 os << "ROUND";
2011 break;
ramelg01b1ba1e32021-09-25 11:53:26 +01002012 case ElementWiseUnary::LOGICAL_NOT:
2013 os << "LOGICAL_NOT";
2014 break;
Michalis Spyroue9362622018-11-23 17:41:37 +00002015 default:
2016 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2017 }
2018
2019 return os;
2020}
2021
Georgios Pinitas7900a9e2018-11-23 11:44:58 +00002022/** Formatted output of the Comparison Operations.
2023 *
2024 * @param[in] op Type to output.
2025 *
2026 * @return Formatted string.
2027 */
2028inline std::string to_string(const ComparisonOperation &op)
2029{
2030 std::stringstream str;
2031 str << op;
2032 return str.str();
2033}
2034
Michalis Spyroue9362622018-11-23 17:41:37 +00002035/** Formatted output of the Elementwise unary Operations.
2036 *
2037 * @param[in] op Type to output.
2038 *
2039 * @return Formatted string.
2040 */
2041inline std::string to_string(const ElementWiseUnary &op)
2042{
2043 std::stringstream str;
2044 str << op;
2045 return str.str();
2046}
2047
Alex Gildayc357c472018-03-21 13:54:09 +00002048/** Formatted output of the Norm Type.
2049 *
2050 * @param[in] type Type to output.
2051 *
2052 * @return Formatted string.
2053 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01002054inline std::string to_string(const NormType &type)
2055{
2056 std::stringstream str;
2057 str << type;
2058 return str.str();
2059}
2060
Alex Gildayc357c472018-03-21 13:54:09 +00002061/** Formatted output of the Pooling Type.
2062 *
2063 * @param[in] type Type to output.
2064 *
2065 * @return Formatted string.
2066 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01002067inline std::string to_string(const PoolingType &type)
2068{
2069 std::stringstream str;
2070 str << type;
2071 return str.str();
2072}
2073
Alex Gildayc357c472018-03-21 13:54:09 +00002074/** Formatted output of the Pooling Layer Info.
2075 *
2076 * @param[in] info Type to output.
2077 *
2078 * @return Formatted string.
2079 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01002080inline std::string to_string(const PoolingLayerInfo &info)
2081{
2082 std::stringstream str;
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +00002083 str << "{Type=" << info.pool_type << ","
Sang-Hoon Park11fedda2020-01-15 14:44:04 +00002084 << "DataLayout=" << info.data_layout << ","
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +00002085 << "IsGlobalPooling=" << info.is_global_pooling;
2086 if(!info.is_global_pooling)
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00002087 {
2088 str << ","
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +00002089 << "PoolSize=" << info.pool_size.width << "," << info.pool_size.height << ","
2090 << "PadStride=" << info.pad_stride_info;
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00002091 }
2092 str << "}";
Anthony Barbier2a07e182017-08-04 18:20:27 +01002093 return str.str();
2094}
2095
ramelg0137515692022-02-26 22:06:20 +00002096/** Formatted output of the Size3D type.
2097 *
2098 * @param[out] os Output stream
2099 * @param[in] size Type to output
2100 *
2101 * @return Modified output stream.
2102 */
2103inline ::std::ostream &operator<<(::std::ostream &os, const Size3D &size)
2104{
2105 os << size.width << "x" << size.height << "x" << size.depth;
2106
2107 return os;
2108}
2109
2110/** Formatted output of the Size3D type.
2111 *
2112 * @param[in] type Type to output
2113 *
2114 * @return Formatted string.
2115 */
2116inline std::string to_string(const Size3D &type)
2117{
2118 std::stringstream str;
2119 str << type;
2120 return str.str();
2121}
2122
2123/** Formatted output of the Padding3D type.
2124 *
2125 * @param[out] os Output stream.
2126 * @param[in] padding3d Padding info for 3D spatial dimension shape.
2127 *
2128 * @return Modified output stream.
2129 */
2130inline ::std::ostream &operator<<(::std::ostream &os, const Padding3D &padding3d)
2131{
2132 os << padding3d.left << "," << padding3d.right << ","
2133 << padding3d.top << "," << padding3d.bottom << ","
2134 << padding3d.front << "," << padding3d.back;
2135 return os;
2136}
2137
2138/** Converts a @ref Padding3D to string
2139 *
2140 * @param[in] padding3d Padding3D value to be converted
2141 *
2142 * @return String representing the corresponding Padding3D
2143 */
2144inline std::string to_string(const Padding3D &padding3d)
2145{
2146 std::stringstream str;
2147 str << padding3d;
2148 return str.str();
2149}
2150
2151/** Formatted output of the DimensionRoundingType type.
2152 *
2153 * @param[out] os Output stream.
2154 * @param[in] rounding_type DimensionRoundingType Dimension rounding type when down-scaling, or compute output shape of pooling(2D or 3D).
2155 *
2156 * @return Modified output stream.
2157 */
2158inline ::std::ostream &operator<<(::std::ostream &os, const DimensionRoundingType &rounding_type)
2159{
2160 switch(rounding_type)
2161 {
2162 case DimensionRoundingType::CEIL:
2163 os << "CEIL";
2164 break;
2165 case DimensionRoundingType::FLOOR:
2166 os << "FLOOR";
2167 break;
2168 default:
2169 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2170 }
2171 return os;
2172}
2173
2174/** Formatted output of the Pooling 3d Layer Info.
2175 *
2176 * @param[out] os Output stream.
2177 * @param[in] info Pooling 3D layer info to print to output stream.
2178 *
2179 * @return Modified output stream.
2180 */
2181inline ::std::ostream &operator<<(::std::ostream &os, const Pooling3dLayerInfo &info)
2182{
2183 os << "{Type=" << info.pool_type << ","
2184 << "IsGlobalPooling=" << info.is_global_pooling;
2185 if(!info.is_global_pooling)
2186 {
2187 os << ","
2188 << "PoolSize=" << info.pool_size << ", "
2189 << "Stride=" << info.stride << ", "
2190 << "Padding=" << info.padding << ", "
2191 << "Exclude Padding=" << info.exclude_padding << ", "
2192 << "fp_mixed_precision=" << info.fp_mixed_precision << ", "
2193 << "DimensionRoundingType=" << info.round_type;
2194 }
2195 os << "}";
2196 return os;
2197}
2198
2199/** Formatted output of the Pooling 3d Layer Info.
2200 *
2201 * @param[in] info Type to output.
2202 *
2203 * @return Formatted string.
2204 */
2205inline std::string to_string(const Pooling3dLayerInfo &info)
2206{
2207 std::stringstream str;
2208 str << info;
2209 return str.str();
2210}
2211
Michalis Spyrou6c7c38e2018-08-29 16:28:11 +01002212/** Formatted output of the PriorBoxLayerInfo.
2213 *
2214 * @param[in] info Type to output.
2215 *
2216 * @return Formatted string.
2217 */
2218inline std::string to_string(const PriorBoxLayerInfo &info)
2219{
2220 std::stringstream str;
2221 str << "{";
2222 str << "Clip:" << info.clip()
2223 << "Flip:" << info.flip()
2224 << "StepX:" << info.steps()[0]
2225 << "StepY:" << info.steps()[1]
2226 << "MinSizes:" << info.min_sizes().size()
2227 << "MaxSizes:" << info.max_sizes().size()
2228 << "ImgSizeX:" << info.img_size().x
2229 << "ImgSizeY:" << info.img_size().y
2230 << "Offset:" << info.offset()
2231 << "Variances:" << info.variances().size();
2232 str << "}";
2233 return str.str();
2234}
2235
Alex Gildayc357c472018-03-21 13:54:09 +00002236/** Formatted output of the Size2D type.
2237 *
2238 * @param[out] os Output stream
2239 * @param[in] size Type to output
2240 *
2241 * @return Modified output stream.
2242 */
John Richardson25f23682017-11-27 14:35:09 +00002243inline ::std::ostream &operator<<(::std::ostream &os, const Size2D &size)
2244{
2245 os << size.width << "x" << size.height;
2246
2247 return os;
2248}
2249
Alex Gildayc357c472018-03-21 13:54:09 +00002250/** Formatted output of the Size2D type.
2251 *
2252 * @param[in] type Type to output
2253 *
2254 * @return Formatted string.
2255 */
John Richardson25f23682017-11-27 14:35:09 +00002256inline std::string to_string(const Size2D &type)
2257{
2258 std::stringstream str;
2259 str << type;
2260 return str.str();
2261}
2262
Alex Gildayc357c472018-03-21 13:54:09 +00002263/** Formatted output of the ConvolutionMethod type.
2264 *
2265 * @param[out] os Output stream
2266 * @param[in] conv_method Type to output
2267 *
2268 * @return Modified output stream.
2269 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002270inline ::std::ostream &operator<<(::std::ostream &os, const ConvolutionMethod &conv_method)
2271{
2272 switch(conv_method)
2273 {
2274 case ConvolutionMethod::GEMM:
2275 os << "GEMM";
2276 break;
2277 case ConvolutionMethod::DIRECT:
2278 os << "DIRECT";
2279 break;
2280 case ConvolutionMethod::WINOGRAD:
2281 os << "WINOGRAD";
2282 break;
SiCongLid9287352021-11-03 19:01:22 +00002283 case ConvolutionMethod::FFT:
2284 os << "FFT";
2285 break;
2286 case ConvolutionMethod::GEMM_CONV2D:
2287 os << "GEMM_CONV2D";
2288 break;
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002289 default:
2290 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2291 }
2292
2293 return os;
2294}
2295
Alex Gildayc357c472018-03-21 13:54:09 +00002296/** Formatted output of the ConvolutionMethod type.
2297 *
2298 * @param[in] conv_method Type to output
2299 *
2300 * @return Formatted string.
2301 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002302inline std::string to_string(const ConvolutionMethod &conv_method)
2303{
2304 std::stringstream str;
2305 str << conv_method;
2306 return str.str();
2307}
2308
Alex Gildayc357c472018-03-21 13:54:09 +00002309/** Formatted output of the GPUTarget type.
2310 *
2311 * @param[out] os Output stream
2312 * @param[in] gpu_target Type to output
2313 *
2314 * @return Modified output stream.
2315 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002316inline ::std::ostream &operator<<(::std::ostream &os, const GPUTarget &gpu_target)
2317{
2318 switch(gpu_target)
2319 {
2320 case GPUTarget::GPU_ARCH_MASK:
2321 os << "GPU_ARCH_MASK";
2322 break;
Gian Marco Iodice3c4d0852022-07-11 12:09:45 +01002323 case GPUTarget::GPU_GENERATION_MASK:
2324 os << "GPU_GENERATION_MASK";
2325 break;
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002326 case GPUTarget::MIDGARD:
2327 os << "MIDGARD";
2328 break;
2329 case GPUTarget::BIFROST:
2330 os << "BIFROST";
2331 break;
Georgios Pinitasd5462ff2019-07-03 19:33:57 +01002332 case GPUTarget::VALHALL:
2333 os << "VALHALL";
2334 break;
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002335 case GPUTarget::T600:
2336 os << "T600";
2337 break;
2338 case GPUTarget::T700:
2339 os << "T700";
2340 break;
2341 case GPUTarget::T800:
2342 os << "T800";
2343 break;
Michalis Spyroua9676112018-02-22 18:07:43 +00002344 case GPUTarget::G71:
2345 os << "G71";
2346 break;
2347 case GPUTarget::G72:
2348 os << "G72";
2349 break;
2350 case GPUTarget::G51:
2351 os << "G51";
2352 break;
2353 case GPUTarget::G51BIG:
2354 os << "G51BIG";
2355 break;
2356 case GPUTarget::G51LIT:
2357 os << "G51LIT";
2358 break;
Gian Marco Iodice3c4d0852022-07-11 12:09:45 +01002359 case GPUTarget::G31:
2360 os << "G31";
2361 break;
Georgios Pinitasb03f7c52018-07-12 10:49:53 +01002362 case GPUTarget::G76:
2363 os << "G76";
Michalis Spyroua9676112018-02-22 18:07:43 +00002364 break;
Gian Marco Iodice3c4d0852022-07-11 12:09:45 +01002365 case GPUTarget::G52:
2366 os << "G52";
2367 break;
2368 case GPUTarget::G52LIT:
2369 os << "G52LIT";
2370 break;
Georgios Pinitasd5462ff2019-07-03 19:33:57 +01002371 case GPUTarget::G77:
2372 os << "G77";
Michalis Spyroua9676112018-02-22 18:07:43 +00002373 break;
Gian Marco Iodice3c4d0852022-07-11 12:09:45 +01002374 case GPUTarget::G57:
2375 os << "G57";
2376 break;
Georgios Pinitas4ffc42a2020-12-01 16:28:24 +00002377 case GPUTarget::G78:
2378 os << "G78";
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002379 break;
Gian Marco Iodice3c4d0852022-07-11 12:09:45 +01002380 case GPUTarget::G68:
2381 os << "G68";
2382 break;
2383 case GPUTarget::G78AE:
2384 os << "G78AE";
Pablo Marquez Tellob1496e62021-06-25 14:49:37 +01002385 break;
Gian Marco Iodiceab2bc732022-01-19 10:06:45 +00002386 case GPUTarget::G710:
2387 os << "G710";
Georgios Pinitasd5462ff2019-07-03 19:33:57 +01002388 break;
Gian Marco Iodice3c4d0852022-07-11 12:09:45 +01002389 case GPUTarget::G610:
2390 os << "G610";
2391 break;
2392 case GPUTarget::G510:
2393 os << "G510";
2394 break;
2395 case GPUTarget::G310:
2396 os << "G310";
2397 break;
Gunes Bayir4bfc70e2021-12-10 16:17:56 +00002398 case GPUTarget::G715:
2399 os << "G715";
2400 break;
2401 case GPUTarget::G615:
2402 os << "G615";
2403 break;
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002404 default:
2405 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2406 }
2407
2408 return os;
2409}
2410
Alex Gildayc357c472018-03-21 13:54:09 +00002411/** Formatted output of the GPUTarget type.
2412 *
2413 * @param[in] gpu_target Type to output
2414 *
2415 * @return Formatted string.
2416 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002417inline std::string to_string(const GPUTarget &gpu_target)
2418{
2419 std::stringstream str;
2420 str << gpu_target;
2421 return str.str();
2422}
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00002423
John Richardson8de92612018-02-22 14:09:31 +00002424/** Formatted output of the DetectionWindow type.
2425 *
2426 * @param[out] os Output stream
2427 * @param[in] detection_window Type to output
2428 *
2429 * @return Modified output stream.
2430 */
John Richardson684cb0f2018-01-09 11:17:00 +00002431inline ::std::ostream &operator<<(::std::ostream &os, const DetectionWindow &detection_window)
2432{
2433 os << "{x=" << detection_window.x << ","
2434 << "y=" << detection_window.y << ","
2435 << "width=" << detection_window.width << ","
2436 << "height=" << detection_window.height << ","
2437 << "idx_class=" << detection_window.idx_class << ","
2438 << "score=" << detection_window.score << "}";
2439
2440 return os;
2441}
2442
Isabella Gottardi05e56442018-11-16 11:26:52 +00002443/** Formatted output of the DetectionOutputLayerCodeType type.
2444 *
2445 * @param[out] os Output stream
2446 * @param[in] detection_code Type to output
2447 *
2448 * @return Modified output stream.
2449 */
2450inline ::std::ostream &operator<<(::std::ostream &os, const DetectionOutputLayerCodeType &detection_code)
2451{
2452 switch(detection_code)
2453 {
2454 case DetectionOutputLayerCodeType::CENTER_SIZE:
2455 os << "CENTER_SIZE";
2456 break;
2457 case DetectionOutputLayerCodeType::CORNER:
2458 os << "CORNER";
2459 break;
2460 case DetectionOutputLayerCodeType::CORNER_SIZE:
2461 os << "CORNER_SIZE";
2462 break;
2463 case DetectionOutputLayerCodeType::TF_CENTER:
2464 os << "TF_CENTER";
2465 break;
2466 default:
2467 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2468 }
2469
2470 return os;
2471}
2472/** Formatted output of the DetectionOutputLayerCodeType type.
2473 *
2474 * @param[in] detection_code Type to output
2475 *
2476 * @return Formatted string.
2477 */
2478inline std::string to_string(const DetectionOutputLayerCodeType &detection_code)
2479{
2480 std::stringstream str;
2481 str << detection_code;
2482 return str.str();
2483}
2484
2485/** Formatted output of the DetectionOutputLayerInfo type.
2486 *
2487 * @param[out] os Output stream
2488 * @param[in] detection_info Type to output
2489 *
2490 * @return Modified output stream.
2491 */
2492inline ::std::ostream &operator<<(::std::ostream &os, const DetectionOutputLayerInfo &detection_info)
2493{
2494 os << "{Classes=" << detection_info.num_classes() << ","
2495 << "ShareLocation=" << detection_info.share_location() << ","
2496 << "CodeType=" << detection_info.code_type() << ","
2497 << "VarianceEncodedInTarget=" << detection_info.variance_encoded_in_target() << ","
2498 << "KeepTopK=" << detection_info.keep_top_k() << ","
2499 << "NMSThreshold=" << detection_info.nms_threshold() << ","
2500 << "Eta=" << detection_info.eta() << ","
2501 << "BackgroundLabelId=" << detection_info.background_label_id() << ","
2502 << "ConfidenceThreshold=" << detection_info.confidence_threshold() << ","
2503 << "TopK=" << detection_info.top_k() << ","
2504 << "NumLocClasses=" << detection_info.num_loc_classes()
2505 << "}";
2506
2507 return os;
2508}
2509
2510/** Formatted output of the DetectionOutputLayerInfo type.
2511 *
2512 * @param[in] detection_info Type to output
2513 *
2514 * @return Formatted string.
2515 */
2516inline std::string to_string(const DetectionOutputLayerInfo &detection_info)
2517{
2518 std::stringstream str;
2519 str << detection_info;
2520 return str.str();
2521}
Isabella Gottardia7acb3c2019-01-08 13:48:44 +00002522/** Formatted output of the DetectionPostProcessLayerInfo type.
2523 *
2524 * @param[out] os Output stream
2525 * @param[in] detection_info Type to output
2526 *
2527 * @return Modified output stream.
2528 */
2529inline ::std::ostream &operator<<(::std::ostream &os, const DetectionPostProcessLayerInfo &detection_info)
2530{
2531 os << "{MaxDetections=" << detection_info.max_detections() << ","
2532 << "MaxClassesPerDetection=" << detection_info.max_classes_per_detection() << ","
2533 << "NmsScoreThreshold=" << detection_info.nms_score_threshold() << ","
2534 << "NmsIouThreshold=" << detection_info.iou_threshold() << ","
2535 << "NumClasses=" << detection_info.num_classes() << ","
2536 << "ScaleValue_y=" << detection_info.scale_value_y() << ","
2537 << "ScaleValue_x=" << detection_info.scale_value_x() << ","
2538 << "ScaleValue_h=" << detection_info.scale_value_h() << ","
2539 << "ScaleValue_w=" << detection_info.scale_value_w() << ","
2540 << "UseRegularNms=" << detection_info.use_regular_nms() << ","
2541 << "DetectionPerClass=" << detection_info.detection_per_class()
2542 << "}";
2543
2544 return os;
2545}
2546
2547/** Formatted output of the DetectionPostProcessLayerInfo type.
2548 *
2549 * @param[in] detection_info Type to output
2550 *
2551 * @return Formatted string.
2552 */
2553inline std::string to_string(const DetectionPostProcessLayerInfo &detection_info)
2554{
2555 std::stringstream str;
2556 str << detection_info;
2557 return str.str();
2558}
Georgios Pinitasc6f95102021-03-30 10:03:01 +01002559
John Richardson8de92612018-02-22 14:09:31 +00002560/** Formatted output of the DetectionWindow type.
2561 *
2562 * @param[in] detection_window Type to output
2563 *
2564 * @return Formatted string.
2565 */
2566inline std::string to_string(const DetectionWindow &detection_window)
2567{
2568 std::stringstream str;
2569 str << detection_window;
2570 return str.str();
2571}
2572
Michalis Spyrou6c7c38e2018-08-29 16:28:11 +01002573/** Formatted output of @ref PriorBoxLayerInfo.
2574 *
2575 * @param[out] os Output stream.
2576 * @param[in] info Type to output.
2577 *
2578 * @return Modified output stream.
2579 */
2580inline ::std::ostream &operator<<(::std::ostream &os, const PriorBoxLayerInfo &info)
2581{
2582 os << "Clip:" << info.clip()
2583 << "Flip:" << info.flip()
2584 << "StepX:" << info.steps()[0]
2585 << "StepY:" << info.steps()[1]
2586 << "MinSizes:" << info.min_sizes()
2587 << "MaxSizes:" << info.max_sizes()
2588 << "ImgSizeX:" << info.img_size().x
2589 << "ImgSizeY:" << info.img_size().y
2590 << "Offset:" << info.offset()
2591 << "Variances:" << info.variances();
2592
2593 return os;
2594}
2595
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00002596/** Formatted output of the WinogradInfo type. */
2597inline ::std::ostream &operator<<(::std::ostream &os, const WinogradInfo &info)
2598{
2599 os << "{OutputTileSize=" << info.output_tile_size << ","
2600 << "KernelSize=" << info.kernel_size << ","
2601 << "PadStride=" << info.convolution_info << ","
2602 << "OutputDataLayout=" << info.output_data_layout << "}";
2603
2604 return os;
2605}
2606
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00002607inline std::string to_string(const WinogradInfo &type)
2608{
2609 std::stringstream str;
2610 str << type;
2611 return str.str();
2612}
Anthony Barbier671a11e2018-07-06 15:11:36 +01002613
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +01002614/** Convert a CLTunerMode value to a string
2615 *
2616 * @param val CLTunerMode value to be converted
2617 *
2618 * @return String representing the corresponding CLTunerMode.
2619 */
2620inline std::string to_string(const CLTunerMode val)
2621{
2622 switch(val)
2623 {
2624 case CLTunerMode::EXHAUSTIVE:
2625 {
2626 return std::string("Exhaustive");
2627 }
2628 case CLTunerMode::NORMAL:
2629 {
2630 return std::string("Normal");
2631 }
2632 case CLTunerMode::RAPID:
2633 {
2634 return std::string("Rapid");
2635 }
2636 default:
2637 {
2638 ARM_COMPUTE_ERROR("Invalid tuner mode.");
2639 return std::string("UNDEFINED");
2640 }
2641 }
2642}
SiCong Lidb4a6c12021-02-05 09:30:57 +00002643/** Converts a @ref CLGEMMKernelType to string
2644 *
2645 * @param[in] val CLGEMMKernelType value to be converted
2646 *
2647 * @return String representing the corresponding CLGEMMKernelType
2648 */
2649inline std::string to_string(CLGEMMKernelType val)
2650{
2651 switch(val)
2652 {
SiCong Lidb4a6c12021-02-05 09:30:57 +00002653 case CLGEMMKernelType::NATIVE:
2654 {
2655 return "Native";
2656 }
2657 case CLGEMMKernelType::RESHAPED_ONLY_RHS:
2658 {
2659 return "Reshaped_Only_RHS";
2660 }
2661 case CLGEMMKernelType::RESHAPED:
2662 {
2663 return "Reshaped";
2664 }
2665 default:
2666 {
2667 return "Unknown";
2668 }
2669 }
2670}
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +01002671/** [Print CLTunerMode type] **/
2672/** Formatted output of the CLTunerMode type.
2673 *
2674 * @param[out] os Output stream.
2675 * @param[in] val CLTunerMode to output.
2676 *
2677 * @return Modified output stream.
2678 */
2679inline ::std::ostream &operator<<(::std::ostream &os, const CLTunerMode &val)
2680{
2681 os << to_string(val);
2682 return os;
2683}
2684
ramelg013ae3d882021-09-12 23:07:47 +01002685/** Formatted output of the ConvolutionInfo type.
2686 *
2687 * @param[out] os Output stream.
2688 * @param[in] conv_info ConvolutionInfo to output.
2689 *
2690 * @return Modified output stream.
2691 */
2692inline ::std::ostream &operator<<(::std::ostream &os, const ConvolutionInfo &conv_info)
2693{
SiCongLi579ca842021-10-18 09:38:33 +01002694 os << "{PadStrideInfo=" << conv_info.pad_stride_info << ", "
2695 << "depth_multiplier=" << conv_info.depth_multiplier << ", "
2696 << "act_info=" << to_string(conv_info.act_info) << ", "
2697 << "dilation=" << conv_info.dilation << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002698 return os;
2699}
2700
2701/** Converts a @ref ConvolutionInfo to string
2702 *
2703 * @param[in] info ConvolutionInfo value to be converted
2704 *
2705 * @return String representing the corresponding ConvolutionInfo
2706 */
2707inline std::string to_string(const ConvolutionInfo &info)
2708{
2709 std::stringstream str;
2710 str << info;
2711 return str.str();
2712}
2713
2714/** Formatted output of the FullyConnectedLayerInfo type.
2715 *
2716 * @param[out] os Output stream.
2717 * @param[in] layer_info FullyConnectedLayerInfo to output.
2718 *
2719 * @return Modified output stream.
2720 */
2721inline ::std::ostream &operator<<(::std::ostream &os, const FullyConnectedLayerInfo &layer_info)
2722{
SiCongLi579ca842021-10-18 09:38:33 +01002723 os << "{activation_info=" << to_string(layer_info.activation_info) << ", "
2724 << "weights_trained_layout=" << layer_info.weights_trained_layout << ", "
2725 << "transpose_weights=" << layer_info.transpose_weights << ", "
2726 << "are_weights_reshaped=" << layer_info.are_weights_reshaped << ", "
2727 << "retain_internal_weights=" << layer_info.retain_internal_weights << ", "
2728 << "constant_weights=" << layer_info.transpose_weights << ", "
2729 << "fp_mixed_precision=" << layer_info.fp_mixed_precision << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002730 return os;
2731}
2732
2733/** Converts a @ref FullyConnectedLayerInfo to string
2734 *
2735 * @param[in] info FullyConnectedLayerInfo value to be converted
2736 *
2737 * @return String representing the corresponding FullyConnectedLayerInfo
2738 */
2739inline std::string to_string(const FullyConnectedLayerInfo &info)
2740{
2741 std::stringstream str;
2742 str << info;
2743 return str.str();
2744}
2745
2746/** Formatted output of the GEMMLowpOutputStageType type.
2747 *
2748 * @param[out] os Output stream.
2749 * @param[in] gemm_type GEMMLowpOutputStageType to output.
2750 *
2751 * @return Modified output stream.
2752 */
2753inline ::std::ostream &operator<<(::std::ostream &os, const GEMMLowpOutputStageType &gemm_type)
2754{
2755 switch(gemm_type)
2756 {
2757 case GEMMLowpOutputStageType::NONE:
2758 os << "NONE";
2759 break;
2760 case GEMMLowpOutputStageType::QUANTIZE_DOWN:
2761 os << "QUANTIZE_DOWN";
2762 break;
2763 case GEMMLowpOutputStageType::QUANTIZE_DOWN_FIXEDPOINT:
2764 os << "QUANTIZE_DOWN_FIXEDPOINT";
2765 break;
2766 case GEMMLowpOutputStageType::QUANTIZE_DOWN_FLOAT:
2767 os << "QUANTIZE_DOWN_FLOAT";
2768 break;
2769 default:
2770 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2771 }
2772 return os;
2773}
2774
2775/** Converts a @ref GEMMLowpOutputStageType to string
2776 *
2777 * @param[in] gemm_type GEMMLowpOutputStageType value to be converted
2778 *
2779 * @return String representing the corresponding GEMMLowpOutputStageType
2780 */
2781inline std::string to_string(const GEMMLowpOutputStageType &gemm_type)
2782{
2783 std::stringstream str;
2784 str << gemm_type;
2785 return str.str();
2786}
2787
2788/** Formatted output of the GEMMLowpOutputStageInfo type.
2789 *
2790 * @param[out] os Output stream.
2791 * @param[in] gemm_info GEMMLowpOutputStageInfo to output.
2792 *
2793 * @return Modified output stream.
2794 */
2795inline ::std::ostream &operator<<(::std::ostream &os, const GEMMLowpOutputStageInfo &gemm_info)
2796{
SiCongLi579ca842021-10-18 09:38:33 +01002797 os << "{type=" << gemm_info.type << ", "
2798 << "gemlowp_offset=" << gemm_info.gemmlowp_offset << ", "
2799 << "gemmlowp_multiplier=" << gemm_info.gemmlowp_multiplier << ", "
2800 << "gemmlowp_shift=" << gemm_info.gemmlowp_shift << ", "
2801 << "gemmlowp_min_bound=" << gemm_info.gemmlowp_min_bound << ", "
2802 << "gemmlowp_max_bound=" << gemm_info.gemmlowp_max_bound << ", "
2803 << "gemmlowp_multipliers=" << gemm_info.gemmlowp_multiplier << ", "
2804 << "gemmlowp_shifts=" << gemm_info.gemmlowp_shift << ", "
2805 << "gemmlowp_real_multiplier=" << gemm_info.gemmlowp_real_multiplier << ", "
2806 << "is_quantized_per_channel=" << gemm_info.is_quantized_per_channel << ", "
2807 << "output_data_type=" << gemm_info.output_data_type << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002808 return os;
2809}
2810
2811/** Converts a @ref GEMMLowpOutputStageInfo to string
2812 *
2813 * @param[in] gemm_info GEMMLowpOutputStageInfo value to be converted
2814 *
2815 * @return String representing the corresponding GEMMLowpOutputStageInfo
2816 */
2817inline std::string to_string(const GEMMLowpOutputStageInfo &gemm_info)
2818{
2819 std::stringstream str;
2820 str << gemm_info;
2821 return str.str();
2822}
2823
2824/** Formatted output of the Conv2dInfo type.
2825 *
2826 * @param[out] os Output stream.
2827 * @param[in] conv_info Conv2dInfo to output.
2828 *
2829 * @return Modified output stream.
2830 */
2831inline ::std::ostream &operator<<(::std::ostream &os, const Conv2dInfo &conv_info)
2832{
SiCongLi579ca842021-10-18 09:38:33 +01002833 os << "{conv_info=" << conv_info.conv_info << ", "
2834 << "dilation=" << conv_info.dilation << ", "
2835 << "act_info=" << to_string(conv_info.act_info) << ", "
2836 << "enable_fast_math=" << conv_info.enable_fast_math << ", "
2837 << "num_groups=" << conv_info.num_groups << ","
2838 << "post_ops=" << conv_info.post_ops << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002839 return os;
2840}
2841
2842/** Converts a @ref Conv2dInfo to string
2843 *
2844 * @param[in] conv_info Conv2dInfo value to be converted
2845 *
2846 * @return String representing the corresponding Conv2dInfo
2847 */
2848inline std::string to_string(const Conv2dInfo &conv_info)
2849{
2850 std::stringstream str;
2851 str << conv_info;
2852 return str.str();
2853}
2854
2855/** Formatted output of the PixelValue type.
2856 *
2857 * @param[out] os Output stream.
2858 * @param[in] pixel_value PixelValue to output.
2859 *
2860 * @return Modified output stream.
2861 */
2862inline ::std::ostream &operator<<(::std::ostream &os, const PixelValue &pixel_value)
2863{
SiCongLi579ca842021-10-18 09:38:33 +01002864 os << "{value.u64=" << pixel_value.get<uint64_t>() << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002865 return os;
2866}
2867
2868/** Converts a @ref PixelValue to string
2869 *
2870 * @param[in] pixel_value PixelValue value to be converted
2871 *
2872 * @return String representing the corresponding PixelValue
2873 */
2874inline std::string to_string(const PixelValue &pixel_value)
2875{
2876 std::stringstream str;
2877 str << pixel_value;
2878 return str.str();
2879}
2880
2881/** Formatted output of the ScaleKernelInfo type.
2882 *
2883 * @param[out] os Output stream.
2884 * @param[in] scale_info ScaleKernelInfo to output.
2885 *
2886 * @return Modified output stream.
2887 */
2888inline ::std::ostream &operator<<(::std::ostream &os, const ScaleKernelInfo &scale_info)
2889{
SiCongLi579ca842021-10-18 09:38:33 +01002890 os << "{interpolation_policy=" << scale_info.interpolation_policy << ", "
2891 << "BorderMode=" << scale_info.border_mode << ", "
2892 << "PixelValue=" << scale_info.constant_border_value << ", "
2893 << "SamplingPolicy=" << scale_info.sampling_policy << ", "
2894 << "use_padding=" << scale_info.use_padding << ", "
2895 << "align_corners=" << scale_info.align_corners << ", "
2896 << "data_layout=" << scale_info.data_layout << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002897 return os;
2898}
2899
2900/** Converts a @ref ScaleKernelInfo to string
2901 *
2902 * @param[in] scale_info ScaleKernelInfo value to be converted
2903 *
2904 * @return String representing the corresponding ScaleKernelInfo
2905 */
2906inline std::string to_string(const ScaleKernelInfo &scale_info)
2907{
2908 std::stringstream str;
2909 str << scale_info;
2910 return str.str();
2911}
2912
2913/** Formatted output of the FFTDirection type.
2914 *
2915 * @param[out] os Output stream.
2916 * @param[in] fft_dir FFTDirection to output.
2917 *
2918 * @return Modified output stream.
2919 */
2920inline ::std::ostream &operator<<(::std::ostream &os, const FFTDirection &fft_dir)
2921{
2922 switch(fft_dir)
2923 {
2924 case FFTDirection::Forward:
2925 os << "Forward";
2926 break;
2927 case FFTDirection::Inverse:
2928 os << "Inverse";
2929 break;
2930 default:
2931 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2932 }
2933 return os;
2934}
2935
2936/** Converts a @ref FFT1DInfo to string
2937 *
2938 * @param[in] fft_dir FFT1DInfo value to be converted
2939 *
2940 * @return String representing the corresponding FFT1DInfo
2941 */
2942inline std::string to_string(const FFTDirection &fft_dir)
2943{
2944 std::stringstream str;
ramelg01cbbb0382021-09-17 17:36:57 +01002945 str << "{" << fft_dir << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002946 return str.str();
2947}
2948
2949/** Formatted output of the FFT1DInfo type.
2950 *
2951 * @param[out] os Output stream.
2952 * @param[in] fft1d_info FFT1DInfo to output.
2953 *
2954 * @return Modified output stream.
2955 */
2956inline ::std::ostream &operator<<(::std::ostream &os, const FFT1DInfo &fft1d_info)
2957{
SiCongLi579ca842021-10-18 09:38:33 +01002958 os << "{axis=" << fft1d_info.axis << ", "
2959 << "direction=" << fft1d_info.direction << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002960 return os;
2961}
2962
2963/** Converts a @ref FFT1DInfo to string
2964 *
2965 * @param[in] fft1d_info FFT1DInfo value to be converted
2966 *
2967 * @return String representing the corresponding FFT1DInfo
2968 */
2969inline std::string to_string(const FFT1DInfo &fft1d_info)
2970{
2971 std::stringstream str;
2972 str << fft1d_info;
2973 return str.str();
2974}
2975
2976/** Formatted output of the FFT2DInfo type.
2977 *
2978 * @param[out] os Output stream.
2979 * @param[in] fft2d_info FFT2DInfo to output.
2980 *
2981 * @return Modified output stream.
2982 */
2983inline ::std::ostream &operator<<(::std::ostream &os, const FFT2DInfo &fft2d_info)
2984{
SiCongLi579ca842021-10-18 09:38:33 +01002985 os << "{axis=" << fft2d_info.axis0 << ", "
2986 << "axis=" << fft2d_info.axis1 << ", "
2987 << "direction=" << fft2d_info.direction << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002988 return os;
2989}
2990
2991/** Converts a @ref FFT2DInfo to string
2992 *
2993 * @param[in] fft2d_info FFT2DInfo value to be converted
2994 *
2995 * @return String representing the corresponding FFT2DInfo
2996 */
2997inline std::string to_string(const FFT2DInfo &fft2d_info)
2998{
2999 std::stringstream str;
3000 str << fft2d_info;
3001 return str.str();
3002}
3003
3004/** Formatted output of the Coordinates2D type.
3005 *
3006 * @param[out] os Output stream.
3007 * @param[in] coord_2d Coordinates2D to output.
3008 *
3009 * @return Modified output stream.
3010 */
3011inline ::std::ostream &operator<<(::std::ostream &os, const Coordinates2D &coord_2d)
3012{
SiCongLi579ca842021-10-18 09:38:33 +01003013 os << "{x=" << coord_2d.x << ", "
3014 << "y=" << coord_2d.y << "}";
ramelg013ae3d882021-09-12 23:07:47 +01003015 return os;
3016}
3017
3018/** Converts a @ref Coordinates2D to string
3019 *
3020 * @param[in] coord_2d Coordinates2D value to be converted
3021 *
3022 * @return String representing the corresponding Coordinates2D
3023 */
3024inline std::string to_string(const Coordinates2D &coord_2d)
3025{
3026 std::stringstream str;
3027 str << coord_2d;
3028 return str.str();
3029}
3030
3031/** Formatted output of the FuseBatchNormalizationType type.
3032 *
3033 * @param[out] os Output stream.
3034 * @param[in] fuse_type FuseBatchNormalizationType to output.
3035 *
3036 * @return Modified output stream.
3037 */
3038inline ::std::ostream &operator<<(::std::ostream &os, const FuseBatchNormalizationType &fuse_type)
3039{
3040 switch(fuse_type)
3041 {
3042 case FuseBatchNormalizationType::CONVOLUTION:
3043 os << "CONVOLUTION";
3044 break;
3045 case FuseBatchNormalizationType::DEPTHWISECONVOLUTION:
3046 os << "DEPTHWISECONVOLUTION";
3047 break;
3048 default:
3049 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
3050 }
3051 return os;
3052}
3053
3054/** Converts a @ref FuseBatchNormalizationType to string
3055 *
3056 * @param[in] fuse_type FuseBatchNormalizationType value to be converted
3057 *
3058 * @return String representing the corresponding FuseBatchNormalizationType
3059 */
3060inline std::string to_string(const FuseBatchNormalizationType &fuse_type)
3061{
3062 std::stringstream str;
3063 str << fuse_type;
3064 return str.str();
3065}
3066
ramelg01cbbb0382021-09-17 17:36:57 +01003067/** Formatted output of the SoftmaxKernelInfo type.
3068 *
3069 * @param[out] os Output stream.
3070 * @param[in] info SoftmaxKernelInfo to output.
3071 *
3072 * @return Modified output stream.
3073 */
3074inline ::std::ostream &operator<<(::std::ostream &os, const SoftmaxKernelInfo &info)
3075{
SiCongLi579ca842021-10-18 09:38:33 +01003076 os << "{beta=" << info.beta << ", "
3077 << "is_log=" << info.is_log << ", "
3078 << "input_data_type=" << info.input_data_type << ", "
3079 << "axis=" << info.axis << "}";
ramelg01cbbb0382021-09-17 17:36:57 +01003080 return os;
3081}
3082
3083/** Converts a @ref SoftmaxKernelInfo to string
3084 *
3085 * @param[in] info SoftmaxKernelInfo value to be converted
3086 *
3087 * @return String representing the corresponding SoftmaxKernelInfo
3088 */
3089inline std::string to_string(const SoftmaxKernelInfo &info)
3090{
3091 std::stringstream str;
3092 str << info;
3093 return str.str();
3094}
3095
3096/** Formatted output of the ScaleKernelInfo type.
3097 *
3098 * @param[out] os Output stream.
3099 * @param[in] lstm_params LSTMParams to output.
3100 *
3101 * @return Modified output stream.
3102 */
3103template <typename T>
ramelg014a6d9e82021-10-02 14:34:36 +01003104::std::ostream &operator<<(::std::ostream &os, const LSTMParams<T> &lstm_params)
ramelg01cbbb0382021-09-17 17:36:57 +01003105{
ramelg014a6d9e82021-10-02 14:34:36 +01003106 os << "{input_to_input_weights=" << to_string(lstm_params.input_to_input_weights()) << ", "
3107 << "recurrent_to_input_weights=" << to_string(lstm_params.recurrent_to_input_weights()) << ", "
3108 << "cell_to_input_weights=" << to_string(lstm_params.cell_to_input_weights()) << ", "
3109 << "input_gate_bias=" << to_string(lstm_params.input_gate_bias()) << ", "
3110 << "cell_to_forget_weights=" << to_string(lstm_params.cell_to_forget_weights()) << ", "
3111 << "cell_to_output_weights=" << to_string(lstm_params.cell_to_output_weights()) << ", "
3112 << "projection_weights=" << to_string(lstm_params.projection_weights()) << ", "
3113 << "projection_bias=" << to_string(lstm_params.projection_bias()) << ", "
3114 << "input_layer_norm_weights=" << to_string(lstm_params.input_layer_norm_weights()) << ", "
3115 << "forget_layer_norm_weights=" << to_string(lstm_params.forget_layer_norm_weights()) << ", "
3116 << "cell_layer_norm_weights=" << to_string(lstm_params.cell_layer_norm_weights()) << ", "
3117 << "output_layer_norm_weights=" << to_string(lstm_params.output_layer_norm_weights()) << ", "
ramelg01cbbb0382021-09-17 17:36:57 +01003118 << "cell_clip=" << lstm_params.cell_clip() << ", "
3119 << "projection_clip=" << lstm_params.projection_clip() << ", "
3120 << "input_intermediate_scale=" << lstm_params.input_intermediate_scale() << ", "
3121 << "forget_intermediate_scale=" << lstm_params.forget_intermediate_scale() << ", "
3122 << "cell_intermediate_scale=" << lstm_params.cell_intermediate_scale() << ", "
3123 << "hidden_state_zero=" << lstm_params.hidden_state_zero() << ", "
3124 << "hidden_state_scale=" << lstm_params.hidden_state_scale() << ", "
3125 << "has_peephole_opt=" << lstm_params.has_peephole_opt() << ", "
3126 << "has_projection=" << lstm_params.has_projection() << ", "
3127 << "has_cifg_opt=" << lstm_params.has_cifg_opt() << ", "
3128 << "use_layer_norm=" << lstm_params.use_layer_norm() << "}";
3129 return os;
3130}
3131
3132/** Converts a @ref LSTMParams to string
3133 *
3134 * @param[in] lstm_params LSTMParams<T> value to be converted
3135 *
3136 * @return String representing the corresponding LSTMParams
3137 */
3138template <typename T>
ramelg014a6d9e82021-10-02 14:34:36 +01003139std::string to_string(const LSTMParams<T> &lstm_params)
ramelg01cbbb0382021-09-17 17:36:57 +01003140{
3141 std::stringstream str;
3142 str << lstm_params;
3143 return str.str();
3144}
3145
3146/** Converts a @ref LSTMParams to string
3147 *
3148 * @param[in] num uint8_t value to be converted
3149 *
3150 * @return String representing the corresponding uint8_t
3151 */
3152inline std::string to_string(const uint8_t num)
3153{
3154 // Explicity cast the uint8_t to signed integer and call the corresponding overloaded to_string() function.
3155 return ::std::to_string(static_cast<int>(num));
3156}
3157
ramelg014a6d9e82021-10-02 14:34:36 +01003158/** Available non maxima suppression types */
3159/** Formatted output of the NMSType type.
3160 *
3161 * @param[out] os Output stream.
3162 * @param[in] nms_type NMSType to output.
3163 *
3164 * @return Modified output stream.
3165 */
3166inline ::std::ostream &operator<<(::std::ostream &os, const NMSType &nms_type)
3167{
3168 switch(nms_type)
3169 {
3170 case NMSType::LINEAR:
3171 os << "LINEAR";
3172 break;
3173 case NMSType::GAUSSIAN:
3174 os << "GAUSSIAN";
3175 break;
3176 case NMSType::ORIGINAL:
3177 os << "ORIGINAL";
3178 break;
3179 default:
3180 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
3181 }
3182 return os;
3183}
3184
3185/** Converts a @ref NMSType to string
3186 *
3187 * @param[in] nms_type NMSType value to be converted
3188 *
3189 * @return String representing the corresponding NMSType
3190 */
3191inline std::string to_string(const NMSType nms_type)
3192{
3193 std::stringstream str;
3194 str << nms_type;
3195 return str.str();
3196}
3197
3198/** Formatted output of the BoxNMSLimitInfo type.
3199 *
3200 * @param[out] os Output stream.
3201 * @param[in] info BoxNMSLimitInfo to output.
3202 *
3203 * @return Modified output stream.
3204 */
3205inline ::std::ostream &operator<<(::std::ostream &os, const BoxNMSLimitInfo &info)
3206{
SiCongLi579ca842021-10-18 09:38:33 +01003207 os << "{score_thresh=" << info.score_thresh() << ", "
3208 << "nms=" << info.nms() << ", "
3209 << "detections_per_im=" << info.detections_per_im() << ", "
3210 << "soft_nms_enabled=" << info.soft_nms_enabled() << ", "
3211 << "soft_nms_min_score_thres=" << info.soft_nms_min_score_thres() << ", "
3212 << "suppress_size=" << info.suppress_size() << ", "
3213 << "min_size=" << info.min_size() << ", "
3214 << "im_width=" << info.im_width() << ", "
3215 << "im_height=" << info.im_height() << "}";
ramelg014a6d9e82021-10-02 14:34:36 +01003216 return os;
3217}
3218
3219/** Converts a @ref BoxNMSLimitInfo to string
3220 *
3221 * @param[in] info BoxNMSLimitInfo value to be converted
3222 *
3223 * @return String representing the corresponding BoxNMSLimitInfo
3224 */
3225inline std::string to_string(const BoxNMSLimitInfo &info)
3226{
3227 std::stringstream str;
3228 str << info;
3229 return str.str();
3230}
3231
Giorgio Arena945ae9e2021-10-13 11:13:04 +01003232/** Converts a @ref DimensionRoundingType to string
3233 *
3234 * @param[in] rounding_type DimensionRoundingType value to be converted
3235 *
3236 * @return String representing the corresponding DimensionRoundingType
3237 */
3238inline std::string to_string(const DimensionRoundingType &rounding_type)
3239{
3240 std::stringstream str;
3241 str << rounding_type;
3242 return str.str();
3243}
3244
Giorgio Arena945ae9e2021-10-13 11:13:04 +01003245/** Formatted output of the Conv3dInfo type.
3246 *
3247 * @param[out] os Output stream.
3248 * @param[in] conv3d_info Type to output.
3249 *
3250 * @return Modified output stream.
3251 */
3252inline ::std::ostream &operator<<(::std::ostream &os, const Conv3dInfo &conv3d_info)
3253{
3254 os << conv3d_info.stride;
3255 os << ";";
3256 os << conv3d_info.padding;
3257 os << ";";
3258 os << to_string(conv3d_info.act_info);
3259 os << ";";
3260 os << conv3d_info.dilation;
3261 os << ";";
3262 os << conv3d_info.round_type;
3263 os << ";";
3264 os << conv3d_info.enable_fast_math;
3265
3266 return os;
3267}
3268
3269/** Formatted output of the Conv3dInfo type.
3270 *
3271 * @param[in] conv3d_info Type to output.
3272 *
3273 * @return Formatted string.
3274 */
3275inline std::string to_string(const Conv3dInfo &conv3d_info)
3276{
3277 std::stringstream str;
3278 str << conv3d_info;
3279 return str.str();
3280}
3281
Ramy Elgammal91780022022-07-20 14:57:37 +01003282/** Formatted output of the arm_compute::WeightFormat type.
3283 *
3284 * @param[in] wf arm_compute::WeightFormat Type to output.
3285 *
3286 * @return Formatted string.
3287 */
3288inline std::string to_string(const WeightFormat wf)
Francesco Petrogalli553f6952022-06-30 10:22:01 +00003289{
Ramy Elgammal91780022022-07-20 14:57:37 +01003290#define __CASE_WEIGHT_FORMAT(wf) \
3291case WeightFormat::wf: \
3292 return #wf;
3293 switch(wf)
3294 {
3295 __CASE_WEIGHT_FORMAT(UNSPECIFIED)
3296 __CASE_WEIGHT_FORMAT(ANY)
3297 __CASE_WEIGHT_FORMAT(OHWI)
3298 __CASE_WEIGHT_FORMAT(OHWIo2)
3299 __CASE_WEIGHT_FORMAT(OHWIo4)
3300 __CASE_WEIGHT_FORMAT(OHWIo8)
3301 __CASE_WEIGHT_FORMAT(OHWIo16)
3302 __CASE_WEIGHT_FORMAT(OHWIo32)
3303 __CASE_WEIGHT_FORMAT(OHWIo64)
3304 __CASE_WEIGHT_FORMAT(OHWIo128)
3305 __CASE_WEIGHT_FORMAT(OHWIo4i2)
3306 __CASE_WEIGHT_FORMAT(OHWIo4i2_bf16)
3307 __CASE_WEIGHT_FORMAT(OHWIo8i2)
3308 __CASE_WEIGHT_FORMAT(OHWIo8i2_bf16)
3309 __CASE_WEIGHT_FORMAT(OHWIo16i2)
3310 __CASE_WEIGHT_FORMAT(OHWIo16i2_bf16)
3311 __CASE_WEIGHT_FORMAT(OHWIo32i2)
3312 __CASE_WEIGHT_FORMAT(OHWIo32i2_bf16)
3313 __CASE_WEIGHT_FORMAT(OHWIo64i2)
3314 __CASE_WEIGHT_FORMAT(OHWIo64i2_bf16)
3315 __CASE_WEIGHT_FORMAT(OHWIo4i4)
3316 __CASE_WEIGHT_FORMAT(OHWIo4i4_bf16)
3317 __CASE_WEIGHT_FORMAT(OHWIo8i4)
3318 __CASE_WEIGHT_FORMAT(OHWIo8i4_bf16)
3319 __CASE_WEIGHT_FORMAT(OHWIo16i4)
3320 __CASE_WEIGHT_FORMAT(OHWIo16i4_bf16)
3321 __CASE_WEIGHT_FORMAT(OHWIo32i4)
3322 __CASE_WEIGHT_FORMAT(OHWIo32i4_bf16)
3323 __CASE_WEIGHT_FORMAT(OHWIo64i4)
3324 __CASE_WEIGHT_FORMAT(OHWIo64i4_bf16)
3325 __CASE_WEIGHT_FORMAT(OHWIo2i8)
3326 __CASE_WEIGHT_FORMAT(OHWIo4i8)
3327 __CASE_WEIGHT_FORMAT(OHWIo8i8)
3328 __CASE_WEIGHT_FORMAT(OHWIo16i8)
3329 __CASE_WEIGHT_FORMAT(OHWIo32i8)
3330 __CASE_WEIGHT_FORMAT(OHWIo64i8)
3331 default:
3332 return "invalid value";
3333 }
3334#undef __CASE_WEIGHT_FORMAT
Francesco Petrogalli553f6952022-06-30 10:22:01 +00003335}
3336
Ramy Elgammal91780022022-07-20 14:57:37 +01003337/** Formatted output of the arm_compute::WeightFormat type.
3338 *
3339 * @param[out] os Output stream.
3340 * @param[in] wf WeightFormat to output.
3341 *
3342 * @return Modified output stream.
3343 */
3344inline ::std::ostream &operator<<(::std::ostream &os, const arm_compute::WeightFormat &wf)
3345{
3346 os << to_string(wf);
3347 return os;
3348}
3349
3350/** Formatted output of the std::tuple<TensorShape, TensorShape, arm_compute::WeightFormat> tuple.
3351 *
3352 * @param[in] values tuple of input and output tensor shapes and WeightFormat used.
3353 *
3354 * @return Formatted string.
3355 */
3356inline std::string to_string(const std::tuple<TensorShape, TensorShape, arm_compute::WeightFormat> values)
Francesco Petrogalli553f6952022-06-30 10:22:01 +00003357{
3358 std::stringstream str;
3359 str << "[Input shape = " << std::get<0>(values);
3360 str << ", ";
3361 str << "Expected output shape = " << std::get<1>(values);
3362
3363 str << ", ";
3364 str << "WeightFormat = " << std::get<2>(values) << "]";
3365 return str.str();
3366}
3367
Anthony Barbier6ff3b192017-09-04 18:44:23 +01003368} // namespace arm_compute
Anthony Barbier4dbc0a92018-08-27 13:39:47 +01003369
3370#endif /* __ARM_COMPUTE_TYPE_PRINTER_H__ */