blob: 5fa92e6360baa3db09945ec1f82b498946618762 [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"
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +010039#include "arm_compute/runtime/CL/CLTunerTypes.h"
SiCong Lidb4a6c12021-02-05 09:30:57 +000040#include "arm_compute/runtime/CL/CLTypes.h"
ramelg013ae3d882021-09-12 23:07:47 +010041#include "arm_compute/runtime/FunctionDescriptors.h"
ramelg01cbbb0382021-09-17 17:36:57 +010042#include "arm_compute/runtime/common/LSTMParams.h"
Matthew Bentham758b5ba2020-03-05 23:37:48 +000043#include "support/StringSupport.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010044
45#include <ostream>
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010046#include <sstream>
47#include <string>
Anthony Barbier6ff3b192017-09-04 18:44:23 +010048
49namespace arm_compute
50{
Anthony Barbierb940fd62018-06-04 14:14:32 +010051/** Formatted output if arg is not null
52 *
53 * @param[in] arg Object to print
54 *
55 * @return String representing arg.
56 */
57template <typename T>
58std::string to_string_if_not_null(T *arg)
59{
60 if(arg == nullptr)
61 {
62 return "nullptr";
63 }
64 else
65 {
66 return to_string(*arg);
67 }
68}
Anthony Barbierb4670212018-05-18 16:55:39 +010069
ramelg014a6d9e82021-10-02 14:34:36 +010070/** Fallback method: try to use std::to_string:
71 *
72 * @param[in] val Value to convert to string
73 *
74 * @return String representing val.
75 */
76template <typename T>
77inline std::string to_string(const T &val)
78{
79 return support::cpp11::to_string(val);
80}
81
ramelg01b1ba1e32021-09-25 11:53:26 +010082/** Formatted output of a vector of objects.
83 *
ramelg014a6d9e82021-10-02 14:34:36 +010084 * @note: Using the overloaded to_string() instead of overloaded operator<<(), because to_string() functions are
85 * overloaded for all types, where two or more of them can use the same operator<<(), ITensor is an example.
86 *
ramelg01b1ba1e32021-09-25 11:53:26 +010087 * @param[out] os Output stream
88 * @param[in] args Vector of objects to print
89 *
90 * @return Modified output stream.
91 */
92template <typename T>
ramelg014a6d9e82021-10-02 14:34:36 +010093::std::ostream &operator<<(::std::ostream &os, const std::vector<T> &args)
ramelg01b1ba1e32021-09-25 11:53:26 +010094{
95 const size_t max_print_size = 5U;
96
97 os << "[";
98 bool first = true;
99 size_t i;
100 for(i = 0; i < args.size(); ++i)
101 {
102 if(i == max_print_size)
103 {
104 break;
105 }
106 if(first)
107 {
108 first = false;
109 }
110 else
111 {
112 os << ", ";
113 }
ramelg014a6d9e82021-10-02 14:34:36 +0100114 os << to_string(args[i]);
ramelg01b1ba1e32021-09-25 11:53:26 +0100115 }
116 if(i < args.size())
117 {
118 os << ", ...";
119 }
120 os << "]";
121 return os;
122}
123
ramelg014a6d9e82021-10-02 14:34:36 +0100124/** Formatted output of a vector of objects.
125 *
126 * @param[in] args Vector of objects to print
127 *
128 * @return String representing args.
129 */
130template <typename T>
131std::string to_string(const std::vector<T> &args)
132{
133 std::stringstream str;
134 str << args;
135 return str.str();
136}
137
Alex Gildayc357c472018-03-21 13:54:09 +0000138/** Formatted output of the Dimensions type.
139 *
140 * @param[out] os Output stream.
141 * @param[in] dimensions Type to output.
142 *
143 * @return Modified output stream.
144 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100145template <typename T>
146inline ::std::ostream &operator<<(::std::ostream &os, const Dimensions<T> &dimensions)
147{
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100148 if(dimensions.num_dimensions() > 0)
149 {
150 os << dimensions[0];
151
152 for(unsigned int d = 1; d < dimensions.num_dimensions(); ++d)
153 {
Freddie Liardetdd23f2a2021-06-17 13:30:11 +0100154 os << "," << dimensions[d];
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100155 }
156 }
157
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100158 return os;
159}
160
Alex Gildayc357c472018-03-21 13:54:09 +0000161/** Formatted output of the RoundingPolicy type.
162 *
163 * @param[out] os Output stream.
164 * @param[in] rounding_policy Type to output.
165 *
166 * @return Modified output stream.
167 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100168inline ::std::ostream &operator<<(::std::ostream &os, const RoundingPolicy &rounding_policy)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100169{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100170 switch(rounding_policy)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100171 {
Anthony Barbier2a07e182017-08-04 18:20:27 +0100172 case RoundingPolicy::TO_ZERO:
173 os << "TO_ZERO";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100174 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100175 case RoundingPolicy::TO_NEAREST_UP:
176 os << "TO_NEAREST_UP";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100177 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100178 case RoundingPolicy::TO_NEAREST_EVEN:
179 os << "TO_NEAREST_EVEN";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100180 break;
181 default:
182 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
183 }
184
185 return os;
186}
187
Alex Gildayc357c472018-03-21 13:54:09 +0000188/** Formatted output of the WeightsInfo type.
189 *
190 * @param[out] os Output stream.
191 * @param[in] weights_info Type to output.
192 *
193 * @return Modified output stream.
194 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100195inline ::std::ostream &operator<<(::std::ostream &os, const WeightsInfo &weights_info)
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100196{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100197 os << weights_info.are_reshaped() << ";";
198 os << weights_info.num_kernels() << ";" << weights_info.kernel_size().first << "," << weights_info.kernel_size().second;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100199
200 return os;
201}
202
Alex Gildayc357c472018-03-21 13:54:09 +0000203/** Formatted output of the ROIPoolingInfo type.
204 *
205 * @param[out] os Output stream.
206 * @param[in] pool_info Type to output.
207 *
208 * @return Modified output stream.
209 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100210inline ::std::ostream &operator<<(::std::ostream &os, const ROIPoolingLayerInfo &pool_info)
Sanghoon Lee70f82912017-08-24 14:21:24 +0100211{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100212 os << pool_info.pooled_width() << "x" << pool_info.pooled_height() << "~" << pool_info.spatial_scale();
Georgios Pinitasd9769582017-08-03 10:19:40 +0100213 return os;
214}
215
giuros0118870812018-09-13 09:31:40 +0100216/** Formatted output of the ROIPoolingInfo type.
217 *
218 * @param[in] pool_info Type to output.
219 *
220 * @return Formatted string.
221 */
222inline std::string to_string(const ROIPoolingLayerInfo &pool_info)
223{
224 std::stringstream str;
225 str << pool_info;
226 return str.str();
227}
228
morgolockaba2f912020-05-05 16:28:19 +0100229/** Formatted output of the GEMMKernelInfo type.
230 *
231 * @param[out] os Output stream.
232 * @param[in] gemm_info Type to output.
233 *
234 * @return Modified output stream.
235 */
236inline ::std::ostream &operator<<(::std::ostream &os, const GEMMKernelInfo &gemm_info)
237{
238 os << "( m= " << gemm_info.m;
239 os << " n= " << gemm_info.n;
240 os << " k= " << gemm_info.k;
241 os << " depth_output_gemm3d= " << gemm_info.depth_output_gemm3d;
242 os << " reinterpret_input_as_3d= " << gemm_info.reinterpret_input_as_3d;
243 os << " broadcast_bias= " << gemm_info.broadcast_bias;
244 os << " fp_mixed_precision= " << gemm_info.fp_mixed_precision;
245 os << " mult_transpose1xW_width= " << gemm_info.mult_transpose1xW_width;
246 os << " mult_interleave4x4_height= " << gemm_info.mult_interleave4x4_height;
247 os << " a_offset = " << gemm_info.a_offset;
248 os << " b_offset = " << gemm_info.b_offset;
249 os << ")";
250 return os;
251}
252
253/** Formatted output of the GEMMLHSMatrixInfo type.
254 *
255 * @param[out] os Output stream.
256 * @param[in] gemm_info Type to output.
257 *
258 * @return Modified output stream.
259 */
260inline ::std::ostream &operator<<(::std::ostream &os, const GEMMLHSMatrixInfo &gemm_info)
261{
262 os << "( m0= " << (unsigned int)gemm_info.m0 << " k0= " << gemm_info.k0 << " v0= " << gemm_info.v0 << " trans= " << gemm_info.transpose << " inter= " << gemm_info.interleave << "})";
263 return os;
264}
265
266/** Formatted output of the GEMMRHSMatrixInfo type.
267 *
268 * @param[out] os Output stream.
269 * @param[in] gemm_info Type to output.
270 *
271 * @return Modified output stream.
272 */
273inline ::std::ostream &operator<<(::std::ostream &os, const GEMMRHSMatrixInfo &gemm_info)
274{
SiCong Lidb4a6c12021-02-05 09:30:57 +0000275 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=" <<
276 gemm_info.export_to_cl_image << "})";
morgolockaba2f912020-05-05 16:28:19 +0100277 return os;
278}
279
280/** Formatted output of the GEMMRHSMatrixInfo type.
281 *
282 * @param[in] gemm_info GEMMRHSMatrixInfo to output.
283 *
284 * @return Formatted string.
285 */
286inline std::string to_string(const GEMMRHSMatrixInfo &gemm_info)
287{
288 std::stringstream str;
289 str << gemm_info;
290 return str.str();
291}
292
293/** Formatted output of the GEMMLHSMatrixInfo type.
294 *
295 * @param[in] gemm_info GEMMLHSMatrixInfo to output.
296 *
297 * @return Formatted string.
298 */
299inline std::string to_string(const GEMMLHSMatrixInfo &gemm_info)
300{
301 std::stringstream str;
302 str << gemm_info;
303 return str.str();
304}
305
306/** Formatted output of the GEMMKernelInfo type.
307 *
308 * @param[in] gemm_info GEMMKernelInfo Type to output.
309 *
310 * @return Formatted string.
311 */
312inline std::string to_string(const GEMMKernelInfo &gemm_info)
313{
314 std::stringstream str;
315 str << gemm_info;
316 return str.str();
317}
318
giuros01c04a0e82018-10-03 12:44:35 +0100319/** Formatted output of the BoundingBoxTransformInfo type.
320 *
321 * @param[out] os Output stream.
322 * @param[in] bbox_info Type to output.
323 *
324 * @return Modified output stream.
325 */
326inline ::std::ostream &operator<<(::std::ostream &os, const BoundingBoxTransformInfo &bbox_info)
327{
328 auto weights = bbox_info.weights();
329 os << "(" << bbox_info.img_width() << "x" << bbox_info.img_height() << ")~" << bbox_info.scale() << "(weights = {" << weights[0] << ", " << weights[1] << ", " << weights[2] << ", " << weights[3] <<
330 "})";
331 return os;
332}
333
334/** Formatted output of the BoundingBoxTransformInfo type.
335 *
336 * @param[in] bbox_info Type to output.
337 *
338 * @return Formatted string.
339 */
340inline std::string to_string(const BoundingBoxTransformInfo &bbox_info)
341{
342 std::stringstream str;
343 str << bbox_info;
344 return str.str();
345}
346
Manuel Bottini5209be52019-02-13 16:34:56 +0000347/** Formatted output of the ComputeAnchorsInfo type.
348 *
349 * @param[out] os Output stream.
350 * @param[in] anchors_info Type to output.
351 *
352 * @return Modified output stream.
353 */
354inline ::std::ostream &operator<<(::std::ostream &os, const ComputeAnchorsInfo &anchors_info)
355{
356 os << "(" << anchors_info.feat_width() << "x" << anchors_info.feat_height() << ")~" << anchors_info.spatial_scale();
357 return os;
358}
359
360/** Formatted output of the ComputeAnchorsInfo type.
361 *
362 * @param[in] anchors_info Type to output.
363 *
364 * @return Formatted string.
365 */
366inline std::string to_string(const ComputeAnchorsInfo &anchors_info)
367{
368 std::stringstream str;
369 str << anchors_info;
370 return str.str();
371}
372
373/** Formatted output of the GenerateProposalsInfo type.
374 *
375 * @param[out] os Output stream.
376 * @param[in] proposals_info Type to output.
377 *
378 * @return Modified output stream.
379 */
380inline ::std::ostream &operator<<(::std::ostream &os, const GenerateProposalsInfo &proposals_info)
381{
382 os << "(" << proposals_info.im_width() << "x" << proposals_info.im_height() << ")~" << proposals_info.im_scale();
383 return os;
384}
385
386/** Formatted output of the GenerateProposalsInfo type.
387 *
388 * @param[in] proposals_info Type to output.
389 *
390 * @return Formatted string.
391 */
392inline std::string to_string(const GenerateProposalsInfo &proposals_info)
393{
394 std::stringstream str;
395 str << proposals_info;
396 return str.str();
397}
398
Alex Gildayc357c472018-03-21 13:54:09 +0000399/** Formatted output of the QuantizationInfo type.
400 *
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100401 * @param[out] os Output stream.
402 * @param[in] qinfo Type to output.
Alex Gildayc357c472018-03-21 13:54:09 +0000403 *
404 * @return Modified output stream.
405 */
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100406inline ::std::ostream &operator<<(::std::ostream &os, const QuantizationInfo &qinfo)
Chunosovd621bca2017-11-03 17:33:15 +0700407{
Georgios Pinitas3d13af82019-06-04 13:04:16 +0100408 const UniformQuantizationInfo uqinfo = qinfo.uniform();
409 os << "Scale:" << uqinfo.scale << "~";
410 os << "Offset:" << uqinfo.offset;
Chunosovd621bca2017-11-03 17:33:15 +0700411 return os;
412}
413
Alex Gildayc357c472018-03-21 13:54:09 +0000414/** Formatted output of the QuantizationInfo type.
415 *
416 * @param[in] quantization_info Type to output.
417 *
418 * @return Formatted string.
419 */
Chunosovd621bca2017-11-03 17:33:15 +0700420inline std::string to_string(const QuantizationInfo &quantization_info)
421{
422 std::stringstream str;
423 str << quantization_info;
424 return str.str();
425}
426
Alex Gildayc357c472018-03-21 13:54:09 +0000427/** Formatted output of the activation function type.
428 *
429 * @param[out] os Output stream.
430 * @param[in] act_function Type to output.
431 *
432 * @return Modified output stream.
433 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100434inline ::std::ostream &operator<<(::std::ostream &os, const ActivationLayerInfo::ActivationFunction &act_function)
435{
436 switch(act_function)
437 {
438 case ActivationLayerInfo::ActivationFunction::ABS:
439 os << "ABS";
440 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100441 case ActivationLayerInfo::ActivationFunction::LINEAR:
442 os << "LINEAR";
443 break;
444 case ActivationLayerInfo::ActivationFunction::LOGISTIC:
445 os << "LOGISTIC";
446 break;
447 case ActivationLayerInfo::ActivationFunction::RELU:
448 os << "RELU";
449 break;
Georgios Pinitas579c0492017-07-12 16:12:12 +0100450 case ActivationLayerInfo::ActivationFunction::BOUNDED_RELU:
451 os << "BOUNDED_RELU";
452 break;
453 case ActivationLayerInfo::ActivationFunction::LEAKY_RELU:
454 os << "LEAKY_RELU";
455 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100456 case ActivationLayerInfo::ActivationFunction::SOFT_RELU:
457 os << "SOFT_RELU";
458 break;
459 case ActivationLayerInfo::ActivationFunction::SQRT:
460 os << "SQRT";
461 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100462 case ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU:
463 os << "LU_BOUNDED_RELU";
Kevin Petitd9f80712017-12-06 12:18:48 +0000464 break;
Georgios Pinitasfb0fdcd2019-08-22 17:10:04 +0100465 case ActivationLayerInfo::ActivationFunction::ELU:
466 os << "ELU";
467 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100468 case ActivationLayerInfo::ActivationFunction::SQUARE:
469 os << "SQUARE";
470 break;
471 case ActivationLayerInfo::ActivationFunction::TANH:
472 os << "TANH";
473 break;
Usama Arif6a98a6e2019-05-10 17:07:27 +0100474 case ActivationLayerInfo::ActivationFunction::IDENTITY:
475 os << "IDENTITY";
476 break;
morgolock07df3d42020-02-27 11:46:28 +0000477 case ActivationLayerInfo::ActivationFunction::HARD_SWISH:
478 os << "HARD_SWISH";
479 break;
480
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100481 default:
482 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
483 }
484
485 return os;
486}
487
Alex Gildayc357c472018-03-21 13:54:09 +0000488/** Formatted output of the activation function info type.
489 *
490 * @param[in] info Type to output.
491 *
492 * @return Formatted string.
493 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100494inline std::string to_string(const arm_compute::ActivationLayerInfo &info)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100495{
496 std::stringstream str;
Isabella Gottardi3f217ec2018-02-12 14:59:19 +0000497 if(info.enabled())
498 {
499 str << info.activation();
500 }
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100501 return str.str();
502}
503
ramelg013ae3d882021-09-12 23:07:47 +0100504/** Formatted output of the activation function info type.
505 *
506 * @param[in] info Type to output.
507 *
508 * @return Formatted string.
509 */
510inline std::string to_string(const arm_compute::ActivationLayerInfo *info)
511{
512 std::string ret_str = "nullptr";
513 if(info != nullptr)
514 {
515 std::stringstream str;
516 if(info->enabled())
517 {
518 str << info->activation();
519 }
520 ret_str = str.str();
521 }
522 return ret_str;
523}
524
Alex Gildayc357c472018-03-21 13:54:09 +0000525/** Formatted output of the activation function type.
526 *
527 * @param[in] function Type to output.
528 *
529 * @return Formatted string.
530 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100531inline std::string to_string(const arm_compute::ActivationLayerInfo::ActivationFunction &function)
532{
533 std::stringstream str;
534 str << function;
535 return str.str();
536}
537
Alex Gildayc357c472018-03-21 13:54:09 +0000538/** Formatted output of the NormType type.
539 *
540 * @param[out] os Output stream.
541 * @param[in] norm_type Type to output.
542 *
543 * @return Modified output stream.
544 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100545inline ::std::ostream &operator<<(::std::ostream &os, const NormType &norm_type)
546{
547 switch(norm_type)
548 {
549 case NormType::CROSS_MAP:
550 os << "CROSS_MAP";
551 break;
552 case NormType::IN_MAP_1D:
553 os << "IN_MAP_1D";
554 break;
555 case NormType::IN_MAP_2D:
556 os << "IN_MAP_2D";
557 break;
558 default:
559 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
560 }
561
562 return os;
563}
564
Alex Gildayc357c472018-03-21 13:54:09 +0000565/** Formatted output of @ref NormalizationLayerInfo.
566 *
567 * @param[in] info Type to output.
568 *
569 * @return Formatted string.
570 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100571inline std::string to_string(const arm_compute::NormalizationLayerInfo &info)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100572{
573 std::stringstream str;
Michalis Spyroud466c2d2018-01-30 10:54:39 +0000574 str << info.type() << ":NormSize=" << info.norm_size();
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100575 return str.str();
576}
577
Alex Gildayc357c472018-03-21 13:54:09 +0000578/** Formatted output of @ref NormalizationLayerInfo.
579 *
580 * @param[out] os Output stream.
581 * @param[in] info Type to output.
582 *
583 * @return Modified output stream.
584 */
Georgios Pinitas6f669f02017-09-26 12:32:57 +0100585inline ::std::ostream &operator<<(::std::ostream &os, const NormalizationLayerInfo &info)
586{
Michalis Spyroud466c2d2018-01-30 10:54:39 +0000587 os << info.type() << ":NormSize=" << info.norm_size();
Georgios Pinitas6f669f02017-09-26 12:32:57 +0100588 return os;
589}
590
Alex Gildayc357c472018-03-21 13:54:09 +0000591/** Formatted output of the PoolingType type.
592 *
593 * @param[out] os Output stream.
594 * @param[in] pool_type Type to output.
595 *
596 * @return Modified output stream.
597 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100598inline ::std::ostream &operator<<(::std::ostream &os, const PoolingType &pool_type)
599{
600 switch(pool_type)
601 {
602 case PoolingType::AVG:
603 os << "AVG";
604 break;
605 case PoolingType::MAX:
606 os << "MAX";
607 break;
Georgios Pinitascdf51452017-08-31 14:21:36 +0100608 case PoolingType::L2:
609 os << "L2";
610 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100611 default:
612 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
613 }
614
615 return os;
616}
617
Alex Gildayc357c472018-03-21 13:54:09 +0000618/** Formatted output of @ref PoolingLayerInfo.
619 *
620 * @param[out] os Output stream.
621 * @param[in] info Type to output.
622 *
623 * @return Modified output stream.
624 */
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100625inline ::std::ostream &operator<<(::std::ostream &os, const PoolingLayerInfo &info)
626{
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +0000627 os << info.pool_type;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100628
629 return os;
630}
631
Alex Gildayc357c472018-03-21 13:54:09 +0000632/** Formatted output of @ref RoundingPolicy.
633 *
634 * @param[in] rounding_policy Type to output.
635 *
636 * @return Formatted string.
637 */
John Richardsondd715f22017-09-18 16:10:48 +0100638inline std::string to_string(const RoundingPolicy &rounding_policy)
639{
640 std::stringstream str;
641 str << rounding_policy;
642 return str.str();
643}
644
Vidhya Sudhan Loganathand646ae12018-11-19 15:18:20 +0000645/** [Print DataLayout type] **/
Alex Gildayc357c472018-03-21 13:54:09 +0000646/** Formatted output of the DataLayout type.
647 *
648 * @param[out] os Output stream.
649 * @param[in] data_layout Type to output.
650 *
651 * @return Modified output stream.
652 */
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000653inline ::std::ostream &operator<<(::std::ostream &os, const DataLayout &data_layout)
654{
655 switch(data_layout)
656 {
657 case DataLayout::UNKNOWN:
658 os << "UNKNOWN";
659 break;
660 case DataLayout::NHWC:
661 os << "NHWC";
662 break;
663 case DataLayout::NCHW:
664 os << "NCHW";
665 break;
Adnan AlSinane4563a02021-09-01 15:32:03 +0100666 case DataLayout::NDHWC:
667 os << "NDHWC";
668 break;
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000669 default:
670 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
671 }
672
673 return os;
674}
675
Alex Gildayc357c472018-03-21 13:54:09 +0000676/** Formatted output of the DataLayout type.
677 *
678 * @param[in] data_layout Type to output.
679 *
680 * @return Formatted string.
681 */
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000682inline std::string to_string(const arm_compute::DataLayout &data_layout)
683{
684 std::stringstream str;
685 str << data_layout;
686 return str.str();
687}
Vidhya Sudhan Loganathand646ae12018-11-19 15:18:20 +0000688/** [Print DataLayout type] **/
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000689
Georgios Pinitase2220552018-07-20 13:23:44 +0100690/** Formatted output of the DataLayoutDimension type.
691 *
692 * @param[out] os Output stream.
693 * @param[in] data_layout_dim Data layout dimension to print.
694 *
695 * @return Modified output stream.
696 */
697inline ::std::ostream &operator<<(::std::ostream &os, const DataLayoutDimension &data_layout_dim)
698{
699 switch(data_layout_dim)
700 {
701 case DataLayoutDimension::WIDTH:
702 os << "WIDTH";
703 break;
704 case DataLayoutDimension::HEIGHT:
705 os << "HEIGHT";
706 break;
707 case DataLayoutDimension::CHANNEL:
708 os << "CHANNEL";
709 break;
710 case DataLayoutDimension::BATCHES:
711 os << "BATCHES";
712 break;
713 default:
714 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
715 }
716 return os;
717}
718
Alex Gildayc357c472018-03-21 13:54:09 +0000719/** Formatted output of the DataType type.
720 *
721 * @param[out] os Output stream.
722 * @param[in] data_type Type to output.
723 *
724 * @return Modified output stream.
725 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100726inline ::std::ostream &operator<<(::std::ostream &os, const DataType &data_type)
727{
728 switch(data_type)
729 {
730 case DataType::UNKNOWN:
731 os << "UNKNOWN";
732 break;
733 case DataType::U8:
734 os << "U8";
735 break;
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100736 case DataType::QSYMM8:
737 os << "QSYMM8";
738 break;
Chunosovd621bca2017-11-03 17:33:15 +0700739 case DataType::QASYMM8:
740 os << "QASYMM8";
741 break;
Georgios Pinitas448a81f2019-11-21 14:10:25 +0000742 case DataType::QASYMM8_SIGNED:
743 os << "QASYMM8_SIGNED";
744 break;
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100745 case DataType::QSYMM8_PER_CHANNEL:
746 os << "QSYMM8_PER_CHANNEL";
747 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100748 case DataType::S8:
749 os << "S8";
750 break;
751 case DataType::U16:
752 os << "U16";
753 break;
754 case DataType::S16:
755 os << "S16";
756 break;
Manuel Bottini3689fcd2019-06-14 17:18:12 +0100757 case DataType::QSYMM16:
758 os << "QSYMM16";
759 break;
Michele Di Giorgio35ea9a72019-08-23 12:02:06 +0100760 case DataType::QASYMM16:
761 os << "QASYMM16";
762 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100763 case DataType::U32:
764 os << "U32";
765 break;
766 case DataType::S32:
767 os << "S32";
768 break;
769 case DataType::U64:
770 os << "U64";
771 break;
772 case DataType::S64:
773 os << "S64";
774 break;
Georgios Pinitase8291ac2020-02-26 09:58:13 +0000775 case DataType::BFLOAT16:
776 os << "BFLOAT16";
777 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100778 case DataType::F16:
779 os << "F16";
780 break;
781 case DataType::F32:
782 os << "F32";
783 break;
784 case DataType::F64:
785 os << "F64";
786 break;
787 case DataType::SIZET:
788 os << "SIZET";
789 break;
790 default:
791 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
792 }
793
794 return os;
795}
796
Alex Gildayc357c472018-03-21 13:54:09 +0000797/** Formatted output of the DataType type.
798 *
799 * @param[in] data_type Type to output.
800 *
801 * @return Formatted string.
802 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100803inline std::string to_string(const arm_compute::DataType &data_type)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100804{
805 std::stringstream str;
806 str << data_type;
807 return str.str();
808}
809
Alex Gildayc357c472018-03-21 13:54:09 +0000810/** Formatted output of the Format type.
811 *
812 * @param[out] os Output stream.
813 * @param[in] format Type to output.
814 *
815 * @return Modified output stream.
816 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100817inline ::std::ostream &operator<<(::std::ostream &os, const Format &format)
818{
819 switch(format)
820 {
821 case Format::UNKNOWN:
822 os << "UNKNOWN";
823 break;
824 case Format::U8:
825 os << "U8";
826 break;
827 case Format::S16:
828 os << "S16";
829 break;
830 case Format::U16:
831 os << "U16";
832 break;
833 case Format::S32:
834 os << "S32";
835 break;
836 case Format::U32:
837 os << "U32";
838 break;
839 case Format::F16:
840 os << "F16";
841 break;
842 case Format::F32:
843 os << "F32";
844 break;
845 case Format::UV88:
846 os << "UV88";
847 break;
848 case Format::RGB888:
849 os << "RGB888";
850 break;
851 case Format::RGBA8888:
852 os << "RGBA8888";
853 break;
854 case Format::YUV444:
855 os << "YUV444";
856 break;
857 case Format::YUYV422:
858 os << "YUYV422";
859 break;
860 case Format::NV12:
861 os << "NV12";
862 break;
863 case Format::NV21:
864 os << "NV21";
865 break;
866 case Format::IYUV:
867 os << "IYUV";
868 break;
869 case Format::UYVY422:
870 os << "UYVY422";
871 break;
872 default:
873 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
874 }
875
876 return os;
877}
878
Alex Gildayc357c472018-03-21 13:54:09 +0000879/** Formatted output of the Format type.
880 *
881 * @param[in] format Type to output.
882 *
883 * @return Formatted string.
884 */
Moritz Pflanzer7655a672017-09-23 11:57:33 +0100885inline std::string to_string(const Format &format)
886{
887 std::stringstream str;
888 str << format;
889 return str.str();
890}
891
Alex Gildayc357c472018-03-21 13:54:09 +0000892/** Formatted output of the Channel type.
893 *
894 * @param[out] os Output stream.
895 * @param[in] channel Type to output.
896 *
897 * @return Modified output stream.
898 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100899inline ::std::ostream &operator<<(::std::ostream &os, const Channel &channel)
900{
901 switch(channel)
902 {
903 case Channel::UNKNOWN:
904 os << "UNKNOWN";
905 break;
906 case Channel::C0:
907 os << "C0";
908 break;
909 case Channel::C1:
910 os << "C1";
911 break;
912 case Channel::C2:
913 os << "C2";
914 break;
915 case Channel::C3:
916 os << "C3";
917 break;
918 case Channel::R:
919 os << "R";
920 break;
921 case Channel::G:
922 os << "G";
923 break;
924 case Channel::B:
925 os << "B";
926 break;
927 case Channel::A:
928 os << "A";
929 break;
930 case Channel::Y:
931 os << "Y";
932 break;
933 case Channel::U:
934 os << "U";
935 break;
936 case Channel::V:
937 os << "V";
938 break;
939 default:
940 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
941 }
942
943 return os;
944}
945
Alex Gildayc357c472018-03-21 13:54:09 +0000946/** Formatted output of the Channel type.
947 *
948 * @param[in] channel Type to output.
949 *
950 * @return Formatted string.
951 */
Ioan-Cristian Szabo9414f642017-10-27 17:35:40 +0100952inline std::string to_string(const Channel &channel)
953{
954 std::stringstream str;
955 str << channel;
956 return str.str();
957}
958
Alex Gildayc357c472018-03-21 13:54:09 +0000959/** Formatted output of the BorderMode type.
960 *
961 * @param[out] os Output stream.
962 * @param[in] mode Type to output.
963 *
964 * @return Modified output stream.
965 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100966inline ::std::ostream &operator<<(::std::ostream &os, const BorderMode &mode)
967{
968 switch(mode)
969 {
970 case BorderMode::UNDEFINED:
971 os << "UNDEFINED";
972 break;
973 case BorderMode::CONSTANT:
974 os << "CONSTANT";
975 break;
976 case BorderMode::REPLICATE:
977 os << "REPLICATE";
978 break;
979 default:
980 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
981 }
982
983 return os;
984}
985
Alex Gildayc357c472018-03-21 13:54:09 +0000986/** Formatted output of the BorderSize type.
987 *
988 * @param[out] os Output stream.
989 * @param[in] border Type to output.
990 *
991 * @return Modified output stream.
992 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100993inline ::std::ostream &operator<<(::std::ostream &os, const BorderSize &border)
994{
Moritz Pflanzerc87fbf82017-07-18 14:02:10 +0100995 os << border.top << ","
996 << border.right << ","
997 << border.bottom << ","
998 << border.left;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100999
1000 return os;
1001}
Anthony Barbier2a07e182017-08-04 18:20:27 +01001002
Giuseppe Rossinid7647d42018-07-17 18:13:13 +01001003/** Formatted output of the PaddingList type.
1004 *
1005 * @param[out] os Output stream.
1006 * @param[in] padding Type to output.
1007 *
1008 * @return Modified output stream.
1009 */
1010inline ::std::ostream &operator<<(::std::ostream &os, const PaddingList &padding)
1011{
1012 os << "{";
1013 for(auto const &p : padding)
1014 {
1015 os << "{" << p.first << "," << p.second << "}";
1016 }
1017 os << "}";
1018 return os;
1019}
1020
giuros013175fcf2018-11-21 09:59:17 +00001021/** Formatted output of the Multiples type.
1022 *
1023 * @param[out] os Output stream.
1024 * @param[in] multiples Type to output.
1025 *
1026 * @return Modified output stream.
1027 */
1028inline ::std::ostream &operator<<(::std::ostream &os, const Multiples &multiples)
1029{
1030 os << "(";
1031 for(size_t i = 0; i < multiples.size() - 1; i++)
1032 {
1033 os << multiples[i] << ", ";
1034 }
1035 os << multiples.back() << ")";
1036 return os;
1037}
1038
Alex Gildayc357c472018-03-21 13:54:09 +00001039/** Formatted output of the InterpolationPolicy type.
1040 *
1041 * @param[out] os Output stream.
1042 * @param[in] policy Type to output.
1043 *
1044 * @return Modified output stream.
1045 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001046inline ::std::ostream &operator<<(::std::ostream &os, const InterpolationPolicy &policy)
1047{
1048 switch(policy)
1049 {
1050 case InterpolationPolicy::NEAREST_NEIGHBOR:
1051 os << "NEAREST_NEIGHBOR";
1052 break;
1053 case InterpolationPolicy::BILINEAR:
1054 os << "BILINEAR";
1055 break;
1056 case InterpolationPolicy::AREA:
1057 os << "AREA";
1058 break;
1059 default:
1060 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1061 }
1062
1063 return os;
1064}
1065
Alex Gildayc357c472018-03-21 13:54:09 +00001066/** Formatted output of the SamplingPolicy type.
1067 *
1068 * @param[out] os Output stream.
1069 * @param[in] policy Type to output.
1070 *
1071 * @return Modified output stream.
1072 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +07001073inline ::std::ostream &operator<<(::std::ostream &os, const SamplingPolicy &policy)
1074{
1075 switch(policy)
1076 {
1077 case SamplingPolicy::CENTER:
1078 os << "CENTER";
1079 break;
1080 case SamplingPolicy::TOP_LEFT:
1081 os << "TOP_LEFT";
1082 break;
1083 default:
1084 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1085 }
1086
1087 return os;
1088}
1089
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001090/** Formatted output of the ITensorInfo type.
1091 *
1092 * @param[out] os Output stream.
1093 * @param[in] info Tensor information.
1094 *
1095 * @return Modified output stream.
1096 */
1097inline ::std::ostream &operator<<(std::ostream &os, const ITensorInfo *info)
1098{
Georgios Pinitasc6f95102021-03-30 10:03:01 +01001099 const DataType data_type = info->data_type();
1100 const DataLayout data_layout = info->data_layout();
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001101
1102 os << "Shape=" << info->tensor_shape() << ","
1103 << "DataLayout=" << string_from_data_layout(data_layout) << ","
ramelg014a6d9e82021-10-02 14:34:36 +01001104 << "DataType=" << string_from_data_type(data_type);
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001105
1106 if(is_data_type_quantized(data_type))
1107 {
ramelg01b1ba1e32021-09-25 11:53:26 +01001108 const QuantizationInfo qinfo = info->quantization_info();
1109 const auto scales = qinfo.scale();
1110 const auto offsets = qinfo.offset();
1111
ramelg014a6d9e82021-10-02 14:34:36 +01001112 os << ", QuantizationInfo={"
ramelg01b1ba1e32021-09-25 11:53:26 +01001113 << "scales.size=" << scales.size()
1114 << ", scale(s)=" << scales << ", ";
1115
1116 os << "offsets.size=" << offsets.size()
1117 << ", offset(s)=" << offsets << "}";
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001118 }
1119 return os;
1120}
1121
ramelg013ae3d882021-09-12 23:07:47 +01001122/** Formatted output of the const TensorInfo& type.
Alex Gildayc357c472018-03-21 13:54:09 +00001123 *
Anthony Barbier366628a2018-08-01 13:55:03 +01001124 * @param[out] os Output stream.
1125 * @param[in] info Type to output.
1126 *
1127 * @return Modified output stream.
1128 */
1129inline ::std::ostream &operator<<(::std::ostream &os, const TensorInfo &info)
1130{
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001131 os << &info;
Georgios Pinitasc6f95102021-03-30 10:03:01 +01001132 return os;
Anthony Barbier366628a2018-08-01 13:55:03 +01001133}
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001134
ramelg013ae3d882021-09-12 23:07:47 +01001135/** Formatted output of the const TensorInfo& type.
Anthony Barbier366628a2018-08-01 13:55:03 +01001136 *
Alex Gildayc357c472018-03-21 13:54:09 +00001137 * @param[in] info Type to output.
1138 *
1139 * @return Formatted string.
1140 */
Georgios Pinitas3faea252017-10-30 14:13:50 +00001141inline std::string to_string(const TensorInfo &info)
1142{
1143 std::stringstream str;
Michele Di Giorgioc22eb1b2021-02-01 10:39:06 +00001144 str << &info;
Georgios Pinitas3faea252017-10-30 14:13:50 +00001145 return str.str();
1146}
1147
ramelg013ae3d882021-09-12 23:07:47 +01001148/** Formatted output of the const ITensorInfo& type.
1149 *
1150 * @param[in] info Type to output.
1151 *
1152 * @return Formatted string.
1153 */
1154inline std::string to_string(const ITensorInfo &info)
1155{
1156 std::stringstream str;
1157 str << &info;
1158 return str.str();
1159}
1160
ramelg013ae3d882021-09-12 23:07:47 +01001161/** Formatted output of the const ITensorInfo* type.
1162 *
1163 * @param[in] info Type to output.
1164 *
1165 * @return Formatted string.
1166 */
Ramy Elgammale920d6a2021-08-19 22:10:30 +01001167inline std::string to_string(const ITensorInfo *info)
1168{
ramelg013ae3d882021-09-12 23:07:47 +01001169 std::string ret_str = "nullptr";
1170 if(info != nullptr)
1171 {
1172 std::stringstream str;
1173 str << info;
1174 ret_str = str.str();
1175 }
1176 return ret_str;
1177}
1178
ramelg01cbbb0382021-09-17 17:36:57 +01001179/** Formatted output of the ITensorInfo* type.
1180 *
1181 * @param[in] info Type to output.
1182 *
1183 * @return Formatted string.
1184 */
1185inline std::string to_string(ITensorInfo *info)
1186{
1187 return to_string(static_cast<const ITensorInfo *>(info));
1188}
1189
1190/** Formatted output of the ITensorInfo type obtained from const ITensor* type.
ramelg013ae3d882021-09-12 23:07:47 +01001191 *
1192 * @param[in] tensor Type to output.
1193 *
1194 * @return Formatted string.
1195 */
1196inline std::string to_string(const ITensor *tensor)
1197{
1198 std::string ret_str = "nullptr";
1199 if(tensor != nullptr)
1200 {
1201 std::stringstream str;
ramelg01cbbb0382021-09-17 17:36:57 +01001202 str << "ITensor->info(): " << tensor->info();
ramelg013ae3d882021-09-12 23:07:47 +01001203 ret_str = str.str();
1204 }
1205 return ret_str;
1206}
1207
ramelg01cbbb0382021-09-17 17:36:57 +01001208/** Formatted output of the ITensorInfo type obtained from the ITensor* type.
ramelg013ae3d882021-09-12 23:07:47 +01001209 *
1210 * @param[in] tensor Type to output.
1211 *
1212 * @return Formatted string.
1213 */
1214inline std::string to_string(ITensor *tensor)
1215{
ramelg01cbbb0382021-09-17 17:36:57 +01001216 return to_string(static_cast<const ITensor *>(tensor));
ramelg013ae3d882021-09-12 23:07:47 +01001217}
1218
ramelg01cbbb0382021-09-17 17:36:57 +01001219/** Formatted output of the ITensorInfo type obtained from the ITensor& type.
ramelg013ae3d882021-09-12 23:07:47 +01001220 *
1221 * @param[in] tensor Type to output.
1222 *
1223 * @return Formatted string.
1224 */
1225inline std::string to_string(ITensor &tensor)
1226{
Ramy Elgammale920d6a2021-08-19 22:10:30 +01001227 std::stringstream str;
ramelg01cbbb0382021-09-17 17:36:57 +01001228 str << "ITensor.info(): " << tensor.info();
Ramy Elgammale920d6a2021-08-19 22:10:30 +01001229 return str.str();
1230}
1231
ramelg01cbbb0382021-09-17 17:36:57 +01001232#ifdef ARM_COMPUTE_OPENCL_ENABLED
1233/** Formatted output of the ITensorInfo type obtained from the const ICLTensor& type.
1234 *
1235 * @param[in] cl_tensor Type to output.
1236 *
1237 * @return Formatted string.
1238 */
1239inline std::string to_string(const ICLTensor *cl_tensor)
1240{
1241 std::string ret_str = "nullptr";
1242 if(cl_tensor != nullptr)
1243 {
1244 std::stringstream str;
1245 str << "ICLTensor->info(): " << cl_tensor->info();
1246 ret_str = str.str();
1247 }
1248 return ret_str;
1249}
1250
1251/** Formatted output of the ITensorInfo type obtained from the ICLTensor& type.
1252 *
1253 * @param[in] cl_tensor Type to output.
1254 *
1255 * @return Formatted string.
1256 */
1257inline std::string to_string(ICLTensor *cl_tensor)
1258{
1259 return to_string(static_cast<const ICLTensor *>(cl_tensor));
1260}
1261#endif /* ARM_COMPUTE_OPENCL_ENABLED */
1262
Alex Gildayc357c472018-03-21 13:54:09 +00001263/** Formatted output of the Dimensions type.
1264 *
1265 * @param[in] dimensions Type to output.
1266 *
1267 * @return Formatted string.
1268 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001269template <typename T>
1270inline std::string to_string(const Dimensions<T> &dimensions)
1271{
1272 std::stringstream str;
1273 str << dimensions;
1274 return str.str();
1275}
1276
Alex Gildayc357c472018-03-21 13:54:09 +00001277/** Formatted output of the Strides type.
1278 *
1279 * @param[in] stride Type to output.
1280 *
1281 * @return Formatted string.
1282 */
John Richardsona36eae12017-09-26 16:55:59 +01001283inline std::string to_string(const Strides &stride)
1284{
1285 std::stringstream str;
1286 str << stride;
1287 return str.str();
1288}
1289
Alex Gildayc357c472018-03-21 13:54:09 +00001290/** Formatted output of the TensorShape type.
1291 *
1292 * @param[in] shape Type to output.
1293 *
1294 * @return Formatted string.
1295 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001296inline std::string to_string(const TensorShape &shape)
1297{
1298 std::stringstream str;
1299 str << shape;
1300 return str.str();
1301}
1302
Alex Gildayc357c472018-03-21 13:54:09 +00001303/** Formatted output of the Coordinates type.
1304 *
1305 * @param[in] coord Type to output.
1306 *
1307 * @return Formatted string.
1308 */
Abe Mbise925ca0f2017-10-02 19:16:33 +01001309inline std::string to_string(const Coordinates &coord)
1310{
1311 std::stringstream str;
1312 str << coord;
1313 return str.str();
1314}
1315
Anthony Barbierb940fd62018-06-04 14:14:32 +01001316/** Formatted output of the GEMMReshapeInfo type.
1317 *
1318 * @param[out] os Output stream.
1319 * @param[in] info Type to output.
1320 *
1321 * @return Modified output stream.
1322 */
1323inline ::std::ostream &operator<<(::std::ostream &os, const GEMMReshapeInfo &info)
1324{
1325 os << "{m=" << info.m() << ",";
1326 os << "n=" << info.n() << ",";
1327 os << "k=" << info.k() << ",";
1328 os << "mult_transpose1xW_width=" << info.mult_transpose1xW_width() << ",";
1329 os << "mult_interleave4x4_height=" << info.mult_interleave4x4_height();
1330 os << "}";
1331
1332 return os;
1333}
1334
1335/** Formatted output of the GEMMInfo type.
1336 *
1337 * @param[out] os Output stream.
1338 * @param[in] info Type to output.
1339 *
1340 * @return Modified output stream.
1341 */
1342inline ::std::ostream &operator<<(::std::ostream &os, const GEMMInfo &info)
1343{
1344 os << "{is_a_reshaped=" << info.is_a_reshaped() << ",";
1345 os << "is_b_reshaped=" << info.is_b_reshaped() << ",";
1346 os << "reshape_b_only_on_first_run=" << info.reshape_b_only_on_first_run() << ",";
Anthony Barbierb4670212018-05-18 16:55:39 +01001347 os << "depth_output_gemm3d=" << info.depth_output_gemm3d() << ",";
1348 os << "reinterpret_input_as_3d=" << info.reinterpret_input_as_3d() << ",";
1349 os << "retain_internal_weights=" << info.retain_internal_weights() << ",";
1350 os << "fp_mixed_precision=" << info.fp_mixed_precision() << ",";
1351 os << "broadcast_bias=" << info.broadcast_bias() << ",";
ramelg01cbbb0382021-09-17 17:36:57 +01001352 os << "pretranspose_B=" << info.pretranspose_B() << ",";
Anthony Barbierb940fd62018-06-04 14:14:32 +01001353
1354 return os;
1355}
1356
1357/** Formatted output of the Window::Dimension type.
1358 *
1359 * @param[out] os Output stream.
1360 * @param[in] dim Type to output.
1361 *
1362 * @return Modified output stream.
1363 */
1364inline ::std::ostream &operator<<(::std::ostream &os, const Window::Dimension &dim)
1365{
1366 os << "{start=" << dim.start() << ", end=" << dim.end() << ", step=" << dim.step() << "}";
1367
1368 return os;
1369}
1370/** Formatted output of the Window type.
1371 *
1372 * @param[out] os Output stream.
1373 * @param[in] win Type to output.
1374 *
1375 * @return Modified output stream.
1376 */
1377inline ::std::ostream &operator<<(::std::ostream &os, const Window &win)
1378{
1379 os << "{";
1380 for(unsigned int i = 0; i < Coordinates::num_max_dimensions; i++)
1381 {
1382 if(i > 0)
1383 {
1384 os << ", ";
1385 }
1386 os << win[i];
1387 }
1388 os << "}";
1389
1390 return os;
1391}
1392
1393/** Formatted output of the WeightsInfo type.
1394 *
1395 * @param[in] info Type to output.
1396 *
1397 * @return Formatted string.
1398 */
1399inline std::string to_string(const WeightsInfo &info)
1400{
1401 std::stringstream str;
1402 str << info;
1403 return str.str();
1404}
1405
1406/** Formatted output of the GEMMReshapeInfo type.
1407 *
1408 * @param[in] info Type to output.
1409 *
1410 * @return Formatted string.
1411 */
1412inline std::string to_string(const GEMMReshapeInfo &info)
1413{
1414 std::stringstream str;
1415 str << info;
1416 return str.str();
1417}
1418
1419/** Formatted output of the GEMMInfo type.
1420 *
1421 * @param[in] info Type to output.
1422 *
1423 * @return Formatted string.
1424 */
1425inline std::string to_string(const GEMMInfo &info)
1426{
1427 std::stringstream str;
1428 str << info;
1429 return str.str();
1430}
1431
1432/** Formatted output of the Window::Dimension type.
1433 *
1434 * @param[in] dim Type to output.
1435 *
1436 * @return Formatted string.
1437 */
1438inline std::string to_string(const Window::Dimension &dim)
1439{
1440 std::stringstream str;
1441 str << dim;
1442 return str.str();
1443}
ramelg01cbbb0382021-09-17 17:36:57 +01001444/** Formatted output of the Window& type.
Anthony Barbierb940fd62018-06-04 14:14:32 +01001445 *
1446 * @param[in] win Type to output.
1447 *
1448 * @return Formatted string.
1449 */
1450inline std::string to_string(const Window &win)
1451{
1452 std::stringstream str;
1453 str << win;
1454 return str.str();
1455}
1456
ramelg01cbbb0382021-09-17 17:36:57 +01001457/** Formatted output of the Window* type.
1458 *
1459 * @param[in] win Type to output.
1460 *
1461 * @return Formatted string.
1462 */
1463inline std::string to_string(Window *win)
1464{
1465 std::string ret_str = "nullptr";
1466 if(win != nullptr)
1467 {
1468 std::stringstream str;
1469 str << *win;
1470 ret_str = str.str();
1471 }
1472 return ret_str;
1473}
1474
Alex Gildayc357c472018-03-21 13:54:09 +00001475/** Formatted output of the Rectangle type.
1476 *
1477 * @param[out] os Output stream.
1478 * @param[in] rect Type to output.
1479 *
1480 * @return Modified output stream.
1481 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001482inline ::std::ostream &operator<<(::std::ostream &os, const Rectangle &rect)
1483{
1484 os << rect.width << "x" << rect.height;
1485 os << "+" << rect.x << "+" << rect.y;
1486
1487 return os;
1488}
1489
Usama Arif8cf8c112019-03-14 15:36:54 +00001490/** Formatted output of the PaddingMode type.
1491 *
1492 * @param[out] os Output stream.
1493 * @param[in] mode Type to output.
1494 *
1495 * @return Modified output stream.
1496 */
1497inline ::std::ostream &operator<<(::std::ostream &os, const PaddingMode &mode)
1498{
1499 switch(mode)
1500 {
1501 case PaddingMode::CONSTANT:
1502 os << "CONSTANT";
1503 break;
1504 case PaddingMode::REFLECT:
1505 os << "REFLECT";
1506 break;
1507 case PaddingMode::SYMMETRIC:
1508 os << "SYMMETRIC";
1509 break;
1510 default:
1511 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1512 }
1513
1514 return os;
1515}
1516
1517/** Formatted output of the PaddingMode type.
1518 *
1519 * @param[in] mode Type to output.
1520 *
1521 * @return Formatted string.
1522 */
1523inline std::string to_string(const PaddingMode &mode)
1524{
1525 std::stringstream str;
1526 str << mode;
1527 return str.str();
1528}
1529
Alex Gildayc357c472018-03-21 13:54:09 +00001530/** Formatted output of the PadStrideInfo type.
1531 *
1532 * @param[out] os Output stream.
1533 * @param[in] pad_stride_info Type to output.
1534 *
1535 * @return Modified output stream.
1536 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001537inline ::std::ostream &operator<<(::std::ostream &os, const PadStrideInfo &pad_stride_info)
1538{
1539 os << pad_stride_info.stride().first << "," << pad_stride_info.stride().second;
1540 os << ";";
Jaroslaw Rzepeckia1ed41f2017-10-13 11:13:58 +01001541 os << pad_stride_info.pad_left() << "," << pad_stride_info.pad_right() << ","
1542 << pad_stride_info.pad_top() << "," << pad_stride_info.pad_bottom();
Anthony Barbier2a07e182017-08-04 18:20:27 +01001543
1544 return os;
1545}
1546
Alex Gildayc357c472018-03-21 13:54:09 +00001547/** Formatted output of the PadStrideInfo type.
1548 *
1549 * @param[in] pad_stride_info Type to output.
1550 *
1551 * @return Formatted string.
1552 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001553inline std::string to_string(const PadStrideInfo &pad_stride_info)
1554{
1555 std::stringstream str;
1556 str << pad_stride_info;
1557 return str.str();
1558}
1559
Alex Gildayc357c472018-03-21 13:54:09 +00001560/** Formatted output of the BorderMode type.
1561 *
1562 * @param[in] mode Type to output.
1563 *
1564 * @return Formatted string.
1565 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001566inline std::string to_string(const BorderMode &mode)
1567{
1568 std::stringstream str;
1569 str << mode;
1570 return str.str();
1571}
1572
Alex Gildayc357c472018-03-21 13:54:09 +00001573/** Formatted output of the BorderSize type.
1574 *
1575 * @param[in] border Type to output.
1576 *
1577 * @return Formatted string.
1578 */
John Richardsonb482ce12017-09-18 12:44:01 +01001579inline std::string to_string(const BorderSize &border)
1580{
1581 std::stringstream str;
1582 str << border;
1583 return str.str();
1584}
1585
Giuseppe Rossinid7647d42018-07-17 18:13:13 +01001586/** Formatted output of the PaddingList type.
1587 *
1588 * @param[in] padding Type to output.
1589 *
1590 * @return Formatted string.
1591 */
1592inline std::string to_string(const PaddingList &padding)
1593{
1594 std::stringstream str;
1595 str << padding;
1596 return str.str();
1597}
1598
giuros013175fcf2018-11-21 09:59:17 +00001599/** Formatted output of the Multiples type.
1600 *
1601 * @param[in] multiples Type to output.
1602 *
1603 * @return Formatted string.
1604 */
1605inline std::string to_string(const Multiples &multiples)
1606{
1607 std::stringstream str;
1608 str << multiples;
1609 return str.str();
1610}
1611
Alex Gildayc357c472018-03-21 13:54:09 +00001612/** Formatted output of the InterpolationPolicy type.
1613 *
1614 * @param[in] policy Type to output.
1615 *
1616 * @return Formatted string.
1617 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001618inline std::string to_string(const InterpolationPolicy &policy)
1619{
1620 std::stringstream str;
1621 str << policy;
1622 return str.str();
1623}
1624
Alex Gildayc357c472018-03-21 13:54:09 +00001625/** Formatted output of the SamplingPolicy type.
1626 *
1627 * @param[in] policy Type to output.
1628 *
1629 * @return Formatted string.
1630 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +07001631inline std::string to_string(const SamplingPolicy &policy)
1632{
1633 std::stringstream str;
1634 str << policy;
1635 return str.str();
1636}
1637
Alex Gildayc357c472018-03-21 13:54:09 +00001638/** Formatted output of the ConvertPolicy type.
1639 *
1640 * @param[out] os Output stream.
1641 * @param[in] policy Type to output.
1642 *
1643 * @return Modified output stream.
1644 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001645inline ::std::ostream &operator<<(::std::ostream &os, const ConvertPolicy &policy)
1646{
1647 switch(policy)
1648 {
1649 case ConvertPolicy::WRAP:
1650 os << "WRAP";
1651 break;
1652 case ConvertPolicy::SATURATE:
1653 os << "SATURATE";
1654 break;
1655 default:
1656 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1657 }
1658
1659 return os;
1660}
1661
1662inline std::string to_string(const ConvertPolicy &policy)
1663{
1664 std::stringstream str;
1665 str << policy;
1666 return str.str();
1667}
1668
giuros01164a2722018-11-20 18:34:46 +00001669/** Formatted output of the ArithmeticOperation type.
1670 *
1671 * @param[out] os Output stream.
1672 * @param[in] op Operation to output.
1673 *
1674 * @return Modified output stream.
1675 */
1676inline ::std::ostream &operator<<(::std::ostream &os, const ArithmeticOperation &op)
1677{
1678 switch(op)
1679 {
1680 case ArithmeticOperation::ADD:
1681 os << "ADD";
1682 break;
1683 case ArithmeticOperation::SUB:
1684 os << "SUB";
1685 break;
1686 case ArithmeticOperation::DIV:
1687 os << "DIV";
1688 break;
1689 case ArithmeticOperation::MAX:
1690 os << "MAX";
1691 break;
1692 case ArithmeticOperation::MIN:
1693 os << "MIN";
1694 break;
1695 case ArithmeticOperation::SQUARED_DIFF:
1696 os << "SQUARED_DIFF";
1697 break;
Usama Arif52c54f62019-05-14 10:22:36 +01001698 case ArithmeticOperation::POWER:
1699 os << "POWER";
1700 break;
giuros01164a2722018-11-20 18:34:46 +00001701 default:
1702 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1703 }
1704
1705 return os;
1706}
1707
1708/** Formatted output of the Arithmetic Operation
1709 *
1710 * @param[in] op Type to output.
1711 *
1712 * @return Formatted string.
1713 */
1714inline std::string to_string(const ArithmeticOperation &op)
1715{
1716 std::stringstream str;
1717 str << op;
1718 return str.str();
1719}
1720
Alex Gildayc357c472018-03-21 13:54:09 +00001721/** Formatted output of the Reduction Operations.
1722 *
1723 * @param[out] os Output stream.
1724 * @param[in] op Type to output.
1725 *
1726 * @return Modified output stream.
1727 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001728inline ::std::ostream &operator<<(::std::ostream &os, const ReductionOperation &op)
1729{
1730 switch(op)
1731 {
Michalis Spyrou7e9391b2018-10-05 14:49:28 +01001732 case ReductionOperation::SUM:
1733 os << "SUM";
1734 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +01001735 case ReductionOperation::SUM_SQUARE:
1736 os << "SUM_SQUARE";
1737 break;
Michalis Spyrou7e9391b2018-10-05 14:49:28 +01001738 case ReductionOperation::MEAN_SUM:
1739 os << "MEAN_SUM";
1740 break;
Michalis Spyrou7930db42018-11-22 17:36:28 +00001741 case ReductionOperation::ARG_IDX_MAX:
1742 os << "ARG_IDX_MAX";
1743 break;
1744 case ReductionOperation::ARG_IDX_MIN:
1745 os << "ARG_IDX_MIN";
1746 break;
Manuel Bottinib412fab2018-12-10 17:40:23 +00001747 case ReductionOperation::PROD:
1748 os << "PROD";
1749 break;
Usama Arifa4a08ad2019-05-20 12:38:33 +01001750 case ReductionOperation::MIN:
1751 os << "MIN";
1752 break;
Usama Arif28f0dd92019-05-20 13:44:34 +01001753 case ReductionOperation::MAX:
1754 os << "MAX";
1755 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +01001756 default:
1757 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1758 }
1759
1760 return os;
1761}
1762
Alex Gildayc357c472018-03-21 13:54:09 +00001763/** Formatted output of the Reduction Operations.
1764 *
1765 * @param[in] op Type to output.
1766 *
1767 * @return Formatted string.
1768 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001769inline std::string to_string(const ReductionOperation &op)
1770{
1771 std::stringstream str;
1772 str << op;
1773 return str.str();
1774}
1775
Georgios Pinitas7900a9e2018-11-23 11:44:58 +00001776/** Formatted output of the Comparison Operations.
1777 *
1778 * @param[out] os Output stream.
1779 * @param[in] op Type to output.
1780 *
1781 * @return Modified output stream.
1782 */
1783inline ::std::ostream &operator<<(::std::ostream &os, const ComparisonOperation &op)
1784{
1785 switch(op)
1786 {
1787 case ComparisonOperation::Equal:
1788 os << "Equal";
1789 break;
1790 case ComparisonOperation::NotEqual:
1791 os << "NotEqual";
1792 break;
1793 case ComparisonOperation::Greater:
1794 os << "Greater";
1795 break;
1796 case ComparisonOperation::GreaterEqual:
1797 os << "GreaterEqual";
1798 break;
1799 case ComparisonOperation::Less:
1800 os << "Less";
1801 break;
1802 case ComparisonOperation::LessEqual:
1803 os << "LessEqual";
1804 break;
1805 default:
1806 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1807 }
1808
1809 return os;
1810}
1811
Michalis Spyroue9362622018-11-23 17:41:37 +00001812/** Formatted output of the Elementwise unary Operations.
1813 *
1814 * @param[out] os Output stream.
1815 * @param[in] op Type to output.
1816 *
1817 * @return Modified output stream.
1818 */
1819inline ::std::ostream &operator<<(::std::ostream &os, const ElementWiseUnary &op)
1820{
1821 switch(op)
1822 {
1823 case ElementWiseUnary::RSQRT:
1824 os << "RSQRT";
1825 break;
1826 case ElementWiseUnary::EXP:
1827 os << "EXP";
1828 break;
Usama Arifeb312ef2019-05-13 17:45:54 +01001829 case ElementWiseUnary::NEG:
1830 os << "NEG";
1831 break;
Usama Arifac33d7e2019-05-20 14:21:40 +01001832 case ElementWiseUnary::LOG:
1833 os << "LOG";
1834 break;
ramelg01b1ba1e32021-09-25 11:53:26 +01001835 case ElementWiseUnary::SIN:
1836 os << "SIN";
1837 break;
1838 case ElementWiseUnary::ABS:
1839 os << "ABS";
1840 break;
Usama Arif6a4d5422019-05-24 14:53:59 +01001841 case ElementWiseUnary::ROUND:
1842 os << "ROUND";
1843 break;
ramelg01b1ba1e32021-09-25 11:53:26 +01001844 case ElementWiseUnary::LOGICAL_NOT:
1845 os << "LOGICAL_NOT";
1846 break;
Michalis Spyroue9362622018-11-23 17:41:37 +00001847 default:
1848 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1849 }
1850
1851 return os;
1852}
1853
Georgios Pinitas7900a9e2018-11-23 11:44:58 +00001854/** Formatted output of the Comparison Operations.
1855 *
1856 * @param[in] op Type to output.
1857 *
1858 * @return Formatted string.
1859 */
1860inline std::string to_string(const ComparisonOperation &op)
1861{
1862 std::stringstream str;
1863 str << op;
1864 return str.str();
1865}
1866
Michalis Spyroue9362622018-11-23 17:41:37 +00001867/** Formatted output of the Elementwise unary Operations.
1868 *
1869 * @param[in] op Type to output.
1870 *
1871 * @return Formatted string.
1872 */
1873inline std::string to_string(const ElementWiseUnary &op)
1874{
1875 std::stringstream str;
1876 str << op;
1877 return str.str();
1878}
1879
Alex Gildayc357c472018-03-21 13:54:09 +00001880/** Formatted output of the Norm Type.
1881 *
1882 * @param[in] type Type to output.
1883 *
1884 * @return Formatted string.
1885 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001886inline std::string to_string(const NormType &type)
1887{
1888 std::stringstream str;
1889 str << type;
1890 return str.str();
1891}
1892
Alex Gildayc357c472018-03-21 13:54:09 +00001893/** Formatted output of the Pooling Type.
1894 *
1895 * @param[in] type Type to output.
1896 *
1897 * @return Formatted string.
1898 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001899inline std::string to_string(const PoolingType &type)
1900{
1901 std::stringstream str;
1902 str << type;
1903 return str.str();
1904}
1905
Alex Gildayc357c472018-03-21 13:54:09 +00001906/** Formatted output of the Pooling Layer Info.
1907 *
1908 * @param[in] info Type to output.
1909 *
1910 * @return Formatted string.
1911 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001912inline std::string to_string(const PoolingLayerInfo &info)
1913{
1914 std::stringstream str;
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +00001915 str << "{Type=" << info.pool_type << ","
Sang-Hoon Park11fedda2020-01-15 14:44:04 +00001916 << "DataLayout=" << info.data_layout << ","
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +00001917 << "IsGlobalPooling=" << info.is_global_pooling;
1918 if(!info.is_global_pooling)
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001919 {
1920 str << ","
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +00001921 << "PoolSize=" << info.pool_size.width << "," << info.pool_size.height << ","
1922 << "PadStride=" << info.pad_stride_info;
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001923 }
1924 str << "}";
Anthony Barbier2a07e182017-08-04 18:20:27 +01001925 return str.str();
1926}
1927
Michalis Spyrou6c7c38e2018-08-29 16:28:11 +01001928/** Formatted output of the PriorBoxLayerInfo.
1929 *
1930 * @param[in] info Type to output.
1931 *
1932 * @return Formatted string.
1933 */
1934inline std::string to_string(const PriorBoxLayerInfo &info)
1935{
1936 std::stringstream str;
1937 str << "{";
1938 str << "Clip:" << info.clip()
1939 << "Flip:" << info.flip()
1940 << "StepX:" << info.steps()[0]
1941 << "StepY:" << info.steps()[1]
1942 << "MinSizes:" << info.min_sizes().size()
1943 << "MaxSizes:" << info.max_sizes().size()
1944 << "ImgSizeX:" << info.img_size().x
1945 << "ImgSizeY:" << info.img_size().y
1946 << "Offset:" << info.offset()
1947 << "Variances:" << info.variances().size();
1948 str << "}";
1949 return str.str();
1950}
1951
Alex Gildayc357c472018-03-21 13:54:09 +00001952/** Formatted output of the Size2D type.
1953 *
1954 * @param[out] os Output stream
1955 * @param[in] size Type to output
1956 *
1957 * @return Modified output stream.
1958 */
John Richardson25f23682017-11-27 14:35:09 +00001959inline ::std::ostream &operator<<(::std::ostream &os, const Size2D &size)
1960{
1961 os << size.width << "x" << size.height;
1962
1963 return os;
1964}
1965
Alex Gildayc357c472018-03-21 13:54:09 +00001966/** Formatted output of the Size2D type.
1967 *
1968 * @param[in] type Type to output
1969 *
1970 * @return Formatted string.
1971 */
John Richardson25f23682017-11-27 14:35:09 +00001972inline std::string to_string(const Size2D &type)
1973{
1974 std::stringstream str;
1975 str << type;
1976 return str.str();
1977}
1978
Alex Gildayc357c472018-03-21 13:54:09 +00001979/** Formatted output of the ConvolutionMethod type.
1980 *
1981 * @param[out] os Output stream
1982 * @param[in] conv_method Type to output
1983 *
1984 * @return Modified output stream.
1985 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001986inline ::std::ostream &operator<<(::std::ostream &os, const ConvolutionMethod &conv_method)
1987{
1988 switch(conv_method)
1989 {
1990 case ConvolutionMethod::GEMM:
1991 os << "GEMM";
1992 break;
1993 case ConvolutionMethod::DIRECT:
1994 os << "DIRECT";
1995 break;
1996 case ConvolutionMethod::WINOGRAD:
1997 os << "WINOGRAD";
1998 break;
1999 default:
2000 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2001 }
2002
2003 return os;
2004}
2005
Alex Gildayc357c472018-03-21 13:54:09 +00002006/** Formatted output of the ConvolutionMethod type.
2007 *
2008 * @param[in] conv_method Type to output
2009 *
2010 * @return Formatted string.
2011 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002012inline std::string to_string(const ConvolutionMethod &conv_method)
2013{
2014 std::stringstream str;
2015 str << conv_method;
2016 return str.str();
2017}
2018
Alex Gildayc357c472018-03-21 13:54:09 +00002019/** Formatted output of the GPUTarget type.
2020 *
2021 * @param[out] os Output stream
2022 * @param[in] gpu_target Type to output
2023 *
2024 * @return Modified output stream.
2025 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002026inline ::std::ostream &operator<<(::std::ostream &os, const GPUTarget &gpu_target)
2027{
2028 switch(gpu_target)
2029 {
2030 case GPUTarget::GPU_ARCH_MASK:
2031 os << "GPU_ARCH_MASK";
2032 break;
2033 case GPUTarget::MIDGARD:
2034 os << "MIDGARD";
2035 break;
2036 case GPUTarget::BIFROST:
2037 os << "BIFROST";
2038 break;
Georgios Pinitasd5462ff2019-07-03 19:33:57 +01002039 case GPUTarget::VALHALL:
2040 os << "VALHALL";
2041 break;
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002042 case GPUTarget::T600:
2043 os << "T600";
2044 break;
2045 case GPUTarget::T700:
2046 os << "T700";
2047 break;
2048 case GPUTarget::T800:
2049 os << "T800";
2050 break;
Michalis Spyroua9676112018-02-22 18:07:43 +00002051 case GPUTarget::G71:
2052 os << "G71";
2053 break;
2054 case GPUTarget::G72:
2055 os << "G72";
2056 break;
2057 case GPUTarget::G51:
2058 os << "G51";
2059 break;
2060 case GPUTarget::G51BIG:
2061 os << "G51BIG";
2062 break;
2063 case GPUTarget::G51LIT:
2064 os << "G51LIT";
2065 break;
Georgios Pinitasb03f7c52018-07-12 10:49:53 +01002066 case GPUTarget::G76:
2067 os << "G76";
Michalis Spyroua9676112018-02-22 18:07:43 +00002068 break;
Georgios Pinitasd5462ff2019-07-03 19:33:57 +01002069 case GPUTarget::G77:
2070 os << "G77";
Michalis Spyroua9676112018-02-22 18:07:43 +00002071 break;
Georgios Pinitas4ffc42a2020-12-01 16:28:24 +00002072 case GPUTarget::G78:
2073 os << "G78";
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002074 break;
Pablo Marquez Tellob1496e62021-06-25 14:49:37 +01002075 case GPUTarget::G31:
2076 os << "G31";
2077 break;
Georgios Pinitasd5462ff2019-07-03 19:33:57 +01002078 case GPUTarget::TODX:
2079 os << "TODX";
2080 break;
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002081 default:
2082 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2083 }
2084
2085 return os;
2086}
2087
Alex Gildayc357c472018-03-21 13:54:09 +00002088/** Formatted output of the GPUTarget type.
2089 *
2090 * @param[in] gpu_target Type to output
2091 *
2092 * @return Formatted string.
2093 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002094inline std::string to_string(const GPUTarget &gpu_target)
2095{
2096 std::stringstream str;
2097 str << gpu_target;
2098 return str.str();
2099}
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00002100
John Richardson8de92612018-02-22 14:09:31 +00002101/** Formatted output of the DetectionWindow type.
2102 *
2103 * @param[out] os Output stream
2104 * @param[in] detection_window Type to output
2105 *
2106 * @return Modified output stream.
2107 */
John Richardson684cb0f2018-01-09 11:17:00 +00002108inline ::std::ostream &operator<<(::std::ostream &os, const DetectionWindow &detection_window)
2109{
2110 os << "{x=" << detection_window.x << ","
2111 << "y=" << detection_window.y << ","
2112 << "width=" << detection_window.width << ","
2113 << "height=" << detection_window.height << ","
2114 << "idx_class=" << detection_window.idx_class << ","
2115 << "score=" << detection_window.score << "}";
2116
2117 return os;
2118}
2119
Isabella Gottardi05e56442018-11-16 11:26:52 +00002120/** Formatted output of the DetectionOutputLayerCodeType type.
2121 *
2122 * @param[out] os Output stream
2123 * @param[in] detection_code Type to output
2124 *
2125 * @return Modified output stream.
2126 */
2127inline ::std::ostream &operator<<(::std::ostream &os, const DetectionOutputLayerCodeType &detection_code)
2128{
2129 switch(detection_code)
2130 {
2131 case DetectionOutputLayerCodeType::CENTER_SIZE:
2132 os << "CENTER_SIZE";
2133 break;
2134 case DetectionOutputLayerCodeType::CORNER:
2135 os << "CORNER";
2136 break;
2137 case DetectionOutputLayerCodeType::CORNER_SIZE:
2138 os << "CORNER_SIZE";
2139 break;
2140 case DetectionOutputLayerCodeType::TF_CENTER:
2141 os << "TF_CENTER";
2142 break;
2143 default:
2144 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2145 }
2146
2147 return os;
2148}
2149/** Formatted output of the DetectionOutputLayerCodeType type.
2150 *
2151 * @param[in] detection_code Type to output
2152 *
2153 * @return Formatted string.
2154 */
2155inline std::string to_string(const DetectionOutputLayerCodeType &detection_code)
2156{
2157 std::stringstream str;
2158 str << detection_code;
2159 return str.str();
2160}
2161
2162/** Formatted output of the DetectionOutputLayerInfo type.
2163 *
2164 * @param[out] os Output stream
2165 * @param[in] detection_info Type to output
2166 *
2167 * @return Modified output stream.
2168 */
2169inline ::std::ostream &operator<<(::std::ostream &os, const DetectionOutputLayerInfo &detection_info)
2170{
2171 os << "{Classes=" << detection_info.num_classes() << ","
2172 << "ShareLocation=" << detection_info.share_location() << ","
2173 << "CodeType=" << detection_info.code_type() << ","
2174 << "VarianceEncodedInTarget=" << detection_info.variance_encoded_in_target() << ","
2175 << "KeepTopK=" << detection_info.keep_top_k() << ","
2176 << "NMSThreshold=" << detection_info.nms_threshold() << ","
2177 << "Eta=" << detection_info.eta() << ","
2178 << "BackgroundLabelId=" << detection_info.background_label_id() << ","
2179 << "ConfidenceThreshold=" << detection_info.confidence_threshold() << ","
2180 << "TopK=" << detection_info.top_k() << ","
2181 << "NumLocClasses=" << detection_info.num_loc_classes()
2182 << "}";
2183
2184 return os;
2185}
2186
2187/** Formatted output of the DetectionOutputLayerInfo type.
2188 *
2189 * @param[in] detection_info Type to output
2190 *
2191 * @return Formatted string.
2192 */
2193inline std::string to_string(const DetectionOutputLayerInfo &detection_info)
2194{
2195 std::stringstream str;
2196 str << detection_info;
2197 return str.str();
2198}
Isabella Gottardia7acb3c2019-01-08 13:48:44 +00002199/** Formatted output of the DetectionPostProcessLayerInfo type.
2200 *
2201 * @param[out] os Output stream
2202 * @param[in] detection_info Type to output
2203 *
2204 * @return Modified output stream.
2205 */
2206inline ::std::ostream &operator<<(::std::ostream &os, const DetectionPostProcessLayerInfo &detection_info)
2207{
2208 os << "{MaxDetections=" << detection_info.max_detections() << ","
2209 << "MaxClassesPerDetection=" << detection_info.max_classes_per_detection() << ","
2210 << "NmsScoreThreshold=" << detection_info.nms_score_threshold() << ","
2211 << "NmsIouThreshold=" << detection_info.iou_threshold() << ","
2212 << "NumClasses=" << detection_info.num_classes() << ","
2213 << "ScaleValue_y=" << detection_info.scale_value_y() << ","
2214 << "ScaleValue_x=" << detection_info.scale_value_x() << ","
2215 << "ScaleValue_h=" << detection_info.scale_value_h() << ","
2216 << "ScaleValue_w=" << detection_info.scale_value_w() << ","
2217 << "UseRegularNms=" << detection_info.use_regular_nms() << ","
2218 << "DetectionPerClass=" << detection_info.detection_per_class()
2219 << "}";
2220
2221 return os;
2222}
2223
2224/** Formatted output of the DetectionPostProcessLayerInfo type.
2225 *
2226 * @param[in] detection_info Type to output
2227 *
2228 * @return Formatted string.
2229 */
2230inline std::string to_string(const DetectionPostProcessLayerInfo &detection_info)
2231{
2232 std::stringstream str;
2233 str << detection_info;
2234 return str.str();
2235}
Georgios Pinitasc6f95102021-03-30 10:03:01 +01002236
John Richardson8de92612018-02-22 14:09:31 +00002237/** Formatted output of the DetectionWindow type.
2238 *
2239 * @param[in] detection_window Type to output
2240 *
2241 * @return Formatted string.
2242 */
2243inline std::string to_string(const DetectionWindow &detection_window)
2244{
2245 std::stringstream str;
2246 str << detection_window;
2247 return str.str();
2248}
2249
Michalis Spyrou6c7c38e2018-08-29 16:28:11 +01002250/** Formatted output of @ref PriorBoxLayerInfo.
2251 *
2252 * @param[out] os Output stream.
2253 * @param[in] info Type to output.
2254 *
2255 * @return Modified output stream.
2256 */
2257inline ::std::ostream &operator<<(::std::ostream &os, const PriorBoxLayerInfo &info)
2258{
2259 os << "Clip:" << info.clip()
2260 << "Flip:" << info.flip()
2261 << "StepX:" << info.steps()[0]
2262 << "StepY:" << info.steps()[1]
2263 << "MinSizes:" << info.min_sizes()
2264 << "MaxSizes:" << info.max_sizes()
2265 << "ImgSizeX:" << info.img_size().x
2266 << "ImgSizeY:" << info.img_size().y
2267 << "Offset:" << info.offset()
2268 << "Variances:" << info.variances();
2269
2270 return os;
2271}
2272
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00002273/** Formatted output of the WinogradInfo type. */
2274inline ::std::ostream &operator<<(::std::ostream &os, const WinogradInfo &info)
2275{
2276 os << "{OutputTileSize=" << info.output_tile_size << ","
2277 << "KernelSize=" << info.kernel_size << ","
2278 << "PadStride=" << info.convolution_info << ","
2279 << "OutputDataLayout=" << info.output_data_layout << "}";
2280
2281 return os;
2282}
2283
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00002284inline std::string to_string(const WinogradInfo &type)
2285{
2286 std::stringstream str;
2287 str << type;
2288 return str.str();
2289}
Anthony Barbier671a11e2018-07-06 15:11:36 +01002290
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +01002291/** Convert a CLTunerMode value to a string
2292 *
2293 * @param val CLTunerMode value to be converted
2294 *
2295 * @return String representing the corresponding CLTunerMode.
2296 */
2297inline std::string to_string(const CLTunerMode val)
2298{
2299 switch(val)
2300 {
2301 case CLTunerMode::EXHAUSTIVE:
2302 {
2303 return std::string("Exhaustive");
2304 }
2305 case CLTunerMode::NORMAL:
2306 {
2307 return std::string("Normal");
2308 }
2309 case CLTunerMode::RAPID:
2310 {
2311 return std::string("Rapid");
2312 }
2313 default:
2314 {
2315 ARM_COMPUTE_ERROR("Invalid tuner mode.");
2316 return std::string("UNDEFINED");
2317 }
2318 }
2319}
SiCong Lidb4a6c12021-02-05 09:30:57 +00002320/** Converts a @ref CLGEMMKernelType to string
2321 *
2322 * @param[in] val CLGEMMKernelType value to be converted
2323 *
2324 * @return String representing the corresponding CLGEMMKernelType
2325 */
2326inline std::string to_string(CLGEMMKernelType val)
2327{
2328 switch(val)
2329 {
2330 case CLGEMMKernelType::NATIVE_V1:
2331 {
2332 return "Native_V1";
2333 }
2334 case CLGEMMKernelType::RESHAPED_V1:
2335 {
2336 return "Reshaped_V1";
2337 }
2338 case CLGEMMKernelType::NATIVE:
2339 {
2340 return "Native";
2341 }
2342 case CLGEMMKernelType::RESHAPED_ONLY_RHS:
2343 {
2344 return "Reshaped_Only_RHS";
2345 }
2346 case CLGEMMKernelType::RESHAPED:
2347 {
2348 return "Reshaped";
2349 }
2350 default:
2351 {
2352 return "Unknown";
2353 }
2354 }
2355}
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +01002356/** [Print CLTunerMode type] **/
2357/** Formatted output of the CLTunerMode type.
2358 *
2359 * @param[out] os Output stream.
2360 * @param[in] val CLTunerMode to output.
2361 *
2362 * @return Modified output stream.
2363 */
2364inline ::std::ostream &operator<<(::std::ostream &os, const CLTunerMode &val)
2365{
2366 os << to_string(val);
2367 return os;
2368}
2369
ramelg013ae3d882021-09-12 23:07:47 +01002370/** Formatted output of the ConvolutionInfo type.
2371 *
2372 * @param[out] os Output stream.
2373 * @param[in] conv_info ConvolutionInfo to output.
2374 *
2375 * @return Modified output stream.
2376 */
2377inline ::std::ostream &operator<<(::std::ostream &os, const ConvolutionInfo &conv_info)
2378{
ramelg01cbbb0382021-09-17 17:36:57 +01002379 os << "{PadStrideInfo = " << conv_info.pad_stride_info << ", "
ramelg013ae3d882021-09-12 23:07:47 +01002380 << "depth_multiplier = " << conv_info.depth_multiplier << ", "
2381 << "act_info = " << to_string(conv_info.act_info) << ", "
ramelg01cbbb0382021-09-17 17:36:57 +01002382 << "dilation = " << conv_info.dilation << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002383 return os;
2384}
2385
2386/** Converts a @ref ConvolutionInfo to string
2387 *
2388 * @param[in] info ConvolutionInfo value to be converted
2389 *
2390 * @return String representing the corresponding ConvolutionInfo
2391 */
2392inline std::string to_string(const ConvolutionInfo &info)
2393{
2394 std::stringstream str;
2395 str << info;
2396 return str.str();
2397}
2398
2399/** Formatted output of the FullyConnectedLayerInfo type.
2400 *
2401 * @param[out] os Output stream.
2402 * @param[in] layer_info FullyConnectedLayerInfo to output.
2403 *
2404 * @return Modified output stream.
2405 */
2406inline ::std::ostream &operator<<(::std::ostream &os, const FullyConnectedLayerInfo &layer_info)
2407{
ramelg01cbbb0382021-09-17 17:36:57 +01002408 os << "{activation_info = " << to_string(layer_info.activation_info) << ", "
ramelg013ae3d882021-09-12 23:07:47 +01002409 << "weights_trained_layout = " << layer_info.weights_trained_layout << ", "
2410 << "transpose_weights = " << layer_info.transpose_weights << ", "
2411 << "are_weights_reshaped = " << layer_info.are_weights_reshaped << ", "
2412 << "retain_internal_weights = " << layer_info.retain_internal_weights << ", "
2413 << "constant_weights = " << layer_info.transpose_weights << ", "
ramelg01cbbb0382021-09-17 17:36:57 +01002414 << "fp_mixed_precision = " << layer_info.fp_mixed_precision << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002415 return os;
2416}
2417
2418/** Converts a @ref FullyConnectedLayerInfo to string
2419 *
2420 * @param[in] info FullyConnectedLayerInfo value to be converted
2421 *
2422 * @return String representing the corresponding FullyConnectedLayerInfo
2423 */
2424inline std::string to_string(const FullyConnectedLayerInfo &info)
2425{
2426 std::stringstream str;
2427 str << info;
2428 return str.str();
2429}
2430
2431/** Formatted output of the GEMMLowpOutputStageType type.
2432 *
2433 * @param[out] os Output stream.
2434 * @param[in] gemm_type GEMMLowpOutputStageType to output.
2435 *
2436 * @return Modified output stream.
2437 */
2438inline ::std::ostream &operator<<(::std::ostream &os, const GEMMLowpOutputStageType &gemm_type)
2439{
2440 switch(gemm_type)
2441 {
2442 case GEMMLowpOutputStageType::NONE:
2443 os << "NONE";
2444 break;
2445 case GEMMLowpOutputStageType::QUANTIZE_DOWN:
2446 os << "QUANTIZE_DOWN";
2447 break;
2448 case GEMMLowpOutputStageType::QUANTIZE_DOWN_FIXEDPOINT:
2449 os << "QUANTIZE_DOWN_FIXEDPOINT";
2450 break;
2451 case GEMMLowpOutputStageType::QUANTIZE_DOWN_FLOAT:
2452 os << "QUANTIZE_DOWN_FLOAT";
2453 break;
2454 default:
2455 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2456 }
2457 return os;
2458}
2459
2460/** Converts a @ref GEMMLowpOutputStageType to string
2461 *
2462 * @param[in] gemm_type GEMMLowpOutputStageType value to be converted
2463 *
2464 * @return String representing the corresponding GEMMLowpOutputStageType
2465 */
2466inline std::string to_string(const GEMMLowpOutputStageType &gemm_type)
2467{
2468 std::stringstream str;
2469 str << gemm_type;
2470 return str.str();
2471}
2472
2473/** Formatted output of the GEMMLowpOutputStageInfo type.
2474 *
2475 * @param[out] os Output stream.
2476 * @param[in] gemm_info GEMMLowpOutputStageInfo to output.
2477 *
2478 * @return Modified output stream.
2479 */
2480inline ::std::ostream &operator<<(::std::ostream &os, const GEMMLowpOutputStageInfo &gemm_info)
2481{
ramelg01cbbb0382021-09-17 17:36:57 +01002482 os << "{type = " << gemm_info.type << ", "
ramelg013ae3d882021-09-12 23:07:47 +01002483 << "gemlowp_offset = " << gemm_info.gemmlowp_offset << ", "
2484 << "gemmlowp_multiplier" << gemm_info.gemmlowp_multiplier << ", "
2485 << "gemmlowp_shift = " << gemm_info.gemmlowp_shift << ", "
2486 << "gemmlowp_min_bound = " << gemm_info.gemmlowp_min_bound << ", "
2487 << "gemmlowp_max_bound = " << gemm_info.gemmlowp_max_bound << ", "
2488 << "gemmlowp_multipliers = " << gemm_info.gemmlowp_multiplier << ", "
2489 << "gemmlowp_shifts = " << gemm_info.gemmlowp_shift << ", "
2490 << "gemmlowp_real_multiplier = " << gemm_info.gemmlowp_real_multiplier << ", "
2491 << "is_quantized_per_channel = " << gemm_info.is_quantized_per_channel << ", "
ramelg01cbbb0382021-09-17 17:36:57 +01002492 << "output_data_type = " << gemm_info.output_data_type << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002493 return os;
2494}
2495
2496/** Converts a @ref GEMMLowpOutputStageInfo to string
2497 *
2498 * @param[in] gemm_info GEMMLowpOutputStageInfo value to be converted
2499 *
2500 * @return String representing the corresponding GEMMLowpOutputStageInfo
2501 */
2502inline std::string to_string(const GEMMLowpOutputStageInfo &gemm_info)
2503{
2504 std::stringstream str;
2505 str << gemm_info;
2506 return str.str();
2507}
2508
2509/** Formatted output of the Conv2dInfo type.
2510 *
2511 * @param[out] os Output stream.
2512 * @param[in] conv_info Conv2dInfo to output.
2513 *
2514 * @return Modified output stream.
2515 */
2516inline ::std::ostream &operator<<(::std::ostream &os, const Conv2dInfo &conv_info)
2517{
ramelg01cbbb0382021-09-17 17:36:57 +01002518 os << "{conv_info = " << conv_info.conv_info << ", "
ramelg013ae3d882021-09-12 23:07:47 +01002519 << "dilation = " << conv_info.dilation << ", "
2520 << "act_info = " << to_string(conv_info.act_info) << ", "
2521 << "enable_fast_math = " << conv_info.enable_fast_math << ", "
ramelg01cbbb0382021-09-17 17:36:57 +01002522 << "num_groups = " << conv_info.num_groups << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002523 return os;
2524}
2525
2526/** Converts a @ref Conv2dInfo to string
2527 *
2528 * @param[in] conv_info Conv2dInfo value to be converted
2529 *
2530 * @return String representing the corresponding Conv2dInfo
2531 */
2532inline std::string to_string(const Conv2dInfo &conv_info)
2533{
2534 std::stringstream str;
2535 str << conv_info;
2536 return str.str();
2537}
2538
2539/** Formatted output of the PixelValue type.
2540 *
2541 * @param[out] os Output stream.
2542 * @param[in] pixel_value PixelValue to output.
2543 *
2544 * @return Modified output stream.
2545 */
2546inline ::std::ostream &operator<<(::std::ostream &os, const PixelValue &pixel_value)
2547{
ramelg01cbbb0382021-09-17 17:36:57 +01002548 os << "{value.u64= " << pixel_value.get<uint64_t>() << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002549 return os;
2550}
2551
2552/** Converts a @ref PixelValue to string
2553 *
2554 * @param[in] pixel_value PixelValue value to be converted
2555 *
2556 * @return String representing the corresponding PixelValue
2557 */
2558inline std::string to_string(const PixelValue &pixel_value)
2559{
2560 std::stringstream str;
2561 str << pixel_value;
2562 return str.str();
2563}
2564
2565/** Formatted output of the ScaleKernelInfo type.
2566 *
2567 * @param[out] os Output stream.
2568 * @param[in] scale_info ScaleKernelInfo to output.
2569 *
2570 * @return Modified output stream.
2571 */
2572inline ::std::ostream &operator<<(::std::ostream &os, const ScaleKernelInfo &scale_info)
2573{
ramelg01cbbb0382021-09-17 17:36:57 +01002574 os << "{interpolation_policy = " << scale_info.interpolation_policy << ", "
ramelg013ae3d882021-09-12 23:07:47 +01002575 << "BorderMode = " << scale_info.border_mode << ", "
2576 << "PixelValue = " << scale_info.constant_border_value << ", "
2577 << "SamplingPolicy = " << scale_info.sampling_policy << ", "
2578 << "use_padding = " << scale_info.use_padding << ", "
2579 << "align_corners = " << scale_info.align_corners << ", "
ramelg01cbbb0382021-09-17 17:36:57 +01002580 << "data_layout = " << scale_info.data_layout << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002581 return os;
2582}
2583
2584/** Converts a @ref ScaleKernelInfo to string
2585 *
2586 * @param[in] scale_info ScaleKernelInfo value to be converted
2587 *
2588 * @return String representing the corresponding ScaleKernelInfo
2589 */
2590inline std::string to_string(const ScaleKernelInfo &scale_info)
2591{
2592 std::stringstream str;
2593 str << scale_info;
2594 return str.str();
2595}
2596
2597/** Formatted output of the FFTDirection type.
2598 *
2599 * @param[out] os Output stream.
2600 * @param[in] fft_dir FFTDirection to output.
2601 *
2602 * @return Modified output stream.
2603 */
2604inline ::std::ostream &operator<<(::std::ostream &os, const FFTDirection &fft_dir)
2605{
2606 switch(fft_dir)
2607 {
2608 case FFTDirection::Forward:
2609 os << "Forward";
2610 break;
2611 case FFTDirection::Inverse:
2612 os << "Inverse";
2613 break;
2614 default:
2615 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2616 }
2617 return os;
2618}
2619
2620/** Converts a @ref FFT1DInfo to string
2621 *
2622 * @param[in] fft_dir FFT1DInfo value to be converted
2623 *
2624 * @return String representing the corresponding FFT1DInfo
2625 */
2626inline std::string to_string(const FFTDirection &fft_dir)
2627{
2628 std::stringstream str;
ramelg01cbbb0382021-09-17 17:36:57 +01002629 str << "{" << fft_dir << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002630 return str.str();
2631}
2632
2633/** Formatted output of the FFT1DInfo type.
2634 *
2635 * @param[out] os Output stream.
2636 * @param[in] fft1d_info FFT1DInfo to output.
2637 *
2638 * @return Modified output stream.
2639 */
2640inline ::std::ostream &operator<<(::std::ostream &os, const FFT1DInfo &fft1d_info)
2641{
ramelg01cbbb0382021-09-17 17:36:57 +01002642 os << "{axis = " << fft1d_info.axis << ", "
2643 << "direction = " << fft1d_info.direction << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002644 return os;
2645}
2646
2647/** Converts a @ref FFT1DInfo to string
2648 *
2649 * @param[in] fft1d_info FFT1DInfo value to be converted
2650 *
2651 * @return String representing the corresponding FFT1DInfo
2652 */
2653inline std::string to_string(const FFT1DInfo &fft1d_info)
2654{
2655 std::stringstream str;
2656 str << fft1d_info;
2657 return str.str();
2658}
2659
2660/** Formatted output of the FFT2DInfo type.
2661 *
2662 * @param[out] os Output stream.
2663 * @param[in] fft2d_info FFT2DInfo to output.
2664 *
2665 * @return Modified output stream.
2666 */
2667inline ::std::ostream &operator<<(::std::ostream &os, const FFT2DInfo &fft2d_info)
2668{
ramelg01cbbb0382021-09-17 17:36:57 +01002669 os << "{axis = " << fft2d_info.axis0 << ", "
ramelg013ae3d882021-09-12 23:07:47 +01002670 << "axis = " << fft2d_info.axis1 << ", "
ramelg01cbbb0382021-09-17 17:36:57 +01002671 << "direction = " << fft2d_info.direction << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002672 return os;
2673}
2674
2675/** Converts a @ref FFT2DInfo to string
2676 *
2677 * @param[in] fft2d_info FFT2DInfo value to be converted
2678 *
2679 * @return String representing the corresponding FFT2DInfo
2680 */
2681inline std::string to_string(const FFT2DInfo &fft2d_info)
2682{
2683 std::stringstream str;
2684 str << fft2d_info;
2685 return str.str();
2686}
2687
2688/** Formatted output of the Coordinates2D type.
2689 *
2690 * @param[out] os Output stream.
2691 * @param[in] coord_2d Coordinates2D to output.
2692 *
2693 * @return Modified output stream.
2694 */
2695inline ::std::ostream &operator<<(::std::ostream &os, const Coordinates2D &coord_2d)
2696{
ramelg01cbbb0382021-09-17 17:36:57 +01002697 os << "{x = " << coord_2d.x << ", "
2698 << "y = " << coord_2d.y << "}";
ramelg013ae3d882021-09-12 23:07:47 +01002699 return os;
2700}
2701
2702/** Converts a @ref Coordinates2D to string
2703 *
2704 * @param[in] coord_2d Coordinates2D value to be converted
2705 *
2706 * @return String representing the corresponding Coordinates2D
2707 */
2708inline std::string to_string(const Coordinates2D &coord_2d)
2709{
2710 std::stringstream str;
2711 str << coord_2d;
2712 return str.str();
2713}
2714
2715/** Formatted output of the FuseBatchNormalizationType type.
2716 *
2717 * @param[out] os Output stream.
2718 * @param[in] fuse_type FuseBatchNormalizationType to output.
2719 *
2720 * @return Modified output stream.
2721 */
2722inline ::std::ostream &operator<<(::std::ostream &os, const FuseBatchNormalizationType &fuse_type)
2723{
2724 switch(fuse_type)
2725 {
2726 case FuseBatchNormalizationType::CONVOLUTION:
2727 os << "CONVOLUTION";
2728 break;
2729 case FuseBatchNormalizationType::DEPTHWISECONVOLUTION:
2730 os << "DEPTHWISECONVOLUTION";
2731 break;
2732 default:
2733 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2734 }
2735 return os;
2736}
2737
2738/** Converts a @ref FuseBatchNormalizationType to string
2739 *
2740 * @param[in] fuse_type FuseBatchNormalizationType value to be converted
2741 *
2742 * @return String representing the corresponding FuseBatchNormalizationType
2743 */
2744inline std::string to_string(const FuseBatchNormalizationType &fuse_type)
2745{
2746 std::stringstream str;
2747 str << fuse_type;
2748 return str.str();
2749}
2750
ramelg01cbbb0382021-09-17 17:36:57 +01002751/** Formatted output of the SoftmaxKernelInfo type.
2752 *
2753 * @param[out] os Output stream.
2754 * @param[in] info SoftmaxKernelInfo to output.
2755 *
2756 * @return Modified output stream.
2757 */
2758inline ::std::ostream &operator<<(::std::ostream &os, const SoftmaxKernelInfo &info)
2759{
2760 os << "{beta = " << info.beta << ", "
2761 << "is_log = " << info.is_log << ", "
2762 << "input_data_type = " << info.input_data_type << ", "
2763 << "axis = " << info.axis << "}";
2764 return os;
2765}
2766
2767/** Converts a @ref SoftmaxKernelInfo to string
2768 *
2769 * @param[in] info SoftmaxKernelInfo value to be converted
2770 *
2771 * @return String representing the corresponding SoftmaxKernelInfo
2772 */
2773inline std::string to_string(const SoftmaxKernelInfo &info)
2774{
2775 std::stringstream str;
2776 str << info;
2777 return str.str();
2778}
2779
2780/** Formatted output of the ScaleKernelInfo type.
2781 *
2782 * @param[out] os Output stream.
2783 * @param[in] lstm_params LSTMParams to output.
2784 *
2785 * @return Modified output stream.
2786 */
2787template <typename T>
ramelg014a6d9e82021-10-02 14:34:36 +01002788::std::ostream &operator<<(::std::ostream &os, const LSTMParams<T> &lstm_params)
ramelg01cbbb0382021-09-17 17:36:57 +01002789{
ramelg014a6d9e82021-10-02 14:34:36 +01002790 os << "{input_to_input_weights=" << to_string(lstm_params.input_to_input_weights()) << ", "
2791 << "recurrent_to_input_weights=" << to_string(lstm_params.recurrent_to_input_weights()) << ", "
2792 << "cell_to_input_weights=" << to_string(lstm_params.cell_to_input_weights()) << ", "
2793 << "input_gate_bias=" << to_string(lstm_params.input_gate_bias()) << ", "
2794 << "cell_to_forget_weights=" << to_string(lstm_params.cell_to_forget_weights()) << ", "
2795 << "cell_to_output_weights=" << to_string(lstm_params.cell_to_output_weights()) << ", "
2796 << "projection_weights=" << to_string(lstm_params.projection_weights()) << ", "
2797 << "projection_bias=" << to_string(lstm_params.projection_bias()) << ", "
2798 << "input_layer_norm_weights=" << to_string(lstm_params.input_layer_norm_weights()) << ", "
2799 << "forget_layer_norm_weights=" << to_string(lstm_params.forget_layer_norm_weights()) << ", "
2800 << "cell_layer_norm_weights=" << to_string(lstm_params.cell_layer_norm_weights()) << ", "
2801 << "output_layer_norm_weights=" << to_string(lstm_params.output_layer_norm_weights()) << ", "
ramelg01cbbb0382021-09-17 17:36:57 +01002802 << "cell_clip=" << lstm_params.cell_clip() << ", "
2803 << "projection_clip=" << lstm_params.projection_clip() << ", "
2804 << "input_intermediate_scale=" << lstm_params.input_intermediate_scale() << ", "
2805 << "forget_intermediate_scale=" << lstm_params.forget_intermediate_scale() << ", "
2806 << "cell_intermediate_scale=" << lstm_params.cell_intermediate_scale() << ", "
2807 << "hidden_state_zero=" << lstm_params.hidden_state_zero() << ", "
2808 << "hidden_state_scale=" << lstm_params.hidden_state_scale() << ", "
2809 << "has_peephole_opt=" << lstm_params.has_peephole_opt() << ", "
2810 << "has_projection=" << lstm_params.has_projection() << ", "
2811 << "has_cifg_opt=" << lstm_params.has_cifg_opt() << ", "
2812 << "use_layer_norm=" << lstm_params.use_layer_norm() << "}";
2813 return os;
2814}
2815
2816/** Converts a @ref LSTMParams to string
2817 *
2818 * @param[in] lstm_params LSTMParams<T> value to be converted
2819 *
2820 * @return String representing the corresponding LSTMParams
2821 */
2822template <typename T>
ramelg014a6d9e82021-10-02 14:34:36 +01002823std::string to_string(const LSTMParams<T> &lstm_params)
ramelg01cbbb0382021-09-17 17:36:57 +01002824{
2825 std::stringstream str;
2826 str << lstm_params;
2827 return str.str();
2828}
2829
2830/** Converts a @ref LSTMParams to string
2831 *
2832 * @param[in] num uint8_t value to be converted
2833 *
2834 * @return String representing the corresponding uint8_t
2835 */
2836inline std::string to_string(const uint8_t num)
2837{
2838 // Explicity cast the uint8_t to signed integer and call the corresponding overloaded to_string() function.
2839 return ::std::to_string(static_cast<int>(num));
2840}
2841
ramelg014a6d9e82021-10-02 14:34:36 +01002842/** Available non maxima suppression types */
2843/** Formatted output of the NMSType type.
2844 *
2845 * @param[out] os Output stream.
2846 * @param[in] nms_type NMSType to output.
2847 *
2848 * @return Modified output stream.
2849 */
2850inline ::std::ostream &operator<<(::std::ostream &os, const NMSType &nms_type)
2851{
2852 switch(nms_type)
2853 {
2854 case NMSType::LINEAR:
2855 os << "LINEAR";
2856 break;
2857 case NMSType::GAUSSIAN:
2858 os << "GAUSSIAN";
2859 break;
2860 case NMSType::ORIGINAL:
2861 os << "ORIGINAL";
2862 break;
2863 default:
2864 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2865 }
2866 return os;
2867}
2868
2869/** Converts a @ref NMSType to string
2870 *
2871 * @param[in] nms_type NMSType value to be converted
2872 *
2873 * @return String representing the corresponding NMSType
2874 */
2875inline std::string to_string(const NMSType nms_type)
2876{
2877 std::stringstream str;
2878 str << nms_type;
2879 return str.str();
2880}
2881
2882/** Formatted output of the BoxNMSLimitInfo type.
2883 *
2884 * @param[out] os Output stream.
2885 * @param[in] info BoxNMSLimitInfo to output.
2886 *
2887 * @return Modified output stream.
2888 */
2889inline ::std::ostream &operator<<(::std::ostream &os, const BoxNMSLimitInfo &info)
2890{
2891 os << "{score_thresh = " << info.score_thresh() << ", "
2892 << "nms = " << info.nms() << ", "
2893 << "detections_per_im = " << info.detections_per_im() << ", "
2894 << "soft_nms_enabled = " << info.soft_nms_enabled() << ", "
2895 << "soft_nms_min_score_thres = " << info.soft_nms_min_score_thres() << ", "
2896 << "suppress_size = " << info.suppress_size() << ", "
2897 << "min_size = " << info.min_size() << ", "
2898 << "im_width = " << info.im_width() << ", "
2899 << "im_height = " << info.im_height() << "}";
2900 return os;
2901}
2902
2903/** Converts a @ref BoxNMSLimitInfo to string
2904 *
2905 * @param[in] info BoxNMSLimitInfo value to be converted
2906 *
2907 * @return String representing the corresponding BoxNMSLimitInfo
2908 */
2909inline std::string to_string(const BoxNMSLimitInfo &info)
2910{
2911 std::stringstream str;
2912 str << info;
2913 return str.str();
2914}
2915
Anthony Barbier6ff3b192017-09-04 18:44:23 +01002916} // namespace arm_compute
Anthony Barbier4dbc0a92018-08-27 13:39:47 +01002917
2918#endif /* __ARM_COMPUTE_TYPE_PRINTER_H__ */