blob: 785b41fc628c0ef68238bf08d1ba5453314f5e99 [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001/*
SiCong Lidb4a6c12021-02-05 09:30:57 +00002 * Copyright (c) 2017-2021 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"
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +010040#include "arm_compute/runtime/CL/CLTunerTypes.h"
SiCong Lidb4a6c12021-02-05 09:30:57 +000041#include "arm_compute/runtime/CL/CLTypes.h"
ramelg013ae3d882021-09-12 23:07:47 +010042#include "arm_compute/runtime/FunctionDescriptors.h"
ramelg01cbbb0382021-09-17 17:36:57 +010043#include "arm_compute/runtime/common/LSTMParams.h"
SiCongLi1af54162021-10-06 15:25:57 +010044#include "src/core/experimental/PostOp.h"
Matthew Bentham758b5ba2020-03-05 23:37:48 +000045#include "support/StringSupport.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010046#include <ostream>
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010047#include <sstream>
48#include <string>
Anthony Barbier6ff3b192017-09-04 18:44:23 +010049
50namespace arm_compute
51{
Anthony Barbierb940fd62018-06-04 14:14:32 +010052/** Formatted output if arg is not null
53 *
54 * @param[in] arg Object to print
55 *
56 * @return String representing arg.
57 */
58template <typename T>
59std::string to_string_if_not_null(T *arg)
60{
61 if(arg == nullptr)
62 {
63 return "nullptr";
64 }
65 else
66 {
67 return to_string(*arg);
68 }
69}
Anthony Barbierb4670212018-05-18 16:55:39 +010070
ramelg014a6d9e82021-10-02 14:34:36 +010071/** Fallback method: try to use std::to_string:
72 *
73 * @param[in] val Value to convert to string
74 *
75 * @return String representing val.
76 */
77template <typename T>
78inline std::string to_string(const T &val)
79{
80 return support::cpp11::to_string(val);
81}
82
ramelg01b1ba1e32021-09-25 11:53:26 +010083/** Formatted output of a vector of objects.
84 *
ramelg014a6d9e82021-10-02 14:34:36 +010085 * @note: Using the overloaded to_string() instead of overloaded operator<<(), because to_string() functions are
86 * overloaded for all types, where two or more of them can use the same operator<<(), ITensor is an example.
87 *
ramelg01b1ba1e32021-09-25 11:53:26 +010088 * @param[out] os Output stream
89 * @param[in] args Vector of objects to print
90 *
91 * @return Modified output stream.
92 */
93template <typename T>
ramelg014a6d9e82021-10-02 14:34:36 +010094::std::ostream &operator<<(::std::ostream &os, const std::vector<T> &args)
ramelg01b1ba1e32021-09-25 11:53:26 +010095{
96 const size_t max_print_size = 5U;
97
98 os << "[";
99 bool first = true;
100 size_t i;
101 for(i = 0; i < args.size(); ++i)
102 {
103 if(i == max_print_size)
104 {
105 break;
106 }
107 if(first)
108 {
109 first = false;
110 }
111 else
112 {
113 os << ", ";
114 }
ramelg014a6d9e82021-10-02 14:34:36 +0100115 os << to_string(args[i]);
ramelg01b1ba1e32021-09-25 11:53:26 +0100116 }
117 if(i < args.size())
118 {
119 os << ", ...";
120 }
121 os << "]";
122 return os;
123}
124
ramelg014a6d9e82021-10-02 14:34:36 +0100125/** Formatted output of a vector of objects.
126 *
127 * @param[in] args Vector of objects to print
128 *
129 * @return String representing args.
130 */
131template <typename T>
132std::string to_string(const std::vector<T> &args)
133{
134 std::stringstream str;
135 str << args;
136 return str.str();
137}
138
SiCongLi1af54162021-10-06 15:25:57 +0100139/** @name (EXPERIMENTAL_POST_OPS)
140 * @{
141 */
142/** Formmated output of the @ref experimental::PostOpType type
143 *
144 * @param[out] os Output stream.
145 * @param[in] post_op_type Type to output.
146 *
147 * @return Modified output stream.
148 */
149inline ::std::ostream &operator<<(::std::ostream &os, experimental::PostOpType post_op_type)
150{
151 os << "type=";
152 switch(post_op_type)
153 {
154 case experimental::PostOpType::Activation:
155 {
156 os << "Activation";
157 break;
158 }
159 case experimental::PostOpType::Eltwise_Add:
160 {
161 os << "Eltwise_Add";
162 break;
163 }
ramelg016049eda2021-10-29 10:52:53 +0100164 case experimental::PostOpType::Eltwise_PRelu:
165 {
166 os << "Eltwise_PRelu";
167 break;
168 }
SiCongLi1af54162021-10-06 15:25:57 +0100169 default:
170 {
171 ARM_COMPUTE_ERROR("Unsupported PostOpType");
172 break;
173 }
174 }
175 return os;
176}
177/** Converts a @ref experimental::PostOpType to string
178 *
179 * @param[in] post_op_type PostOpType value to be converted
180 *
181 * @return String representing the corresponding PostOpType
182 */
183inline std::string to_string(experimental::PostOpType post_op_type)
184{
185 std::stringstream str;
186 str << post_op_type;
187 return str.str();
188}
189/** Formatted output of the @ref experimental::IPostOp type.
190 *
191 * @param[out] os Output stream.
192 * @param[in] post_op Type to output.
193 *
194 * @return Modified output stream.
195 */
196template <typename T>
197inline ::std::ostream &operator<<(::std::ostream &os, const experimental::IPostOp<T> &post_op)
198{
199 os << "<";
200 os << post_op.type() << ",";
SiCongLieb8bd812021-10-29 15:05:49 +0100201 os << "prev_dst_pos=" << post_op.prev_dst_pos() << ",";
SiCongLi1af54162021-10-06 15:25:57 +0100202 switch(post_op.type())
203 {
204 case experimental::PostOpType::Activation:
205 {
206 const auto _post_op = utils::cast::polymorphic_downcast<const experimental::PostOpAct<T> *>(&post_op);
207 os << "act_info=" << &(_post_op->_act_info);
208 break;
209 }
210 case experimental::PostOpType::Eltwise_Add:
211 {
212 const auto _post_op = utils::cast::polymorphic_downcast<const experimental::PostOpEltwiseAdd<T> *>(&post_op);
213 os << "convert_policy=" << _post_op->_policy;
214 break;
215 }
ramelg016049eda2021-10-29 10:52:53 +0100216 case experimental::PostOpType::Eltwise_PRelu:
217 {
218 const auto _post_op = utils::cast::polymorphic_downcast<const experimental::PostOpEltwisePRelu<T> *>(&post_op);
219 os << "convert_policy=" << _post_op->_policy;
220 break;
221 }
SiCongLi1af54162021-10-06 15:25:57 +0100222 default:
223 {
224 ARM_COMPUTE_ERROR("Unsupported PostOpType");
225 break;
226 }
227 }
228 os << ">";
229 return os;
230}
231/** Converts an @ref experimental::IPostOp to string
232 *
233 * @param[in] post_op IPostOp value to be converted
234 *
235 * @return String representing the corresponding IPostOp
236 */
237template <typename T>
238inline std::string to_string(const experimental::IPostOp<T> &post_op)
239{
240 std::stringstream str;
241 str << post_op;
242 return str.str();
243}
244/** Formatted output of the @ref experimental::PostOpList type.
245 *
246 * @param[out] os Output stream.
247 * @param[in] post_ops Type to output.
248 *
249 * @return Modified output stream.
250 */
251template <typename T>
252inline ::std::ostream &operator<<(::std::ostream &os, const experimental::PostOpList<T> &post_ops)
253{
254 os << "[";
255 for(const auto &post_op : post_ops.get_list())
256 {
257 os << *post_op << ",";
258 }
259 os << "]";
260 return os;
261}
262/** Converts a @ref experimental::PostOpList to string
263 *
264 * @param[in] post_ops PostOpList value to be converted
265 *
266 * @return String representing the corresponding PostOpList
267 */
268template <typename T>
269inline std::string to_string(const experimental::PostOpList<T> &post_ops)
270{
271 std::stringstream str;
272 str << post_ops;
273 return str.str();
274}
275/** @} */ // end of group (EXPERIMENTAL_POST_OPS)
276
Alex Gildayc357c472018-03-21 13:54:09 +0000277/** Formatted output of the Dimensions type.
278 *
279 * @param[out] os Output stream.
280 * @param[in] dimensions Type to output.
281 *
282 * @return Modified output stream.
283 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100284template <typename T>
285inline ::std::ostream &operator<<(::std::ostream &os, const Dimensions<T> &dimensions)
286{
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100287 if(dimensions.num_dimensions() > 0)
288 {
289 os << dimensions[0];
290
291 for(unsigned int d = 1; d < dimensions.num_dimensions(); ++d)
292 {
Freddie Liardetdd23f2a2021-06-17 13:30:11 +0100293 os << "," << dimensions[d];
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100294 }
295 }
296
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100297 return os;
298}
299
Alex Gildayc357c472018-03-21 13:54:09 +0000300/** Formatted output of the RoundingPolicy type.
301 *
302 * @param[out] os Output stream.
303 * @param[in] rounding_policy Type to output.
304 *
305 * @return Modified output stream.
306 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100307inline ::std::ostream &operator<<(::std::ostream &os, const RoundingPolicy &rounding_policy)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100308{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100309 switch(rounding_policy)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100310 {
Anthony Barbier2a07e182017-08-04 18:20:27 +0100311 case RoundingPolicy::TO_ZERO:
312 os << "TO_ZERO";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100313 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100314 case RoundingPolicy::TO_NEAREST_UP:
315 os << "TO_NEAREST_UP";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100316 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100317 case RoundingPolicy::TO_NEAREST_EVEN:
318 os << "TO_NEAREST_EVEN";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100319 break;
320 default:
321 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
322 }
323
324 return os;
325}
326
Alex Gildayc357c472018-03-21 13:54:09 +0000327/** Formatted output of the WeightsInfo type.
328 *
329 * @param[out] os Output stream.
330 * @param[in] weights_info Type to output.
331 *
332 * @return Modified output stream.
333 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100334inline ::std::ostream &operator<<(::std::ostream &os, const WeightsInfo &weights_info)
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100335{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100336 os << weights_info.are_reshaped() << ";";
337 os << weights_info.num_kernels() << ";" << weights_info.kernel_size().first << "," << weights_info.kernel_size().second;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100338
339 return os;
340}
341
Alex Gildayc357c472018-03-21 13:54:09 +0000342/** Formatted output of the ROIPoolingInfo type.
343 *
344 * @param[out] os Output stream.
345 * @param[in] pool_info Type to output.
346 *
347 * @return Modified output stream.
348 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100349inline ::std::ostream &operator<<(::std::ostream &os, const ROIPoolingLayerInfo &pool_info)
Sanghoon Lee70f82912017-08-24 14:21:24 +0100350{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100351 os << pool_info.pooled_width() << "x" << pool_info.pooled_height() << "~" << pool_info.spatial_scale();
Georgios Pinitasd9769582017-08-03 10:19:40 +0100352 return os;
353}
354
giuros0118870812018-09-13 09:31:40 +0100355/** Formatted output of the ROIPoolingInfo type.
356 *
357 * @param[in] pool_info Type to output.
358 *
359 * @return Formatted string.
360 */
361inline std::string to_string(const ROIPoolingLayerInfo &pool_info)
362{
363 std::stringstream str;
364 str << pool_info;
365 return str.str();
366}
367
morgolockaba2f912020-05-05 16:28:19 +0100368/** Formatted output of the GEMMKernelInfo type.
369 *
370 * @param[out] os Output stream.
371 * @param[in] gemm_info Type to output.
372 *
373 * @return Modified output stream.
374 */
375inline ::std::ostream &operator<<(::std::ostream &os, const GEMMKernelInfo &gemm_info)
376{
SiCongLi579ca842021-10-18 09:38:33 +0100377 os << "( m=" << gemm_info.m;
378 os << " n=" << gemm_info.n;
379 os << " k=" << gemm_info.k;
380 os << " depth_output_gemm3d=" << gemm_info.depth_output_gemm3d;
381 os << " reinterpret_input_as_3d=" << gemm_info.reinterpret_input_as_3d;
382 os << " broadcast_bias=" << gemm_info.broadcast_bias;
383 os << " fp_mixed_precision=" << gemm_info.fp_mixed_precision;
384 os << " mult_transpose1xW_width=" << gemm_info.mult_transpose1xW_width;
385 os << " mult_interleave4x4_height=" << gemm_info.mult_interleave4x4_height;
386 os << " a_offset=" << gemm_info.a_offset;
387 os << " b_offset=" << gemm_info.b_offset;
388 os << "post_ops=" << gemm_info.post_ops;
morgolockaba2f912020-05-05 16:28:19 +0100389 os << ")";
390 return os;
391}
392
393/** Formatted output of the GEMMLHSMatrixInfo type.
394 *
395 * @param[out] os Output stream.
396 * @param[in] gemm_info Type to output.
397 *
398 * @return Modified output stream.
399 */
400inline ::std::ostream &operator<<(::std::ostream &os, const GEMMLHSMatrixInfo &gemm_info)
401{
SiCongLi579ca842021-10-18 09:38:33 +0100402 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 +0100403 return os;
404}
405
406/** Formatted output of the GEMMRHSMatrixInfo type.
407 *
408 * @param[out] os Output stream.
409 * @param[in] gemm_info Type to output.
410 *
411 * @return Modified output stream.
412 */
413inline ::std::ostream &operator<<(::std::ostream &os, const GEMMRHSMatrixInfo &gemm_info)
414{
SiCongLi579ca842021-10-18 09:38:33 +0100415 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 +0000416 gemm_info.export_to_cl_image << "})";
morgolockaba2f912020-05-05 16:28:19 +0100417 return os;
418}
419
420/** Formatted output of the GEMMRHSMatrixInfo type.
421 *
422 * @param[in] gemm_info GEMMRHSMatrixInfo to output.
423 *
424 * @return Formatted string.
425 */
426inline std::string to_string(const GEMMRHSMatrixInfo &gemm_info)
427{
428 std::stringstream str;
429 str << gemm_info;
430 return str.str();
431}
432
433/** Formatted output of the GEMMLHSMatrixInfo type.
434 *
435 * @param[in] gemm_info GEMMLHSMatrixInfo to output.
436 *
437 * @return Formatted string.
438 */
439inline std::string to_string(const GEMMLHSMatrixInfo &gemm_info)
440{
441 std::stringstream str;
442 str << gemm_info;
443 return str.str();
444}
445
446/** Formatted output of the GEMMKernelInfo type.
447 *
448 * @param[in] gemm_info GEMMKernelInfo Type to output.
449 *
450 * @return Formatted string.
451 */
452inline std::string to_string(const GEMMKernelInfo &gemm_info)
453{
454 std::stringstream str;
455 str << gemm_info;
456 return str.str();
457}
458
giuros01c04a0e82018-10-03 12:44:35 +0100459/** Formatted output of the BoundingBoxTransformInfo type.
460 *
461 * @param[out] os Output stream.
462 * @param[in] bbox_info Type to output.
463 *
464 * @return Modified output stream.
465 */
466inline ::std::ostream &operator<<(::std::ostream &os, const BoundingBoxTransformInfo &bbox_info)
467{
468 auto weights = bbox_info.weights();
SiCongLi579ca842021-10-18 09:38:33 +0100469 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 +0100470 "})";
471 return os;
472}
473
474/** Formatted output of the BoundingBoxTransformInfo type.
475 *
476 * @param[in] bbox_info Type to output.
477 *
478 * @return Formatted string.
479 */
480inline std::string to_string(const BoundingBoxTransformInfo &bbox_info)
481{
482 std::stringstream str;
483 str << bbox_info;
484 return str.str();
485}
486
Manuel Bottini5209be52019-02-13 16:34:56 +0000487/** Formatted output of the ComputeAnchorsInfo type.
488 *
489 * @param[out] os Output stream.
490 * @param[in] anchors_info Type to output.
491 *
492 * @return Modified output stream.
493 */
494inline ::std::ostream &operator<<(::std::ostream &os, const ComputeAnchorsInfo &anchors_info)
495{
496 os << "(" << anchors_info.feat_width() << "x" << anchors_info.feat_height() << ")~" << anchors_info.spatial_scale();
497 return os;
498}
499
500/** Formatted output of the ComputeAnchorsInfo type.
501 *
502 * @param[in] anchors_info Type to output.
503 *
504 * @return Formatted string.
505 */
506inline std::string to_string(const ComputeAnchorsInfo &anchors_info)
507{
508 std::stringstream str;
509 str << anchors_info;
510 return str.str();
511}
512
513/** Formatted output of the GenerateProposalsInfo type.
514 *
515 * @param[out] os Output stream.
516 * @param[in] proposals_info Type to output.
517 *
518 * @return Modified output stream.
519 */
520inline ::std::ostream &operator<<(::std::ostream &os, const GenerateProposalsInfo &proposals_info)
521{
522 os << "(" << proposals_info.im_width() << "x" << proposals_info.im_height() << ")~" << proposals_info.im_scale();
523 return os;
524}
525
526/** Formatted output of the GenerateProposalsInfo type.
527 *
528 * @param[in] proposals_info Type to output.
529 *
530 * @return Formatted string.
531 */
532inline std::string to_string(const GenerateProposalsInfo &proposals_info)
533{
534 std::stringstream str;
535 str << proposals_info;
536 return str.str();
537}
538
Alex Gildayc357c472018-03-21 13:54:09 +0000539/** Formatted output of the QuantizationInfo type.
540 *
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100541 * @param[out] os Output stream.
542 * @param[in] qinfo Type to output.
Alex Gildayc357c472018-03-21 13:54:09 +0000543 *
544 * @return Modified output stream.
545 */
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100546inline ::std::ostream &operator<<(::std::ostream &os, const QuantizationInfo &qinfo)
Chunosovd621bca2017-11-03 17:33:15 +0700547{
Georgios Pinitas3d13af82019-06-04 13:04:16 +0100548 const UniformQuantizationInfo uqinfo = qinfo.uniform();
549 os << "Scale:" << uqinfo.scale << "~";
550 os << "Offset:" << uqinfo.offset;
Chunosovd621bca2017-11-03 17:33:15 +0700551 return os;
552}
553
Alex Gildayc357c472018-03-21 13:54:09 +0000554/** Formatted output of the QuantizationInfo type.
555 *
556 * @param[in] quantization_info Type to output.
557 *
558 * @return Formatted string.
559 */
Chunosovd621bca2017-11-03 17:33:15 +0700560inline std::string to_string(const QuantizationInfo &quantization_info)
561{
562 std::stringstream str;
563 str << quantization_info;
564 return str.str();
565}
566
Alex Gildayc357c472018-03-21 13:54:09 +0000567/** Formatted output of the activation function type.
568 *
569 * @param[out] os Output stream.
570 * @param[in] act_function Type to output.
571 *
572 * @return Modified output stream.
573 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100574inline ::std::ostream &operator<<(::std::ostream &os, const ActivationLayerInfo::ActivationFunction &act_function)
575{
576 switch(act_function)
577 {
578 case ActivationLayerInfo::ActivationFunction::ABS:
579 os << "ABS";
580 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100581 case ActivationLayerInfo::ActivationFunction::LINEAR:
582 os << "LINEAR";
583 break;
584 case ActivationLayerInfo::ActivationFunction::LOGISTIC:
585 os << "LOGISTIC";
586 break;
587 case ActivationLayerInfo::ActivationFunction::RELU:
588 os << "RELU";
589 break;
Georgios Pinitas579c0492017-07-12 16:12:12 +0100590 case ActivationLayerInfo::ActivationFunction::BOUNDED_RELU:
591 os << "BOUNDED_RELU";
592 break;
593 case ActivationLayerInfo::ActivationFunction::LEAKY_RELU:
594 os << "LEAKY_RELU";
595 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100596 case ActivationLayerInfo::ActivationFunction::SOFT_RELU:
597 os << "SOFT_RELU";
598 break;
599 case ActivationLayerInfo::ActivationFunction::SQRT:
600 os << "SQRT";
601 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100602 case ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU:
603 os << "LU_BOUNDED_RELU";
Kevin Petitd9f80712017-12-06 12:18:48 +0000604 break;
Georgios Pinitasfb0fdcd2019-08-22 17:10:04 +0100605 case ActivationLayerInfo::ActivationFunction::ELU:
606 os << "ELU";
607 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100608 case ActivationLayerInfo::ActivationFunction::SQUARE:
609 os << "SQUARE";
610 break;
611 case ActivationLayerInfo::ActivationFunction::TANH:
612 os << "TANH";
613 break;
Usama Arif6a98a6e2019-05-10 17:07:27 +0100614 case ActivationLayerInfo::ActivationFunction::IDENTITY:
615 os << "IDENTITY";
616 break;
morgolock07df3d42020-02-27 11:46:28 +0000617 case ActivationLayerInfo::ActivationFunction::HARD_SWISH:
618 os << "HARD_SWISH";
619 break;
620
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100621 default:
622 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
623 }
624
625 return os;
626}
627
Alex Gildayc357c472018-03-21 13:54:09 +0000628/** Formatted output of the activation function info type.
629 *
SiCongLi1af54162021-10-06 15:25:57 +0100630 * @param[in] info ActivationLayerInfo to output.
Alex Gildayc357c472018-03-21 13:54:09 +0000631 *
632 * @return Formatted string.
633 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100634inline std::string to_string(const arm_compute::ActivationLayerInfo &info)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100635{
636 std::stringstream str;
Isabella Gottardi3f217ec2018-02-12 14:59:19 +0000637 if(info.enabled())
638 {
639 str << info.activation();
640 }
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100641 return str.str();
642}
643
SiCongLi1af54162021-10-06 15:25:57 +0100644/** Formatted output of the activation function info.
ramelg013ae3d882021-09-12 23:07:47 +0100645 *
SiCongLi1af54162021-10-06 15:25:57 +0100646 * @param[out] os Output stream.
647 * @param[in] info ActivationLayerInfo to output.
ramelg013ae3d882021-09-12 23:07:47 +0100648 *
649 * @return Formatted string.
650 */
SiCongLi1af54162021-10-06 15:25:57 +0100651inline ::std::ostream &operator<<(::std::ostream &os, const ActivationLayerInfo *info)
ramelg013ae3d882021-09-12 23:07:47 +0100652{
ramelg013ae3d882021-09-12 23:07:47 +0100653 if(info != nullptr)
654 {
ramelg013ae3d882021-09-12 23:07:47 +0100655 if(info->enabled())
656 {
SiCongLi1af54162021-10-06 15:25:57 +0100657 os << info->activation();
658 os << "(";
659 os << "VAL_A=" << info->a() << ",";
660 os << "VAL_B=" << info->b();
661 os << ")";
ramelg013ae3d882021-09-12 23:07:47 +0100662 }
SiCongLi1af54162021-10-06 15:25:57 +0100663 else
664 {
665 os << "disabled";
666 }
ramelg013ae3d882021-09-12 23:07:47 +0100667 }
SiCongLi1af54162021-10-06 15:25:57 +0100668 else
669 {
670 os << "nullptr";
671 }
672 return os;
ramelg013ae3d882021-09-12 23:07:47 +0100673}
674
Alex Gildayc357c472018-03-21 13:54:09 +0000675/** Formatted output of the activation function type.
676 *
677 * @param[in] function Type to output.
678 *
679 * @return Formatted string.
680 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100681inline std::string to_string(const arm_compute::ActivationLayerInfo::ActivationFunction &function)
682{
683 std::stringstream str;
684 str << function;
685 return str.str();
686}
687
Alex Gildayc357c472018-03-21 13:54:09 +0000688/** Formatted output of the NormType type.
689 *
690 * @param[out] os Output stream.
691 * @param[in] norm_type Type to output.
692 *
693 * @return Modified output stream.
694 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100695inline ::std::ostream &operator<<(::std::ostream &os, const NormType &norm_type)
696{
697 switch(norm_type)
698 {
699 case NormType::CROSS_MAP:
700 os << "CROSS_MAP";
701 break;
702 case NormType::IN_MAP_1D:
703 os << "IN_MAP_1D";
704 break;
705 case NormType::IN_MAP_2D:
706 os << "IN_MAP_2D";
707 break;
708 default:
709 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
710 }
711
712 return os;
713}
714
Alex Gildayc357c472018-03-21 13:54:09 +0000715/** Formatted output of @ref NormalizationLayerInfo.
716 *
717 * @param[in] info Type to output.
718 *
719 * @return Formatted string.
720 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100721inline std::string to_string(const arm_compute::NormalizationLayerInfo &info)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100722{
723 std::stringstream str;
Michalis Spyroud466c2d2018-01-30 10:54:39 +0000724 str << info.type() << ":NormSize=" << info.norm_size();
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100725 return str.str();
726}
727
Alex Gildayc357c472018-03-21 13:54:09 +0000728/** Formatted output of @ref NormalizationLayerInfo.
729 *
730 * @param[out] os Output stream.
731 * @param[in] info Type to output.
732 *
733 * @return Modified output stream.
734 */
Georgios Pinitas6f669f02017-09-26 12:32:57 +0100735inline ::std::ostream &operator<<(::std::ostream &os, const NormalizationLayerInfo &info)
736{
Michalis Spyroud466c2d2018-01-30 10:54:39 +0000737 os << info.type() << ":NormSize=" << info.norm_size();
Georgios Pinitas6f669f02017-09-26 12:32:57 +0100738 return os;
739}
740
Alex Gildayc357c472018-03-21 13:54:09 +0000741/** Formatted output of the PoolingType type.
742 *
743 * @param[out] os Output stream.
744 * @param[in] pool_type Type to output.
745 *
746 * @return Modified output stream.
747 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100748inline ::std::ostream &operator<<(::std::ostream &os, const PoolingType &pool_type)
749{
750 switch(pool_type)
751 {
752 case PoolingType::AVG:
753 os << "AVG";
754 break;
755 case PoolingType::MAX:
756 os << "MAX";
757 break;
Georgios Pinitascdf51452017-08-31 14:21:36 +0100758 case PoolingType::L2:
759 os << "L2";
760 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100761 default:
762 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
763 }
764
765 return os;
766}
767
Alex Gildayc357c472018-03-21 13:54:09 +0000768/** Formatted output of @ref PoolingLayerInfo.
769 *
770 * @param[out] os Output stream.
771 * @param[in] info Type to output.
772 *
773 * @return Modified output stream.
774 */
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100775inline ::std::ostream &operator<<(::std::ostream &os, const PoolingLayerInfo &info)
776{
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +0000777 os << info.pool_type;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100778
779 return os;
780}
781
Alex Gildayc357c472018-03-21 13:54:09 +0000782/** Formatted output of @ref RoundingPolicy.
783 *
784 * @param[in] rounding_policy Type to output.
785 *
786 * @return Formatted string.
787 */
John Richardsondd715f22017-09-18 16:10:48 +0100788inline std::string to_string(const RoundingPolicy &rounding_policy)
789{
790 std::stringstream str;
791 str << rounding_policy;
792 return str.str();
793}
794
Vidhya Sudhan Loganathand646ae12018-11-19 15:18:20 +0000795/** [Print DataLayout type] **/
Alex Gildayc357c472018-03-21 13:54:09 +0000796/** Formatted output of the DataLayout type.
797 *
798 * @param[out] os Output stream.
799 * @param[in] data_layout Type to output.
800 *
801 * @return Modified output stream.
802 */
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000803inline ::std::ostream &operator<<(::std::ostream &os, const DataLayout &data_layout)
804{
805 switch(data_layout)
806 {
807 case DataLayout::UNKNOWN:
808 os << "UNKNOWN";
809 break;
810 case DataLayout::NHWC:
811 os << "NHWC";
812 break;
813 case DataLayout::NCHW:
814 os << "NCHW";
815 break;
Adnan AlSinane4563a02021-09-01 15:32:03 +0100816 case DataLayout::NDHWC:
817 os << "NDHWC";
818 break;
Giorgio Arenac9fe9fc2021-10-06 12:54:29 +0100819 case DataLayout::NCDHW:
820 os << "NCDHW";
821 break;
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000822 default:
823 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
824 }
825
826 return os;
827}
828
Alex Gildayc357c472018-03-21 13:54:09 +0000829/** Formatted output of the DataLayout type.
830 *
831 * @param[in] data_layout Type to output.
832 *
833 * @return Formatted string.
834 */
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000835inline std::string to_string(const arm_compute::DataLayout &data_layout)
836{
837 std::stringstream str;
838 str << data_layout;
839 return str.str();
840}
Vidhya Sudhan Loganathand646ae12018-11-19 15:18:20 +0000841/** [Print DataLayout type] **/
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000842
Georgios Pinitase2220552018-07-20 13:23:44 +0100843/** Formatted output of the DataLayoutDimension type.
844 *
845 * @param[out] os Output stream.
846 * @param[in] data_layout_dim Data layout dimension to print.
847 *
848 * @return Modified output stream.
849 */
850inline ::std::ostream &operator<<(::std::ostream &os, const DataLayoutDimension &data_layout_dim)
851{
852 switch(data_layout_dim)
853 {
854 case DataLayoutDimension::WIDTH:
855 os << "WIDTH";
856 break;
857 case DataLayoutDimension::HEIGHT:
858 os << "HEIGHT";
859 break;
860 case DataLayoutDimension::CHANNEL:
861 os << "CHANNEL";
862 break;
Giorgio Arenac9fe9fc2021-10-06 12:54:29 +0100863 case DataLayoutDimension::DEPTH:
864 os << "DEPTH";
865 break;
Georgios Pinitase2220552018-07-20 13:23:44 +0100866 case DataLayoutDimension::BATCHES:
867 os << "BATCHES";
868 break;
869 default:
870 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
871 }
872 return os;
873}
874
Alex Gildayc357c472018-03-21 13:54:09 +0000875/** Formatted output of the DataType type.
876 *
877 * @param[out] os Output stream.
878 * @param[in] data_type Type to output.
879 *
880 * @return Modified output stream.
881 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100882inline ::std::ostream &operator<<(::std::ostream &os, const DataType &data_type)
883{
884 switch(data_type)
885 {
886 case DataType::UNKNOWN:
887 os << "UNKNOWN";
888 break;
889 case DataType::U8:
890 os << "U8";
891 break;
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100892 case DataType::QSYMM8:
893 os << "QSYMM8";
894 break;
Chunosovd621bca2017-11-03 17:33:15 +0700895 case DataType::QASYMM8:
896 os << "QASYMM8";
897 break;
Georgios Pinitas448a81f2019-11-21 14:10:25 +0000898 case DataType::QASYMM8_SIGNED:
899 os << "QASYMM8_SIGNED";
900 break;
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100901 case DataType::QSYMM8_PER_CHANNEL:
902 os << "QSYMM8_PER_CHANNEL";
903 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100904 case DataType::S8:
905 os << "S8";
906 break;
907 case DataType::U16:
908 os << "U16";
909 break;
910 case DataType::S16:
911 os << "S16";
912 break;
Manuel Bottini3689fcd2019-06-14 17:18:12 +0100913 case DataType::QSYMM16:
914 os << "QSYMM16";
915 break;
Michele Di Giorgio35ea9a72019-08-23 12:02:06 +0100916 case DataType::QASYMM16:
917 os << "QASYMM16";
918 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100919 case DataType::U32:
920 os << "U32";
921 break;
922 case DataType::S32:
923 os << "S32";
924 break;
925 case DataType::U64:
926 os << "U64";
927 break;
928 case DataType::S64:
929 os << "S64";
930 break;
Georgios Pinitase8291ac2020-02-26 09:58:13 +0000931 case DataType::BFLOAT16:
932 os << "BFLOAT16";
933 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100934 case DataType::F16:
935 os << "F16";
936 break;
937 case DataType::F32:
938 os << "F32";
939 break;
940 case DataType::F64:
941 os << "F64";
942 break;
943 case DataType::SIZET:
944 os << "SIZET";
945 break;
946 default:
947 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
948 }
949
950 return os;
951}
952
Alex Gildayc357c472018-03-21 13:54:09 +0000953/** Formatted output of the DataType type.
954 *
955 * @param[in] data_type Type to output.
956 *
957 * @return Formatted string.
958 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100959inline std::string to_string(const arm_compute::DataType &data_type)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100960{
961 std::stringstream str;
962 str << data_type;
963 return str.str();
964}
965
Alex Gildayc357c472018-03-21 13:54:09 +0000966/** Formatted output of the Format type.
967 *
968 * @param[out] os Output stream.
969 * @param[in] format Type to output.
970 *
971 * @return Modified output stream.
972 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100973inline ::std::ostream &operator<<(::std::ostream &os, const Format &format)
974{
975 switch(format)
976 {
977 case Format::UNKNOWN:
978 os << "UNKNOWN";
979 break;
980 case Format::U8:
981 os << "U8";
982 break;
983 case Format::S16:
984 os << "S16";
985 break;
986 case Format::U16:
987 os << "U16";
988 break;
989 case Format::S32:
990 os << "S32";
991 break;
992 case Format::U32:
993 os << "U32";
994 break;
995 case Format::F16:
996 os << "F16";
997 break;
998 case Format::F32:
999 os << "F32";
1000 break;
1001 case Format::UV88:
1002 os << "UV88";
1003 break;
1004 case Format::RGB888:
1005 os << "RGB888";
1006 break;
1007 case Format::RGBA8888:
1008 os << "RGBA8888";
1009 break;
1010 case Format::YUV444:
1011 os << "YUV444";
1012 break;
1013 case Format::YUYV422:
1014 os << "YUYV422";
1015 break;
1016 case Format::NV12:
1017 os << "NV12";
1018 break;
1019 case Format::NV21:
1020 os << "NV21";
1021 break;
1022 case Format::IYUV:
1023 os << "IYUV";
1024 break;
1025 case Format::UYVY422:
1026 os << "UYVY422";
1027 break;
1028 default:
1029 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1030 }
1031
1032 return os;
1033}
1034
Alex Gildayc357c472018-03-21 13:54:09 +00001035/** Formatted output of the Format type.
1036 *
1037 * @param[in] format Type to output.
1038 *
1039 * @return Formatted string.
1040 */
Moritz Pflanzer7655a672017-09-23 11:57:33 +01001041inline std::string to_string(const Format &format)
1042{
1043 std::stringstream str;
1044 str << format;
1045 return str.str();
1046}
1047
Alex Gildayc357c472018-03-21 13:54:09 +00001048/** Formatted output of the Channel type.
1049 *
1050 * @param[out] os Output stream.
1051 * @param[in] channel Type to output.
1052 *
1053 * @return Modified output stream.
1054 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001055inline ::std::ostream &operator<<(::std::ostream &os, const Channel &channel)
1056{
1057 switch(channel)
1058 {
1059 case Channel::UNKNOWN:
1060 os << "UNKNOWN";
1061 break;
1062 case Channel::C0:
1063 os << "C0";
1064 break;
1065 case Channel::C1:
1066 os << "C1";
1067 break;
1068 case Channel::C2:
1069 os << "C2";
1070 break;
1071 case Channel::C3:
1072 os << "C3";
1073 break;
1074 case Channel::R:
1075 os << "R";
1076 break;
1077 case Channel::G:
1078 os << "G";
1079 break;
1080 case Channel::B:
1081 os << "B";
1082 break;
1083 case Channel::A:
1084 os << "A";
1085 break;
1086 case Channel::Y:
1087 os << "Y";
1088 break;
1089 case Channel::U:
1090 os << "U";
1091 break;
1092 case Channel::V:
1093 os << "V";
1094 break;
1095 default:
1096 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1097 }
1098
1099 return os;
1100}
1101
Alex Gildayc357c472018-03-21 13:54:09 +00001102/** Formatted output of the Channel type.
1103 *
1104 * @param[in] channel Type to output.
1105 *
1106 * @return Formatted string.
1107 */
Ioan-Cristian Szabo9414f642017-10-27 17:35:40 +01001108inline std::string to_string(const Channel &channel)
1109{
1110 std::stringstream str;
1111 str << channel;
1112 return str.str();
1113}
1114
Alex Gildayc357c472018-03-21 13:54:09 +00001115/** Formatted output of the BorderMode type.
1116 *
1117 * @param[out] os Output stream.
1118 * @param[in] mode Type to output.
1119 *
1120 * @return Modified output stream.
1121 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001122inline ::std::ostream &operator<<(::std::ostream &os, const BorderMode &mode)
1123{
1124 switch(mode)
1125 {
1126 case BorderMode::UNDEFINED:
1127 os << "UNDEFINED";
1128 break;
1129 case BorderMode::CONSTANT:
1130 os << "CONSTANT";
1131 break;
1132 case BorderMode::REPLICATE:
1133 os << "REPLICATE";
1134 break;
1135 default:
1136 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1137 }
1138
1139 return os;
1140}
1141
Alex Gildayc357c472018-03-21 13:54:09 +00001142/** Formatted output of the BorderSize type.
1143 *
1144 * @param[out] os Output stream.
1145 * @param[in] border Type to output.
1146 *
1147 * @return Modified output stream.
1148 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001149inline ::std::ostream &operator<<(::std::ostream &os, const BorderSize &border)
1150{
Moritz Pflanzerc87fbf82017-07-18 14:02:10 +01001151 os << border.top << ","
1152 << border.right << ","
1153 << border.bottom << ","
1154 << border.left;
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001155
1156 return os;
1157}
Anthony Barbier2a07e182017-08-04 18:20:27 +01001158
Giuseppe Rossinid7647d42018-07-17 18:13:13 +01001159/** Formatted output of the PaddingList type.
1160 *
1161 * @param[out] os Output stream.
1162 * @param[in] padding Type to output.
1163 *
1164 * @return Modified output stream.
1165 */
1166inline ::std::ostream &operator<<(::std::ostream &os, const PaddingList &padding)
1167{
1168 os << "{";
1169 for(auto const &p : padding)
1170 {
1171 os << "{" << p.first << "," << p.second << "}";
1172 }
1173 os << "}";
1174 return os;
1175}
1176
giuros013175fcf2018-11-21 09:59:17 +00001177/** Formatted output of the Multiples type.
1178 *
1179 * @param[out] os Output stream.
1180 * @param[in] multiples Type to output.
1181 *
1182 * @return Modified output stream.
1183 */
1184inline ::std::ostream &operator<<(::std::ostream &os, const Multiples &multiples)
1185{
1186 os << "(";
1187 for(size_t i = 0; i < multiples.size() - 1; i++)
1188 {
1189 os << multiples[i] << ", ";
1190 }
1191 os << multiples.back() << ")";
1192 return os;
1193}
1194
Alex Gildayc357c472018-03-21 13:54:09 +00001195/** Formatted output of the InterpolationPolicy type.
1196 *
1197 * @param[out] os Output stream.
1198 * @param[in] policy Type to output.
1199 *
1200 * @return Modified output stream.
1201 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001202inline ::std::ostream &operator<<(::std::ostream &os, const InterpolationPolicy &policy)
1203{
1204 switch(policy)
1205 {
1206 case InterpolationPolicy::NEAREST_NEIGHBOR:
1207 os << "NEAREST_NEIGHBOR";
1208 break;
1209 case InterpolationPolicy::BILINEAR:
1210 os << "BILINEAR";
1211 break;
1212 case InterpolationPolicy::AREA:
1213 os << "AREA";
1214 break;
1215 default:
1216 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1217 }
1218
1219 return os;
1220}
1221
Alex Gildayc357c472018-03-21 13:54:09 +00001222/** Formatted output of the SamplingPolicy type.
1223 *
1224 * @param[out] os Output stream.
1225 * @param[in] policy Type to output.
1226 *
1227 * @return Modified output stream.
1228 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +07001229inline ::std::ostream &operator<<(::std::ostream &os, const SamplingPolicy &policy)
1230{
1231 switch(policy)
1232 {
1233 case SamplingPolicy::CENTER:
1234 os << "CENTER";
1235 break;
1236 case SamplingPolicy::TOP_LEFT:
1237 os << "TOP_LEFT";
1238 break;
1239 default:
1240 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1241 }
1242
1243 return os;
1244}
1245
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001246/** Formatted output of the ITensorInfo type.
1247 *
1248 * @param[out] os Output stream.
1249 * @param[in] info Tensor information.
1250 *
1251 * @return Modified output stream.
1252 */
1253inline ::std::ostream &operator<<(std::ostream &os, const ITensorInfo *info)
1254{
Georgios Pinitasc6f95102021-03-30 10:03:01 +01001255 const DataType data_type = info->data_type();
1256 const DataLayout data_layout = info->data_layout();
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001257
1258 os << "Shape=" << info->tensor_shape() << ","
1259 << "DataLayout=" << string_from_data_layout(data_layout) << ","
ramelg014a6d9e82021-10-02 14:34:36 +01001260 << "DataType=" << string_from_data_type(data_type);
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001261
1262 if(is_data_type_quantized(data_type))
1263 {
ramelg01b1ba1e32021-09-25 11:53:26 +01001264 const QuantizationInfo qinfo = info->quantization_info();
1265 const auto scales = qinfo.scale();
1266 const auto offsets = qinfo.offset();
1267
ramelg014a6d9e82021-10-02 14:34:36 +01001268 os << ", QuantizationInfo={"
ramelg01b1ba1e32021-09-25 11:53:26 +01001269 << "scales.size=" << scales.size()
1270 << ", scale(s)=" << scales << ", ";
1271
1272 os << "offsets.size=" << offsets.size()
1273 << ", offset(s)=" << offsets << "}";
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001274 }
1275 return os;
1276}
1277
ramelg013ae3d882021-09-12 23:07:47 +01001278/** Formatted output of the const TensorInfo& type.
Alex Gildayc357c472018-03-21 13:54:09 +00001279 *
Anthony Barbier366628a2018-08-01 13:55:03 +01001280 * @param[out] os Output stream.
1281 * @param[in] info Type to output.
1282 *
1283 * @return Modified output stream.
1284 */
1285inline ::std::ostream &operator<<(::std::ostream &os, const TensorInfo &info)
1286{
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001287 os << &info;
Georgios Pinitasc6f95102021-03-30 10:03:01 +01001288 return os;
Anthony Barbier366628a2018-08-01 13:55:03 +01001289}
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001290
ramelg013ae3d882021-09-12 23:07:47 +01001291/** Formatted output of the const TensorInfo& type.
Anthony Barbier366628a2018-08-01 13:55:03 +01001292 *
Alex Gildayc357c472018-03-21 13:54:09 +00001293 * @param[in] info Type to output.
1294 *
1295 * @return Formatted string.
1296 */
Georgios Pinitas3faea252017-10-30 14:13:50 +00001297inline std::string to_string(const TensorInfo &info)
1298{
1299 std::stringstream str;
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001300 str << &info;
Georgios Pinitas3faea252017-10-30 14:13:50 +00001301 return str.str();
1302}
1303
ramelg013ae3d882021-09-12 23:07:47 +01001304/** Formatted output of the const ITensorInfo& type.
1305 *
1306 * @param[in] info Type to output.
1307 *
1308 * @return Formatted string.
1309 */
1310inline std::string to_string(const ITensorInfo &info)
1311{
1312 std::stringstream str;
1313 str << &info;
1314 return str.str();
1315}
1316
ramelg013ae3d882021-09-12 23:07:47 +01001317/** Formatted output of the const ITensorInfo* type.
1318 *
1319 * @param[in] info Type to output.
1320 *
1321 * @return Formatted string.
1322 */
Ramy Elgammale920d6a2021-08-19 22:10:30 +01001323inline std::string to_string(const ITensorInfo *info)
1324{
ramelg013ae3d882021-09-12 23:07:47 +01001325 std::string ret_str = "nullptr";
1326 if(info != nullptr)
1327 {
1328 std::stringstream str;
1329 str << info;
1330 ret_str = str.str();
1331 }
1332 return ret_str;
1333}
1334
ramelg01cbbb0382021-09-17 17:36:57 +01001335/** Formatted output of the ITensorInfo* type.
1336 *
1337 * @param[in] info Type to output.
1338 *
1339 * @return Formatted string.
1340 */
1341inline std::string to_string(ITensorInfo *info)
1342{
1343 return to_string(static_cast<const ITensorInfo *>(info));
1344}
1345
1346/** Formatted output of the ITensorInfo type obtained from const ITensor* type.
ramelg013ae3d882021-09-12 23:07:47 +01001347 *
1348 * @param[in] tensor Type to output.
1349 *
1350 * @return Formatted string.
1351 */
1352inline std::string to_string(const ITensor *tensor)
1353{
1354 std::string ret_str = "nullptr";
1355 if(tensor != nullptr)
1356 {
1357 std::stringstream str;
ramelg01cbbb0382021-09-17 17:36:57 +01001358 str << "ITensor->info(): " << tensor->info();
ramelg013ae3d882021-09-12 23:07:47 +01001359 ret_str = str.str();
1360 }
1361 return ret_str;
1362}
1363
ramelg01cbbb0382021-09-17 17:36:57 +01001364/** Formatted output of the ITensorInfo type obtained from the ITensor* type.
ramelg013ae3d882021-09-12 23:07:47 +01001365 *
1366 * @param[in] tensor Type to output.
1367 *
1368 * @return Formatted string.
1369 */
1370inline std::string to_string(ITensor *tensor)
1371{
ramelg01cbbb0382021-09-17 17:36:57 +01001372 return to_string(static_cast<const ITensor *>(tensor));
ramelg013ae3d882021-09-12 23:07:47 +01001373}
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{
Ramy Elgammale920d6a2021-08-19 22:10:30 +01001383 std::stringstream str;
ramelg01cbbb0382021-09-17 17:36:57 +01001384 str << "ITensor.info(): " << tensor.info();
Ramy Elgammale920d6a2021-08-19 22:10:30 +01001385 return str.str();
1386}
1387
ramelg01cbbb0382021-09-17 17:36:57 +01001388#ifdef ARM_COMPUTE_OPENCL_ENABLED
1389/** Formatted output of the ITensorInfo type obtained from the const ICLTensor& type.
1390 *
1391 * @param[in] cl_tensor Type to output.
1392 *
1393 * @return Formatted string.
1394 */
1395inline std::string to_string(const ICLTensor *cl_tensor)
1396{
1397 std::string ret_str = "nullptr";
1398 if(cl_tensor != nullptr)
1399 {
1400 std::stringstream str;
1401 str << "ICLTensor->info(): " << cl_tensor->info();
1402 ret_str = str.str();
1403 }
1404 return ret_str;
1405}
1406
1407/** Formatted output of the ITensorInfo type obtained from the ICLTensor& type.
1408 *
1409 * @param[in] cl_tensor Type to output.
1410 *
1411 * @return Formatted string.
1412 */
1413inline std::string to_string(ICLTensor *cl_tensor)
1414{
1415 return to_string(static_cast<const ICLTensor *>(cl_tensor));
1416}
1417#endif /* ARM_COMPUTE_OPENCL_ENABLED */
1418
Alex Gildayc357c472018-03-21 13:54:09 +00001419/** Formatted output of the Dimensions type.
1420 *
1421 * @param[in] dimensions Type to output.
1422 *
1423 * @return Formatted string.
1424 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001425template <typename T>
1426inline std::string to_string(const Dimensions<T> &dimensions)
1427{
1428 std::stringstream str;
1429 str << dimensions;
1430 return str.str();
1431}
1432
Alex Gildayc357c472018-03-21 13:54:09 +00001433/** Formatted output of the Strides type.
1434 *
1435 * @param[in] stride Type to output.
1436 *
1437 * @return Formatted string.
1438 */
John Richardsona36eae12017-09-26 16:55:59 +01001439inline std::string to_string(const Strides &stride)
1440{
1441 std::stringstream str;
1442 str << stride;
1443 return str.str();
1444}
1445
Alex Gildayc357c472018-03-21 13:54:09 +00001446/** Formatted output of the TensorShape type.
1447 *
1448 * @param[in] shape Type to output.
1449 *
1450 * @return Formatted string.
1451 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001452inline std::string to_string(const TensorShape &shape)
1453{
1454 std::stringstream str;
1455 str << shape;
1456 return str.str();
1457}
1458
Alex Gildayc357c472018-03-21 13:54:09 +00001459/** Formatted output of the Coordinates type.
1460 *
1461 * @param[in] coord Type to output.
1462 *
1463 * @return Formatted string.
1464 */
Abe Mbise925ca0f2017-10-02 19:16:33 +01001465inline std::string to_string(const Coordinates &coord)
1466{
1467 std::stringstream str;
1468 str << coord;
1469 return str.str();
1470}
1471
Anthony Barbierb940fd62018-06-04 14:14:32 +01001472/** Formatted output of the GEMMReshapeInfo type.
1473 *
1474 * @param[out] os Output stream.
1475 * @param[in] info Type to output.
1476 *
1477 * @return Modified output stream.
1478 */
1479inline ::std::ostream &operator<<(::std::ostream &os, const GEMMReshapeInfo &info)
1480{
1481 os << "{m=" << info.m() << ",";
1482 os << "n=" << info.n() << ",";
1483 os << "k=" << info.k() << ",";
1484 os << "mult_transpose1xW_width=" << info.mult_transpose1xW_width() << ",";
1485 os << "mult_interleave4x4_height=" << info.mult_interleave4x4_height();
1486 os << "}";
1487
1488 return os;
1489}
1490
1491/** Formatted output of the GEMMInfo type.
1492 *
1493 * @param[out] os Output stream.
1494 * @param[in] info Type to output.
1495 *
1496 * @return Modified output stream.
1497 */
1498inline ::std::ostream &operator<<(::std::ostream &os, const GEMMInfo &info)
1499{
1500 os << "{is_a_reshaped=" << info.is_a_reshaped() << ",";
1501 os << "is_b_reshaped=" << info.is_b_reshaped() << ",";
1502 os << "reshape_b_only_on_first_run=" << info.reshape_b_only_on_first_run() << ",";
Anthony Barbierb4670212018-05-18 16:55:39 +01001503 os << "depth_output_gemm3d=" << info.depth_output_gemm3d() << ",";
1504 os << "reinterpret_input_as_3d=" << info.reinterpret_input_as_3d() << ",";
1505 os << "retain_internal_weights=" << info.retain_internal_weights() << ",";
1506 os << "fp_mixed_precision=" << info.fp_mixed_precision() << ",";
1507 os << "broadcast_bias=" << info.broadcast_bias() << ",";
ramelg01cbbb0382021-09-17 17:36:57 +01001508 os << "pretranspose_B=" << info.pretranspose_B() << ",";
SiCongLi579ca842021-10-18 09:38:33 +01001509 os << "post_ops=" << info.post_ops() << "}";
Anthony Barbierb940fd62018-06-04 14:14:32 +01001510
1511 return os;
1512}
1513
1514/** Formatted output of the Window::Dimension type.
1515 *
1516 * @param[out] os Output stream.
1517 * @param[in] dim Type to output.
1518 *
1519 * @return Modified output stream.
1520 */
1521inline ::std::ostream &operator<<(::std::ostream &os, const Window::Dimension &dim)
1522{
1523 os << "{start=" << dim.start() << ", end=" << dim.end() << ", step=" << dim.step() << "}";
1524
1525 return os;
1526}
1527/** Formatted output of the Window type.
1528 *
1529 * @param[out] os Output stream.
1530 * @param[in] win Type to output.
1531 *
1532 * @return Modified output stream.
1533 */
1534inline ::std::ostream &operator<<(::std::ostream &os, const Window &win)
1535{
1536 os << "{";
1537 for(unsigned int i = 0; i < Coordinates::num_max_dimensions; i++)
1538 {
1539 if(i > 0)
1540 {
1541 os << ", ";
1542 }
1543 os << win[i];
1544 }
1545 os << "}";
1546
1547 return os;
1548}
1549
1550/** Formatted output of the WeightsInfo type.
1551 *
1552 * @param[in] info Type to output.
1553 *
1554 * @return Formatted string.
1555 */
1556inline std::string to_string(const WeightsInfo &info)
1557{
1558 std::stringstream str;
1559 str << info;
1560 return str.str();
1561}
1562
1563/** Formatted output of the GEMMReshapeInfo type.
1564 *
1565 * @param[in] info Type to output.
1566 *
1567 * @return Formatted string.
1568 */
1569inline std::string to_string(const GEMMReshapeInfo &info)
1570{
1571 std::stringstream str;
1572 str << info;
1573 return str.str();
1574}
1575
1576/** Formatted output of the GEMMInfo type.
1577 *
1578 * @param[in] info Type to output.
1579 *
1580 * @return Formatted string.
1581 */
1582inline std::string to_string(const GEMMInfo &info)
1583{
1584 std::stringstream str;
1585 str << info;
1586 return str.str();
1587}
1588
1589/** Formatted output of the Window::Dimension type.
1590 *
1591 * @param[in] dim Type to output.
1592 *
1593 * @return Formatted string.
1594 */
1595inline std::string to_string(const Window::Dimension &dim)
1596{
1597 std::stringstream str;
1598 str << dim;
1599 return str.str();
1600}
ramelg01cbbb0382021-09-17 17:36:57 +01001601/** Formatted output of the Window& type.
Anthony Barbierb940fd62018-06-04 14:14:32 +01001602 *
1603 * @param[in] win Type to output.
1604 *
1605 * @return Formatted string.
1606 */
1607inline std::string to_string(const Window &win)
1608{
1609 std::stringstream str;
1610 str << win;
1611 return str.str();
1612}
1613
ramelg01cbbb0382021-09-17 17:36:57 +01001614/** Formatted output of the Window* type.
1615 *
1616 * @param[in] win Type to output.
1617 *
1618 * @return Formatted string.
1619 */
1620inline std::string to_string(Window *win)
1621{
1622 std::string ret_str = "nullptr";
1623 if(win != nullptr)
1624 {
1625 std::stringstream str;
1626 str << *win;
1627 ret_str = str.str();
1628 }
1629 return ret_str;
1630}
1631
Alex Gildayc357c472018-03-21 13:54:09 +00001632/** Formatted output of the Rectangle type.
1633 *
1634 * @param[out] os Output stream.
1635 * @param[in] rect Type to output.
1636 *
1637 * @return Modified output stream.
1638 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001639inline ::std::ostream &operator<<(::std::ostream &os, const Rectangle &rect)
1640{
1641 os << rect.width << "x" << rect.height;
1642 os << "+" << rect.x << "+" << rect.y;
1643
1644 return os;
1645}
1646
Usama Arif8cf8c112019-03-14 15:36:54 +00001647/** Formatted output of the PaddingMode type.
1648 *
1649 * @param[out] os Output stream.
1650 * @param[in] mode Type to output.
1651 *
1652 * @return Modified output stream.
1653 */
1654inline ::std::ostream &operator<<(::std::ostream &os, const PaddingMode &mode)
1655{
1656 switch(mode)
1657 {
1658 case PaddingMode::CONSTANT:
1659 os << "CONSTANT";
1660 break;
1661 case PaddingMode::REFLECT:
1662 os << "REFLECT";
1663 break;
1664 case PaddingMode::SYMMETRIC:
1665 os << "SYMMETRIC";
1666 break;
1667 default:
1668 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1669 }
1670
1671 return os;
1672}
1673
1674/** Formatted output of the PaddingMode type.
1675 *
1676 * @param[in] mode Type to output.
1677 *
1678 * @return Formatted string.
1679 */
1680inline std::string to_string(const PaddingMode &mode)
1681{
1682 std::stringstream str;
1683 str << mode;
1684 return str.str();
1685}
1686
Alex Gildayc357c472018-03-21 13:54:09 +00001687/** Formatted output of the PadStrideInfo type.
1688 *
1689 * @param[out] os Output stream.
1690 * @param[in] pad_stride_info Type to output.
1691 *
1692 * @return Modified output stream.
1693 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001694inline ::std::ostream &operator<<(::std::ostream &os, const PadStrideInfo &pad_stride_info)
1695{
1696 os << pad_stride_info.stride().first << "," << pad_stride_info.stride().second;
1697 os << ";";
Jaroslaw Rzepeckia1ed41f2017-10-13 11:13:58 +01001698 os << pad_stride_info.pad_left() << "," << pad_stride_info.pad_right() << ","
1699 << pad_stride_info.pad_top() << "," << pad_stride_info.pad_bottom();
Anthony Barbier2a07e182017-08-04 18:20:27 +01001700
1701 return os;
1702}
1703
Alex Gildayc357c472018-03-21 13:54:09 +00001704/** Formatted output of the PadStrideInfo type.
1705 *
1706 * @param[in] pad_stride_info Type to output.
1707 *
1708 * @return Formatted string.
1709 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001710inline std::string to_string(const PadStrideInfo &pad_stride_info)
1711{
1712 std::stringstream str;
1713 str << pad_stride_info;
1714 return str.str();
1715}
1716
Alex Gildayc357c472018-03-21 13:54:09 +00001717/** Formatted output of the BorderMode type.
1718 *
1719 * @param[in] mode Type to output.
1720 *
1721 * @return Formatted string.
1722 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001723inline std::string to_string(const BorderMode &mode)
1724{
1725 std::stringstream str;
1726 str << mode;
1727 return str.str();
1728}
1729
Alex Gildayc357c472018-03-21 13:54:09 +00001730/** Formatted output of the BorderSize type.
1731 *
1732 * @param[in] border Type to output.
1733 *
1734 * @return Formatted string.
1735 */
John Richardsonb482ce12017-09-18 12:44:01 +01001736inline std::string to_string(const BorderSize &border)
1737{
1738 std::stringstream str;
1739 str << border;
1740 return str.str();
1741}
1742
Giuseppe Rossinid7647d42018-07-17 18:13:13 +01001743/** Formatted output of the PaddingList type.
1744 *
1745 * @param[in] padding Type to output.
1746 *
1747 * @return Formatted string.
1748 */
1749inline std::string to_string(const PaddingList &padding)
1750{
1751 std::stringstream str;
1752 str << padding;
1753 return str.str();
1754}
1755
giuros013175fcf2018-11-21 09:59:17 +00001756/** Formatted output of the Multiples type.
1757 *
1758 * @param[in] multiples Type to output.
1759 *
1760 * @return Formatted string.
1761 */
1762inline std::string to_string(const Multiples &multiples)
1763{
1764 std::stringstream str;
1765 str << multiples;
1766 return str.str();
1767}
1768
Alex Gildayc357c472018-03-21 13:54:09 +00001769/** Formatted output of the InterpolationPolicy type.
1770 *
1771 * @param[in] policy Type to output.
1772 *
1773 * @return Formatted string.
1774 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001775inline std::string to_string(const InterpolationPolicy &policy)
1776{
1777 std::stringstream str;
1778 str << policy;
1779 return str.str();
1780}
1781
Alex Gildayc357c472018-03-21 13:54:09 +00001782/** Formatted output of the SamplingPolicy type.
1783 *
1784 * @param[in] policy Type to output.
1785 *
1786 * @return Formatted string.
1787 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +07001788inline std::string to_string(const SamplingPolicy &policy)
1789{
1790 std::stringstream str;
1791 str << policy;
1792 return str.str();
1793}
1794
Alex Gildayc357c472018-03-21 13:54:09 +00001795/** Formatted output of the ConvertPolicy type.
1796 *
1797 * @param[out] os Output stream.
1798 * @param[in] policy Type to output.
1799 *
1800 * @return Modified output stream.
1801 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001802inline ::std::ostream &operator<<(::std::ostream &os, const ConvertPolicy &policy)
1803{
1804 switch(policy)
1805 {
1806 case ConvertPolicy::WRAP:
1807 os << "WRAP";
1808 break;
1809 case ConvertPolicy::SATURATE:
1810 os << "SATURATE";
1811 break;
1812 default:
1813 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1814 }
1815
1816 return os;
1817}
1818
1819inline std::string to_string(const ConvertPolicy &policy)
1820{
1821 std::stringstream str;
1822 str << policy;
1823 return str.str();
1824}
1825
giuros01164a2722018-11-20 18:34:46 +00001826/** Formatted output of the ArithmeticOperation type.
1827 *
1828 * @param[out] os Output stream.
1829 * @param[in] op Operation to output.
1830 *
1831 * @return Modified output stream.
1832 */
1833inline ::std::ostream &operator<<(::std::ostream &os, const ArithmeticOperation &op)
1834{
1835 switch(op)
1836 {
1837 case ArithmeticOperation::ADD:
1838 os << "ADD";
1839 break;
1840 case ArithmeticOperation::SUB:
1841 os << "SUB";
1842 break;
1843 case ArithmeticOperation::DIV:
1844 os << "DIV";
1845 break;
1846 case ArithmeticOperation::MAX:
1847 os << "MAX";
1848 break;
1849 case ArithmeticOperation::MIN:
1850 os << "MIN";
1851 break;
1852 case ArithmeticOperation::SQUARED_DIFF:
1853 os << "SQUARED_DIFF";
1854 break;
Usama Arif52c54f62019-05-14 10:22:36 +01001855 case ArithmeticOperation::POWER:
1856 os << "POWER";
1857 break;
giuros01164a2722018-11-20 18:34:46 +00001858 default:
1859 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1860 }
1861
1862 return os;
1863}
1864
1865/** Formatted output of the Arithmetic Operation
1866 *
1867 * @param[in] op Type to output.
1868 *
1869 * @return Formatted string.
1870 */
1871inline std::string to_string(const ArithmeticOperation &op)
1872{
1873 std::stringstream str;
1874 str << op;
1875 return str.str();
1876}
1877
Alex Gildayc357c472018-03-21 13:54:09 +00001878/** Formatted output of the Reduction Operations.
1879 *
1880 * @param[out] os Output stream.
1881 * @param[in] op Type to output.
1882 *
1883 * @return Modified output stream.
1884 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001885inline ::std::ostream &operator<<(::std::ostream &os, const ReductionOperation &op)
1886{
1887 switch(op)
1888 {
Michalis Spyrou7e9391b2018-10-05 14:49:28 +01001889 case ReductionOperation::SUM:
1890 os << "SUM";
1891 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +01001892 case ReductionOperation::SUM_SQUARE:
1893 os << "SUM_SQUARE";
1894 break;
Michalis Spyrou7e9391b2018-10-05 14:49:28 +01001895 case ReductionOperation::MEAN_SUM:
1896 os << "MEAN_SUM";
1897 break;
Michalis Spyrou7930db42018-11-22 17:36:28 +00001898 case ReductionOperation::ARG_IDX_MAX:
1899 os << "ARG_IDX_MAX";
1900 break;
1901 case ReductionOperation::ARG_IDX_MIN:
1902 os << "ARG_IDX_MIN";
1903 break;
Manuel Bottinib412fab2018-12-10 17:40:23 +00001904 case ReductionOperation::PROD:
1905 os << "PROD";
1906 break;
Usama Arifa4a08ad2019-05-20 12:38:33 +01001907 case ReductionOperation::MIN:
1908 os << "MIN";
1909 break;
Usama Arif28f0dd92019-05-20 13:44:34 +01001910 case ReductionOperation::MAX:
1911 os << "MAX";
1912 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +01001913 default:
1914 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1915 }
1916
1917 return os;
1918}
1919
Alex Gildayc357c472018-03-21 13:54:09 +00001920/** Formatted output of the Reduction Operations.
1921 *
1922 * @param[in] op Type to output.
1923 *
1924 * @return Formatted string.
1925 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001926inline std::string to_string(const ReductionOperation &op)
1927{
1928 std::stringstream str;
1929 str << op;
1930 return str.str();
1931}
1932
Georgios Pinitas7900a9e2018-11-23 11:44:58 +00001933/** Formatted output of the Comparison Operations.
1934 *
1935 * @param[out] os Output stream.
1936 * @param[in] op Type to output.
1937 *
1938 * @return Modified output stream.
1939 */
1940inline ::std::ostream &operator<<(::std::ostream &os, const ComparisonOperation &op)
1941{
1942 switch(op)
1943 {
1944 case ComparisonOperation::Equal:
1945 os << "Equal";
1946 break;
1947 case ComparisonOperation::NotEqual:
1948 os << "NotEqual";
1949 break;
1950 case ComparisonOperation::Greater:
1951 os << "Greater";
1952 break;
1953 case ComparisonOperation::GreaterEqual:
1954 os << "GreaterEqual";
1955 break;
1956 case ComparisonOperation::Less:
1957 os << "Less";
1958 break;
1959 case ComparisonOperation::LessEqual:
1960 os << "LessEqual";
1961 break;
1962 default:
1963 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1964 }
1965
1966 return os;
1967}
1968
Michalis Spyroue9362622018-11-23 17:41:37 +00001969/** Formatted output of the Elementwise unary Operations.
1970 *
1971 * @param[out] os Output stream.
1972 * @param[in] op Type to output.
1973 *
1974 * @return Modified output stream.
1975 */
1976inline ::std::ostream &operator<<(::std::ostream &os, const ElementWiseUnary &op)
1977{
1978 switch(op)
1979 {
1980 case ElementWiseUnary::RSQRT:
1981 os << "RSQRT";
1982 break;
1983 case ElementWiseUnary::EXP:
1984 os << "EXP";
1985 break;
Usama Arifeb312ef2019-05-13 17:45:54 +01001986 case ElementWiseUnary::NEG:
1987 os << "NEG";
1988 break;
Usama Arifac33d7e2019-05-20 14:21:40 +01001989 case ElementWiseUnary::LOG:
1990 os << "LOG";
1991 break;
ramelg01b1ba1e32021-09-25 11:53:26 +01001992 case ElementWiseUnary::SIN:
1993 os << "SIN";
1994 break;
1995 case ElementWiseUnary::ABS:
1996 os << "ABS";
1997 break;
Usama Arif6a4d5422019-05-24 14:53:59 +01001998 case ElementWiseUnary::ROUND:
1999 os << "ROUND";
2000 break;
ramelg01b1ba1e32021-09-25 11:53:26 +01002001 case ElementWiseUnary::LOGICAL_NOT:
2002 os << "LOGICAL_NOT";
2003 break;
Michalis Spyroue9362622018-11-23 17:41:37 +00002004 default:
2005 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2006 }
2007
2008 return os;
2009}
2010
Georgios Pinitas7900a9e2018-11-23 11:44:58 +00002011/** Formatted output of the Comparison Operations.
2012 *
2013 * @param[in] op Type to output.
2014 *
2015 * @return Formatted string.
2016 */
2017inline std::string to_string(const ComparisonOperation &op)
2018{
2019 std::stringstream str;
2020 str << op;
2021 return str.str();
2022}
2023
Michalis Spyroue9362622018-11-23 17:41:37 +00002024/** Formatted output of the Elementwise unary Operations.
2025 *
2026 * @param[in] op Type to output.
2027 *
2028 * @return Formatted string.
2029 */
2030inline std::string to_string(const ElementWiseUnary &op)
2031{
2032 std::stringstream str;
2033 str << op;
2034 return str.str();
2035}
2036
Alex Gildayc357c472018-03-21 13:54:09 +00002037/** Formatted output of the Norm Type.
2038 *
2039 * @param[in] type Type to output.
2040 *
2041 * @return Formatted string.
2042 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01002043inline std::string to_string(const NormType &type)
2044{
2045 std::stringstream str;
2046 str << type;
2047 return str.str();
2048}
2049
Alex Gildayc357c472018-03-21 13:54:09 +00002050/** Formatted output of the Pooling Type.
2051 *
2052 * @param[in] type Type to output.
2053 *
2054 * @return Formatted string.
2055 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01002056inline std::string to_string(const PoolingType &type)
2057{
2058 std::stringstream str;
2059 str << type;
2060 return str.str();
2061}
2062
Alex Gildayc357c472018-03-21 13:54:09 +00002063/** Formatted output of the Pooling Layer Info.
2064 *
2065 * @param[in] info Type to output.
2066 *
2067 * @return Formatted string.
2068 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01002069inline std::string to_string(const PoolingLayerInfo &info)
2070{
2071 std::stringstream str;
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +00002072 str << "{Type=" << info.pool_type << ","
Sang-Hoon Park11fedda2020-01-15 14:44:04 +00002073 << "DataLayout=" << info.data_layout << ","
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +00002074 << "IsGlobalPooling=" << info.is_global_pooling;
2075 if(!info.is_global_pooling)
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00002076 {
2077 str << ","
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +00002078 << "PoolSize=" << info.pool_size.width << "," << info.pool_size.height << ","
2079 << "PadStride=" << info.pad_stride_info;
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00002080 }
2081 str << "}";
Anthony Barbier2a07e182017-08-04 18:20:27 +01002082 return str.str();
2083}
2084
Michalis Spyrou6c7c38e2018-08-29 16:28:11 +01002085/** Formatted output of the PriorBoxLayerInfo.
2086 *
2087 * @param[in] info Type to output.
2088 *
2089 * @return Formatted string.
2090 */
2091inline std::string to_string(const PriorBoxLayerInfo &info)
2092{
2093 std::stringstream str;
2094 str << "{";
2095 str << "Clip:" << info.clip()
2096 << "Flip:" << info.flip()
2097 << "StepX:" << info.steps()[0]
2098 << "StepY:" << info.steps()[1]
2099 << "MinSizes:" << info.min_sizes().size()
2100 << "MaxSizes:" << info.max_sizes().size()
2101 << "ImgSizeX:" << info.img_size().x
2102 << "ImgSizeY:" << info.img_size().y
2103 << "Offset:" << info.offset()
2104 << "Variances:" << info.variances().size();
2105 str << "}";
2106 return str.str();
2107}
2108
Alex Gildayc357c472018-03-21 13:54:09 +00002109/** Formatted output of the Size2D type.
2110 *
2111 * @param[out] os Output stream
2112 * @param[in] size Type to output
2113 *
2114 * @return Modified output stream.
2115 */
John Richardson25f23682017-11-27 14:35:09 +00002116inline ::std::ostream &operator<<(::std::ostream &os, const Size2D &size)
2117{
2118 os << size.width << "x" << size.height;
2119
2120 return os;
2121}
2122
Alex Gildayc357c472018-03-21 13:54:09 +00002123/** Formatted output of the Size2D type.
2124 *
2125 * @param[in] type Type to output
2126 *
2127 * @return Formatted string.
2128 */
John Richardson25f23682017-11-27 14:35:09 +00002129inline std::string to_string(const Size2D &type)
2130{
2131 std::stringstream str;
2132 str << type;
2133 return str.str();
2134}
2135
Giorgio Arena945ae9e2021-10-13 11:13:04 +01002136/** Formatted output of the Size3D type.
2137 *
2138 * @param[out] os Output stream
2139 * @param[in] size Type to output
2140 *
2141 * @return Modified output stream.
2142 */
2143inline ::std::ostream &operator<<(::std::ostream &os, const Size3D &size)
2144{
2145 os << size.width << "x" << size.height << "x" << size.depth;
2146
2147 return os;
2148}
2149
2150/** Formatted output of the Size2D type.
2151 *
2152 * @param[in] type Type to output
2153 *
2154 * @return Formatted string.
2155 */
2156inline std::string to_string(const Size3D &type)
2157{
2158 std::stringstream str;
2159 str << type;
2160 return str.str();
2161}
2162
Alex Gildayc357c472018-03-21 13:54:09 +00002163/** Formatted output of the ConvolutionMethod type.
2164 *
2165 * @param[out] os Output stream
2166 * @param[in] conv_method Type to output
2167 *
2168 * @return Modified output stream.
2169 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002170inline ::std::ostream &operator<<(::std::ostream &os, const ConvolutionMethod &conv_method)
2171{
2172 switch(conv_method)
2173 {
2174 case ConvolutionMethod::GEMM:
2175 os << "GEMM";
2176 break;
2177 case ConvolutionMethod::DIRECT:
2178 os << "DIRECT";
2179 break;
2180 case ConvolutionMethod::WINOGRAD:
2181 os << "WINOGRAD";
2182 break;
2183 default:
2184 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2185 }
2186
2187 return os;
2188}
2189
Alex Gildayc357c472018-03-21 13:54:09 +00002190/** Formatted output of the ConvolutionMethod type.
2191 *
2192 * @param[in] conv_method Type to output
2193 *
2194 * @return Formatted string.
2195 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002196inline std::string to_string(const ConvolutionMethod &conv_method)
2197{
2198 std::stringstream str;
2199 str << conv_method;
2200 return str.str();
2201}
2202
Alex Gildayc357c472018-03-21 13:54:09 +00002203/** Formatted output of the GPUTarget type.
2204 *
2205 * @param[out] os Output stream
2206 * @param[in] gpu_target Type to output
2207 *
2208 * @return Modified output stream.
2209 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002210inline ::std::ostream &operator<<(::std::ostream &os, const GPUTarget &gpu_target)
2211{
2212 switch(gpu_target)
2213 {
2214 case GPUTarget::GPU_ARCH_MASK:
2215 os << "GPU_ARCH_MASK";
2216 break;
2217 case GPUTarget::MIDGARD:
2218 os << "MIDGARD";
2219 break;
2220 case GPUTarget::BIFROST:
2221 os << "BIFROST";
2222 break;
Georgios Pinitasd5462ff2019-07-03 19:33:57 +01002223 case GPUTarget::VALHALL:
2224 os << "VALHALL";
2225 break;
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002226 case GPUTarget::T600:
2227 os << "T600";
2228 break;
2229 case GPUTarget::T700:
2230 os << "T700";
2231 break;
2232 case GPUTarget::T800:
2233 os << "T800";
2234 break;
Michalis Spyroua9676112018-02-22 18:07:43 +00002235 case GPUTarget::G71:
2236 os << "G71";
2237 break;
2238 case GPUTarget::G72:
2239 os << "G72";
2240 break;
2241 case GPUTarget::G51:
2242 os << "G51";
2243 break;
2244 case GPUTarget::G51BIG:
2245 os << "G51BIG";
2246 break;
2247 case GPUTarget::G51LIT:
2248 os << "G51LIT";
2249 break;
Georgios Pinitasb03f7c52018-07-12 10:49:53 +01002250 case GPUTarget::G76:
2251 os << "G76";
Michalis Spyroua9676112018-02-22 18:07:43 +00002252 break;
Georgios Pinitasd5462ff2019-07-03 19:33:57 +01002253 case GPUTarget::G77:
2254 os << "G77";
Michalis Spyroua9676112018-02-22 18:07:43 +00002255 break;
Georgios Pinitas4ffc42a2020-12-01 16:28:24 +00002256 case GPUTarget::G78:
2257 os << "G78";
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002258 break;
Pablo Marquez Tellob1496e62021-06-25 14:49:37 +01002259 case GPUTarget::G31:
2260 os << "G31";
2261 break;
Georgios Pinitasd5462ff2019-07-03 19:33:57 +01002262 case GPUTarget::TODX:
2263 os << "TODX";
2264 break;
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002265 default:
2266 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2267 }
2268
2269 return os;
2270}
2271
Alex Gildayc357c472018-03-21 13:54:09 +00002272/** Formatted output of the GPUTarget type.
2273 *
2274 * @param[in] gpu_target Type to output
2275 *
2276 * @return Formatted string.
2277 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002278inline std::string to_string(const GPUTarget &gpu_target)
2279{
2280 std::stringstream str;
2281 str << gpu_target;
2282 return str.str();
2283}
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00002284
John Richardson8de92612018-02-22 14:09:31 +00002285/** Formatted output of the DetectionWindow type.
2286 *
2287 * @param[out] os Output stream
2288 * @param[in] detection_window Type to output
2289 *
2290 * @return Modified output stream.
2291 */
John Richardson684cb0f2018-01-09 11:17:00 +00002292inline ::std::ostream &operator<<(::std::ostream &os, const DetectionWindow &detection_window)
2293{
2294 os << "{x=" << detection_window.x << ","
2295 << "y=" << detection_window.y << ","
2296 << "width=" << detection_window.width << ","
2297 << "height=" << detection_window.height << ","
2298 << "idx_class=" << detection_window.idx_class << ","
2299 << "score=" << detection_window.score << "}";
2300
2301 return os;
2302}
2303
Isabella Gottardi05e56442018-11-16 11:26:52 +00002304/** Formatted output of the DetectionOutputLayerCodeType type.
2305 *
2306 * @param[out] os Output stream
2307 * @param[in] detection_code Type to output
2308 *
2309 * @return Modified output stream.
2310 */
2311inline ::std::ostream &operator<<(::std::ostream &os, const DetectionOutputLayerCodeType &detection_code)
2312{
2313 switch(detection_code)
2314 {
2315 case DetectionOutputLayerCodeType::CENTER_SIZE:
2316 os << "CENTER_SIZE";
2317 break;
2318 case DetectionOutputLayerCodeType::CORNER:
2319 os << "CORNER";
2320 break;
2321 case DetectionOutputLayerCodeType::CORNER_SIZE:
2322 os << "CORNER_SIZE";
2323 break;
2324 case DetectionOutputLayerCodeType::TF_CENTER:
2325 os << "TF_CENTER";
2326 break;
2327 default:
2328 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2329 }
2330
2331 return os;
2332}
2333/** Formatted output of the DetectionOutputLayerCodeType type.
2334 *
2335 * @param[in] detection_code Type to output
2336 *
2337 * @return Formatted string.
2338 */
2339inline std::string to_string(const DetectionOutputLayerCodeType &detection_code)
2340{
2341 std::stringstream str;
2342 str << detection_code;
2343 return str.str();
2344}
2345
2346/** Formatted output of the DetectionOutputLayerInfo type.
2347 *
2348 * @param[out] os Output stream
2349 * @param[in] detection_info Type to output
2350 *
2351 * @return Modified output stream.
2352 */
2353inline ::std::ostream &operator<<(::std::ostream &os, const DetectionOutputLayerInfo &detection_info)
2354{
2355 os << "{Classes=" << detection_info.num_classes() << ","
2356 << "ShareLocation=" << detection_info.share_location() << ","
2357 << "CodeType=" << detection_info.code_type() << ","
2358 << "VarianceEncodedInTarget=" << detection_info.variance_encoded_in_target() << ","
2359 << "KeepTopK=" << detection_info.keep_top_k() << ","
2360 << "NMSThreshold=" << detection_info.nms_threshold() << ","
2361 << "Eta=" << detection_info.eta() << ","
2362 << "BackgroundLabelId=" << detection_info.background_label_id() << ","
2363 << "ConfidenceThreshold=" << detection_info.confidence_threshold() << ","
2364 << "TopK=" << detection_info.top_k() << ","
2365 << "NumLocClasses=" << detection_info.num_loc_classes()
2366 << "}";
2367
2368 return os;
2369}
2370
2371/** Formatted output of the DetectionOutputLayerInfo type.
2372 *
2373 * @param[in] detection_info Type to output
2374 *
2375 * @return Formatted string.
2376 */
2377inline std::string to_string(const DetectionOutputLayerInfo &detection_info)
2378{
2379 std::stringstream str;
2380 str << detection_info;
2381 return str.str();
2382}
Isabella Gottardia7acb3c2019-01-08 13:48:44 +00002383/** Formatted output of the DetectionPostProcessLayerInfo type.
2384 *
2385 * @param[out] os Output stream
2386 * @param[in] detection_info Type to output
2387 *
2388 * @return Modified output stream.
2389 */
2390inline ::std::ostream &operator<<(::std::ostream &os, const DetectionPostProcessLayerInfo &detection_info)
2391{
2392 os << "{MaxDetections=" << detection_info.max_detections() << ","
2393 << "MaxClassesPerDetection=" << detection_info.max_classes_per_detection() << ","
2394 << "NmsScoreThreshold=" << detection_info.nms_score_threshold() << ","
2395 << "NmsIouThreshold=" << detection_info.iou_threshold() << ","
2396 << "NumClasses=" << detection_info.num_classes() << ","
2397 << "ScaleValue_y=" << detection_info.scale_value_y() << ","
2398 << "ScaleValue_x=" << detection_info.scale_value_x() << ","
2399 << "ScaleValue_h=" << detection_info.scale_value_h() << ","
2400 << "ScaleValue_w=" << detection_info.scale_value_w() << ","
2401 << "UseRegularNms=" << detection_info.use_regular_nms() << ","
2402 << "DetectionPerClass=" << detection_info.detection_per_class()
2403 << "}";
2404
2405 return os;
2406}
2407
2408/** Formatted output of the DetectionPostProcessLayerInfo type.
2409 *
2410 * @param[in] detection_info Type to output
2411 *
2412 * @return Formatted string.
2413 */
2414inline std::string to_string(const DetectionPostProcessLayerInfo &detection_info)
2415{
2416 std::stringstream str;
2417 str << detection_info;
2418 return str.str();
2419}
Georgios Pinitasc6f95102021-03-30 10:03:01 +01002420
John Richardson8de92612018-02-22 14:09:31 +00002421/** Formatted output of the DetectionWindow type.
2422 *
2423 * @param[in] detection_window Type to output
2424 *
2425 * @return Formatted string.
2426 */
2427inline std::string to_string(const DetectionWindow &detection_window)
2428{
2429 std::stringstream str;
2430 str << detection_window;
2431 return str.str();
2432}
2433
Michalis Spyrou6c7c38e2018-08-29 16:28:11 +01002434/** Formatted output of @ref PriorBoxLayerInfo.
2435 *
2436 * @param[out] os Output stream.
2437 * @param[in] info Type to output.
2438 *
2439 * @return Modified output stream.
2440 */
2441inline ::std::ostream &operator<<(::std::ostream &os, const PriorBoxLayerInfo &info)
2442{
2443 os << "Clip:" << info.clip()
2444 << "Flip:" << info.flip()
2445 << "StepX:" << info.steps()[0]
2446 << "StepY:" << info.steps()[1]
2447 << "MinSizes:" << info.min_sizes()
2448 << "MaxSizes:" << info.max_sizes()
2449 << "ImgSizeX:" << info.img_size().x
2450 << "ImgSizeY:" << info.img_size().y
2451 << "Offset:" << info.offset()
2452 << "Variances:" << info.variances();
2453
2454 return os;
2455}
2456
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00002457/** Formatted output of the WinogradInfo type. */
2458inline ::std::ostream &operator<<(::std::ostream &os, const WinogradInfo &info)
2459{
2460 os << "{OutputTileSize=" << info.output_tile_size << ","
2461 << "KernelSize=" << info.kernel_size << ","
2462 << "PadStride=" << info.convolution_info << ","
2463 << "OutputDataLayout=" << info.output_data_layout << "}";
2464
2465 return os;
2466}
2467
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00002468inline std::string to_string(const WinogradInfo &type)
2469{
2470 std::stringstream str;
2471 str << type;
2472 return str.str();
2473}
Anthony Barbier671a11e2018-07-06 15:11:36 +01002474
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +01002475/** Convert a CLTunerMode value to a string
2476 *
2477 * @param val CLTunerMode value to be converted
2478 *
2479 * @return String representing the corresponding CLTunerMode.
2480 */
2481inline std::string to_string(const CLTunerMode val)
2482{
2483 switch(val)
2484 {
2485 case CLTunerMode::EXHAUSTIVE:
2486 {
2487 return std::string("Exhaustive");
2488 }
2489 case CLTunerMode::NORMAL:
2490 {
2491 return std::string("Normal");
2492 }
2493 case CLTunerMode::RAPID:
2494 {
2495 return std::string("Rapid");
2496 }
2497 default:
2498 {
2499 ARM_COMPUTE_ERROR("Invalid tuner mode.");
2500 return std::string("UNDEFINED");
2501 }
2502 }
2503}
SiCong Lidb4a6c12021-02-05 09:30:57 +00002504/** Converts a @ref CLGEMMKernelType to string
2505 *
2506 * @param[in] val CLGEMMKernelType value to be converted
2507 *
2508 * @return String representing the corresponding CLGEMMKernelType
2509 */
2510inline std::string to_string(CLGEMMKernelType val)
2511{
2512 switch(val)
2513 {
SiCong Lidb4a6c12021-02-05 09:30:57 +00002514 case CLGEMMKernelType::NATIVE:
2515 {
2516 return "Native";
2517 }
2518 case CLGEMMKernelType::RESHAPED_ONLY_RHS:
2519 {
2520 return "Reshaped_Only_RHS";
2521 }
2522 case CLGEMMKernelType::RESHAPED:
2523 {
2524 return "Reshaped";
2525 }
2526 default:
2527 {
2528 return "Unknown";
2529 }
2530 }
2531}
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +01002532/** [Print CLTunerMode type] **/
2533/** Formatted output of the CLTunerMode type.
2534 *
2535 * @param[out] os Output stream.
2536 * @param[in] val CLTunerMode to output.
2537 *
2538 * @return Modified output stream.
2539 */
2540inline ::std::ostream &operator<<(::std::ostream &os, const CLTunerMode &val)
2541{
2542 os << to_string(val);
2543 return os;
2544}
2545
ramelg013ae3d882021-09-12 23:07:47 +01002546/** Formatted output of the ConvolutionInfo type.
2547 *
2548 * @param[out] os Output stream.
2549 * @param[in] conv_info ConvolutionInfo to output.
2550 *
2551 * @return Modified output stream.
2552 */
2553inline ::std::ostream &operator<<(::std::ostream &os, const ConvolutionInfo &conv_info)
2554{
SiCongLi579ca842021-10-18 09:38:33 +01002555 os << "{PadStrideInfo=" << conv_info.pad_stride_info << ", "
2556 << "depth_multiplier=" << conv_info.depth_multiplier << ", "
2557 << "act_info=" << to_string(conv_info.act_info) << ", "
2558 << "dilation=" << conv_info.dilation << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002559 return os;
2560}
2561
2562/** Converts a @ref ConvolutionInfo to string
2563 *
2564 * @param[in] info ConvolutionInfo value to be converted
2565 *
2566 * @return String representing the corresponding ConvolutionInfo
2567 */
2568inline std::string to_string(const ConvolutionInfo &info)
2569{
2570 std::stringstream str;
2571 str << info;
2572 return str.str();
2573}
2574
2575/** Formatted output of the FullyConnectedLayerInfo type.
2576 *
2577 * @param[out] os Output stream.
2578 * @param[in] layer_info FullyConnectedLayerInfo to output.
2579 *
2580 * @return Modified output stream.
2581 */
2582inline ::std::ostream &operator<<(::std::ostream &os, const FullyConnectedLayerInfo &layer_info)
2583{
SiCongLi579ca842021-10-18 09:38:33 +01002584 os << "{activation_info=" << to_string(layer_info.activation_info) << ", "
2585 << "weights_trained_layout=" << layer_info.weights_trained_layout << ", "
2586 << "transpose_weights=" << layer_info.transpose_weights << ", "
2587 << "are_weights_reshaped=" << layer_info.are_weights_reshaped << ", "
2588 << "retain_internal_weights=" << layer_info.retain_internal_weights << ", "
2589 << "constant_weights=" << layer_info.transpose_weights << ", "
2590 << "fp_mixed_precision=" << layer_info.fp_mixed_precision << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002591 return os;
2592}
2593
2594/** Converts a @ref FullyConnectedLayerInfo to string
2595 *
2596 * @param[in] info FullyConnectedLayerInfo value to be converted
2597 *
2598 * @return String representing the corresponding FullyConnectedLayerInfo
2599 */
2600inline std::string to_string(const FullyConnectedLayerInfo &info)
2601{
2602 std::stringstream str;
2603 str << info;
2604 return str.str();
2605}
2606
2607/** Formatted output of the GEMMLowpOutputStageType type.
2608 *
2609 * @param[out] os Output stream.
2610 * @param[in] gemm_type GEMMLowpOutputStageType to output.
2611 *
2612 * @return Modified output stream.
2613 */
2614inline ::std::ostream &operator<<(::std::ostream &os, const GEMMLowpOutputStageType &gemm_type)
2615{
2616 switch(gemm_type)
2617 {
2618 case GEMMLowpOutputStageType::NONE:
2619 os << "NONE";
2620 break;
2621 case GEMMLowpOutputStageType::QUANTIZE_DOWN:
2622 os << "QUANTIZE_DOWN";
2623 break;
2624 case GEMMLowpOutputStageType::QUANTIZE_DOWN_FIXEDPOINT:
2625 os << "QUANTIZE_DOWN_FIXEDPOINT";
2626 break;
2627 case GEMMLowpOutputStageType::QUANTIZE_DOWN_FLOAT:
2628 os << "QUANTIZE_DOWN_FLOAT";
2629 break;
2630 default:
2631 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2632 }
2633 return os;
2634}
2635
2636/** Converts a @ref GEMMLowpOutputStageType to string
2637 *
2638 * @param[in] gemm_type GEMMLowpOutputStageType value to be converted
2639 *
2640 * @return String representing the corresponding GEMMLowpOutputStageType
2641 */
2642inline std::string to_string(const GEMMLowpOutputStageType &gemm_type)
2643{
2644 std::stringstream str;
2645 str << gemm_type;
2646 return str.str();
2647}
2648
2649/** Formatted output of the GEMMLowpOutputStageInfo type.
2650 *
2651 * @param[out] os Output stream.
2652 * @param[in] gemm_info GEMMLowpOutputStageInfo to output.
2653 *
2654 * @return Modified output stream.
2655 */
2656inline ::std::ostream &operator<<(::std::ostream &os, const GEMMLowpOutputStageInfo &gemm_info)
2657{
SiCongLi579ca842021-10-18 09:38:33 +01002658 os << "{type=" << gemm_info.type << ", "
2659 << "gemlowp_offset=" << gemm_info.gemmlowp_offset << ", "
2660 << "gemmlowp_multiplier=" << gemm_info.gemmlowp_multiplier << ", "
2661 << "gemmlowp_shift=" << gemm_info.gemmlowp_shift << ", "
2662 << "gemmlowp_min_bound=" << gemm_info.gemmlowp_min_bound << ", "
2663 << "gemmlowp_max_bound=" << gemm_info.gemmlowp_max_bound << ", "
2664 << "gemmlowp_multipliers=" << gemm_info.gemmlowp_multiplier << ", "
2665 << "gemmlowp_shifts=" << gemm_info.gemmlowp_shift << ", "
2666 << "gemmlowp_real_multiplier=" << gemm_info.gemmlowp_real_multiplier << ", "
2667 << "is_quantized_per_channel=" << gemm_info.is_quantized_per_channel << ", "
2668 << "output_data_type=" << gemm_info.output_data_type << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002669 return os;
2670}
2671
2672/** Converts a @ref GEMMLowpOutputStageInfo to string
2673 *
2674 * @param[in] gemm_info GEMMLowpOutputStageInfo value to be converted
2675 *
2676 * @return String representing the corresponding GEMMLowpOutputStageInfo
2677 */
2678inline std::string to_string(const GEMMLowpOutputStageInfo &gemm_info)
2679{
2680 std::stringstream str;
2681 str << gemm_info;
2682 return str.str();
2683}
2684
2685/** Formatted output of the Conv2dInfo type.
2686 *
2687 * @param[out] os Output stream.
2688 * @param[in] conv_info Conv2dInfo to output.
2689 *
2690 * @return Modified output stream.
2691 */
2692inline ::std::ostream &operator<<(::std::ostream &os, const Conv2dInfo &conv_info)
2693{
SiCongLi579ca842021-10-18 09:38:33 +01002694 os << "{conv_info=" << conv_info.conv_info << ", "
2695 << "dilation=" << conv_info.dilation << ", "
2696 << "act_info=" << to_string(conv_info.act_info) << ", "
2697 << "enable_fast_math=" << conv_info.enable_fast_math << ", "
2698 << "num_groups=" << conv_info.num_groups << ","
2699 << "post_ops=" << conv_info.post_ops << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002700 return os;
2701}
2702
2703/** Converts a @ref Conv2dInfo to string
2704 *
2705 * @param[in] conv_info Conv2dInfo value to be converted
2706 *
2707 * @return String representing the corresponding Conv2dInfo
2708 */
2709inline std::string to_string(const Conv2dInfo &conv_info)
2710{
2711 std::stringstream str;
2712 str << conv_info;
2713 return str.str();
2714}
2715
2716/** Formatted output of the PixelValue type.
2717 *
2718 * @param[out] os Output stream.
2719 * @param[in] pixel_value PixelValue to output.
2720 *
2721 * @return Modified output stream.
2722 */
2723inline ::std::ostream &operator<<(::std::ostream &os, const PixelValue &pixel_value)
2724{
SiCongLi579ca842021-10-18 09:38:33 +01002725 os << "{value.u64=" << pixel_value.get<uint64_t>() << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002726 return os;
2727}
2728
2729/** Converts a @ref PixelValue to string
2730 *
2731 * @param[in] pixel_value PixelValue value to be converted
2732 *
2733 * @return String representing the corresponding PixelValue
2734 */
2735inline std::string to_string(const PixelValue &pixel_value)
2736{
2737 std::stringstream str;
2738 str << pixel_value;
2739 return str.str();
2740}
2741
2742/** Formatted output of the ScaleKernelInfo type.
2743 *
2744 * @param[out] os Output stream.
2745 * @param[in] scale_info ScaleKernelInfo to output.
2746 *
2747 * @return Modified output stream.
2748 */
2749inline ::std::ostream &operator<<(::std::ostream &os, const ScaleKernelInfo &scale_info)
2750{
SiCongLi579ca842021-10-18 09:38:33 +01002751 os << "{interpolation_policy=" << scale_info.interpolation_policy << ", "
2752 << "BorderMode=" << scale_info.border_mode << ", "
2753 << "PixelValue=" << scale_info.constant_border_value << ", "
2754 << "SamplingPolicy=" << scale_info.sampling_policy << ", "
2755 << "use_padding=" << scale_info.use_padding << ", "
2756 << "align_corners=" << scale_info.align_corners << ", "
2757 << "data_layout=" << scale_info.data_layout << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002758 return os;
2759}
2760
2761/** Converts a @ref ScaleKernelInfo to string
2762 *
2763 * @param[in] scale_info ScaleKernelInfo value to be converted
2764 *
2765 * @return String representing the corresponding ScaleKernelInfo
2766 */
2767inline std::string to_string(const ScaleKernelInfo &scale_info)
2768{
2769 std::stringstream str;
2770 str << scale_info;
2771 return str.str();
2772}
2773
2774/** Formatted output of the FFTDirection type.
2775 *
2776 * @param[out] os Output stream.
2777 * @param[in] fft_dir FFTDirection to output.
2778 *
2779 * @return Modified output stream.
2780 */
2781inline ::std::ostream &operator<<(::std::ostream &os, const FFTDirection &fft_dir)
2782{
2783 switch(fft_dir)
2784 {
2785 case FFTDirection::Forward:
2786 os << "Forward";
2787 break;
2788 case FFTDirection::Inverse:
2789 os << "Inverse";
2790 break;
2791 default:
2792 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2793 }
2794 return os;
2795}
2796
2797/** Converts a @ref FFT1DInfo to string
2798 *
2799 * @param[in] fft_dir FFT1DInfo value to be converted
2800 *
2801 * @return String representing the corresponding FFT1DInfo
2802 */
2803inline std::string to_string(const FFTDirection &fft_dir)
2804{
2805 std::stringstream str;
ramelg01cbbb0382021-09-17 17:36:57 +01002806 str << "{" << fft_dir << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002807 return str.str();
2808}
2809
2810/** Formatted output of the FFT1DInfo type.
2811 *
2812 * @param[out] os Output stream.
2813 * @param[in] fft1d_info FFT1DInfo to output.
2814 *
2815 * @return Modified output stream.
2816 */
2817inline ::std::ostream &operator<<(::std::ostream &os, const FFT1DInfo &fft1d_info)
2818{
SiCongLi579ca842021-10-18 09:38:33 +01002819 os << "{axis=" << fft1d_info.axis << ", "
2820 << "direction=" << fft1d_info.direction << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002821 return os;
2822}
2823
2824/** Converts a @ref FFT1DInfo to string
2825 *
2826 * @param[in] fft1d_info FFT1DInfo value to be converted
2827 *
2828 * @return String representing the corresponding FFT1DInfo
2829 */
2830inline std::string to_string(const FFT1DInfo &fft1d_info)
2831{
2832 std::stringstream str;
2833 str << fft1d_info;
2834 return str.str();
2835}
2836
2837/** Formatted output of the FFT2DInfo type.
2838 *
2839 * @param[out] os Output stream.
2840 * @param[in] fft2d_info FFT2DInfo to output.
2841 *
2842 * @return Modified output stream.
2843 */
2844inline ::std::ostream &operator<<(::std::ostream &os, const FFT2DInfo &fft2d_info)
2845{
SiCongLi579ca842021-10-18 09:38:33 +01002846 os << "{axis=" << fft2d_info.axis0 << ", "
2847 << "axis=" << fft2d_info.axis1 << ", "
2848 << "direction=" << fft2d_info.direction << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002849 return os;
2850}
2851
2852/** Converts a @ref FFT2DInfo to string
2853 *
2854 * @param[in] fft2d_info FFT2DInfo value to be converted
2855 *
2856 * @return String representing the corresponding FFT2DInfo
2857 */
2858inline std::string to_string(const FFT2DInfo &fft2d_info)
2859{
2860 std::stringstream str;
2861 str << fft2d_info;
2862 return str.str();
2863}
2864
2865/** Formatted output of the Coordinates2D type.
2866 *
2867 * @param[out] os Output stream.
2868 * @param[in] coord_2d Coordinates2D to output.
2869 *
2870 * @return Modified output stream.
2871 */
2872inline ::std::ostream &operator<<(::std::ostream &os, const Coordinates2D &coord_2d)
2873{
SiCongLi579ca842021-10-18 09:38:33 +01002874 os << "{x=" << coord_2d.x << ", "
2875 << "y=" << coord_2d.y << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002876 return os;
2877}
2878
2879/** Converts a @ref Coordinates2D to string
2880 *
2881 * @param[in] coord_2d Coordinates2D value to be converted
2882 *
2883 * @return String representing the corresponding Coordinates2D
2884 */
2885inline std::string to_string(const Coordinates2D &coord_2d)
2886{
2887 std::stringstream str;
2888 str << coord_2d;
2889 return str.str();
2890}
2891
2892/** Formatted output of the FuseBatchNormalizationType type.
2893 *
2894 * @param[out] os Output stream.
2895 * @param[in] fuse_type FuseBatchNormalizationType to output.
2896 *
2897 * @return Modified output stream.
2898 */
2899inline ::std::ostream &operator<<(::std::ostream &os, const FuseBatchNormalizationType &fuse_type)
2900{
2901 switch(fuse_type)
2902 {
2903 case FuseBatchNormalizationType::CONVOLUTION:
2904 os << "CONVOLUTION";
2905 break;
2906 case FuseBatchNormalizationType::DEPTHWISECONVOLUTION:
2907 os << "DEPTHWISECONVOLUTION";
2908 break;
2909 default:
2910 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2911 }
2912 return os;
2913}
2914
2915/** Converts a @ref FuseBatchNormalizationType to string
2916 *
2917 * @param[in] fuse_type FuseBatchNormalizationType value to be converted
2918 *
2919 * @return String representing the corresponding FuseBatchNormalizationType
2920 */
2921inline std::string to_string(const FuseBatchNormalizationType &fuse_type)
2922{
2923 std::stringstream str;
2924 str << fuse_type;
2925 return str.str();
2926}
2927
ramelg01cbbb0382021-09-17 17:36:57 +01002928/** Formatted output of the SoftmaxKernelInfo type.
2929 *
2930 * @param[out] os Output stream.
2931 * @param[in] info SoftmaxKernelInfo to output.
2932 *
2933 * @return Modified output stream.
2934 */
2935inline ::std::ostream &operator<<(::std::ostream &os, const SoftmaxKernelInfo &info)
2936{
SiCongLi579ca842021-10-18 09:38:33 +01002937 os << "{beta=" << info.beta << ", "
2938 << "is_log=" << info.is_log << ", "
2939 << "input_data_type=" << info.input_data_type << ", "
2940 << "axis=" << info.axis << "}";
ramelg01cbbb0382021-09-17 17:36:57 +01002941 return os;
2942}
2943
2944/** Converts a @ref SoftmaxKernelInfo to string
2945 *
2946 * @param[in] info SoftmaxKernelInfo value to be converted
2947 *
2948 * @return String representing the corresponding SoftmaxKernelInfo
2949 */
2950inline std::string to_string(const SoftmaxKernelInfo &info)
2951{
2952 std::stringstream str;
2953 str << info;
2954 return str.str();
2955}
2956
2957/** Formatted output of the ScaleKernelInfo type.
2958 *
2959 * @param[out] os Output stream.
2960 * @param[in] lstm_params LSTMParams to output.
2961 *
2962 * @return Modified output stream.
2963 */
2964template <typename T>
ramelg014a6d9e82021-10-02 14:34:36 +01002965::std::ostream &operator<<(::std::ostream &os, const LSTMParams<T> &lstm_params)
ramelg01cbbb0382021-09-17 17:36:57 +01002966{
ramelg014a6d9e82021-10-02 14:34:36 +01002967 os << "{input_to_input_weights=" << to_string(lstm_params.input_to_input_weights()) << ", "
2968 << "recurrent_to_input_weights=" << to_string(lstm_params.recurrent_to_input_weights()) << ", "
2969 << "cell_to_input_weights=" << to_string(lstm_params.cell_to_input_weights()) << ", "
2970 << "input_gate_bias=" << to_string(lstm_params.input_gate_bias()) << ", "
2971 << "cell_to_forget_weights=" << to_string(lstm_params.cell_to_forget_weights()) << ", "
2972 << "cell_to_output_weights=" << to_string(lstm_params.cell_to_output_weights()) << ", "
2973 << "projection_weights=" << to_string(lstm_params.projection_weights()) << ", "
2974 << "projection_bias=" << to_string(lstm_params.projection_bias()) << ", "
2975 << "input_layer_norm_weights=" << to_string(lstm_params.input_layer_norm_weights()) << ", "
2976 << "forget_layer_norm_weights=" << to_string(lstm_params.forget_layer_norm_weights()) << ", "
2977 << "cell_layer_norm_weights=" << to_string(lstm_params.cell_layer_norm_weights()) << ", "
2978 << "output_layer_norm_weights=" << to_string(lstm_params.output_layer_norm_weights()) << ", "
ramelg01cbbb0382021-09-17 17:36:57 +01002979 << "cell_clip=" << lstm_params.cell_clip() << ", "
2980 << "projection_clip=" << lstm_params.projection_clip() << ", "
2981 << "input_intermediate_scale=" << lstm_params.input_intermediate_scale() << ", "
2982 << "forget_intermediate_scale=" << lstm_params.forget_intermediate_scale() << ", "
2983 << "cell_intermediate_scale=" << lstm_params.cell_intermediate_scale() << ", "
2984 << "hidden_state_zero=" << lstm_params.hidden_state_zero() << ", "
2985 << "hidden_state_scale=" << lstm_params.hidden_state_scale() << ", "
2986 << "has_peephole_opt=" << lstm_params.has_peephole_opt() << ", "
2987 << "has_projection=" << lstm_params.has_projection() << ", "
2988 << "has_cifg_opt=" << lstm_params.has_cifg_opt() << ", "
2989 << "use_layer_norm=" << lstm_params.use_layer_norm() << "}";
2990 return os;
2991}
2992
2993/** Converts a @ref LSTMParams to string
2994 *
2995 * @param[in] lstm_params LSTMParams<T> value to be converted
2996 *
2997 * @return String representing the corresponding LSTMParams
2998 */
2999template <typename T>
ramelg014a6d9e82021-10-02 14:34:36 +01003000std::string to_string(const LSTMParams<T> &lstm_params)
ramelg01cbbb0382021-09-17 17:36:57 +01003001{
3002 std::stringstream str;
3003 str << lstm_params;
3004 return str.str();
3005}
3006
3007/** Converts a @ref LSTMParams to string
3008 *
3009 * @param[in] num uint8_t value to be converted
3010 *
3011 * @return String representing the corresponding uint8_t
3012 */
3013inline std::string to_string(const uint8_t num)
3014{
3015 // Explicity cast the uint8_t to signed integer and call the corresponding overloaded to_string() function.
3016 return ::std::to_string(static_cast<int>(num));
3017}
3018
ramelg014a6d9e82021-10-02 14:34:36 +01003019/** Available non maxima suppression types */
3020/** Formatted output of the NMSType type.
3021 *
3022 * @param[out] os Output stream.
3023 * @param[in] nms_type NMSType to output.
3024 *
3025 * @return Modified output stream.
3026 */
3027inline ::std::ostream &operator<<(::std::ostream &os, const NMSType &nms_type)
3028{
3029 switch(nms_type)
3030 {
3031 case NMSType::LINEAR:
3032 os << "LINEAR";
3033 break;
3034 case NMSType::GAUSSIAN:
3035 os << "GAUSSIAN";
3036 break;
3037 case NMSType::ORIGINAL:
3038 os << "ORIGINAL";
3039 break;
3040 default:
3041 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
3042 }
3043 return os;
3044}
3045
3046/** Converts a @ref NMSType to string
3047 *
3048 * @param[in] nms_type NMSType value to be converted
3049 *
3050 * @return String representing the corresponding NMSType
3051 */
3052inline std::string to_string(const NMSType nms_type)
3053{
3054 std::stringstream str;
3055 str << nms_type;
3056 return str.str();
3057}
3058
3059/** Formatted output of the BoxNMSLimitInfo type.
3060 *
3061 * @param[out] os Output stream.
3062 * @param[in] info BoxNMSLimitInfo to output.
3063 *
3064 * @return Modified output stream.
3065 */
3066inline ::std::ostream &operator<<(::std::ostream &os, const BoxNMSLimitInfo &info)
3067{
SiCongLi579ca842021-10-18 09:38:33 +01003068 os << "{score_thresh=" << info.score_thresh() << ", "
3069 << "nms=" << info.nms() << ", "
3070 << "detections_per_im=" << info.detections_per_im() << ", "
3071 << "soft_nms_enabled=" << info.soft_nms_enabled() << ", "
3072 << "soft_nms_min_score_thres=" << info.soft_nms_min_score_thres() << ", "
3073 << "suppress_size=" << info.suppress_size() << ", "
3074 << "min_size=" << info.min_size() << ", "
3075 << "im_width=" << info.im_width() << ", "
3076 << "im_height=" << info.im_height() << "}";
ramelg014a6d9e82021-10-02 14:34:36 +01003077 return os;
3078}
3079
3080/** Converts a @ref BoxNMSLimitInfo to string
3081 *
3082 * @param[in] info BoxNMSLimitInfo value to be converted
3083 *
3084 * @return String representing the corresponding BoxNMSLimitInfo
3085 */
3086inline std::string to_string(const BoxNMSLimitInfo &info)
3087{
3088 std::stringstream str;
3089 str << info;
3090 return str.str();
3091}
3092
Giorgio Arena945ae9e2021-10-13 11:13:04 +01003093/** Formatted output of the DimensionRoundingType type.
3094 *
3095 * @param[out] os Output stream.
3096 * @param[in] rounding_type DimensionRoundingType to output.
3097 *
3098 * @return Modified output stream.
3099 */
3100inline ::std::ostream &operator<<(::std::ostream &os, const DimensionRoundingType &rounding_type)
3101{
3102 switch(rounding_type)
3103 {
3104 case DimensionRoundingType::CEIL:
3105 os << "CEIL";
3106 break;
3107 case DimensionRoundingType::FLOOR:
3108 os << "FLOOR";
3109 break;
3110 default:
3111 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
3112 }
3113 return os;
3114}
3115
3116/** Converts a @ref DimensionRoundingType to string
3117 *
3118 * @param[in] rounding_type DimensionRoundingType value to be converted
3119 *
3120 * @return String representing the corresponding DimensionRoundingType
3121 */
3122inline std::string to_string(const DimensionRoundingType &rounding_type)
3123{
3124 std::stringstream str;
3125 str << rounding_type;
3126 return str.str();
3127}
3128
3129/** Formatted output of the Padding3D type.
3130 *
3131 * @param[out] os Output stream.
3132 * @param[in] padding3d Padding3D to output.
3133 *
3134 * @return Modified output stream.
3135 */
3136inline ::std::ostream &operator<<(::std::ostream &os, const Padding3D &padding3d)
3137{
3138 os << padding3d.left << "," << padding3d.right << ","
3139 << padding3d.top << "," << padding3d.bottom << ","
3140 << padding3d.front << "," << padding3d.back;
3141 return os;
3142}
3143
3144/** Converts a @ref Padding3D to string
3145 *
3146 * @param[in] padding3d Padding3D value to be converted
3147 *
3148 * @return String representing the corresponding Padding3D
3149 */
3150inline std::string to_string(const Padding3D &padding3d)
3151{
3152 std::stringstream str;
3153 str << padding3d;
3154 return str.str();
3155}
3156
3157/** Formatted output of the Conv3dInfo type.
3158 *
3159 * @param[out] os Output stream.
3160 * @param[in] conv3d_info Type to output.
3161 *
3162 * @return Modified output stream.
3163 */
3164inline ::std::ostream &operator<<(::std::ostream &os, const Conv3dInfo &conv3d_info)
3165{
3166 os << conv3d_info.stride;
3167 os << ";";
3168 os << conv3d_info.padding;
3169 os << ";";
3170 os << to_string(conv3d_info.act_info);
3171 os << ";";
3172 os << conv3d_info.dilation;
3173 os << ";";
3174 os << conv3d_info.round_type;
3175 os << ";";
3176 os << conv3d_info.enable_fast_math;
3177
3178 return os;
3179}
3180
3181/** Formatted output of the Conv3dInfo type.
3182 *
3183 * @param[in] conv3d_info Type to output.
3184 *
3185 * @return Formatted string.
3186 */
3187inline std::string to_string(const Conv3dInfo &conv3d_info)
3188{
3189 std::stringstream str;
3190 str << conv3d_info;
3191 return str.str();
3192}
3193
Anthony Barbier6ff3b192017-09-04 18:44:23 +01003194} // namespace arm_compute
Anthony Barbier4dbc0a92018-08-27 13:39:47 +01003195
3196#endif /* __ARM_COMPUTE_TYPE_PRINTER_H__ */