blob: bf5b64a1eb6007159ac14cf3b93047c90dab0a90 [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
Anthony Barbier8914e322018-08-10 15:28:25 +010027#include "arm_compute/core/CPP/CPPTypes.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010028#include "arm_compute/core/Dimensions.h"
29#include "arm_compute/core/Error.h"
Michele Di Giorgiob8fc60f2018-04-25 11:58:07 +010030#include "arm_compute/core/GPUTarget.h"
John Richardson25f23682017-11-27 14:35:09 +000031#include "arm_compute/core/HOGInfo.h"
morgolockaba2f912020-05-05 16:28:19 +010032#include "arm_compute/core/KernelDescriptors.h"
John Richardson25f23682017-11-27 14:35:09 +000033#include "arm_compute/core/Size2D.h"
John Richardsona36eae12017-09-26 16:55:59 +010034#include "arm_compute/core/Strides.h"
Georgios Pinitas3faea252017-10-30 14:13:50 +000035#include "arm_compute/core/TensorInfo.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010036#include "arm_compute/core/Types.h"
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +010037#include "arm_compute/runtime/CL/CLTunerTypes.h"
SiCong Lidb4a6c12021-02-05 09:30:57 +000038#include "arm_compute/runtime/CL/CLTypes.h"
Matthew Bentham758b5ba2020-03-05 23:37:48 +000039#include "support/StringSupport.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010040
41#include <ostream>
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010042#include <sstream>
43#include <string>
Anthony Barbier6ff3b192017-09-04 18:44:23 +010044
45namespace arm_compute
46{
Anthony Barbierb940fd62018-06-04 14:14:32 +010047/** Formatted output if arg is not null
48 *
49 * @param[in] arg Object to print
50 *
51 * @return String representing arg.
52 */
53template <typename T>
54std::string to_string_if_not_null(T *arg)
55{
56 if(arg == nullptr)
57 {
58 return "nullptr";
59 }
60 else
61 {
62 return to_string(*arg);
63 }
64}
Anthony Barbierb4670212018-05-18 16:55:39 +010065
Alex Gildayc357c472018-03-21 13:54:09 +000066/** Formatted output of the Dimensions type.
67 *
68 * @param[out] os Output stream.
69 * @param[in] dimensions Type to output.
70 *
71 * @return Modified output stream.
72 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +010073template <typename T>
74inline ::std::ostream &operator<<(::std::ostream &os, const Dimensions<T> &dimensions)
75{
Anthony Barbier6ff3b192017-09-04 18:44:23 +010076 if(dimensions.num_dimensions() > 0)
77 {
78 os << dimensions[0];
79
80 for(unsigned int d = 1; d < dimensions.num_dimensions(); ++d)
81 {
Moritz Pflanzerc87fbf82017-07-18 14:02:10 +010082 os << "x" << dimensions[d];
Anthony Barbier6ff3b192017-09-04 18:44:23 +010083 }
84 }
85
Anthony Barbier6ff3b192017-09-04 18:44:23 +010086 return os;
87}
88
Alex Gildayc357c472018-03-21 13:54:09 +000089/** Formatted output of the NonLinearFilterFunction type.
90 *
91 * @param[out] os Output stream.
92 * @param[in] function Type to output.
93 *
94 * @return Modified output stream.
95 */
Isabella Gottardi3b77e9d2017-06-22 11:05:41 +010096inline ::std::ostream &operator<<(::std::ostream &os, const NonLinearFilterFunction &function)
97{
98 switch(function)
99 {
100 case NonLinearFilterFunction::MAX:
101 os << "MAX";
102 break;
103 case NonLinearFilterFunction::MEDIAN:
104 os << "MEDIAN";
105 break;
106 case NonLinearFilterFunction::MIN:
107 os << "MIN";
108 break;
109 default:
110 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
111 }
112
113 return os;
114}
115
Alex Gildayc357c472018-03-21 13:54:09 +0000116/** Formatted output of the NonLinearFilterFunction type.
117 *
118 * @param[in] function Type to output.
119 *
120 * @return Formatted string.
121 */
John Richardson6f4d49f2017-09-07 11:21:10 +0100122inline std::string to_string(const NonLinearFilterFunction &function)
123{
124 std::stringstream str;
125 str << function;
126 return str.str();
127}
128
Alex Gildayc357c472018-03-21 13:54:09 +0000129/** Formatted output of the MatrixPattern type.
130 *
131 * @param[out] os Output stream.
132 * @param[in] pattern Type to output.
133 *
134 * @return Modified output stream.
135 */
Isabella Gottardi3b77e9d2017-06-22 11:05:41 +0100136inline ::std::ostream &operator<<(::std::ostream &os, const MatrixPattern &pattern)
137{
138 switch(pattern)
139 {
140 case MatrixPattern::BOX:
141 os << "BOX";
142 break;
143 case MatrixPattern::CROSS:
144 os << "CROSS";
145 break;
146 case MatrixPattern::DISK:
147 os << "DISK";
148 break;
149 case MatrixPattern::OTHER:
150 os << "OTHER";
151 break;
152 default:
153 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
154 }
155
156 return os;
157}
158
Alex Gildayc357c472018-03-21 13:54:09 +0000159/** Formatted output of the MatrixPattern type.
160 *
161 * @param[in] pattern Type to output.
162 *
163 * @return Formatted string.
164 */
John Richardson6f4d49f2017-09-07 11:21:10 +0100165inline std::string to_string(const MatrixPattern &pattern)
166{
167 std::stringstream str;
168 str << pattern;
169 return str.str();
170}
171
Alex Gildayc357c472018-03-21 13:54:09 +0000172/** Formatted output of the RoundingPolicy type.
173 *
174 * @param[out] os Output stream.
175 * @param[in] rounding_policy Type to output.
176 *
177 * @return Modified output stream.
178 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100179inline ::std::ostream &operator<<(::std::ostream &os, const RoundingPolicy &rounding_policy)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100180{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100181 switch(rounding_policy)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100182 {
Anthony Barbier2a07e182017-08-04 18:20:27 +0100183 case RoundingPolicy::TO_ZERO:
184 os << "TO_ZERO";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100185 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100186 case RoundingPolicy::TO_NEAREST_UP:
187 os << "TO_NEAREST_UP";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100188 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100189 case RoundingPolicy::TO_NEAREST_EVEN:
190 os << "TO_NEAREST_EVEN";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100191 break;
192 default:
193 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
194 }
195
196 return os;
197}
198
Alex Gildayc357c472018-03-21 13:54:09 +0000199/** Formatted output of the WeightsInfo type.
200 *
201 * @param[out] os Output stream.
202 * @param[in] weights_info Type to output.
203 *
204 * @return Modified output stream.
205 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100206inline ::std::ostream &operator<<(::std::ostream &os, const WeightsInfo &weights_info)
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100207{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100208 os << weights_info.are_reshaped() << ";";
209 os << weights_info.num_kernels() << ";" << weights_info.kernel_size().first << "," << weights_info.kernel_size().second;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100210
211 return os;
212}
213
Alex Gildayc357c472018-03-21 13:54:09 +0000214/** Formatted output of the ROIPoolingInfo type.
215 *
216 * @param[out] os Output stream.
217 * @param[in] pool_info Type to output.
218 *
219 * @return Modified output stream.
220 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100221inline ::std::ostream &operator<<(::std::ostream &os, const ROIPoolingLayerInfo &pool_info)
Sanghoon Lee70f82912017-08-24 14:21:24 +0100222{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100223 os << pool_info.pooled_width() << "x" << pool_info.pooled_height() << "~" << pool_info.spatial_scale();
Georgios Pinitasd9769582017-08-03 10:19:40 +0100224 return os;
225}
226
giuros0118870812018-09-13 09:31:40 +0100227/** Formatted output of the ROIPoolingInfo type.
228 *
229 * @param[in] pool_info Type to output.
230 *
231 * @return Formatted string.
232 */
233inline std::string to_string(const ROIPoolingLayerInfo &pool_info)
234{
235 std::stringstream str;
236 str << pool_info;
237 return str.str();
238}
239
morgolockaba2f912020-05-05 16:28:19 +0100240/** Formatted output of the GEMMKernelInfo type.
241 *
242 * @param[out] os Output stream.
243 * @param[in] gemm_info Type to output.
244 *
245 * @return Modified output stream.
246 */
247inline ::std::ostream &operator<<(::std::ostream &os, const GEMMKernelInfo &gemm_info)
248{
249 os << "( m= " << gemm_info.m;
250 os << " n= " << gemm_info.n;
251 os << " k= " << gemm_info.k;
252 os << " depth_output_gemm3d= " << gemm_info.depth_output_gemm3d;
253 os << " reinterpret_input_as_3d= " << gemm_info.reinterpret_input_as_3d;
254 os << " broadcast_bias= " << gemm_info.broadcast_bias;
255 os << " fp_mixed_precision= " << gemm_info.fp_mixed_precision;
256 os << " mult_transpose1xW_width= " << gemm_info.mult_transpose1xW_width;
257 os << " mult_interleave4x4_height= " << gemm_info.mult_interleave4x4_height;
258 os << " a_offset = " << gemm_info.a_offset;
259 os << " b_offset = " << gemm_info.b_offset;
260 os << ")";
261 return os;
262}
263
264/** Formatted output of the GEMMLHSMatrixInfo type.
265 *
266 * @param[out] os Output stream.
267 * @param[in] gemm_info Type to output.
268 *
269 * @return Modified output stream.
270 */
271inline ::std::ostream &operator<<(::std::ostream &os, const GEMMLHSMatrixInfo &gemm_info)
272{
273 os << "( m0= " << (unsigned int)gemm_info.m0 << " k0= " << gemm_info.k0 << " v0= " << gemm_info.v0 << " trans= " << gemm_info.transpose << " inter= " << gemm_info.interleave << "})";
274 return os;
275}
276
277/** Formatted output of the GEMMRHSMatrixInfo type.
278 *
279 * @param[out] os Output stream.
280 * @param[in] gemm_info Type to output.
281 *
282 * @return Modified output stream.
283 */
284inline ::std::ostream &operator<<(::std::ostream &os, const GEMMRHSMatrixInfo &gemm_info)
285{
SiCong Lidb4a6c12021-02-05 09:30:57 +0000286 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=" <<
287 gemm_info.export_to_cl_image << "})";
morgolockaba2f912020-05-05 16:28:19 +0100288 return os;
289}
290
291/** Formatted output of the GEMMRHSMatrixInfo type.
292 *
293 * @param[in] gemm_info GEMMRHSMatrixInfo to output.
294 *
295 * @return Formatted string.
296 */
297inline std::string to_string(const GEMMRHSMatrixInfo &gemm_info)
298{
299 std::stringstream str;
300 str << gemm_info;
301 return str.str();
302}
303
304/** Formatted output of the GEMMLHSMatrixInfo type.
305 *
306 * @param[in] gemm_info GEMMLHSMatrixInfo to output.
307 *
308 * @return Formatted string.
309 */
310inline std::string to_string(const GEMMLHSMatrixInfo &gemm_info)
311{
312 std::stringstream str;
313 str << gemm_info;
314 return str.str();
315}
316
317/** Formatted output of the GEMMKernelInfo type.
318 *
319 * @param[in] gemm_info GEMMKernelInfo Type to output.
320 *
321 * @return Formatted string.
322 */
323inline std::string to_string(const GEMMKernelInfo &gemm_info)
324{
325 std::stringstream str;
326 str << gemm_info;
327 return str.str();
328}
329
giuros01c04a0e82018-10-03 12:44:35 +0100330/** Formatted output of the BoundingBoxTransformInfo type.
331 *
332 * @param[out] os Output stream.
333 * @param[in] bbox_info Type to output.
334 *
335 * @return Modified output stream.
336 */
337inline ::std::ostream &operator<<(::std::ostream &os, const BoundingBoxTransformInfo &bbox_info)
338{
339 auto weights = bbox_info.weights();
340 os << "(" << bbox_info.img_width() << "x" << bbox_info.img_height() << ")~" << bbox_info.scale() << "(weights = {" << weights[0] << ", " << weights[1] << ", " << weights[2] << ", " << weights[3] <<
341 "})";
342 return os;
343}
344
345/** Formatted output of the BoundingBoxTransformInfo type.
346 *
347 * @param[in] bbox_info Type to output.
348 *
349 * @return Formatted string.
350 */
351inline std::string to_string(const BoundingBoxTransformInfo &bbox_info)
352{
353 std::stringstream str;
354 str << bbox_info;
355 return str.str();
356}
357
Manuel Bottini5209be52019-02-13 16:34:56 +0000358/** Formatted output of the ComputeAnchorsInfo type.
359 *
360 * @param[out] os Output stream.
361 * @param[in] anchors_info Type to output.
362 *
363 * @return Modified output stream.
364 */
365inline ::std::ostream &operator<<(::std::ostream &os, const ComputeAnchorsInfo &anchors_info)
366{
367 os << "(" << anchors_info.feat_width() << "x" << anchors_info.feat_height() << ")~" << anchors_info.spatial_scale();
368 return os;
369}
370
371/** Formatted output of the ComputeAnchorsInfo type.
372 *
373 * @param[in] anchors_info Type to output.
374 *
375 * @return Formatted string.
376 */
377inline std::string to_string(const ComputeAnchorsInfo &anchors_info)
378{
379 std::stringstream str;
380 str << anchors_info;
381 return str.str();
382}
383
384/** Formatted output of the GenerateProposalsInfo type.
385 *
386 * @param[out] os Output stream.
387 * @param[in] proposals_info Type to output.
388 *
389 * @return Modified output stream.
390 */
391inline ::std::ostream &operator<<(::std::ostream &os, const GenerateProposalsInfo &proposals_info)
392{
393 os << "(" << proposals_info.im_width() << "x" << proposals_info.im_height() << ")~" << proposals_info.im_scale();
394 return os;
395}
396
397/** Formatted output of the GenerateProposalsInfo type.
398 *
399 * @param[in] proposals_info Type to output.
400 *
401 * @return Formatted string.
402 */
403inline std::string to_string(const GenerateProposalsInfo &proposals_info)
404{
405 std::stringstream str;
406 str << proposals_info;
407 return str.str();
408}
409
Alex Gildayc357c472018-03-21 13:54:09 +0000410/** Formatted output of the QuantizationInfo type.
411 *
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100412 * @param[out] os Output stream.
413 * @param[in] qinfo Type to output.
Alex Gildayc357c472018-03-21 13:54:09 +0000414 *
415 * @return Modified output stream.
416 */
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100417inline ::std::ostream &operator<<(::std::ostream &os, const QuantizationInfo &qinfo)
Chunosovd621bca2017-11-03 17:33:15 +0700418{
Georgios Pinitas3d13af82019-06-04 13:04:16 +0100419 const UniformQuantizationInfo uqinfo = qinfo.uniform();
420 os << "Scale:" << uqinfo.scale << "~";
421 os << "Offset:" << uqinfo.offset;
Chunosovd621bca2017-11-03 17:33:15 +0700422 return os;
423}
424
Alex Gildayc357c472018-03-21 13:54:09 +0000425/** Formatted output of the QuantizationInfo type.
426 *
427 * @param[in] quantization_info Type to output.
428 *
429 * @return Formatted string.
430 */
Chunosovd621bca2017-11-03 17:33:15 +0700431inline std::string to_string(const QuantizationInfo &quantization_info)
432{
433 std::stringstream str;
434 str << quantization_info;
435 return str.str();
436}
437
Alex Gildayc357c472018-03-21 13:54:09 +0000438/** Formatted output of the activation function type.
439 *
440 * @param[out] os Output stream.
441 * @param[in] act_function Type to output.
442 *
443 * @return Modified output stream.
444 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100445inline ::std::ostream &operator<<(::std::ostream &os, const ActivationLayerInfo::ActivationFunction &act_function)
446{
447 switch(act_function)
448 {
449 case ActivationLayerInfo::ActivationFunction::ABS:
450 os << "ABS";
451 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100452 case ActivationLayerInfo::ActivationFunction::LINEAR:
453 os << "LINEAR";
454 break;
455 case ActivationLayerInfo::ActivationFunction::LOGISTIC:
456 os << "LOGISTIC";
457 break;
458 case ActivationLayerInfo::ActivationFunction::RELU:
459 os << "RELU";
460 break;
Georgios Pinitas579c0492017-07-12 16:12:12 +0100461 case ActivationLayerInfo::ActivationFunction::BOUNDED_RELU:
462 os << "BOUNDED_RELU";
463 break;
464 case ActivationLayerInfo::ActivationFunction::LEAKY_RELU:
465 os << "LEAKY_RELU";
466 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100467 case ActivationLayerInfo::ActivationFunction::SOFT_RELU:
468 os << "SOFT_RELU";
469 break;
470 case ActivationLayerInfo::ActivationFunction::SQRT:
471 os << "SQRT";
472 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100473 case ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU:
474 os << "LU_BOUNDED_RELU";
Kevin Petitd9f80712017-12-06 12:18:48 +0000475 break;
Georgios Pinitasfb0fdcd2019-08-22 17:10:04 +0100476 case ActivationLayerInfo::ActivationFunction::ELU:
477 os << "ELU";
478 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100479 case ActivationLayerInfo::ActivationFunction::SQUARE:
480 os << "SQUARE";
481 break;
482 case ActivationLayerInfo::ActivationFunction::TANH:
483 os << "TANH";
484 break;
Usama Arif6a98a6e2019-05-10 17:07:27 +0100485 case ActivationLayerInfo::ActivationFunction::IDENTITY:
486 os << "IDENTITY";
487 break;
morgolock07df3d42020-02-27 11:46:28 +0000488 case ActivationLayerInfo::ActivationFunction::HARD_SWISH:
489 os << "HARD_SWISH";
490 break;
491
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100492 default:
493 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
494 }
495
496 return os;
497}
498
Alex Gildayc357c472018-03-21 13:54:09 +0000499/** Formatted output of the activation function info type.
500 *
501 * @param[in] info Type to output.
502 *
503 * @return Formatted string.
504 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100505inline std::string to_string(const arm_compute::ActivationLayerInfo &info)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100506{
507 std::stringstream str;
Isabella Gottardi3f217ec2018-02-12 14:59:19 +0000508 if(info.enabled())
509 {
510 str << info.activation();
511 }
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100512 return str.str();
513}
514
Alex Gildayc357c472018-03-21 13:54:09 +0000515/** Formatted output of the activation function type.
516 *
517 * @param[in] function Type to output.
518 *
519 * @return Formatted string.
520 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100521inline std::string to_string(const arm_compute::ActivationLayerInfo::ActivationFunction &function)
522{
523 std::stringstream str;
524 str << function;
525 return str.str();
526}
527
Alex Gildayc357c472018-03-21 13:54:09 +0000528/** Formatted output of the NormType type.
529 *
530 * @param[out] os Output stream.
531 * @param[in] norm_type Type to output.
532 *
533 * @return Modified output stream.
534 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100535inline ::std::ostream &operator<<(::std::ostream &os, const NormType &norm_type)
536{
537 switch(norm_type)
538 {
539 case NormType::CROSS_MAP:
540 os << "CROSS_MAP";
541 break;
542 case NormType::IN_MAP_1D:
543 os << "IN_MAP_1D";
544 break;
545 case NormType::IN_MAP_2D:
546 os << "IN_MAP_2D";
547 break;
548 default:
549 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
550 }
551
552 return os;
553}
554
Alex Gildayc357c472018-03-21 13:54:09 +0000555/** Formatted output of @ref NormalizationLayerInfo.
556 *
557 * @param[in] info Type to output.
558 *
559 * @return Formatted string.
560 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100561inline std::string to_string(const arm_compute::NormalizationLayerInfo &info)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100562{
563 std::stringstream str;
Michalis Spyroud466c2d2018-01-30 10:54:39 +0000564 str << info.type() << ":NormSize=" << info.norm_size();
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100565 return str.str();
566}
567
Alex Gildayc357c472018-03-21 13:54:09 +0000568/** Formatted output of @ref NormalizationLayerInfo.
569 *
570 * @param[out] os Output stream.
571 * @param[in] info Type to output.
572 *
573 * @return Modified output stream.
574 */
Georgios Pinitas6f669f02017-09-26 12:32:57 +0100575inline ::std::ostream &operator<<(::std::ostream &os, const NormalizationLayerInfo &info)
576{
Michalis Spyroud466c2d2018-01-30 10:54:39 +0000577 os << info.type() << ":NormSize=" << info.norm_size();
Georgios Pinitas6f669f02017-09-26 12:32:57 +0100578 return os;
579}
580
Alex Gildayc357c472018-03-21 13:54:09 +0000581/** Formatted output of the PoolingType type.
582 *
583 * @param[out] os Output stream.
584 * @param[in] pool_type Type to output.
585 *
586 * @return Modified output stream.
587 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100588inline ::std::ostream &operator<<(::std::ostream &os, const PoolingType &pool_type)
589{
590 switch(pool_type)
591 {
592 case PoolingType::AVG:
593 os << "AVG";
594 break;
595 case PoolingType::MAX:
596 os << "MAX";
597 break;
Georgios Pinitascdf51452017-08-31 14:21:36 +0100598 case PoolingType::L2:
599 os << "L2";
600 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100601 default:
602 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
603 }
604
605 return os;
606}
607
Alex Gildayc357c472018-03-21 13:54:09 +0000608/** Formatted output of @ref PoolingLayerInfo.
609 *
610 * @param[out] os Output stream.
611 * @param[in] info Type to output.
612 *
613 * @return Modified output stream.
614 */
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100615inline ::std::ostream &operator<<(::std::ostream &os, const PoolingLayerInfo &info)
616{
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +0000617 os << info.pool_type;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100618
619 return os;
620}
621
Alex Gildayc357c472018-03-21 13:54:09 +0000622/** Formatted output of @ref RoundingPolicy.
623 *
624 * @param[in] rounding_policy Type to output.
625 *
626 * @return Formatted string.
627 */
John Richardsondd715f22017-09-18 16:10:48 +0100628inline std::string to_string(const RoundingPolicy &rounding_policy)
629{
630 std::stringstream str;
631 str << rounding_policy;
632 return str.str();
633}
634
Vidhya Sudhan Loganathand646ae12018-11-19 15:18:20 +0000635/** [Print DataLayout type] **/
Alex Gildayc357c472018-03-21 13:54:09 +0000636/** Formatted output of the DataLayout type.
637 *
638 * @param[out] os Output stream.
639 * @param[in] data_layout Type to output.
640 *
641 * @return Modified output stream.
642 */
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000643inline ::std::ostream &operator<<(::std::ostream &os, const DataLayout &data_layout)
644{
645 switch(data_layout)
646 {
647 case DataLayout::UNKNOWN:
648 os << "UNKNOWN";
649 break;
650 case DataLayout::NHWC:
651 os << "NHWC";
652 break;
653 case DataLayout::NCHW:
654 os << "NCHW";
655 break;
656 default:
657 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
658 }
659
660 return os;
661}
662
Alex Gildayc357c472018-03-21 13:54:09 +0000663/** Formatted output of the DataLayout type.
664 *
665 * @param[in] data_layout Type to output.
666 *
667 * @return Formatted string.
668 */
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000669inline std::string to_string(const arm_compute::DataLayout &data_layout)
670{
671 std::stringstream str;
672 str << data_layout;
673 return str.str();
674}
Vidhya Sudhan Loganathand646ae12018-11-19 15:18:20 +0000675/** [Print DataLayout type] **/
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000676
Georgios Pinitase2220552018-07-20 13:23:44 +0100677/** Formatted output of the DataLayoutDimension type.
678 *
679 * @param[out] os Output stream.
680 * @param[in] data_layout_dim Data layout dimension to print.
681 *
682 * @return Modified output stream.
683 */
684inline ::std::ostream &operator<<(::std::ostream &os, const DataLayoutDimension &data_layout_dim)
685{
686 switch(data_layout_dim)
687 {
688 case DataLayoutDimension::WIDTH:
689 os << "WIDTH";
690 break;
691 case DataLayoutDimension::HEIGHT:
692 os << "HEIGHT";
693 break;
694 case DataLayoutDimension::CHANNEL:
695 os << "CHANNEL";
696 break;
697 case DataLayoutDimension::BATCHES:
698 os << "BATCHES";
699 break;
700 default:
701 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
702 }
703 return os;
704}
705
Alex Gildayc357c472018-03-21 13:54:09 +0000706/** Formatted output of the DataType type.
707 *
708 * @param[out] os Output stream.
709 * @param[in] data_type Type to output.
710 *
711 * @return Modified output stream.
712 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100713inline ::std::ostream &operator<<(::std::ostream &os, const DataType &data_type)
714{
715 switch(data_type)
716 {
717 case DataType::UNKNOWN:
718 os << "UNKNOWN";
719 break;
720 case DataType::U8:
721 os << "U8";
722 break;
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100723 case DataType::QSYMM8:
724 os << "QSYMM8";
725 break;
Chunosovd621bca2017-11-03 17:33:15 +0700726 case DataType::QASYMM8:
727 os << "QASYMM8";
728 break;
Georgios Pinitas448a81f2019-11-21 14:10:25 +0000729 case DataType::QASYMM8_SIGNED:
730 os << "QASYMM8_SIGNED";
731 break;
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100732 case DataType::QSYMM8_PER_CHANNEL:
733 os << "QSYMM8_PER_CHANNEL";
734 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100735 case DataType::S8:
736 os << "S8";
737 break;
738 case DataType::U16:
739 os << "U16";
740 break;
741 case DataType::S16:
742 os << "S16";
743 break;
Manuel Bottini3689fcd2019-06-14 17:18:12 +0100744 case DataType::QSYMM16:
745 os << "QSYMM16";
746 break;
Michele Di Giorgio35ea9a72019-08-23 12:02:06 +0100747 case DataType::QASYMM16:
748 os << "QASYMM16";
749 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100750 case DataType::U32:
751 os << "U32";
752 break;
753 case DataType::S32:
754 os << "S32";
755 break;
756 case DataType::U64:
757 os << "U64";
758 break;
759 case DataType::S64:
760 os << "S64";
761 break;
Georgios Pinitase8291ac2020-02-26 09:58:13 +0000762 case DataType::BFLOAT16:
763 os << "BFLOAT16";
764 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100765 case DataType::F16:
766 os << "F16";
767 break;
768 case DataType::F32:
769 os << "F32";
770 break;
771 case DataType::F64:
772 os << "F64";
773 break;
774 case DataType::SIZET:
775 os << "SIZET";
776 break;
777 default:
778 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
779 }
780
781 return os;
782}
783
Alex Gildayc357c472018-03-21 13:54:09 +0000784/** Formatted output of the DataType type.
785 *
786 * @param[in] data_type Type to output.
787 *
788 * @return Formatted string.
789 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100790inline std::string to_string(const arm_compute::DataType &data_type)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100791{
792 std::stringstream str;
793 str << data_type;
794 return str.str();
795}
796
Alex Gildayc357c472018-03-21 13:54:09 +0000797/** Formatted output of the Format type.
798 *
799 * @param[out] os Output stream.
800 * @param[in] format Type to output.
801 *
802 * @return Modified output stream.
803 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100804inline ::std::ostream &operator<<(::std::ostream &os, const Format &format)
805{
806 switch(format)
807 {
808 case Format::UNKNOWN:
809 os << "UNKNOWN";
810 break;
811 case Format::U8:
812 os << "U8";
813 break;
814 case Format::S16:
815 os << "S16";
816 break;
817 case Format::U16:
818 os << "U16";
819 break;
820 case Format::S32:
821 os << "S32";
822 break;
823 case Format::U32:
824 os << "U32";
825 break;
826 case Format::F16:
827 os << "F16";
828 break;
829 case Format::F32:
830 os << "F32";
831 break;
832 case Format::UV88:
833 os << "UV88";
834 break;
835 case Format::RGB888:
836 os << "RGB888";
837 break;
838 case Format::RGBA8888:
839 os << "RGBA8888";
840 break;
841 case Format::YUV444:
842 os << "YUV444";
843 break;
844 case Format::YUYV422:
845 os << "YUYV422";
846 break;
847 case Format::NV12:
848 os << "NV12";
849 break;
850 case Format::NV21:
851 os << "NV21";
852 break;
853 case Format::IYUV:
854 os << "IYUV";
855 break;
856 case Format::UYVY422:
857 os << "UYVY422";
858 break;
859 default:
860 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
861 }
862
863 return os;
864}
865
Alex Gildayc357c472018-03-21 13:54:09 +0000866/** Formatted output of the Format type.
867 *
868 * @param[in] format Type to output.
869 *
870 * @return Formatted string.
871 */
Moritz Pflanzer7655a672017-09-23 11:57:33 +0100872inline std::string to_string(const Format &format)
873{
874 std::stringstream str;
875 str << format;
876 return str.str();
877}
878
Alex Gildayc357c472018-03-21 13:54:09 +0000879/** Formatted output of the Channel type.
880 *
881 * @param[out] os Output stream.
882 * @param[in] channel Type to output.
883 *
884 * @return Modified output stream.
885 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100886inline ::std::ostream &operator<<(::std::ostream &os, const Channel &channel)
887{
888 switch(channel)
889 {
890 case Channel::UNKNOWN:
891 os << "UNKNOWN";
892 break;
893 case Channel::C0:
894 os << "C0";
895 break;
896 case Channel::C1:
897 os << "C1";
898 break;
899 case Channel::C2:
900 os << "C2";
901 break;
902 case Channel::C3:
903 os << "C3";
904 break;
905 case Channel::R:
906 os << "R";
907 break;
908 case Channel::G:
909 os << "G";
910 break;
911 case Channel::B:
912 os << "B";
913 break;
914 case Channel::A:
915 os << "A";
916 break;
917 case Channel::Y:
918 os << "Y";
919 break;
920 case Channel::U:
921 os << "U";
922 break;
923 case Channel::V:
924 os << "V";
925 break;
926 default:
927 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
928 }
929
930 return os;
931}
932
Alex Gildayc357c472018-03-21 13:54:09 +0000933/** Formatted output of the Channel type.
934 *
935 * @param[in] channel Type to output.
936 *
937 * @return Formatted string.
938 */
Ioan-Cristian Szabo9414f642017-10-27 17:35:40 +0100939inline std::string to_string(const Channel &channel)
940{
941 std::stringstream str;
942 str << channel;
943 return str.str();
944}
945
Alex Gildayc357c472018-03-21 13:54:09 +0000946/** Formatted output of the BorderMode type.
947 *
948 * @param[out] os Output stream.
949 * @param[in] mode Type to output.
950 *
951 * @return Modified output stream.
952 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100953inline ::std::ostream &operator<<(::std::ostream &os, const BorderMode &mode)
954{
955 switch(mode)
956 {
957 case BorderMode::UNDEFINED:
958 os << "UNDEFINED";
959 break;
960 case BorderMode::CONSTANT:
961 os << "CONSTANT";
962 break;
963 case BorderMode::REPLICATE:
964 os << "REPLICATE";
965 break;
966 default:
967 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
968 }
969
970 return os;
971}
972
Alex Gildayc357c472018-03-21 13:54:09 +0000973/** Formatted output of the BorderSize type.
974 *
975 * @param[out] os Output stream.
976 * @param[in] border Type to output.
977 *
978 * @return Modified output stream.
979 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100980inline ::std::ostream &operator<<(::std::ostream &os, const BorderSize &border)
981{
Moritz Pflanzerc87fbf82017-07-18 14:02:10 +0100982 os << border.top << ","
983 << border.right << ","
984 << border.bottom << ","
985 << border.left;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100986
987 return os;
988}
Anthony Barbier2a07e182017-08-04 18:20:27 +0100989
Giuseppe Rossinid7647d42018-07-17 18:13:13 +0100990/** Formatted output of the PaddingList type.
991 *
992 * @param[out] os Output stream.
993 * @param[in] padding Type to output.
994 *
995 * @return Modified output stream.
996 */
997inline ::std::ostream &operator<<(::std::ostream &os, const PaddingList &padding)
998{
999 os << "{";
1000 for(auto const &p : padding)
1001 {
1002 os << "{" << p.first << "," << p.second << "}";
1003 }
1004 os << "}";
1005 return os;
1006}
1007
giuros013175fcf2018-11-21 09:59:17 +00001008/** Formatted output of the Multiples type.
1009 *
1010 * @param[out] os Output stream.
1011 * @param[in] multiples Type to output.
1012 *
1013 * @return Modified output stream.
1014 */
1015inline ::std::ostream &operator<<(::std::ostream &os, const Multiples &multiples)
1016{
1017 os << "(";
1018 for(size_t i = 0; i < multiples.size() - 1; i++)
1019 {
1020 os << multiples[i] << ", ";
1021 }
1022 os << multiples.back() << ")";
1023 return os;
1024}
1025
Alex Gildayc357c472018-03-21 13:54:09 +00001026/** Formatted output of the InterpolationPolicy type.
1027 *
1028 * @param[out] os Output stream.
1029 * @param[in] policy Type to output.
1030 *
1031 * @return Modified output stream.
1032 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001033inline ::std::ostream &operator<<(::std::ostream &os, const InterpolationPolicy &policy)
1034{
1035 switch(policy)
1036 {
1037 case InterpolationPolicy::NEAREST_NEIGHBOR:
1038 os << "NEAREST_NEIGHBOR";
1039 break;
1040 case InterpolationPolicy::BILINEAR:
1041 os << "BILINEAR";
1042 break;
1043 case InterpolationPolicy::AREA:
1044 os << "AREA";
1045 break;
1046 default:
1047 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1048 }
1049
1050 return os;
1051}
1052
Alex Gildayc357c472018-03-21 13:54:09 +00001053/** Formatted output of the SamplingPolicy type.
1054 *
1055 * @param[out] os Output stream.
1056 * @param[in] policy Type to output.
1057 *
1058 * @return Modified output stream.
1059 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +07001060inline ::std::ostream &operator<<(::std::ostream &os, const SamplingPolicy &policy)
1061{
1062 switch(policy)
1063 {
1064 case SamplingPolicy::CENTER:
1065 os << "CENTER";
1066 break;
1067 case SamplingPolicy::TOP_LEFT:
1068 os << "TOP_LEFT";
1069 break;
1070 default:
1071 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1072 }
1073
1074 return os;
1075}
1076
Alex Gildayc357c472018-03-21 13:54:09 +00001077/** Formatted output of the TensorInfo type.
1078 *
Anthony Barbier366628a2018-08-01 13:55:03 +01001079 * @param[out] os Output stream.
1080 * @param[in] info Type to output.
1081 *
1082 * @return Modified output stream.
1083 */
1084inline ::std::ostream &operator<<(::std::ostream &os, const TensorInfo &info)
1085{
1086 os << "{Shape=" << info.tensor_shape() << ","
1087 << "Type=" << info.data_type() << ","
1088 << "Channels=" << info.num_channels() << "}";
1089 return os;
1090}
1091/** Formatted output of the TensorInfo type.
1092 *
Alex Gildayc357c472018-03-21 13:54:09 +00001093 * @param[in] info Type to output.
1094 *
1095 * @return Formatted string.
1096 */
Georgios Pinitas3faea252017-10-30 14:13:50 +00001097inline std::string to_string(const TensorInfo &info)
1098{
1099 std::stringstream str;
Anthony Barbier366628a2018-08-01 13:55:03 +01001100 str << info;
Georgios Pinitas3faea252017-10-30 14:13:50 +00001101 return str.str();
1102}
1103
Alex Gildayc357c472018-03-21 13:54:09 +00001104/** Formatted output of the Dimensions type.
1105 *
1106 * @param[in] dimensions Type to output.
1107 *
1108 * @return Formatted string.
1109 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001110template <typename T>
1111inline std::string to_string(const Dimensions<T> &dimensions)
1112{
1113 std::stringstream str;
1114 str << dimensions;
1115 return str.str();
1116}
1117
Alex Gildayc357c472018-03-21 13:54:09 +00001118/** Formatted output of the Strides type.
1119 *
1120 * @param[in] stride Type to output.
1121 *
1122 * @return Formatted string.
1123 */
John Richardsona36eae12017-09-26 16:55:59 +01001124inline std::string to_string(const Strides &stride)
1125{
1126 std::stringstream str;
1127 str << stride;
1128 return str.str();
1129}
1130
Alex Gildayc357c472018-03-21 13:54:09 +00001131/** Formatted output of the TensorShape type.
1132 *
1133 * @param[in] shape Type to output.
1134 *
1135 * @return Formatted string.
1136 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001137inline std::string to_string(const TensorShape &shape)
1138{
1139 std::stringstream str;
1140 str << shape;
1141 return str.str();
1142}
1143
Alex Gildayc357c472018-03-21 13:54:09 +00001144/** Formatted output of the Coordinates type.
1145 *
1146 * @param[in] coord Type to output.
1147 *
1148 * @return Formatted string.
1149 */
Abe Mbise925ca0f2017-10-02 19:16:33 +01001150inline std::string to_string(const Coordinates &coord)
1151{
1152 std::stringstream str;
1153 str << coord;
1154 return str.str();
1155}
1156
Anthony Barbierb940fd62018-06-04 14:14:32 +01001157/** Formatted output of the GEMMReshapeInfo type.
1158 *
1159 * @param[out] os Output stream.
1160 * @param[in] info Type to output.
1161 *
1162 * @return Modified output stream.
1163 */
1164inline ::std::ostream &operator<<(::std::ostream &os, const GEMMReshapeInfo &info)
1165{
1166 os << "{m=" << info.m() << ",";
1167 os << "n=" << info.n() << ",";
1168 os << "k=" << info.k() << ",";
1169 os << "mult_transpose1xW_width=" << info.mult_transpose1xW_width() << ",";
1170 os << "mult_interleave4x4_height=" << info.mult_interleave4x4_height();
1171 os << "}";
1172
1173 return os;
1174}
1175
1176/** Formatted output of the GEMMInfo type.
1177 *
1178 * @param[out] os Output stream.
1179 * @param[in] info Type to output.
1180 *
1181 * @return Modified output stream.
1182 */
1183inline ::std::ostream &operator<<(::std::ostream &os, const GEMMInfo &info)
1184{
1185 os << "{is_a_reshaped=" << info.is_a_reshaped() << ",";
1186 os << "is_b_reshaped=" << info.is_b_reshaped() << ",";
1187 os << "reshape_b_only_on_first_run=" << info.reshape_b_only_on_first_run() << ",";
Anthony Barbierb4670212018-05-18 16:55:39 +01001188 os << "depth_output_gemm3d=" << info.depth_output_gemm3d() << ",";
1189 os << "reinterpret_input_as_3d=" << info.reinterpret_input_as_3d() << ",";
1190 os << "retain_internal_weights=" << info.retain_internal_weights() << ",";
1191 os << "fp_mixed_precision=" << info.fp_mixed_precision() << ",";
1192 os << "broadcast_bias=" << info.broadcast_bias() << ",";
1193 os << "pretranpose_B=" << info.pretranpose_B() << ",";
Anthony Barbierb940fd62018-06-04 14:14:32 +01001194
1195 return os;
1196}
1197
1198/** Formatted output of the Window::Dimension type.
1199 *
1200 * @param[out] os Output stream.
1201 * @param[in] dim Type to output.
1202 *
1203 * @return Modified output stream.
1204 */
1205inline ::std::ostream &operator<<(::std::ostream &os, const Window::Dimension &dim)
1206{
1207 os << "{start=" << dim.start() << ", end=" << dim.end() << ", step=" << dim.step() << "}";
1208
1209 return os;
1210}
1211/** Formatted output of the Window type.
1212 *
1213 * @param[out] os Output stream.
1214 * @param[in] win Type to output.
1215 *
1216 * @return Modified output stream.
1217 */
1218inline ::std::ostream &operator<<(::std::ostream &os, const Window &win)
1219{
1220 os << "{";
1221 for(unsigned int i = 0; i < Coordinates::num_max_dimensions; i++)
1222 {
1223 if(i > 0)
1224 {
1225 os << ", ";
1226 }
1227 os << win[i];
1228 }
1229 os << "}";
1230
1231 return os;
1232}
1233
1234/** Formatted output of the WeightsInfo type.
1235 *
1236 * @param[in] info Type to output.
1237 *
1238 * @return Formatted string.
1239 */
1240inline std::string to_string(const WeightsInfo &info)
1241{
1242 std::stringstream str;
1243 str << info;
1244 return str.str();
1245}
1246
1247/** Formatted output of the GEMMReshapeInfo type.
1248 *
1249 * @param[in] info Type to output.
1250 *
1251 * @return Formatted string.
1252 */
1253inline std::string to_string(const GEMMReshapeInfo &info)
1254{
1255 std::stringstream str;
1256 str << info;
1257 return str.str();
1258}
1259
1260/** Formatted output of the GEMMInfo type.
1261 *
1262 * @param[in] info Type to output.
1263 *
1264 * @return Formatted string.
1265 */
1266inline std::string to_string(const GEMMInfo &info)
1267{
1268 std::stringstream str;
1269 str << info;
1270 return str.str();
1271}
1272
1273/** Formatted output of the Window::Dimension type.
1274 *
1275 * @param[in] dim Type to output.
1276 *
1277 * @return Formatted string.
1278 */
1279inline std::string to_string(const Window::Dimension &dim)
1280{
1281 std::stringstream str;
1282 str << dim;
1283 return str.str();
1284}
1285/** Formatted output of the Window type.
1286 *
1287 * @param[in] win Type to output.
1288 *
1289 * @return Formatted string.
1290 */
1291inline std::string to_string(const Window &win)
1292{
1293 std::stringstream str;
1294 str << win;
1295 return str.str();
1296}
1297
Alex Gildayc357c472018-03-21 13:54:09 +00001298/** Formatted output of the Rectangle type.
1299 *
1300 * @param[out] os Output stream.
1301 * @param[in] rect Type to output.
1302 *
1303 * @return Modified output stream.
1304 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001305inline ::std::ostream &operator<<(::std::ostream &os, const Rectangle &rect)
1306{
1307 os << rect.width << "x" << rect.height;
1308 os << "+" << rect.x << "+" << rect.y;
1309
1310 return os;
1311}
1312
Usama Arif8cf8c112019-03-14 15:36:54 +00001313/** Formatted output of the PaddingMode type.
1314 *
1315 * @param[out] os Output stream.
1316 * @param[in] mode Type to output.
1317 *
1318 * @return Modified output stream.
1319 */
1320inline ::std::ostream &operator<<(::std::ostream &os, const PaddingMode &mode)
1321{
1322 switch(mode)
1323 {
1324 case PaddingMode::CONSTANT:
1325 os << "CONSTANT";
1326 break;
1327 case PaddingMode::REFLECT:
1328 os << "REFLECT";
1329 break;
1330 case PaddingMode::SYMMETRIC:
1331 os << "SYMMETRIC";
1332 break;
1333 default:
1334 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1335 }
1336
1337 return os;
1338}
1339
1340/** Formatted output of the PaddingMode type.
1341 *
1342 * @param[in] mode Type to output.
1343 *
1344 * @return Formatted string.
1345 */
1346inline std::string to_string(const PaddingMode &mode)
1347{
1348 std::stringstream str;
1349 str << mode;
1350 return str.str();
1351}
1352
Alex Gildayc357c472018-03-21 13:54:09 +00001353/** Formatted output of the PadStrideInfo type.
1354 *
1355 * @param[out] os Output stream.
1356 * @param[in] pad_stride_info Type to output.
1357 *
1358 * @return Modified output stream.
1359 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001360inline ::std::ostream &operator<<(::std::ostream &os, const PadStrideInfo &pad_stride_info)
1361{
1362 os << pad_stride_info.stride().first << "," << pad_stride_info.stride().second;
1363 os << ";";
Jaroslaw Rzepeckia1ed41f2017-10-13 11:13:58 +01001364 os << pad_stride_info.pad_left() << "," << pad_stride_info.pad_right() << ","
1365 << pad_stride_info.pad_top() << "," << pad_stride_info.pad_bottom();
Anthony Barbier2a07e182017-08-04 18:20:27 +01001366
1367 return os;
1368}
1369
Alex Gildayc357c472018-03-21 13:54:09 +00001370/** Formatted output of the PadStrideInfo type.
1371 *
1372 * @param[in] pad_stride_info Type to output.
1373 *
1374 * @return Formatted string.
1375 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001376inline std::string to_string(const PadStrideInfo &pad_stride_info)
1377{
1378 std::stringstream str;
1379 str << pad_stride_info;
1380 return str.str();
1381}
1382
Alex Gildayc357c472018-03-21 13:54:09 +00001383/** Formatted output of the BorderMode type.
1384 *
1385 * @param[in] mode Type to output.
1386 *
1387 * @return Formatted string.
1388 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001389inline std::string to_string(const BorderMode &mode)
1390{
1391 std::stringstream str;
1392 str << mode;
1393 return str.str();
1394}
1395
Alex Gildayc357c472018-03-21 13:54:09 +00001396/** Formatted output of the BorderSize type.
1397 *
1398 * @param[in] border Type to output.
1399 *
1400 * @return Formatted string.
1401 */
John Richardsonb482ce12017-09-18 12:44:01 +01001402inline std::string to_string(const BorderSize &border)
1403{
1404 std::stringstream str;
1405 str << border;
1406 return str.str();
1407}
1408
Giuseppe Rossinid7647d42018-07-17 18:13:13 +01001409/** Formatted output of the PaddingList type.
1410 *
1411 * @param[in] padding Type to output.
1412 *
1413 * @return Formatted string.
1414 */
1415inline std::string to_string(const PaddingList &padding)
1416{
1417 std::stringstream str;
1418 str << padding;
1419 return str.str();
1420}
1421
giuros013175fcf2018-11-21 09:59:17 +00001422/** Formatted output of the Multiples type.
1423 *
1424 * @param[in] multiples Type to output.
1425 *
1426 * @return Formatted string.
1427 */
1428inline std::string to_string(const Multiples &multiples)
1429{
1430 std::stringstream str;
1431 str << multiples;
1432 return str.str();
1433}
1434
Alex Gildayc357c472018-03-21 13:54:09 +00001435/** Formatted output of the InterpolationPolicy type.
1436 *
1437 * @param[in] policy Type to output.
1438 *
1439 * @return Formatted string.
1440 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001441inline std::string to_string(const InterpolationPolicy &policy)
1442{
1443 std::stringstream str;
1444 str << policy;
1445 return str.str();
1446}
1447
Alex Gildayc357c472018-03-21 13:54:09 +00001448/** Formatted output of the SamplingPolicy type.
1449 *
1450 * @param[in] policy Type to output.
1451 *
1452 * @return Formatted string.
1453 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +07001454inline std::string to_string(const SamplingPolicy &policy)
1455{
1456 std::stringstream str;
1457 str << policy;
1458 return str.str();
1459}
1460
Alex Gildayc357c472018-03-21 13:54:09 +00001461/** Formatted output of the ConvertPolicy type.
1462 *
1463 * @param[out] os Output stream.
1464 * @param[in] policy Type to output.
1465 *
1466 * @return Modified output stream.
1467 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001468inline ::std::ostream &operator<<(::std::ostream &os, const ConvertPolicy &policy)
1469{
1470 switch(policy)
1471 {
1472 case ConvertPolicy::WRAP:
1473 os << "WRAP";
1474 break;
1475 case ConvertPolicy::SATURATE:
1476 os << "SATURATE";
1477 break;
1478 default:
1479 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1480 }
1481
1482 return os;
1483}
1484
1485inline std::string to_string(const ConvertPolicy &policy)
1486{
1487 std::stringstream str;
1488 str << policy;
1489 return str.str();
1490}
1491
giuros01164a2722018-11-20 18:34:46 +00001492/** Formatted output of the ArithmeticOperation type.
1493 *
1494 * @param[out] os Output stream.
1495 * @param[in] op Operation to output.
1496 *
1497 * @return Modified output stream.
1498 */
1499inline ::std::ostream &operator<<(::std::ostream &os, const ArithmeticOperation &op)
1500{
1501 switch(op)
1502 {
1503 case ArithmeticOperation::ADD:
1504 os << "ADD";
1505 break;
1506 case ArithmeticOperation::SUB:
1507 os << "SUB";
1508 break;
1509 case ArithmeticOperation::DIV:
1510 os << "DIV";
1511 break;
1512 case ArithmeticOperation::MAX:
1513 os << "MAX";
1514 break;
1515 case ArithmeticOperation::MIN:
1516 os << "MIN";
1517 break;
1518 case ArithmeticOperation::SQUARED_DIFF:
1519 os << "SQUARED_DIFF";
1520 break;
Usama Arif52c54f62019-05-14 10:22:36 +01001521 case ArithmeticOperation::POWER:
1522 os << "POWER";
1523 break;
giuros01164a2722018-11-20 18:34:46 +00001524 default:
1525 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1526 }
1527
1528 return os;
1529}
1530
1531/** Formatted output of the Arithmetic Operation
1532 *
1533 * @param[in] op Type to output.
1534 *
1535 * @return Formatted string.
1536 */
1537inline std::string to_string(const ArithmeticOperation &op)
1538{
1539 std::stringstream str;
1540 str << op;
1541 return str.str();
1542}
1543
Alex Gildayc357c472018-03-21 13:54:09 +00001544/** Formatted output of the Reduction Operations.
1545 *
1546 * @param[out] os Output stream.
1547 * @param[in] op Type to output.
1548 *
1549 * @return Modified output stream.
1550 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001551inline ::std::ostream &operator<<(::std::ostream &os, const ReductionOperation &op)
1552{
1553 switch(op)
1554 {
Michalis Spyrou7e9391b2018-10-05 14:49:28 +01001555 case ReductionOperation::SUM:
1556 os << "SUM";
1557 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +01001558 case ReductionOperation::SUM_SQUARE:
1559 os << "SUM_SQUARE";
1560 break;
Michalis Spyrou7e9391b2018-10-05 14:49:28 +01001561 case ReductionOperation::MEAN_SUM:
1562 os << "MEAN_SUM";
1563 break;
Michalis Spyrou7930db42018-11-22 17:36:28 +00001564 case ReductionOperation::ARG_IDX_MAX:
1565 os << "ARG_IDX_MAX";
1566 break;
1567 case ReductionOperation::ARG_IDX_MIN:
1568 os << "ARG_IDX_MIN";
1569 break;
Manuel Bottinib412fab2018-12-10 17:40:23 +00001570 case ReductionOperation::PROD:
1571 os << "PROD";
1572 break;
Usama Arifa4a08ad2019-05-20 12:38:33 +01001573 case ReductionOperation::MIN:
1574 os << "MIN";
1575 break;
Usama Arif28f0dd92019-05-20 13:44:34 +01001576 case ReductionOperation::MAX:
1577 os << "MAX";
1578 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +01001579 default:
1580 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1581 }
1582
1583 return os;
1584}
1585
Alex Gildayc357c472018-03-21 13:54:09 +00001586/** Formatted output of the Reduction Operations.
1587 *
1588 * @param[in] op Type to output.
1589 *
1590 * @return Formatted string.
1591 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001592inline std::string to_string(const ReductionOperation &op)
1593{
1594 std::stringstream str;
1595 str << op;
1596 return str.str();
1597}
1598
Georgios Pinitas7900a9e2018-11-23 11:44:58 +00001599/** Formatted output of the Comparison Operations.
1600 *
1601 * @param[out] os Output stream.
1602 * @param[in] op Type to output.
1603 *
1604 * @return Modified output stream.
1605 */
1606inline ::std::ostream &operator<<(::std::ostream &os, const ComparisonOperation &op)
1607{
1608 switch(op)
1609 {
1610 case ComparisonOperation::Equal:
1611 os << "Equal";
1612 break;
1613 case ComparisonOperation::NotEqual:
1614 os << "NotEqual";
1615 break;
1616 case ComparisonOperation::Greater:
1617 os << "Greater";
1618 break;
1619 case ComparisonOperation::GreaterEqual:
1620 os << "GreaterEqual";
1621 break;
1622 case ComparisonOperation::Less:
1623 os << "Less";
1624 break;
1625 case ComparisonOperation::LessEqual:
1626 os << "LessEqual";
1627 break;
1628 default:
1629 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1630 }
1631
1632 return os;
1633}
1634
Michalis Spyroue9362622018-11-23 17:41:37 +00001635/** Formatted output of the Elementwise unary Operations.
1636 *
1637 * @param[out] os Output stream.
1638 * @param[in] op Type to output.
1639 *
1640 * @return Modified output stream.
1641 */
1642inline ::std::ostream &operator<<(::std::ostream &os, const ElementWiseUnary &op)
1643{
1644 switch(op)
1645 {
1646 case ElementWiseUnary::RSQRT:
1647 os << "RSQRT";
1648 break;
1649 case ElementWiseUnary::EXP:
1650 os << "EXP";
1651 break;
Usama Arifeb312ef2019-05-13 17:45:54 +01001652 case ElementWiseUnary::NEG:
1653 os << "NEG";
1654 break;
Usama Arifac33d7e2019-05-20 14:21:40 +01001655 case ElementWiseUnary::LOG:
1656 os << "LOG";
1657 break;
Usama Arif6a4d5422019-05-24 14:53:59 +01001658 case ElementWiseUnary::ROUND:
1659 os << "ROUND";
1660 break;
Michalis Spyroue9362622018-11-23 17:41:37 +00001661 default:
1662 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1663 }
1664
1665 return os;
1666}
1667
Georgios Pinitas7900a9e2018-11-23 11:44:58 +00001668/** Formatted output of the Comparison Operations.
1669 *
1670 * @param[in] op Type to output.
1671 *
1672 * @return Formatted string.
1673 */
1674inline std::string to_string(const ComparisonOperation &op)
1675{
1676 std::stringstream str;
1677 str << op;
1678 return str.str();
1679}
1680
Michalis Spyroue9362622018-11-23 17:41:37 +00001681/** Formatted output of the Elementwise unary Operations.
1682 *
1683 * @param[in] op Type to output.
1684 *
1685 * @return Formatted string.
1686 */
1687inline std::string to_string(const ElementWiseUnary &op)
1688{
1689 std::stringstream str;
1690 str << op;
1691 return str.str();
1692}
1693
Alex Gildayc357c472018-03-21 13:54:09 +00001694/** Formatted output of the Norm Type.
1695 *
1696 * @param[in] type Type to output.
1697 *
1698 * @return Formatted string.
1699 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001700inline std::string to_string(const NormType &type)
1701{
1702 std::stringstream str;
1703 str << type;
1704 return str.str();
1705}
1706
Alex Gildayc357c472018-03-21 13:54:09 +00001707/** Formatted output of the Pooling Type.
1708 *
1709 * @param[in] type Type to output.
1710 *
1711 * @return Formatted string.
1712 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001713inline std::string to_string(const PoolingType &type)
1714{
1715 std::stringstream str;
1716 str << type;
1717 return str.str();
1718}
1719
Alex Gildayc357c472018-03-21 13:54:09 +00001720/** Formatted output of the Pooling Layer Info.
1721 *
1722 * @param[in] info Type to output.
1723 *
1724 * @return Formatted string.
1725 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001726inline std::string to_string(const PoolingLayerInfo &info)
1727{
1728 std::stringstream str;
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +00001729 str << "{Type=" << info.pool_type << ","
Sang-Hoon Park11fedda2020-01-15 14:44:04 +00001730 << "DataLayout=" << info.data_layout << ","
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +00001731 << "IsGlobalPooling=" << info.is_global_pooling;
1732 if(!info.is_global_pooling)
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001733 {
1734 str << ","
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +00001735 << "PoolSize=" << info.pool_size.width << "," << info.pool_size.height << ","
1736 << "PadStride=" << info.pad_stride_info;
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001737 }
1738 str << "}";
Anthony Barbier2a07e182017-08-04 18:20:27 +01001739 return str.str();
1740}
1741
Michalis Spyrou6c7c38e2018-08-29 16:28:11 +01001742/** Formatted output of the PriorBoxLayerInfo.
1743 *
1744 * @param[in] info Type to output.
1745 *
1746 * @return Formatted string.
1747 */
1748inline std::string to_string(const PriorBoxLayerInfo &info)
1749{
1750 std::stringstream str;
1751 str << "{";
1752 str << "Clip:" << info.clip()
1753 << "Flip:" << info.flip()
1754 << "StepX:" << info.steps()[0]
1755 << "StepY:" << info.steps()[1]
1756 << "MinSizes:" << info.min_sizes().size()
1757 << "MaxSizes:" << info.max_sizes().size()
1758 << "ImgSizeX:" << info.img_size().x
1759 << "ImgSizeY:" << info.img_size().y
1760 << "Offset:" << info.offset()
1761 << "Variances:" << info.variances().size();
1762 str << "}";
1763 return str.str();
1764}
1765
Alex Gildayc357c472018-03-21 13:54:09 +00001766/** Formatted output of the KeyPoint type.
1767 *
1768 * @param[out] os Output stream
1769 * @param[in] point Type to output.
1770 *
1771 * @return Modified output stream.
1772 */
Moritz Pflanzer6c6597c2017-09-24 12:09:41 +01001773inline ::std::ostream &operator<<(::std::ostream &os, const KeyPoint &point)
1774{
1775 os << "{x=" << point.x << ","
1776 << "y=" << point.y << ","
1777 << "strength=" << point.strength << ","
1778 << "scale=" << point.scale << ","
1779 << "orientation=" << point.orientation << ","
1780 << "tracking_status=" << point.tracking_status << ","
1781 << "error=" << point.error << "}";
1782
1783 return os;
1784}
John Richardson63e50412017-10-13 20:51:42 +01001785
Alex Gildayc357c472018-03-21 13:54:09 +00001786/** Formatted output of the PhaseType type.
1787 *
1788 * @param[out] os Output stream
1789 * @param[in] phase_type Type to output.
1790 *
1791 * @return Modified output stream.
1792 */
John Richardson63e50412017-10-13 20:51:42 +01001793inline ::std::ostream &operator<<(::std::ostream &os, const PhaseType &phase_type)
1794{
1795 switch(phase_type)
1796 {
1797 case PhaseType::SIGNED:
1798 os << "SIGNED";
1799 break;
1800 case PhaseType::UNSIGNED:
1801 os << "UNSIGNED";
1802 break;
1803 default:
1804 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1805 }
1806
1807 return os;
1808}
1809
Alex Gildayc357c472018-03-21 13:54:09 +00001810/** Formatted output of the PhaseType type.
1811 *
1812 * @param[in] type Type to output.
1813 *
1814 * @return Formatted string.
1815 */
John Richardson63e50412017-10-13 20:51:42 +01001816inline std::string to_string(const arm_compute::PhaseType &type)
1817{
1818 std::stringstream str;
1819 str << type;
1820 return str.str();
1821}
John Richardson3c5f9492017-10-04 15:27:37 +01001822
Alex Gildayc357c472018-03-21 13:54:09 +00001823/** Formatted output of the MagnitudeType type.
1824 *
1825 * @param[out] os Output stream
1826 * @param[in] magnitude_type Type to output.
1827 *
1828 * @return Modified output stream.
1829 */
John Richardson3c5f9492017-10-04 15:27:37 +01001830inline ::std::ostream &operator<<(::std::ostream &os, const MagnitudeType &magnitude_type)
1831{
1832 switch(magnitude_type)
1833 {
1834 case MagnitudeType::L1NORM:
1835 os << "L1NORM";
1836 break;
1837 case MagnitudeType::L2NORM:
1838 os << "L2NORM";
1839 break;
1840 default:
1841 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1842 }
1843
1844 return os;
1845}
1846
Alex Gildayc357c472018-03-21 13:54:09 +00001847/** Formatted output of the MagnitudeType type.
1848 *
1849 * @param[in] type Type to output.
1850 *
1851 * @return Formatted string.
1852 */
John Richardson3c5f9492017-10-04 15:27:37 +01001853inline std::string to_string(const arm_compute::MagnitudeType &type)
1854{
1855 std::stringstream str;
1856 str << type;
1857 return str.str();
1858}
John Richardson1c529922017-11-01 10:57:48 +00001859
Alex Gildayc357c472018-03-21 13:54:09 +00001860/** Formatted output of the HOGNormType type.
1861 *
1862 * @param[out] os Output stream
1863 * @param[in] norm_type Type to output
1864 *
1865 * @return Modified output stream.
1866 */
John Richardson25f23682017-11-27 14:35:09 +00001867inline ::std::ostream &operator<<(::std::ostream &os, const HOGNormType &norm_type)
1868{
1869 switch(norm_type)
1870 {
1871 case HOGNormType::L1_NORM:
1872 os << "L1_NORM";
1873 break;
1874 case HOGNormType::L2_NORM:
1875 os << "L2_NORM";
1876 break;
1877 case HOGNormType::L2HYS_NORM:
1878 os << "L2HYS_NORM";
1879 break;
1880 default:
1881 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1882 }
1883
1884 return os;
1885}
1886
Alex Gildayc357c472018-03-21 13:54:09 +00001887/** Formatted output of the HOGNormType type.
1888 *
1889 * @param[in] type Type to output
1890 *
1891 * @return Formatted string.
1892 */
John Richardson25f23682017-11-27 14:35:09 +00001893inline std::string to_string(const HOGNormType &type)
1894{
1895 std::stringstream str;
1896 str << type;
1897 return str.str();
1898}
1899
Alex Gildayc357c472018-03-21 13:54:09 +00001900/** Formatted output of the Size2D type.
1901 *
1902 * @param[out] os Output stream
1903 * @param[in] size Type to output
1904 *
1905 * @return Modified output stream.
1906 */
John Richardson25f23682017-11-27 14:35:09 +00001907inline ::std::ostream &operator<<(::std::ostream &os, const Size2D &size)
1908{
1909 os << size.width << "x" << size.height;
1910
1911 return os;
1912}
1913
Alex Gildayc357c472018-03-21 13:54:09 +00001914/** Formatted output of the Size2D type.
1915 *
1916 * @param[in] type Type to output
1917 *
1918 * @return Formatted string.
1919 */
John Richardson25f23682017-11-27 14:35:09 +00001920inline std::string to_string(const Size2D &type)
1921{
1922 std::stringstream str;
1923 str << type;
1924 return str.str();
1925}
1926
Alex Gildayc357c472018-03-21 13:54:09 +00001927/** Formatted output of the HOGInfo type.
1928 *
1929 * @param[out] os Output stream
1930 * @param[in] hog_info Type to output
1931 *
1932 * @return Modified output stream.
1933 */
John Richardson25f23682017-11-27 14:35:09 +00001934inline ::std::ostream &operator<<(::std::ostream &os, const HOGInfo &hog_info)
1935{
1936 os << "{CellSize=" << hog_info.cell_size() << ","
1937 << "BlockSize=" << hog_info.block_size() << ","
1938 << "DetectionWindowSize=" << hog_info.detection_window_size() << ","
1939 << "BlockStride=" << hog_info.block_stride() << ","
1940 << "NumBins=" << hog_info.num_bins() << ","
1941 << "NormType=" << hog_info.normalization_type() << ","
1942 << "L2HystThreshold=" << hog_info.l2_hyst_threshold() << ","
1943 << "PhaseType=" << hog_info.phase_type() << "}";
1944
1945 return os;
1946}
1947
Alex Gildayc357c472018-03-21 13:54:09 +00001948/** Formatted output of the HOGInfo type.
1949 *
1950 * @param[in] type Type to output
1951 *
1952 * @return Formatted string.
1953 */
John Richardson25f23682017-11-27 14:35:09 +00001954inline std::string to_string(const HOGInfo &type)
1955{
1956 std::stringstream str;
1957 str << type;
1958 return str.str();
1959}
1960
Alex Gildayc357c472018-03-21 13:54:09 +00001961/** Formatted output of the ConvolutionMethod type.
1962 *
1963 * @param[out] os Output stream
1964 * @param[in] conv_method Type to output
1965 *
1966 * @return Modified output stream.
1967 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001968inline ::std::ostream &operator<<(::std::ostream &os, const ConvolutionMethod &conv_method)
1969{
1970 switch(conv_method)
1971 {
1972 case ConvolutionMethod::GEMM:
1973 os << "GEMM";
1974 break;
1975 case ConvolutionMethod::DIRECT:
1976 os << "DIRECT";
1977 break;
1978 case ConvolutionMethod::WINOGRAD:
1979 os << "WINOGRAD";
1980 break;
1981 default:
1982 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1983 }
1984
1985 return os;
1986}
1987
Alex Gildayc357c472018-03-21 13:54:09 +00001988/** Formatted output of the ConvolutionMethod type.
1989 *
1990 * @param[in] conv_method Type to output
1991 *
1992 * @return Formatted string.
1993 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001994inline std::string to_string(const ConvolutionMethod &conv_method)
1995{
1996 std::stringstream str;
1997 str << conv_method;
1998 return str.str();
1999}
2000
Alex Gildayc357c472018-03-21 13:54:09 +00002001/** Formatted output of the GPUTarget type.
2002 *
2003 * @param[out] os Output stream
2004 * @param[in] gpu_target Type to output
2005 *
2006 * @return Modified output stream.
2007 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002008inline ::std::ostream &operator<<(::std::ostream &os, const GPUTarget &gpu_target)
2009{
2010 switch(gpu_target)
2011 {
2012 case GPUTarget::GPU_ARCH_MASK:
2013 os << "GPU_ARCH_MASK";
2014 break;
2015 case GPUTarget::MIDGARD:
2016 os << "MIDGARD";
2017 break;
2018 case GPUTarget::BIFROST:
2019 os << "BIFROST";
2020 break;
Georgios Pinitasd5462ff2019-07-03 19:33:57 +01002021 case GPUTarget::VALHALL:
2022 os << "VALHALL";
2023 break;
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002024 case GPUTarget::T600:
2025 os << "T600";
2026 break;
2027 case GPUTarget::T700:
2028 os << "T700";
2029 break;
2030 case GPUTarget::T800:
2031 os << "T800";
2032 break;
Michalis Spyroua9676112018-02-22 18:07:43 +00002033 case GPUTarget::G71:
2034 os << "G71";
2035 break;
2036 case GPUTarget::G72:
2037 os << "G72";
2038 break;
2039 case GPUTarget::G51:
2040 os << "G51";
2041 break;
2042 case GPUTarget::G51BIG:
2043 os << "G51BIG";
2044 break;
2045 case GPUTarget::G51LIT:
2046 os << "G51LIT";
2047 break;
Georgios Pinitasb03f7c52018-07-12 10:49:53 +01002048 case GPUTarget::G76:
2049 os << "G76";
Michalis Spyroua9676112018-02-22 18:07:43 +00002050 break;
Georgios Pinitasd5462ff2019-07-03 19:33:57 +01002051 case GPUTarget::G77:
2052 os << "G77";
Michalis Spyroua9676112018-02-22 18:07:43 +00002053 break;
Georgios Pinitas4ffc42a2020-12-01 16:28:24 +00002054 case GPUTarget::G78:
2055 os << "G78";
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002056 break;
Georgios Pinitasd5462ff2019-07-03 19:33:57 +01002057 case GPUTarget::TODX:
2058 os << "TODX";
2059 break;
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002060 default:
2061 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2062 }
2063
2064 return os;
2065}
2066
Alex Gildayc357c472018-03-21 13:54:09 +00002067/** Formatted output of the GPUTarget type.
2068 *
2069 * @param[in] gpu_target Type to output
2070 *
2071 * @return Formatted string.
2072 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00002073inline std::string to_string(const GPUTarget &gpu_target)
2074{
2075 std::stringstream str;
2076 str << gpu_target;
2077 return str.str();
2078}
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00002079
John Richardson8de92612018-02-22 14:09:31 +00002080/** Formatted output of the DetectionWindow type.
2081 *
2082 * @param[out] os Output stream
2083 * @param[in] detection_window Type to output
2084 *
2085 * @return Modified output stream.
2086 */
John Richardson684cb0f2018-01-09 11:17:00 +00002087inline ::std::ostream &operator<<(::std::ostream &os, const DetectionWindow &detection_window)
2088{
2089 os << "{x=" << detection_window.x << ","
2090 << "y=" << detection_window.y << ","
2091 << "width=" << detection_window.width << ","
2092 << "height=" << detection_window.height << ","
2093 << "idx_class=" << detection_window.idx_class << ","
2094 << "score=" << detection_window.score << "}";
2095
2096 return os;
2097}
2098
Isabella Gottardi05e56442018-11-16 11:26:52 +00002099/** Formatted output of the DetectionOutputLayerCodeType type.
2100 *
2101 * @param[out] os Output stream
2102 * @param[in] detection_code Type to output
2103 *
2104 * @return Modified output stream.
2105 */
2106inline ::std::ostream &operator<<(::std::ostream &os, const DetectionOutputLayerCodeType &detection_code)
2107{
2108 switch(detection_code)
2109 {
2110 case DetectionOutputLayerCodeType::CENTER_SIZE:
2111 os << "CENTER_SIZE";
2112 break;
2113 case DetectionOutputLayerCodeType::CORNER:
2114 os << "CORNER";
2115 break;
2116 case DetectionOutputLayerCodeType::CORNER_SIZE:
2117 os << "CORNER_SIZE";
2118 break;
2119 case DetectionOutputLayerCodeType::TF_CENTER:
2120 os << "TF_CENTER";
2121 break;
2122 default:
2123 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2124 }
2125
2126 return os;
2127}
2128/** Formatted output of the DetectionOutputLayerCodeType type.
2129 *
2130 * @param[in] detection_code Type to output
2131 *
2132 * @return Formatted string.
2133 */
2134inline std::string to_string(const DetectionOutputLayerCodeType &detection_code)
2135{
2136 std::stringstream str;
2137 str << detection_code;
2138 return str.str();
2139}
2140
2141/** Formatted output of the DetectionOutputLayerInfo type.
2142 *
2143 * @param[out] os Output stream
2144 * @param[in] detection_info Type to output
2145 *
2146 * @return Modified output stream.
2147 */
2148inline ::std::ostream &operator<<(::std::ostream &os, const DetectionOutputLayerInfo &detection_info)
2149{
2150 os << "{Classes=" << detection_info.num_classes() << ","
2151 << "ShareLocation=" << detection_info.share_location() << ","
2152 << "CodeType=" << detection_info.code_type() << ","
2153 << "VarianceEncodedInTarget=" << detection_info.variance_encoded_in_target() << ","
2154 << "KeepTopK=" << detection_info.keep_top_k() << ","
2155 << "NMSThreshold=" << detection_info.nms_threshold() << ","
2156 << "Eta=" << detection_info.eta() << ","
2157 << "BackgroundLabelId=" << detection_info.background_label_id() << ","
2158 << "ConfidenceThreshold=" << detection_info.confidence_threshold() << ","
2159 << "TopK=" << detection_info.top_k() << ","
2160 << "NumLocClasses=" << detection_info.num_loc_classes()
2161 << "}";
2162
2163 return os;
2164}
2165
2166/** Formatted output of the DetectionOutputLayerInfo type.
2167 *
2168 * @param[in] detection_info Type to output
2169 *
2170 * @return Formatted string.
2171 */
2172inline std::string to_string(const DetectionOutputLayerInfo &detection_info)
2173{
2174 std::stringstream str;
2175 str << detection_info;
2176 return str.str();
2177}
Isabella Gottardia7acb3c2019-01-08 13:48:44 +00002178/** Formatted output of the DetectionPostProcessLayerInfo type.
2179 *
2180 * @param[out] os Output stream
2181 * @param[in] detection_info Type to output
2182 *
2183 * @return Modified output stream.
2184 */
2185inline ::std::ostream &operator<<(::std::ostream &os, const DetectionPostProcessLayerInfo &detection_info)
2186{
2187 os << "{MaxDetections=" << detection_info.max_detections() << ","
2188 << "MaxClassesPerDetection=" << detection_info.max_classes_per_detection() << ","
2189 << "NmsScoreThreshold=" << detection_info.nms_score_threshold() << ","
2190 << "NmsIouThreshold=" << detection_info.iou_threshold() << ","
2191 << "NumClasses=" << detection_info.num_classes() << ","
2192 << "ScaleValue_y=" << detection_info.scale_value_y() << ","
2193 << "ScaleValue_x=" << detection_info.scale_value_x() << ","
2194 << "ScaleValue_h=" << detection_info.scale_value_h() << ","
2195 << "ScaleValue_w=" << detection_info.scale_value_w() << ","
2196 << "UseRegularNms=" << detection_info.use_regular_nms() << ","
2197 << "DetectionPerClass=" << detection_info.detection_per_class()
2198 << "}";
2199
2200 return os;
2201}
2202
2203/** Formatted output of the DetectionPostProcessLayerInfo type.
2204 *
2205 * @param[in] detection_info Type to output
2206 *
2207 * @return Formatted string.
2208 */
2209inline std::string to_string(const DetectionPostProcessLayerInfo &detection_info)
2210{
2211 std::stringstream str;
2212 str << detection_info;
2213 return str.str();
2214}
John Richardson8de92612018-02-22 14:09:31 +00002215/** Formatted output of the DetectionWindow type.
2216 *
2217 * @param[in] detection_window Type to output
2218 *
2219 * @return Formatted string.
2220 */
2221inline std::string to_string(const DetectionWindow &detection_window)
2222{
2223 std::stringstream str;
2224 str << detection_window;
2225 return str.str();
2226}
2227
2228/** Formatted output of the Termination type.
2229 *
2230 * @param[out] os Output stream
2231 * @param[in] termination Type to output
2232 *
2233 * @return Modified output stream.
2234 */
2235inline ::std::ostream &operator<<(::std::ostream &os, const Termination &termination)
2236{
2237 switch(termination)
2238 {
2239 case Termination::TERM_CRITERIA_EPSILON:
2240 os << "TERM_CRITERIA_EPSILON";
2241 break;
2242 case Termination::TERM_CRITERIA_ITERATIONS:
2243 os << "TERM_CRITERIA_ITERATIONS";
2244 break;
2245 case Termination::TERM_CRITERIA_BOTH:
2246 os << "TERM_CRITERIA_BOTH";
2247 break;
2248 default:
2249 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2250 }
2251
2252 return os;
2253}
2254
2255/** Formatted output of the Termination type.
2256 *
2257 * @param[in] termination Type to output
2258 *
2259 * @return Formatted string.
2260 */
2261inline std::string to_string(const Termination &termination)
2262{
2263 std::stringstream str;
2264 str << termination;
2265 return str.str();
2266}
2267
Anthony Barbier8914e322018-08-10 15:28:25 +01002268/** Formatted output of the CPUModel type.
2269 *
2270 * @param[out] os Output stream
2271 * @param[in] cpu_model Model to output
2272 *
2273 * @return Modified output stream.
2274 */
2275inline ::std::ostream &operator<<(::std::ostream &os, const CPUModel &cpu_model)
2276{
2277 switch(cpu_model)
2278 {
2279 case CPUModel::GENERIC:
2280 os << "GENERIC";
2281 break;
2282 case CPUModel::GENERIC_FP16:
2283 os << "GENERIC_FP16";
2284 break;
2285 case CPUModel::GENERIC_FP16_DOT:
2286 os << "GENERIC_FP16_DOT";
2287 break;
2288 case CPUModel::A53:
2289 os << "A53";
2290 break;
2291 case CPUModel::A55r0:
2292 os << "A55r0";
2293 break;
2294 case CPUModel::A55r1:
2295 os << "A55r1";
2296 break;
David Mansell318c9f42020-07-08 13:28:45 +01002297 case CPUModel::A73:
2298 os << "A73";
2299 break;
2300 case CPUModel::X1:
2301 os << "X1";
2302 break;
Anthony Barbier8914e322018-08-10 15:28:25 +01002303 default:
2304 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2305 }
2306
2307 return os;
2308}
2309
2310/** Formatted output of the CPUModel type.
2311 *
2312 * @param[in] cpu_model Model to output
2313 *
2314 * @return Formatted string.
2315 */
2316inline std::string to_string(const CPUModel &cpu_model)
2317{
2318 std::stringstream str;
2319 str << cpu_model;
2320 return str.str();
2321}
Anthony Barbier671a11e2018-07-06 15:11:36 +01002322/** Formatted output of a vector of objects.
2323 *
2324 * @param[out] os Output stream
2325 * @param[in] args Vector of objects to print
2326 *
2327 * @return Modified output stream.
2328 */
2329template <typename T>
2330inline ::std::ostream &operator<<(::std::ostream &os, const std::vector<T> &args)
2331{
2332 os << "[";
2333 bool first = true;
2334 for(auto &arg : args)
2335 {
2336 if(first)
2337 {
2338 first = false;
2339 }
2340 else
2341 {
2342 os << ", ";
2343 }
2344 os << arg;
2345 }
2346 os << "]";
2347 return os;
2348}
2349
Michalis Spyrou6c7c38e2018-08-29 16:28:11 +01002350/** Formatted output of @ref PriorBoxLayerInfo.
2351 *
2352 * @param[out] os Output stream.
2353 * @param[in] info Type to output.
2354 *
2355 * @return Modified output stream.
2356 */
2357inline ::std::ostream &operator<<(::std::ostream &os, const PriorBoxLayerInfo &info)
2358{
2359 os << "Clip:" << info.clip()
2360 << "Flip:" << info.flip()
2361 << "StepX:" << info.steps()[0]
2362 << "StepY:" << info.steps()[1]
2363 << "MinSizes:" << info.min_sizes()
2364 << "MaxSizes:" << info.max_sizes()
2365 << "ImgSizeX:" << info.img_size().x
2366 << "ImgSizeY:" << info.img_size().y
2367 << "Offset:" << info.offset()
2368 << "Variances:" << info.variances();
2369
2370 return os;
2371}
2372
Anthony Barbier671a11e2018-07-06 15:11:36 +01002373/** Formatted output of a vector of objects.
2374 *
2375 * @param[in] args Vector of objects to print
2376 *
2377 * @return String representing args.
2378 */
2379template <typename T>
2380std::string to_string(const std::vector<T> &args)
2381{
2382 std::stringstream str;
2383 str << args;
2384 return str.str();
2385}
2386
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00002387/** Formatted output of the WinogradInfo type. */
2388inline ::std::ostream &operator<<(::std::ostream &os, const WinogradInfo &info)
2389{
2390 os << "{OutputTileSize=" << info.output_tile_size << ","
2391 << "KernelSize=" << info.kernel_size << ","
2392 << "PadStride=" << info.convolution_info << ","
2393 << "OutputDataLayout=" << info.output_data_layout << "}";
2394
2395 return os;
2396}
2397
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00002398inline std::string to_string(const WinogradInfo &type)
2399{
2400 std::stringstream str;
2401 str << type;
2402 return str.str();
2403}
Anthony Barbier671a11e2018-07-06 15:11:36 +01002404
2405/** Fallback method: try to use std::to_string:
2406 *
2407 * @param[in] val Value to convert to string
2408 *
2409 * @return String representing val.
2410 */
2411template <typename T>
2412inline std::string to_string(const T &val)
2413{
2414 return support::cpp11::to_string(val);
2415}
2416
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +01002417/** Convert a CLTunerMode value to a string
2418 *
2419 * @param val CLTunerMode value to be converted
2420 *
2421 * @return String representing the corresponding CLTunerMode.
2422 */
2423inline std::string to_string(const CLTunerMode val)
2424{
2425 switch(val)
2426 {
2427 case CLTunerMode::EXHAUSTIVE:
2428 {
2429 return std::string("Exhaustive");
2430 }
2431 case CLTunerMode::NORMAL:
2432 {
2433 return std::string("Normal");
2434 }
2435 case CLTunerMode::RAPID:
2436 {
2437 return std::string("Rapid");
2438 }
2439 default:
2440 {
2441 ARM_COMPUTE_ERROR("Invalid tuner mode.");
2442 return std::string("UNDEFINED");
2443 }
2444 }
2445}
SiCong Lidb4a6c12021-02-05 09:30:57 +00002446/** Converts a @ref CLGEMMKernelType to string
2447 *
2448 * @param[in] val CLGEMMKernelType value to be converted
2449 *
2450 * @return String representing the corresponding CLGEMMKernelType
2451 */
2452inline std::string to_string(CLGEMMKernelType val)
2453{
2454 switch(val)
2455 {
2456 case CLGEMMKernelType::NATIVE_V1:
2457 {
2458 return "Native_V1";
2459 }
2460 case CLGEMMKernelType::RESHAPED_V1:
2461 {
2462 return "Reshaped_V1";
2463 }
2464 case CLGEMMKernelType::NATIVE:
2465 {
2466 return "Native";
2467 }
2468 case CLGEMMKernelType::RESHAPED_ONLY_RHS:
2469 {
2470 return "Reshaped_Only_RHS";
2471 }
2472 case CLGEMMKernelType::RESHAPED:
2473 {
2474 return "Reshaped";
2475 }
2476 default:
2477 {
2478 return "Unknown";
2479 }
2480 }
2481}
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +01002482/** [Print CLTunerMode type] **/
2483/** Formatted output of the CLTunerMode type.
2484 *
2485 * @param[out] os Output stream.
2486 * @param[in] val CLTunerMode to output.
2487 *
2488 * @return Modified output stream.
2489 */
2490inline ::std::ostream &operator<<(::std::ostream &os, const CLTunerMode &val)
2491{
2492 os << to_string(val);
2493 return os;
2494}
2495
Anthony Barbier6ff3b192017-09-04 18:44:23 +01002496} // namespace arm_compute
Anthony Barbier4dbc0a92018-08-27 13:39:47 +01002497
2498#endif /* __ARM_COMPUTE_TYPE_PRINTER_H__ */