• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2017-2020 Arm Limited.
3  *
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  */
24 #ifndef __ARM_COMPUTE_TYPE_PRINTER_H__
25 #define __ARM_COMPUTE_TYPE_PRINTER_H__
26 
27 #include "arm_compute/core/CPP/CPPTypes.h"
28 #include "arm_compute/core/Dimensions.h"
29 #include "arm_compute/core/Error.h"
30 #include "arm_compute/core/GPUTarget.h"
31 #include "arm_compute/core/HOGInfo.h"
32 #include "arm_compute/core/KernelDescriptors.h"
33 #include "arm_compute/core/Size2D.h"
34 #include "arm_compute/core/Strides.h"
35 #include "arm_compute/core/TensorInfo.h"
36 #include "arm_compute/core/Types.h"
37 #include "arm_compute/runtime/CL/CLTunerTypes.h"
38 #include "support/StringSupport.h"
39 
40 #include <ostream>
41 #include <sstream>
42 #include <string>
43 
44 namespace arm_compute
45 {
46 /** Formatted output if arg is not null
47  *
48  * @param[in] arg Object to print
49  *
50  * @return String representing arg.
51  */
52 template <typename T>
to_string_if_not_null(T * arg)53 std::string to_string_if_not_null(T *arg)
54 {
55     if(arg == nullptr)
56     {
57         return "nullptr";
58     }
59     else
60     {
61         return to_string(*arg);
62     }
63 }
64 
65 /** Formatted output of the Dimensions type.
66  *
67  * @param[out] os         Output stream.
68  * @param[in]  dimensions Type to output.
69  *
70  * @return Modified output stream.
71  */
72 template <typename T>
73 inline ::std::ostream &operator<<(::std::ostream &os, const Dimensions<T> &dimensions)
74 {
75     if(dimensions.num_dimensions() > 0)
76     {
77         os << dimensions[0];
78 
79         for(unsigned int d = 1; d < dimensions.num_dimensions(); ++d)
80         {
81             os << "x" << dimensions[d];
82         }
83     }
84 
85     return os;
86 }
87 
88 /** Formatted output of the NonLinearFilterFunction type.
89  *
90  * @param[out] os       Output stream.
91  * @param[in]  function Type to output.
92  *
93  * @return Modified output stream.
94  */
95 inline ::std::ostream &operator<<(::std::ostream &os, const NonLinearFilterFunction &function)
96 {
97     switch(function)
98     {
99         case NonLinearFilterFunction::MAX:
100             os << "MAX";
101             break;
102         case NonLinearFilterFunction::MEDIAN:
103             os << "MEDIAN";
104             break;
105         case NonLinearFilterFunction::MIN:
106             os << "MIN";
107             break;
108         default:
109             ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
110     }
111 
112     return os;
113 }
114 
115 /** Formatted output of the NonLinearFilterFunction type.
116  *
117  * @param[in] function Type to output.
118  *
119  * @return Formatted string.
120  */
to_string(const NonLinearFilterFunction & function)121 inline std::string to_string(const NonLinearFilterFunction &function)
122 {
123     std::stringstream str;
124     str << function;
125     return str.str();
126 }
127 
128 /** Formatted output of the MatrixPattern type.
129  *
130  * @param[out] os      Output stream.
131  * @param[in]  pattern Type to output.
132  *
133  * @return Modified output stream.
134  */
135 inline ::std::ostream &operator<<(::std::ostream &os, const MatrixPattern &pattern)
136 {
137     switch(pattern)
138     {
139         case MatrixPattern::BOX:
140             os << "BOX";
141             break;
142         case MatrixPattern::CROSS:
143             os << "CROSS";
144             break;
145         case MatrixPattern::DISK:
146             os << "DISK";
147             break;
148         case MatrixPattern::OTHER:
149             os << "OTHER";
150             break;
151         default:
152             ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
153     }
154 
155     return os;
156 }
157 
158 /** Formatted output of the MatrixPattern type.
159  *
160  * @param[in] pattern Type to output.
161  *
162  * @return Formatted string.
163  */
to_string(const MatrixPattern & pattern)164 inline std::string to_string(const MatrixPattern &pattern)
165 {
166     std::stringstream str;
167     str << pattern;
168     return str.str();
169 }
170 
171 /** Formatted output of the RoundingPolicy type.
172  *
173  * @param[out] os              Output stream.
174  * @param[in]  rounding_policy Type to output.
175  *
176  * @return Modified output stream.
177  */
178 inline ::std::ostream &operator<<(::std::ostream &os, const RoundingPolicy &rounding_policy)
179 {
180     switch(rounding_policy)
181     {
182         case RoundingPolicy::TO_ZERO:
183             os << "TO_ZERO";
184             break;
185         case RoundingPolicy::TO_NEAREST_UP:
186             os << "TO_NEAREST_UP";
187             break;
188         case RoundingPolicy::TO_NEAREST_EVEN:
189             os << "TO_NEAREST_EVEN";
190             break;
191         default:
192             ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
193     }
194 
195     return os;
196 }
197 
198 /** Formatted output of the WeightsInfo type.
199  *
200  * @param[out] os           Output stream.
201  * @param[in]  weights_info Type to output.
202  *
203  * @return Modified output stream.
204  */
205 inline ::std::ostream &operator<<(::std::ostream &os, const WeightsInfo &weights_info)
206 {
207     os << weights_info.are_reshaped() << ";";
208     os << weights_info.num_kernels() << ";" << weights_info.kernel_size().first << "," << weights_info.kernel_size().second;
209 
210     return os;
211 }
212 
213 /** Formatted output of the ROIPoolingInfo type.
214  *
215  * @param[out] os        Output stream.
216  * @param[in]  pool_info Type to output.
217  *
218  * @return Modified output stream.
219  */
220 inline ::std::ostream &operator<<(::std::ostream &os, const ROIPoolingLayerInfo &pool_info)
221 {
222     os << pool_info.pooled_width() << "x" << pool_info.pooled_height() << "~" << pool_info.spatial_scale();
223     return os;
224 }
225 
226 /** Formatted output of the ROIPoolingInfo type.
227  *
228  * @param[in] pool_info Type to output.
229  *
230  * @return Formatted string.
231  */
to_string(const ROIPoolingLayerInfo & pool_info)232 inline std::string to_string(const ROIPoolingLayerInfo &pool_info)
233 {
234     std::stringstream str;
235     str << pool_info;
236     return str.str();
237 }
238 
239 /** Formatted output of the GEMMKernelInfo type.
240  *
241  * @param[out] os        Output stream.
242  * @param[in]  gemm_info Type to output.
243  *
244  * @return Modified output stream.
245  */
246 inline ::std::ostream &operator<<(::std::ostream &os, const GEMMKernelInfo &gemm_info)
247 {
248     os << "( m= " << gemm_info.m;
249     os << " n= " << gemm_info.n;
250     os << " k= " << gemm_info.k;
251     os << " depth_output_gemm3d= " << gemm_info.depth_output_gemm3d;
252     os << " reinterpret_input_as_3d= " << gemm_info.reinterpret_input_as_3d;
253     os << " broadcast_bias= " << gemm_info.broadcast_bias;
254     os << " fp_mixed_precision= " << gemm_info.fp_mixed_precision;
255     os << " mult_transpose1xW_width= " << gemm_info.mult_transpose1xW_width;
256     os << " mult_interleave4x4_height= " << gemm_info.mult_interleave4x4_height;
257     os << " a_offset = " << gemm_info.a_offset;
258     os << " b_offset = " << gemm_info.b_offset;
259     os << ")";
260     return os;
261 }
262 
263 /** Formatted output of the GEMMLHSMatrixInfo type.
264  *
265  * @param[out] os        Output stream.
266  * @param[in]  gemm_info Type to output.
267  *
268  * @return Modified output stream.
269  */
270 inline ::std::ostream &operator<<(::std::ostream &os, const GEMMLHSMatrixInfo &gemm_info)
271 {
272     os << "( m0= " << (unsigned int)gemm_info.m0 << " k0= " << gemm_info.k0 << "  v0= " << gemm_info.v0 << "  trans= " << gemm_info.transpose << "  inter= " << gemm_info.interleave << "})";
273     return os;
274 }
275 
276 /** Formatted output of the GEMMRHSMatrixInfo type.
277  *
278  * @param[out] os        Output stream.
279  * @param[in]  gemm_info Type to output.
280  *
281  * @return Modified output stream.
282  */
283 inline ::std::ostream &operator<<(::std::ostream &os, const GEMMRHSMatrixInfo &gemm_info)
284 {
285     os << "( n0= " << (unsigned int)gemm_info.n0 << " k0= " << gemm_info.k0 << "  h0= " << gemm_info.h0 << "  trans= " << gemm_info.transpose << "  inter= " << gemm_info.interleave << "})";
286     return os;
287 }
288 
289 /** Formatted output of the GEMMRHSMatrixInfo type.
290  *
291  * @param[in] gemm_info GEMMRHSMatrixInfo to output.
292  *
293  * @return Formatted string.
294  */
to_string(const GEMMRHSMatrixInfo & gemm_info)295 inline std::string to_string(const GEMMRHSMatrixInfo &gemm_info)
296 {
297     std::stringstream str;
298     str << gemm_info;
299     return str.str();
300 }
301 
302 /** Formatted output of the GEMMLHSMatrixInfo type.
303  *
304  * @param[in] gemm_info GEMMLHSMatrixInfo to output.
305  *
306  * @return Formatted string.
307  */
to_string(const GEMMLHSMatrixInfo & gemm_info)308 inline std::string to_string(const GEMMLHSMatrixInfo &gemm_info)
309 {
310     std::stringstream str;
311     str << gemm_info;
312     return str.str();
313 }
314 
315 /** Formatted output of the GEMMKernelInfo type.
316  *
317  * @param[in] gemm_info GEMMKernelInfo Type to output.
318  *
319  * @return Formatted string.
320  */
to_string(const GEMMKernelInfo & gemm_info)321 inline std::string to_string(const GEMMKernelInfo &gemm_info)
322 {
323     std::stringstream str;
324     str << gemm_info;
325     return str.str();
326 }
327 
328 /** Formatted output of the BoundingBoxTransformInfo type.
329  *
330  * @param[out] os        Output stream.
331  * @param[in]  bbox_info Type to output.
332  *
333  * @return Modified output stream.
334  */
335 inline ::std::ostream &operator<<(::std::ostream &os, const BoundingBoxTransformInfo &bbox_info)
336 {
337     auto weights = bbox_info.weights();
338     os << "(" << bbox_info.img_width() << "x" << bbox_info.img_height() << ")~" << bbox_info.scale() << "(weights = {" << weights[0] << ", " << weights[1] << ", " << weights[2] << ", " << weights[3] <<
339        "})";
340     return os;
341 }
342 
343 /** Formatted output of the BoundingBoxTransformInfo type.
344  *
345  * @param[in] bbox_info Type to output.
346  *
347  * @return Formatted string.
348  */
to_string(const BoundingBoxTransformInfo & bbox_info)349 inline std::string to_string(const BoundingBoxTransformInfo &bbox_info)
350 {
351     std::stringstream str;
352     str << bbox_info;
353     return str.str();
354 }
355 
356 /** Formatted output of the ComputeAnchorsInfo type.
357  *
358  * @param[out] os           Output stream.
359  * @param[in]  anchors_info Type to output.
360  *
361  * @return Modified output stream.
362  */
363 inline ::std::ostream &operator<<(::std::ostream &os, const ComputeAnchorsInfo &anchors_info)
364 {
365     os << "(" << anchors_info.feat_width() << "x" << anchors_info.feat_height() << ")~" << anchors_info.spatial_scale();
366     return os;
367 }
368 
369 /** Formatted output of the ComputeAnchorsInfo type.
370  *
371  * @param[in] anchors_info Type to output.
372  *
373  * @return Formatted string.
374  */
to_string(const ComputeAnchorsInfo & anchors_info)375 inline std::string to_string(const ComputeAnchorsInfo &anchors_info)
376 {
377     std::stringstream str;
378     str << anchors_info;
379     return str.str();
380 }
381 
382 /** Formatted output of the GenerateProposalsInfo type.
383  *
384  * @param[out] os             Output stream.
385  * @param[in]  proposals_info Type to output.
386  *
387  * @return Modified output stream.
388  */
389 inline ::std::ostream &operator<<(::std::ostream &os, const GenerateProposalsInfo &proposals_info)
390 {
391     os << "(" << proposals_info.im_width() << "x" << proposals_info.im_height() << ")~" << proposals_info.im_scale();
392     return os;
393 }
394 
395 /** Formatted output of the GenerateProposalsInfo type.
396  *
397  * @param[in] proposals_info Type to output.
398  *
399  * @return Formatted string.
400  */
to_string(const GenerateProposalsInfo & proposals_info)401 inline std::string to_string(const GenerateProposalsInfo &proposals_info)
402 {
403     std::stringstream str;
404     str << proposals_info;
405     return str.str();
406 }
407 
408 /** Formatted output of the QuantizationInfo type.
409  *
410  * @param[out] os    Output stream.
411  * @param[in]  qinfo Type to output.
412  *
413  * @return Modified output stream.
414  */
415 inline ::std::ostream &operator<<(::std::ostream &os, const QuantizationInfo &qinfo)
416 {
417     const UniformQuantizationInfo uqinfo = qinfo.uniform();
418     os << "Scale:" << uqinfo.scale << "~";
419     os << "Offset:" << uqinfo.offset;
420     return os;
421 }
422 
423 /** Formatted output of the QuantizationInfo type.
424  *
425  * @param[in] quantization_info Type to output.
426  *
427  * @return Formatted string.
428  */
to_string(const QuantizationInfo & quantization_info)429 inline std::string to_string(const QuantizationInfo &quantization_info)
430 {
431     std::stringstream str;
432     str << quantization_info;
433     return str.str();
434 }
435 
436 /** Formatted output of the activation function type.
437  *
438  * @param[out] os           Output stream.
439  * @param[in]  act_function Type to output.
440  *
441  * @return Modified output stream.
442  */
443 inline ::std::ostream &operator<<(::std::ostream &os, const ActivationLayerInfo::ActivationFunction &act_function)
444 {
445     switch(act_function)
446     {
447         case ActivationLayerInfo::ActivationFunction::ABS:
448             os << "ABS";
449             break;
450         case ActivationLayerInfo::ActivationFunction::LINEAR:
451             os << "LINEAR";
452             break;
453         case ActivationLayerInfo::ActivationFunction::LOGISTIC:
454             os << "LOGISTIC";
455             break;
456         case ActivationLayerInfo::ActivationFunction::RELU:
457             os << "RELU";
458             break;
459         case ActivationLayerInfo::ActivationFunction::BOUNDED_RELU:
460             os << "BOUNDED_RELU";
461             break;
462         case ActivationLayerInfo::ActivationFunction::LEAKY_RELU:
463             os << "LEAKY_RELU";
464             break;
465         case ActivationLayerInfo::ActivationFunction::SOFT_RELU:
466             os << "SOFT_RELU";
467             break;
468         case ActivationLayerInfo::ActivationFunction::SQRT:
469             os << "SQRT";
470             break;
471         case ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU:
472             os << "LU_BOUNDED_RELU";
473             break;
474         case ActivationLayerInfo::ActivationFunction::ELU:
475             os << "ELU";
476             break;
477         case ActivationLayerInfo::ActivationFunction::SQUARE:
478             os << "SQUARE";
479             break;
480         case ActivationLayerInfo::ActivationFunction::TANH:
481             os << "TANH";
482             break;
483         case ActivationLayerInfo::ActivationFunction::IDENTITY:
484             os << "IDENTITY";
485             break;
486         case ActivationLayerInfo::ActivationFunction::HARD_SWISH:
487             os << "HARD_SWISH";
488             break;
489 
490         default:
491             ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
492     }
493 
494     return os;
495 }
496 
497 /** Formatted output of the activation function info type.
498  *
499  * @param[in] info Type to output.
500  *
501  * @return Formatted string.
502  */
to_string(const arm_compute::ActivationLayerInfo & info)503 inline std::string to_string(const arm_compute::ActivationLayerInfo &info)
504 {
505     std::stringstream str;
506     if(info.enabled())
507     {
508         str << info.activation();
509     }
510     return str.str();
511 }
512 
513 /** Formatted output of the activation function type.
514  *
515  * @param[in] function Type to output.
516  *
517  * @return Formatted string.
518  */
to_string(const arm_compute::ActivationLayerInfo::ActivationFunction & function)519 inline std::string to_string(const arm_compute::ActivationLayerInfo::ActivationFunction &function)
520 {
521     std::stringstream str;
522     str << function;
523     return str.str();
524 }
525 
526 /** Formatted output of the NormType type.
527  *
528  * @param[out] os        Output stream.
529  * @param[in]  norm_type Type to output.
530  *
531  * @return Modified output stream.
532  */
533 inline ::std::ostream &operator<<(::std::ostream &os, const NormType &norm_type)
534 {
535     switch(norm_type)
536     {
537         case NormType::CROSS_MAP:
538             os << "CROSS_MAP";
539             break;
540         case NormType::IN_MAP_1D:
541             os << "IN_MAP_1D";
542             break;
543         case NormType::IN_MAP_2D:
544             os << "IN_MAP_2D";
545             break;
546         default:
547             ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
548     }
549 
550     return os;
551 }
552 
553 /** Formatted output of @ref NormalizationLayerInfo.
554  *
555  * @param[in] info Type to output.
556  *
557  * @return Formatted string.
558  */
to_string(const arm_compute::NormalizationLayerInfo & info)559 inline std::string to_string(const arm_compute::NormalizationLayerInfo &info)
560 {
561     std::stringstream str;
562     str << info.type() << ":NormSize=" << info.norm_size();
563     return str.str();
564 }
565 
566 /** Formatted output of @ref NormalizationLayerInfo.
567  *
568  * @param[out] os   Output stream.
569  * @param[in]  info Type to output.
570  *
571  * @return Modified output stream.
572  */
573 inline ::std::ostream &operator<<(::std::ostream &os, const NormalizationLayerInfo &info)
574 {
575     os << info.type() << ":NormSize=" << info.norm_size();
576     return os;
577 }
578 
579 /** Formatted output of the PoolingType type.
580  *
581  * @param[out] os        Output stream.
582  * @param[in]  pool_type Type to output.
583  *
584  * @return Modified output stream.
585  */
586 inline ::std::ostream &operator<<(::std::ostream &os, const PoolingType &pool_type)
587 {
588     switch(pool_type)
589     {
590         case PoolingType::AVG:
591             os << "AVG";
592             break;
593         case PoolingType::MAX:
594             os << "MAX";
595             break;
596         case PoolingType::L2:
597             os << "L2";
598             break;
599         default:
600             ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
601     }
602 
603     return os;
604 }
605 
606 /** Formatted output of @ref PoolingLayerInfo.
607  *
608  * @param[out] os   Output stream.
609  * @param[in]  info Type to output.
610  *
611  * @return Modified output stream.
612  */
613 inline ::std::ostream &operator<<(::std::ostream &os, const PoolingLayerInfo &info)
614 {
615     os << info.pool_type;
616 
617     return os;
618 }
619 
620 /** Formatted output of @ref RoundingPolicy.
621  *
622  * @param[in] rounding_policy Type to output.
623  *
624  * @return Formatted string.
625  */
to_string(const RoundingPolicy & rounding_policy)626 inline std::string to_string(const RoundingPolicy &rounding_policy)
627 {
628     std::stringstream str;
629     str << rounding_policy;
630     return str.str();
631 }
632 
633 /** [Print DataLayout type] **/
634 /** Formatted output of the DataLayout type.
635  *
636  * @param[out] os          Output stream.
637  * @param[in]  data_layout Type to output.
638  *
639  * @return Modified output stream.
640  */
641 inline ::std::ostream &operator<<(::std::ostream &os, const DataLayout &data_layout)
642 {
643     switch(data_layout)
644     {
645         case DataLayout::UNKNOWN:
646             os << "UNKNOWN";
647             break;
648         case DataLayout::NHWC:
649             os << "NHWC";
650             break;
651         case DataLayout::NCHW:
652             os << "NCHW";
653             break;
654         default:
655             ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
656     }
657 
658     return os;
659 }
660 
661 /** Formatted output of the DataLayout type.
662  *
663  * @param[in] data_layout Type to output.
664  *
665  * @return Formatted string.
666  */
to_string(const arm_compute::DataLayout & data_layout)667 inline std::string to_string(const arm_compute::DataLayout &data_layout)
668 {
669     std::stringstream str;
670     str << data_layout;
671     return str.str();
672 }
673 /** [Print DataLayout type] **/
674 
675 /** Formatted output of the DataLayoutDimension type.
676  *
677  * @param[out] os              Output stream.
678  * @param[in]  data_layout_dim Data layout dimension to print.
679  *
680  * @return Modified output stream.
681  */
682 inline ::std::ostream &operator<<(::std::ostream &os, const DataLayoutDimension &data_layout_dim)
683 {
684     switch(data_layout_dim)
685     {
686         case DataLayoutDimension::WIDTH:
687             os << "WIDTH";
688             break;
689         case DataLayoutDimension::HEIGHT:
690             os << "HEIGHT";
691             break;
692         case DataLayoutDimension::CHANNEL:
693             os << "CHANNEL";
694             break;
695         case DataLayoutDimension::BATCHES:
696             os << "BATCHES";
697             break;
698         default:
699             ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
700     }
701     return os;
702 }
703 
704 /** Formatted output of the DataType type.
705  *
706  * @param[out] os        Output stream.
707  * @param[in]  data_type Type to output.
708  *
709  * @return Modified output stream.
710  */
711 inline ::std::ostream &operator<<(::std::ostream &os, const DataType &data_type)
712 {
713     switch(data_type)
714     {
715         case DataType::UNKNOWN:
716             os << "UNKNOWN";
717             break;
718         case DataType::U8:
719             os << "U8";
720             break;
721         case DataType::QSYMM8:
722             os << "QSYMM8";
723             break;
724         case DataType::QASYMM8:
725             os << "QASYMM8";
726             break;
727         case DataType::QASYMM8_SIGNED:
728             os << "QASYMM8_SIGNED";
729             break;
730         case DataType::QSYMM8_PER_CHANNEL:
731             os << "QSYMM8_PER_CHANNEL";
732             break;
733         case DataType::S8:
734             os << "S8";
735             break;
736         case DataType::U16:
737             os << "U16";
738             break;
739         case DataType::S16:
740             os << "S16";
741             break;
742         case DataType::QSYMM16:
743             os << "QSYMM16";
744             break;
745         case DataType::QASYMM16:
746             os << "QASYMM16";
747             break;
748         case DataType::U32:
749             os << "U32";
750             break;
751         case DataType::S32:
752             os << "S32";
753             break;
754         case DataType::U64:
755             os << "U64";
756             break;
757         case DataType::S64:
758             os << "S64";
759             break;
760         case DataType::BFLOAT16:
761             os << "BFLOAT16";
762             break;
763         case DataType::F16:
764             os << "F16";
765             break;
766         case DataType::F32:
767             os << "F32";
768             break;
769         case DataType::F64:
770             os << "F64";
771             break;
772         case DataType::SIZET:
773             os << "SIZET";
774             break;
775         default:
776             ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
777     }
778 
779     return os;
780 }
781 
782 /** Formatted output of the DataType type.
783  *
784  * @param[in] data_type Type to output.
785  *
786  * @return Formatted string.
787  */
to_string(const arm_compute::DataType & data_type)788 inline std::string to_string(const arm_compute::DataType &data_type)
789 {
790     std::stringstream str;
791     str << data_type;
792     return str.str();
793 }
794 
795 /** Formatted output of the Format type.
796  *
797  * @param[out] os     Output stream.
798  * @param[in]  format Type to output.
799  *
800  * @return Modified output stream.
801  */
802 inline ::std::ostream &operator<<(::std::ostream &os, const Format &format)
803 {
804     switch(format)
805     {
806         case Format::UNKNOWN:
807             os << "UNKNOWN";
808             break;
809         case Format::U8:
810             os << "U8";
811             break;
812         case Format::S16:
813             os << "S16";
814             break;
815         case Format::U16:
816             os << "U16";
817             break;
818         case Format::S32:
819             os << "S32";
820             break;
821         case Format::U32:
822             os << "U32";
823             break;
824         case Format::F16:
825             os << "F16";
826             break;
827         case Format::F32:
828             os << "F32";
829             break;
830         case Format::UV88:
831             os << "UV88";
832             break;
833         case Format::RGB888:
834             os << "RGB888";
835             break;
836         case Format::RGBA8888:
837             os << "RGBA8888";
838             break;
839         case Format::YUV444:
840             os << "YUV444";
841             break;
842         case Format::YUYV422:
843             os << "YUYV422";
844             break;
845         case Format::NV12:
846             os << "NV12";
847             break;
848         case Format::NV21:
849             os << "NV21";
850             break;
851         case Format::IYUV:
852             os << "IYUV";
853             break;
854         case Format::UYVY422:
855             os << "UYVY422";
856             break;
857         default:
858             ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
859     }
860 
861     return os;
862 }
863 
864 /** Formatted output of the Format type.
865  *
866  * @param[in] format Type to output.
867  *
868  * @return Formatted string.
869  */
to_string(const Format & format)870 inline std::string to_string(const Format &format)
871 {
872     std::stringstream str;
873     str << format;
874     return str.str();
875 }
876 
877 /** Formatted output of the Channel type.
878  *
879  * @param[out] os      Output stream.
880  * @param[in]  channel Type to output.
881  *
882  * @return Modified output stream.
883  */
884 inline ::std::ostream &operator<<(::std::ostream &os, const Channel &channel)
885 {
886     switch(channel)
887     {
888         case Channel::UNKNOWN:
889             os << "UNKNOWN";
890             break;
891         case Channel::C0:
892             os << "C0";
893             break;
894         case Channel::C1:
895             os << "C1";
896             break;
897         case Channel::C2:
898             os << "C2";
899             break;
900         case Channel::C3:
901             os << "C3";
902             break;
903         case Channel::R:
904             os << "R";
905             break;
906         case Channel::G:
907             os << "G";
908             break;
909         case Channel::B:
910             os << "B";
911             break;
912         case Channel::A:
913             os << "A";
914             break;
915         case Channel::Y:
916             os << "Y";
917             break;
918         case Channel::U:
919             os << "U";
920             break;
921         case Channel::V:
922             os << "V";
923             break;
924         default:
925             ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
926     }
927 
928     return os;
929 }
930 
931 /** Formatted output of the Channel type.
932  *
933  * @param[in] channel Type to output.
934  *
935  * @return Formatted string.
936  */
to_string(const Channel & channel)937 inline std::string to_string(const Channel &channel)
938 {
939     std::stringstream str;
940     str << channel;
941     return str.str();
942 }
943 
944 /** Formatted output of the BorderMode type.
945  *
946  * @param[out] os   Output stream.
947  * @param[in]  mode Type to output.
948  *
949  * @return Modified output stream.
950  */
951 inline ::std::ostream &operator<<(::std::ostream &os, const BorderMode &mode)
952 {
953     switch(mode)
954     {
955         case BorderMode::UNDEFINED:
956             os << "UNDEFINED";
957             break;
958         case BorderMode::CONSTANT:
959             os << "CONSTANT";
960             break;
961         case BorderMode::REPLICATE:
962             os << "REPLICATE";
963             break;
964         default:
965             ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
966     }
967 
968     return os;
969 }
970 
971 /** Formatted output of the BorderSize type.
972  *
973  * @param[out] os     Output stream.
974  * @param[in]  border Type to output.
975  *
976  * @return Modified output stream.
977  */
978 inline ::std::ostream &operator<<(::std::ostream &os, const BorderSize &border)
979 {
980     os << border.top << ","
981        << border.right << ","
982        << border.bottom << ","
983        << border.left;
984 
985     return os;
986 }
987 
988 /** Formatted output of the PaddingList type.
989  *
990  * @param[out] os      Output stream.
991  * @param[in]  padding Type to output.
992  *
993  * @return Modified output stream.
994  */
995 inline ::std::ostream &operator<<(::std::ostream &os, const PaddingList &padding)
996 {
997     os << "{";
998     for(auto const &p : padding)
999     {
1000         os << "{" << p.first << "," << p.second << "}";
1001     }
1002     os << "}";
1003     return os;
1004 }
1005 
1006 /** Formatted output of the Multiples type.
1007  *
1008  * @param[out] os        Output stream.
1009  * @param[in]  multiples Type to output.
1010  *
1011  * @return Modified output stream.
1012  */
1013 inline ::std::ostream &operator<<(::std::ostream &os, const Multiples &multiples)
1014 {
1015     os << "(";
1016     for(size_t i = 0; i < multiples.size() - 1; i++)
1017     {
1018         os << multiples[i] << ", ";
1019     }
1020     os << multiples.back() << ")";
1021     return os;
1022 }
1023 
1024 /** Formatted output of the InterpolationPolicy type.
1025  *
1026  * @param[out] os     Output stream.
1027  * @param[in]  policy Type to output.
1028  *
1029  * @return Modified output stream.
1030  */
1031 inline ::std::ostream &operator<<(::std::ostream &os, const InterpolationPolicy &policy)
1032 {
1033     switch(policy)
1034     {
1035         case InterpolationPolicy::NEAREST_NEIGHBOR:
1036             os << "NEAREST_NEIGHBOR";
1037             break;
1038         case InterpolationPolicy::BILINEAR:
1039             os << "BILINEAR";
1040             break;
1041         case InterpolationPolicy::AREA:
1042             os << "AREA";
1043             break;
1044         default:
1045             ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1046     }
1047 
1048     return os;
1049 }
1050 
1051 /** Formatted output of the SamplingPolicy type.
1052  *
1053  * @param[out] os     Output stream.
1054  * @param[in]  policy Type to output.
1055  *
1056  * @return Modified output stream.
1057  */
1058 inline ::std::ostream &operator<<(::std::ostream &os, const SamplingPolicy &policy)
1059 {
1060     switch(policy)
1061     {
1062         case SamplingPolicy::CENTER:
1063             os << "CENTER";
1064             break;
1065         case SamplingPolicy::TOP_LEFT:
1066             os << "TOP_LEFT";
1067             break;
1068         default:
1069             ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1070     }
1071 
1072     return os;
1073 }
1074 
1075 /** Formatted output of the TensorInfo type.
1076  *
1077  * @param[out] os   Output stream.
1078  * @param[in]  info Type to output.
1079  *
1080  * @return Modified output stream.
1081  */
1082 inline ::std::ostream &operator<<(::std::ostream &os, const TensorInfo &info)
1083 {
1084     os << "{Shape=" << info.tensor_shape() << ","
1085        << "Type=" << info.data_type() << ","
1086        << "Channels=" << info.num_channels() << "}";
1087     return os;
1088 }
1089 /** Formatted output of the TensorInfo type.
1090  *
1091  * @param[in] info Type to output.
1092  *
1093  * @return Formatted string.
1094  */
to_string(const TensorInfo & info)1095 inline std::string to_string(const TensorInfo &info)
1096 {
1097     std::stringstream str;
1098     str << info;
1099     return str.str();
1100 }
1101 
1102 /** Formatted output of the Dimensions type.
1103  *
1104  * @param[in] dimensions Type to output.
1105  *
1106  * @return Formatted string.
1107  */
1108 template <typename T>
to_string(const Dimensions<T> & dimensions)1109 inline std::string to_string(const Dimensions<T> &dimensions)
1110 {
1111     std::stringstream str;
1112     str << dimensions;
1113     return str.str();
1114 }
1115 
1116 /** Formatted output of the Strides type.
1117  *
1118  * @param[in] stride Type to output.
1119  *
1120  * @return Formatted string.
1121  */
to_string(const Strides & stride)1122 inline std::string to_string(const Strides &stride)
1123 {
1124     std::stringstream str;
1125     str << stride;
1126     return str.str();
1127 }
1128 
1129 /** Formatted output of the TensorShape type.
1130  *
1131  * @param[in] shape Type to output.
1132  *
1133  * @return Formatted string.
1134  */
to_string(const TensorShape & shape)1135 inline std::string to_string(const TensorShape &shape)
1136 {
1137     std::stringstream str;
1138     str << shape;
1139     return str.str();
1140 }
1141 
1142 /** Formatted output of the Coordinates type.
1143  *
1144  * @param[in] coord Type to output.
1145  *
1146  * @return Formatted string.
1147  */
to_string(const Coordinates & coord)1148 inline std::string to_string(const Coordinates &coord)
1149 {
1150     std::stringstream str;
1151     str << coord;
1152     return str.str();
1153 }
1154 
1155 /** Formatted output of the GEMMReshapeInfo type.
1156  *
1157  * @param[out] os   Output stream.
1158  * @param[in]  info Type to output.
1159  *
1160  * @return Modified output stream.
1161  */
1162 inline ::std::ostream &operator<<(::std::ostream &os, const GEMMReshapeInfo &info)
1163 {
1164     os << "{m=" << info.m() << ",";
1165     os << "n=" << info.n() << ",";
1166     os << "k=" << info.k() << ",";
1167     os << "mult_transpose1xW_width=" << info.mult_transpose1xW_width() << ",";
1168     os << "mult_interleave4x4_height=" << info.mult_interleave4x4_height();
1169     os << "}";
1170 
1171     return os;
1172 }
1173 
1174 /** Formatted output of the GEMMInfo type.
1175  *
1176  * @param[out] os   Output stream.
1177  * @param[in]  info Type to output.
1178  *
1179  * @return Modified output stream.
1180  */
1181 inline ::std::ostream &operator<<(::std::ostream &os, const GEMMInfo &info)
1182 {
1183     os << "{is_a_reshaped=" << info.is_a_reshaped() << ",";
1184     os << "is_b_reshaped=" << info.is_b_reshaped() << ",";
1185     os << "reshape_b_only_on_first_run=" << info.reshape_b_only_on_first_run() << ",";
1186     os << "depth_output_gemm3d=" << info.depth_output_gemm3d() << ",";
1187     os << "reinterpret_input_as_3d=" << info.reinterpret_input_as_3d() << ",";
1188     os << "retain_internal_weights=" << info.retain_internal_weights() << ",";
1189     os << "fp_mixed_precision=" << info.fp_mixed_precision() << ",";
1190     os << "broadcast_bias=" << info.broadcast_bias() << ",";
1191     os << "pretranpose_B=" << info.pretranpose_B() << ",";
1192 
1193     return os;
1194 }
1195 
1196 /** Formatted output of the Window::Dimension type.
1197  *
1198  * @param[out] os  Output stream.
1199  * @param[in]  dim Type to output.
1200  *
1201  * @return Modified output stream.
1202  */
1203 inline ::std::ostream &operator<<(::std::ostream &os, const Window::Dimension &dim)
1204 {
1205     os << "{start=" << dim.start() << ", end=" << dim.end() << ", step=" << dim.step() << "}";
1206 
1207     return os;
1208 }
1209 /** Formatted output of the Window type.
1210  *
1211  * @param[out] os  Output stream.
1212  * @param[in]  win Type to output.
1213  *
1214  * @return Modified output stream.
1215  */
1216 inline ::std::ostream &operator<<(::std::ostream &os, const Window &win)
1217 {
1218     os << "{";
1219     for(unsigned int i = 0; i < Coordinates::num_max_dimensions; i++)
1220     {
1221         if(i > 0)
1222         {
1223             os << ", ";
1224         }
1225         os << win[i];
1226     }
1227     os << "}";
1228 
1229     return os;
1230 }
1231 
1232 /** Formatted output of the WeightsInfo type.
1233  *
1234  * @param[in] info Type to output.
1235  *
1236  * @return Formatted string.
1237  */
to_string(const WeightsInfo & info)1238 inline std::string to_string(const WeightsInfo &info)
1239 {
1240     std::stringstream str;
1241     str << info;
1242     return str.str();
1243 }
1244 
1245 /** Formatted output of the GEMMReshapeInfo type.
1246  *
1247  * @param[in] info Type to output.
1248  *
1249  * @return Formatted string.
1250  */
to_string(const GEMMReshapeInfo & info)1251 inline std::string to_string(const GEMMReshapeInfo &info)
1252 {
1253     std::stringstream str;
1254     str << info;
1255     return str.str();
1256 }
1257 
1258 /** Formatted output of the GEMMInfo type.
1259  *
1260  * @param[in] info Type to output.
1261  *
1262  * @return Formatted string.
1263  */
to_string(const GEMMInfo & info)1264 inline std::string to_string(const GEMMInfo &info)
1265 {
1266     std::stringstream str;
1267     str << info;
1268     return str.str();
1269 }
1270 
1271 /** Formatted output of the Window::Dimension type.
1272  *
1273  * @param[in] dim Type to output.
1274  *
1275  * @return Formatted string.
1276  */
to_string(const Window::Dimension & dim)1277 inline std::string to_string(const Window::Dimension &dim)
1278 {
1279     std::stringstream str;
1280     str << dim;
1281     return str.str();
1282 }
1283 /** Formatted output of the Window type.
1284  *
1285  * @param[in] win Type to output.
1286  *
1287  * @return Formatted string.
1288  */
to_string(const Window & win)1289 inline std::string to_string(const Window &win)
1290 {
1291     std::stringstream str;
1292     str << win;
1293     return str.str();
1294 }
1295 
1296 /** Formatted output of the Rectangle type.
1297  *
1298  * @param[out] os   Output stream.
1299  * @param[in]  rect Type to output.
1300  *
1301  * @return Modified output stream.
1302  */
1303 inline ::std::ostream &operator<<(::std::ostream &os, const Rectangle &rect)
1304 {
1305     os << rect.width << "x" << rect.height;
1306     os << "+" << rect.x << "+" << rect.y;
1307 
1308     return os;
1309 }
1310 
1311 /** Formatted output of the PaddingMode type.
1312  *
1313  * @param[out] os   Output stream.
1314  * @param[in]  mode Type to output.
1315  *
1316  * @return Modified output stream.
1317  */
1318 inline ::std::ostream &operator<<(::std::ostream &os, const PaddingMode &mode)
1319 {
1320     switch(mode)
1321     {
1322         case PaddingMode::CONSTANT:
1323             os << "CONSTANT";
1324             break;
1325         case PaddingMode::REFLECT:
1326             os << "REFLECT";
1327             break;
1328         case PaddingMode::SYMMETRIC:
1329             os << "SYMMETRIC";
1330             break;
1331         default:
1332             ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1333     }
1334 
1335     return os;
1336 }
1337 
1338 /** Formatted output of the PaddingMode type.
1339  *
1340  * @param[in] mode Type to output.
1341  *
1342  * @return Formatted string.
1343  */
to_string(const PaddingMode & mode)1344 inline std::string to_string(const PaddingMode &mode)
1345 {
1346     std::stringstream str;
1347     str << mode;
1348     return str.str();
1349 }
1350 
1351 /** Formatted output of the PadStrideInfo type.
1352  *
1353  * @param[out] os              Output stream.
1354  * @param[in]  pad_stride_info Type to output.
1355  *
1356  * @return Modified output stream.
1357  */
1358 inline ::std::ostream &operator<<(::std::ostream &os, const PadStrideInfo &pad_stride_info)
1359 {
1360     os << pad_stride_info.stride().first << "," << pad_stride_info.stride().second;
1361     os << ";";
1362     os << pad_stride_info.pad_left() << "," << pad_stride_info.pad_right() << ","
1363        << pad_stride_info.pad_top() << "," << pad_stride_info.pad_bottom();
1364 
1365     return os;
1366 }
1367 
1368 /** Formatted output of the PadStrideInfo type.
1369  *
1370  * @param[in] pad_stride_info Type to output.
1371  *
1372  * @return Formatted string.
1373  */
to_string(const PadStrideInfo & pad_stride_info)1374 inline std::string to_string(const PadStrideInfo &pad_stride_info)
1375 {
1376     std::stringstream str;
1377     str << pad_stride_info;
1378     return str.str();
1379 }
1380 
1381 /** Formatted output of the BorderMode type.
1382  *
1383  * @param[in] mode Type to output.
1384  *
1385  * @return Formatted string.
1386  */
to_string(const BorderMode & mode)1387 inline std::string to_string(const BorderMode &mode)
1388 {
1389     std::stringstream str;
1390     str << mode;
1391     return str.str();
1392 }
1393 
1394 /** Formatted output of the BorderSize type.
1395  *
1396  * @param[in] border Type to output.
1397  *
1398  * @return Formatted string.
1399  */
to_string(const BorderSize & border)1400 inline std::string to_string(const BorderSize &border)
1401 {
1402     std::stringstream str;
1403     str << border;
1404     return str.str();
1405 }
1406 
1407 /** Formatted output of the PaddingList type.
1408  *
1409  * @param[in] padding Type to output.
1410  *
1411  * @return Formatted string.
1412  */
to_string(const PaddingList & padding)1413 inline std::string to_string(const PaddingList &padding)
1414 {
1415     std::stringstream str;
1416     str << padding;
1417     return str.str();
1418 }
1419 
1420 /** Formatted output of the Multiples type.
1421  *
1422  * @param[in] multiples Type to output.
1423  *
1424  * @return Formatted string.
1425  */
to_string(const Multiples & multiples)1426 inline std::string to_string(const Multiples &multiples)
1427 {
1428     std::stringstream str;
1429     str << multiples;
1430     return str.str();
1431 }
1432 
1433 /** Formatted output of the InterpolationPolicy type.
1434  *
1435  * @param[in] policy Type to output.
1436  *
1437  * @return Formatted string.
1438  */
to_string(const InterpolationPolicy & policy)1439 inline std::string to_string(const InterpolationPolicy &policy)
1440 {
1441     std::stringstream str;
1442     str << policy;
1443     return str.str();
1444 }
1445 
1446 /** Formatted output of the SamplingPolicy type.
1447  *
1448  * @param[in] policy Type to output.
1449  *
1450  * @return Formatted string.
1451  */
to_string(const SamplingPolicy & policy)1452 inline std::string to_string(const SamplingPolicy &policy)
1453 {
1454     std::stringstream str;
1455     str << policy;
1456     return str.str();
1457 }
1458 
1459 /** Formatted output of the ConvertPolicy type.
1460  *
1461  * @param[out] os     Output stream.
1462  * @param[in]  policy Type to output.
1463  *
1464  * @return Modified output stream.
1465  */
1466 inline ::std::ostream &operator<<(::std::ostream &os, const ConvertPolicy &policy)
1467 {
1468     switch(policy)
1469     {
1470         case ConvertPolicy::WRAP:
1471             os << "WRAP";
1472             break;
1473         case ConvertPolicy::SATURATE:
1474             os << "SATURATE";
1475             break;
1476         default:
1477             ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1478     }
1479 
1480     return os;
1481 }
1482 
to_string(const ConvertPolicy & policy)1483 inline std::string to_string(const ConvertPolicy &policy)
1484 {
1485     std::stringstream str;
1486     str << policy;
1487     return str.str();
1488 }
1489 
1490 /** Formatted output of the ArithmeticOperation type.
1491  *
1492  * @param[out] os Output stream.
1493  * @param[in]  op Operation to output.
1494  *
1495  * @return Modified output stream.
1496  */
1497 inline ::std::ostream &operator<<(::std::ostream &os, const ArithmeticOperation &op)
1498 {
1499     switch(op)
1500     {
1501         case ArithmeticOperation::ADD:
1502             os << "ADD";
1503             break;
1504         case ArithmeticOperation::SUB:
1505             os << "SUB";
1506             break;
1507         case ArithmeticOperation::DIV:
1508             os << "DIV";
1509             break;
1510         case ArithmeticOperation::MAX:
1511             os << "MAX";
1512             break;
1513         case ArithmeticOperation::MIN:
1514             os << "MIN";
1515             break;
1516         case ArithmeticOperation::SQUARED_DIFF:
1517             os << "SQUARED_DIFF";
1518             break;
1519         case ArithmeticOperation::POWER:
1520             os << "POWER";
1521             break;
1522         default:
1523             ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1524     }
1525 
1526     return os;
1527 }
1528 
1529 /** Formatted output of the Arithmetic Operation
1530  *
1531  * @param[in] op Type to output.
1532  *
1533  * @return Formatted string.
1534  */
to_string(const ArithmeticOperation & op)1535 inline std::string to_string(const ArithmeticOperation &op)
1536 {
1537     std::stringstream str;
1538     str << op;
1539     return str.str();
1540 }
1541 
1542 /** Formatted output of the Reduction Operations.
1543  *
1544  * @param[out] os Output stream.
1545  * @param[in]  op Type to output.
1546  *
1547  * @return Modified output stream.
1548  */
1549 inline ::std::ostream &operator<<(::std::ostream &os, const ReductionOperation &op)
1550 {
1551     switch(op)
1552     {
1553         case ReductionOperation::SUM:
1554             os << "SUM";
1555             break;
1556         case ReductionOperation::SUM_SQUARE:
1557             os << "SUM_SQUARE";
1558             break;
1559         case ReductionOperation::MEAN_SUM:
1560             os << "MEAN_SUM";
1561             break;
1562         case ReductionOperation::ARG_IDX_MAX:
1563             os << "ARG_IDX_MAX";
1564             break;
1565         case ReductionOperation::ARG_IDX_MIN:
1566             os << "ARG_IDX_MIN";
1567             break;
1568         case ReductionOperation::PROD:
1569             os << "PROD";
1570             break;
1571         case ReductionOperation::MIN:
1572             os << "MIN";
1573             break;
1574         case ReductionOperation::MAX:
1575             os << "MAX";
1576             break;
1577         default:
1578             ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1579     }
1580 
1581     return os;
1582 }
1583 
1584 /** Formatted output of the Reduction Operations.
1585  *
1586  * @param[in] op Type to output.
1587  *
1588  * @return Formatted string.
1589  */
to_string(const ReductionOperation & op)1590 inline std::string to_string(const ReductionOperation &op)
1591 {
1592     std::stringstream str;
1593     str << op;
1594     return str.str();
1595 }
1596 
1597 /** Formatted output of the Comparison Operations.
1598  *
1599  * @param[out] os Output stream.
1600  * @param[in]  op Type to output.
1601  *
1602  * @return Modified output stream.
1603  */
1604 inline ::std::ostream &operator<<(::std::ostream &os, const ComparisonOperation &op)
1605 {
1606     switch(op)
1607     {
1608         case ComparisonOperation::Equal:
1609             os << "Equal";
1610             break;
1611         case ComparisonOperation::NotEqual:
1612             os << "NotEqual";
1613             break;
1614         case ComparisonOperation::Greater:
1615             os << "Greater";
1616             break;
1617         case ComparisonOperation::GreaterEqual:
1618             os << "GreaterEqual";
1619             break;
1620         case ComparisonOperation::Less:
1621             os << "Less";
1622             break;
1623         case ComparisonOperation::LessEqual:
1624             os << "LessEqual";
1625             break;
1626         default:
1627             ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1628     }
1629 
1630     return os;
1631 }
1632 
1633 /** Formatted output of the Elementwise unary Operations.
1634  *
1635  * @param[out] os Output stream.
1636  * @param[in]  op Type to output.
1637  *
1638  * @return Modified output stream.
1639  */
1640 inline ::std::ostream &operator<<(::std::ostream &os, const ElementWiseUnary &op)
1641 {
1642     switch(op)
1643     {
1644         case ElementWiseUnary::RSQRT:
1645             os << "RSQRT";
1646             break;
1647         case ElementWiseUnary::EXP:
1648             os << "EXP";
1649             break;
1650         case ElementWiseUnary::NEG:
1651             os << "NEG";
1652             break;
1653         case ElementWiseUnary::LOG:
1654             os << "LOG";
1655             break;
1656         case ElementWiseUnary::ROUND:
1657             os << "ROUND";
1658             break;
1659         default:
1660             ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1661     }
1662 
1663     return os;
1664 }
1665 
1666 /** Formatted output of the Comparison Operations.
1667  *
1668  * @param[in] op Type to output.
1669  *
1670  * @return Formatted string.
1671  */
to_string(const ComparisonOperation & op)1672 inline std::string to_string(const ComparisonOperation &op)
1673 {
1674     std::stringstream str;
1675     str << op;
1676     return str.str();
1677 }
1678 
1679 /** Formatted output of the Elementwise unary Operations.
1680  *
1681  * @param[in] op Type to output.
1682  *
1683  * @return Formatted string.
1684  */
to_string(const ElementWiseUnary & op)1685 inline std::string to_string(const ElementWiseUnary &op)
1686 {
1687     std::stringstream str;
1688     str << op;
1689     return str.str();
1690 }
1691 
1692 /** Formatted output of the Norm Type.
1693  *
1694  * @param[in] type Type to output.
1695  *
1696  * @return Formatted string.
1697  */
to_string(const NormType & type)1698 inline std::string to_string(const NormType &type)
1699 {
1700     std::stringstream str;
1701     str << type;
1702     return str.str();
1703 }
1704 
1705 /** Formatted output of the Pooling Type.
1706  *
1707  * @param[in] type Type to output.
1708  *
1709  * @return Formatted string.
1710  */
to_string(const PoolingType & type)1711 inline std::string to_string(const PoolingType &type)
1712 {
1713     std::stringstream str;
1714     str << type;
1715     return str.str();
1716 }
1717 
1718 /** Formatted output of the Pooling Layer Info.
1719  *
1720  * @param[in] info Type to output.
1721  *
1722  * @return Formatted string.
1723  */
to_string(const PoolingLayerInfo & info)1724 inline std::string to_string(const PoolingLayerInfo &info)
1725 {
1726     std::stringstream str;
1727     str << "{Type=" << info.pool_type << ","
1728         << "DataLayout=" << info.data_layout << ","
1729         << "IsGlobalPooling=" << info.is_global_pooling;
1730     if(!info.is_global_pooling)
1731     {
1732         str << ","
1733             << "PoolSize=" << info.pool_size.width << "," << info.pool_size.height << ","
1734             << "PadStride=" << info.pad_stride_info;
1735     }
1736     str << "}";
1737     return str.str();
1738 }
1739 
1740 /** Formatted output of the PriorBoxLayerInfo.
1741  *
1742  * @param[in] info Type to output.
1743  *
1744  * @return Formatted string.
1745  */
to_string(const PriorBoxLayerInfo & info)1746 inline std::string to_string(const PriorBoxLayerInfo &info)
1747 {
1748     std::stringstream str;
1749     str << "{";
1750     str << "Clip:" << info.clip()
1751         << "Flip:" << info.flip()
1752         << "StepX:" << info.steps()[0]
1753         << "StepY:" << info.steps()[1]
1754         << "MinSizes:" << info.min_sizes().size()
1755         << "MaxSizes:" << info.max_sizes().size()
1756         << "ImgSizeX:" << info.img_size().x
1757         << "ImgSizeY:" << info.img_size().y
1758         << "Offset:" << info.offset()
1759         << "Variances:" << info.variances().size();
1760     str << "}";
1761     return str.str();
1762 }
1763 
1764 /** Formatted output of the KeyPoint type.
1765  *
1766  * @param[out] os    Output stream
1767  * @param[in]  point Type to output.
1768  *
1769  * @return Modified output stream.
1770  */
1771 inline ::std::ostream &operator<<(::std::ostream &os, const KeyPoint &point)
1772 {
1773     os << "{x=" << point.x << ","
1774        << "y=" << point.y << ","
1775        << "strength=" << point.strength << ","
1776        << "scale=" << point.scale << ","
1777        << "orientation=" << point.orientation << ","
1778        << "tracking_status=" << point.tracking_status << ","
1779        << "error=" << point.error << "}";
1780 
1781     return os;
1782 }
1783 
1784 /** Formatted output of the PhaseType type.
1785  *
1786  * @param[out] os         Output stream
1787  * @param[in]  phase_type Type to output.
1788  *
1789  * @return Modified output stream.
1790  */
1791 inline ::std::ostream &operator<<(::std::ostream &os, const PhaseType &phase_type)
1792 {
1793     switch(phase_type)
1794     {
1795         case PhaseType::SIGNED:
1796             os << "SIGNED";
1797             break;
1798         case PhaseType::UNSIGNED:
1799             os << "UNSIGNED";
1800             break;
1801         default:
1802             ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1803     }
1804 
1805     return os;
1806 }
1807 
1808 /** Formatted output of the PhaseType type.
1809  *
1810  * @param[in] type Type to output.
1811  *
1812  * @return Formatted string.
1813  */
to_string(const arm_compute::PhaseType & type)1814 inline std::string to_string(const arm_compute::PhaseType &type)
1815 {
1816     std::stringstream str;
1817     str << type;
1818     return str.str();
1819 }
1820 
1821 /** Formatted output of the MagnitudeType type.
1822  *
1823  * @param[out] os             Output stream
1824  * @param[in]  magnitude_type Type to output.
1825  *
1826  * @return Modified output stream.
1827  */
1828 inline ::std::ostream &operator<<(::std::ostream &os, const MagnitudeType &magnitude_type)
1829 {
1830     switch(magnitude_type)
1831     {
1832         case MagnitudeType::L1NORM:
1833             os << "L1NORM";
1834             break;
1835         case MagnitudeType::L2NORM:
1836             os << "L2NORM";
1837             break;
1838         default:
1839             ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1840     }
1841 
1842     return os;
1843 }
1844 
1845 /** Formatted output of the MagnitudeType type.
1846  *
1847  * @param[in] type Type to output.
1848  *
1849  * @return Formatted string.
1850  */
to_string(const arm_compute::MagnitudeType & type)1851 inline std::string to_string(const arm_compute::MagnitudeType &type)
1852 {
1853     std::stringstream str;
1854     str << type;
1855     return str.str();
1856 }
1857 
1858 /** Formatted output of the HOGNormType type.
1859  *
1860  * @param[out] os        Output stream
1861  * @param[in]  norm_type Type to output
1862  *
1863  * @return Modified output stream.
1864  */
1865 inline ::std::ostream &operator<<(::std::ostream &os, const HOGNormType &norm_type)
1866 {
1867     switch(norm_type)
1868     {
1869         case HOGNormType::L1_NORM:
1870             os << "L1_NORM";
1871             break;
1872         case HOGNormType::L2_NORM:
1873             os << "L2_NORM";
1874             break;
1875         case HOGNormType::L2HYS_NORM:
1876             os << "L2HYS_NORM";
1877             break;
1878         default:
1879             ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1880     }
1881 
1882     return os;
1883 }
1884 
1885 /** Formatted output of the HOGNormType type.
1886  *
1887  * @param[in] type Type to output
1888  *
1889  * @return Formatted string.
1890  */
to_string(const HOGNormType & type)1891 inline std::string to_string(const HOGNormType &type)
1892 {
1893     std::stringstream str;
1894     str << type;
1895     return str.str();
1896 }
1897 
1898 /** Formatted output of the Size2D type.
1899  *
1900  * @param[out] os   Output stream
1901  * @param[in]  size Type to output
1902  *
1903  * @return Modified output stream.
1904  */
1905 inline ::std::ostream &operator<<(::std::ostream &os, const Size2D &size)
1906 {
1907     os << size.width << "x" << size.height;
1908 
1909     return os;
1910 }
1911 
1912 /** Formatted output of the Size2D type.
1913  *
1914  * @param[in] type Type to output
1915  *
1916  * @return Formatted string.
1917  */
to_string(const Size2D & type)1918 inline std::string to_string(const Size2D &type)
1919 {
1920     std::stringstream str;
1921     str << type;
1922     return str.str();
1923 }
1924 
1925 /** Formatted output of the HOGInfo type.
1926  *
1927  * @param[out] os       Output stream
1928  * @param[in]  hog_info Type to output
1929  *
1930  * @return Modified output stream.
1931  */
1932 inline ::std::ostream &operator<<(::std::ostream &os, const HOGInfo &hog_info)
1933 {
1934     os << "{CellSize=" << hog_info.cell_size() << ","
1935        << "BlockSize=" << hog_info.block_size() << ","
1936        << "DetectionWindowSize=" << hog_info.detection_window_size() << ","
1937        << "BlockStride=" << hog_info.block_stride() << ","
1938        << "NumBins=" << hog_info.num_bins() << ","
1939        << "NormType=" << hog_info.normalization_type() << ","
1940        << "L2HystThreshold=" << hog_info.l2_hyst_threshold() << ","
1941        << "PhaseType=" << hog_info.phase_type() << "}";
1942 
1943     return os;
1944 }
1945 
1946 /** Formatted output of the HOGInfo type.
1947  *
1948  * @param[in] type Type to output
1949  *
1950  * @return Formatted string.
1951  */
to_string(const HOGInfo & type)1952 inline std::string to_string(const HOGInfo &type)
1953 {
1954     std::stringstream str;
1955     str << type;
1956     return str.str();
1957 }
1958 
1959 /** Formatted output of the ConvolutionMethod type.
1960  *
1961  * @param[out] os          Output stream
1962  * @param[in]  conv_method Type to output
1963  *
1964  * @return Modified output stream.
1965  */
1966 inline ::std::ostream &operator<<(::std::ostream &os, const ConvolutionMethod &conv_method)
1967 {
1968     switch(conv_method)
1969     {
1970         case ConvolutionMethod::GEMM:
1971             os << "GEMM";
1972             break;
1973         case ConvolutionMethod::DIRECT:
1974             os << "DIRECT";
1975             break;
1976         case ConvolutionMethod::WINOGRAD:
1977             os << "WINOGRAD";
1978             break;
1979         default:
1980             ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1981     }
1982 
1983     return os;
1984 }
1985 
1986 /** Formatted output of the ConvolutionMethod type.
1987  *
1988  * @param[in] conv_method Type to output
1989  *
1990  * @return Formatted string.
1991  */
to_string(const ConvolutionMethod & conv_method)1992 inline std::string to_string(const ConvolutionMethod &conv_method)
1993 {
1994     std::stringstream str;
1995     str << conv_method;
1996     return str.str();
1997 }
1998 
1999 /** Formatted output of the GPUTarget type.
2000  *
2001  * @param[out] os         Output stream
2002  * @param[in]  gpu_target Type to output
2003  *
2004  * @return Modified output stream.
2005  */
2006 inline ::std::ostream &operator<<(::std::ostream &os, const GPUTarget &gpu_target)
2007 {
2008     switch(gpu_target)
2009     {
2010         case GPUTarget::GPU_ARCH_MASK:
2011             os << "GPU_ARCH_MASK";
2012             break;
2013         case GPUTarget::MIDGARD:
2014             os << "MIDGARD";
2015             break;
2016         case GPUTarget::BIFROST:
2017             os << "BIFROST";
2018             break;
2019         case GPUTarget::VALHALL:
2020             os << "VALHALL";
2021             break;
2022         case GPUTarget::T600:
2023             os << "T600";
2024             break;
2025         case GPUTarget::T700:
2026             os << "T700";
2027             break;
2028         case GPUTarget::T800:
2029             os << "T800";
2030             break;
2031         case GPUTarget::G71:
2032             os << "G71";
2033             break;
2034         case GPUTarget::G72:
2035             os << "G72";
2036             break;
2037         case GPUTarget::G51:
2038             os << "G51";
2039             break;
2040         case GPUTarget::G51BIG:
2041             os << "G51BIG";
2042             break;
2043         case GPUTarget::G51LIT:
2044             os << "G51LIT";
2045             break;
2046         case GPUTarget::G76:
2047             os << "G76";
2048             break;
2049         case GPUTarget::G77:
2050             os << "G77";
2051             break;
2052         case GPUTarget::TBOX:
2053             os << "TBOX";
2054             break;
2055         case GPUTarget::TODX:
2056             os << "TODX";
2057             break;
2058         default:
2059             ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2060     }
2061 
2062     return os;
2063 }
2064 
2065 /** Formatted output of the GPUTarget type.
2066  *
2067  * @param[in] gpu_target Type to output
2068  *
2069  * @return Formatted string.
2070  */
to_string(const GPUTarget & gpu_target)2071 inline std::string to_string(const GPUTarget &gpu_target)
2072 {
2073     std::stringstream str;
2074     str << gpu_target;
2075     return str.str();
2076 }
2077 
2078 /** Formatted output of the DetectionWindow type.
2079  *
2080  * @param[out] os               Output stream
2081  * @param[in]  detection_window Type to output
2082  *
2083  * @return Modified output stream.
2084  */
2085 inline ::std::ostream &operator<<(::std::ostream &os, const DetectionWindow &detection_window)
2086 {
2087     os << "{x=" << detection_window.x << ","
2088        << "y=" << detection_window.y << ","
2089        << "width=" << detection_window.width << ","
2090        << "height=" << detection_window.height << ","
2091        << "idx_class=" << detection_window.idx_class << ","
2092        << "score=" << detection_window.score << "}";
2093 
2094     return os;
2095 }
2096 
2097 /** Formatted output of the DetectionOutputLayerCodeType type.
2098  *
2099  * @param[out] os             Output stream
2100  * @param[in]  detection_code Type to output
2101  *
2102  * @return Modified output stream.
2103  */
2104 inline ::std::ostream &operator<<(::std::ostream &os, const DetectionOutputLayerCodeType &detection_code)
2105 {
2106     switch(detection_code)
2107     {
2108         case DetectionOutputLayerCodeType::CENTER_SIZE:
2109             os << "CENTER_SIZE";
2110             break;
2111         case DetectionOutputLayerCodeType::CORNER:
2112             os << "CORNER";
2113             break;
2114         case DetectionOutputLayerCodeType::CORNER_SIZE:
2115             os << "CORNER_SIZE";
2116             break;
2117         case DetectionOutputLayerCodeType::TF_CENTER:
2118             os << "TF_CENTER";
2119             break;
2120         default:
2121             ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2122     }
2123 
2124     return os;
2125 }
2126 /** Formatted output of the DetectionOutputLayerCodeType type.
2127  *
2128  * @param[in] detection_code Type to output
2129  *
2130  * @return Formatted string.
2131  */
to_string(const DetectionOutputLayerCodeType & detection_code)2132 inline std::string to_string(const DetectionOutputLayerCodeType &detection_code)
2133 {
2134     std::stringstream str;
2135     str << detection_code;
2136     return str.str();
2137 }
2138 
2139 /** Formatted output of the DetectionOutputLayerInfo type.
2140  *
2141  * @param[out] os             Output stream
2142  * @param[in]  detection_info Type to output
2143  *
2144  * @return Modified output stream.
2145  */
2146 inline ::std::ostream &operator<<(::std::ostream &os, const DetectionOutputLayerInfo &detection_info)
2147 {
2148     os << "{Classes=" << detection_info.num_classes() << ","
2149        << "ShareLocation=" << detection_info.share_location() << ","
2150        << "CodeType=" << detection_info.code_type() << ","
2151        << "VarianceEncodedInTarget=" << detection_info.variance_encoded_in_target() << ","
2152        << "KeepTopK=" << detection_info.keep_top_k() << ","
2153        << "NMSThreshold=" << detection_info.nms_threshold() << ","
2154        << "Eta=" << detection_info.eta() << ","
2155        << "BackgroundLabelId=" << detection_info.background_label_id() << ","
2156        << "ConfidenceThreshold=" << detection_info.confidence_threshold() << ","
2157        << "TopK=" << detection_info.top_k() << ","
2158        << "NumLocClasses=" << detection_info.num_loc_classes()
2159        << "}";
2160 
2161     return os;
2162 }
2163 
2164 /** Formatted output of the DetectionOutputLayerInfo type.
2165  *
2166  * @param[in] detection_info Type to output
2167  *
2168  * @return Formatted string.
2169  */
to_string(const DetectionOutputLayerInfo & detection_info)2170 inline std::string to_string(const DetectionOutputLayerInfo &detection_info)
2171 {
2172     std::stringstream str;
2173     str << detection_info;
2174     return str.str();
2175 }
2176 /** Formatted output of the DetectionPostProcessLayerInfo type.
2177  *
2178  * @param[out] os             Output stream
2179  * @param[in]  detection_info Type to output
2180  *
2181  * @return Modified output stream.
2182  */
2183 inline ::std::ostream &operator<<(::std::ostream &os, const DetectionPostProcessLayerInfo &detection_info)
2184 {
2185     os << "{MaxDetections=" << detection_info.max_detections() << ","
2186        << "MaxClassesPerDetection=" << detection_info.max_classes_per_detection() << ","
2187        << "NmsScoreThreshold=" << detection_info.nms_score_threshold() << ","
2188        << "NmsIouThreshold=" << detection_info.iou_threshold() << ","
2189        << "NumClasses=" << detection_info.num_classes() << ","
2190        << "ScaleValue_y=" << detection_info.scale_value_y() << ","
2191        << "ScaleValue_x=" << detection_info.scale_value_x() << ","
2192        << "ScaleValue_h=" << detection_info.scale_value_h() << ","
2193        << "ScaleValue_w=" << detection_info.scale_value_w() << ","
2194        << "UseRegularNms=" << detection_info.use_regular_nms() << ","
2195        << "DetectionPerClass=" << detection_info.detection_per_class()
2196        << "}";
2197 
2198     return os;
2199 }
2200 
2201 /** Formatted output of the DetectionPostProcessLayerInfo type.
2202  *
2203  * @param[in] detection_info Type to output
2204  *
2205  * @return Formatted string.
2206  */
to_string(const DetectionPostProcessLayerInfo & detection_info)2207 inline std::string to_string(const DetectionPostProcessLayerInfo &detection_info)
2208 {
2209     std::stringstream str;
2210     str << detection_info;
2211     return str.str();
2212 }
2213 /** Formatted output of the DetectionWindow type.
2214  *
2215  * @param[in] detection_window Type to output
2216  *
2217  * @return Formatted string.
2218  */
to_string(const DetectionWindow & detection_window)2219 inline std::string to_string(const DetectionWindow &detection_window)
2220 {
2221     std::stringstream str;
2222     str << detection_window;
2223     return str.str();
2224 }
2225 
2226 /** Formatted output of the Termination type.
2227  *
2228  * @param[out] os          Output stream
2229  * @param[in]  termination Type to output
2230  *
2231  * @return Modified output stream.
2232  */
2233 inline ::std::ostream &operator<<(::std::ostream &os, const Termination &termination)
2234 {
2235     switch(termination)
2236     {
2237         case Termination::TERM_CRITERIA_EPSILON:
2238             os << "TERM_CRITERIA_EPSILON";
2239             break;
2240         case Termination::TERM_CRITERIA_ITERATIONS:
2241             os << "TERM_CRITERIA_ITERATIONS";
2242             break;
2243         case Termination::TERM_CRITERIA_BOTH:
2244             os << "TERM_CRITERIA_BOTH";
2245             break;
2246         default:
2247             ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2248     }
2249 
2250     return os;
2251 }
2252 
2253 /** Formatted output of the Termination type.
2254  *
2255  * @param[in] termination Type to output
2256  *
2257  * @return Formatted string.
2258  */
to_string(const Termination & termination)2259 inline std::string to_string(const Termination &termination)
2260 {
2261     std::stringstream str;
2262     str << termination;
2263     return str.str();
2264 }
2265 
2266 /** Formatted output of the CPUModel type.
2267  *
2268  * @param[out] os        Output stream
2269  * @param[in]  cpu_model Model to output
2270  *
2271  * @return Modified output stream.
2272  */
2273 inline ::std::ostream &operator<<(::std::ostream &os, const CPUModel &cpu_model)
2274 {
2275     switch(cpu_model)
2276     {
2277         case CPUModel::GENERIC:
2278             os << "GENERIC";
2279             break;
2280         case CPUModel::GENERIC_FP16:
2281             os << "GENERIC_FP16";
2282             break;
2283         case CPUModel::GENERIC_FP16_DOT:
2284             os << "GENERIC_FP16_DOT";
2285             break;
2286         case CPUModel::A53:
2287             os << "A53";
2288             break;
2289         case CPUModel::A55r0:
2290             os << "A55r0";
2291             break;
2292         case CPUModel::A55r1:
2293             os << "A55r1";
2294             break;
2295         case CPUModel::A73:
2296             os << "A73";
2297             break;
2298         case CPUModel::X1:
2299             os << "X1";
2300             break;
2301         default:
2302             ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2303     }
2304 
2305     return os;
2306 }
2307 
2308 /** Formatted output of the CPUModel type.
2309  *
2310  * @param[in] cpu_model Model to output
2311  *
2312  * @return Formatted string.
2313  */
to_string(const CPUModel & cpu_model)2314 inline std::string to_string(const CPUModel &cpu_model)
2315 {
2316     std::stringstream str;
2317     str << cpu_model;
2318     return str.str();
2319 }
2320 /** Formatted output of a vector of objects.
2321  *
2322  * @param[out] os   Output stream
2323  * @param[in]  args Vector of objects to print
2324  *
2325  * @return Modified output stream.
2326  */
2327 template <typename T>
2328 inline ::std::ostream &operator<<(::std::ostream &os, const std::vector<T> &args)
2329 {
2330     os << "[";
2331     bool first = true;
2332     for(auto &arg : args)
2333     {
2334         if(first)
2335         {
2336             first = false;
2337         }
2338         else
2339         {
2340             os << ", ";
2341         }
2342         os << arg;
2343     }
2344     os << "]";
2345     return os;
2346 }
2347 
2348 /** Formatted output of @ref PriorBoxLayerInfo.
2349  *
2350  * @param[out] os   Output stream.
2351  * @param[in]  info Type to output.
2352  *
2353  * @return Modified output stream.
2354  */
2355 inline ::std::ostream &operator<<(::std::ostream &os, const PriorBoxLayerInfo &info)
2356 {
2357     os << "Clip:" << info.clip()
2358        << "Flip:" << info.flip()
2359        << "StepX:" << info.steps()[0]
2360        << "StepY:" << info.steps()[1]
2361        << "MinSizes:" << info.min_sizes()
2362        << "MaxSizes:" << info.max_sizes()
2363        << "ImgSizeX:" << info.img_size().x
2364        << "ImgSizeY:" << info.img_size().y
2365        << "Offset:" << info.offset()
2366        << "Variances:" << info.variances();
2367 
2368     return os;
2369 }
2370 
2371 /** Formatted output of a vector of objects.
2372  *
2373  * @param[in] args Vector of objects to print
2374  *
2375  * @return String representing args.
2376  */
2377 template <typename T>
to_string(const std::vector<T> & args)2378 std::string to_string(const std::vector<T> &args)
2379 {
2380     std::stringstream str;
2381     str << args;
2382     return str.str();
2383 }
2384 
2385 /** Formatted output of the WinogradInfo type. */
2386 inline ::std::ostream &operator<<(::std::ostream &os, const WinogradInfo &info)
2387 {
2388     os << "{OutputTileSize=" << info.output_tile_size << ","
2389        << "KernelSize=" << info.kernel_size << ","
2390        << "PadStride=" << info.convolution_info << ","
2391        << "OutputDataLayout=" << info.output_data_layout << "}";
2392 
2393     return os;
2394 }
2395 
to_string(const WinogradInfo & type)2396 inline std::string to_string(const WinogradInfo &type)
2397 {
2398     std::stringstream str;
2399     str << type;
2400     return str.str();
2401 }
2402 
2403 /** Fallback method: try to use std::to_string:
2404  *
2405  * @param[in] val Value to convert to string
2406  *
2407  * @return String representing val.
2408  */
2409 template <typename T>
to_string(const T & val)2410 inline std::string to_string(const T &val)
2411 {
2412     return support::cpp11::to_string(val);
2413 }
2414 
2415 /** Convert a CLTunerMode value to a string
2416  *
2417  * @param val CLTunerMode value to be converted
2418  *
2419  * @return String representing the corresponding CLTunerMode.
2420  */
to_string(const CLTunerMode val)2421 inline std::string to_string(const CLTunerMode val)
2422 {
2423     switch(val)
2424     {
2425         case CLTunerMode::EXHAUSTIVE:
2426         {
2427             return std::string("Exhaustive");
2428         }
2429         case CLTunerMode::NORMAL:
2430         {
2431             return std::string("Normal");
2432         }
2433         case CLTunerMode::RAPID:
2434         {
2435             return std::string("Rapid");
2436         }
2437         default:
2438         {
2439             ARM_COMPUTE_ERROR("Invalid tuner mode.");
2440             return std::string("UNDEFINED");
2441         }
2442     }
2443 }
2444 /** [Print CLTunerMode type] **/
2445 /** Formatted output of the CLTunerMode type.
2446  *
2447  * @param[out] os  Output stream.
2448  * @param[in]  val CLTunerMode to output.
2449  *
2450  * @return Modified output stream.
2451  */
2452 inline ::std::ostream &operator<<(::std::ostream &os, const CLTunerMode &val)
2453 {
2454     os << to_string(val);
2455     return os;
2456 }
2457 
2458 } // namespace arm_compute
2459 
2460 #endif /* __ARM_COMPUTE_TYPE_PRINTER_H__ */
2461