blob: 904115360adbdedf0e56a7b134f90751ad424998 [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001/*
Manuel Bottinib412fab2018-12-10 17:40:23 +00002 * Copyright (c) 2017-2019 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"
32#include "arm_compute/core/Size2D.h"
John Richardsona36eae12017-09-26 16:55:59 +010033#include "arm_compute/core/Strides.h"
Georgios Pinitas3faea252017-10-30 14:13:50 +000034#include "arm_compute/core/TensorInfo.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010035#include "arm_compute/core/Types.h"
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +010036#include "arm_compute/runtime/CL/CLTunerTypes.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010037
38#include <ostream>
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010039#include <sstream>
40#include <string>
Anthony Barbier6ff3b192017-09-04 18:44:23 +010041
42namespace arm_compute
43{
Anthony Barbierb940fd62018-06-04 14:14:32 +010044/** Formatted output if arg is not null
45 *
46 * @param[in] arg Object to print
47 *
48 * @return String representing arg.
49 */
50template <typename T>
51std::string to_string_if_not_null(T *arg)
52{
53 if(arg == nullptr)
54 {
55 return "nullptr";
56 }
57 else
58 {
59 return to_string(*arg);
60 }
61}
Alex Gildayc357c472018-03-21 13:54:09 +000062/** Formatted output of the Dimensions type.
63 *
64 * @param[out] os Output stream.
65 * @param[in] dimensions Type to output.
66 *
67 * @return Modified output stream.
68 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +010069template <typename T>
70inline ::std::ostream &operator<<(::std::ostream &os, const Dimensions<T> &dimensions)
71{
Anthony Barbier6ff3b192017-09-04 18:44:23 +010072 if(dimensions.num_dimensions() > 0)
73 {
74 os << dimensions[0];
75
76 for(unsigned int d = 1; d < dimensions.num_dimensions(); ++d)
77 {
Moritz Pflanzerc87fbf82017-07-18 14:02:10 +010078 os << "x" << dimensions[d];
Anthony Barbier6ff3b192017-09-04 18:44:23 +010079 }
80 }
81
Anthony Barbier6ff3b192017-09-04 18:44:23 +010082 return os;
83}
84
Alex Gildayc357c472018-03-21 13:54:09 +000085/** Formatted output of the NonLinearFilterFunction type.
86 *
87 * @param[out] os Output stream.
88 * @param[in] function Type to output.
89 *
90 * @return Modified output stream.
91 */
Isabella Gottardi3b77e9d2017-06-22 11:05:41 +010092inline ::std::ostream &operator<<(::std::ostream &os, const NonLinearFilterFunction &function)
93{
94 switch(function)
95 {
96 case NonLinearFilterFunction::MAX:
97 os << "MAX";
98 break;
99 case NonLinearFilterFunction::MEDIAN:
100 os << "MEDIAN";
101 break;
102 case NonLinearFilterFunction::MIN:
103 os << "MIN";
104 break;
105 default:
106 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
107 }
108
109 return os;
110}
111
Alex Gildayc357c472018-03-21 13:54:09 +0000112/** Formatted output of the NonLinearFilterFunction type.
113 *
114 * @param[in] function Type to output.
115 *
116 * @return Formatted string.
117 */
John Richardson6f4d49f2017-09-07 11:21:10 +0100118inline std::string to_string(const NonLinearFilterFunction &function)
119{
120 std::stringstream str;
121 str << function;
122 return str.str();
123}
124
Alex Gildayc357c472018-03-21 13:54:09 +0000125/** Formatted output of the MatrixPattern type.
126 *
127 * @param[out] os Output stream.
128 * @param[in] pattern Type to output.
129 *
130 * @return Modified output stream.
131 */
Isabella Gottardi3b77e9d2017-06-22 11:05:41 +0100132inline ::std::ostream &operator<<(::std::ostream &os, const MatrixPattern &pattern)
133{
134 switch(pattern)
135 {
136 case MatrixPattern::BOX:
137 os << "BOX";
138 break;
139 case MatrixPattern::CROSS:
140 os << "CROSS";
141 break;
142 case MatrixPattern::DISK:
143 os << "DISK";
144 break;
145 case MatrixPattern::OTHER:
146 os << "OTHER";
147 break;
148 default:
149 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
150 }
151
152 return os;
153}
154
Alex Gildayc357c472018-03-21 13:54:09 +0000155/** Formatted output of the MatrixPattern type.
156 *
157 * @param[in] pattern Type to output.
158 *
159 * @return Formatted string.
160 */
John Richardson6f4d49f2017-09-07 11:21:10 +0100161inline std::string to_string(const MatrixPattern &pattern)
162{
163 std::stringstream str;
164 str << pattern;
165 return str.str();
166}
167
Alex Gildayc357c472018-03-21 13:54:09 +0000168/** Formatted output of the RoundingPolicy type.
169 *
170 * @param[out] os Output stream.
171 * @param[in] rounding_policy Type to output.
172 *
173 * @return Modified output stream.
174 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100175inline ::std::ostream &operator<<(::std::ostream &os, const RoundingPolicy &rounding_policy)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100176{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100177 switch(rounding_policy)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100178 {
Anthony Barbier2a07e182017-08-04 18:20:27 +0100179 case RoundingPolicy::TO_ZERO:
180 os << "TO_ZERO";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100181 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100182 case RoundingPolicy::TO_NEAREST_UP:
183 os << "TO_NEAREST_UP";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100184 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100185 case RoundingPolicy::TO_NEAREST_EVEN:
186 os << "TO_NEAREST_EVEN";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100187 break;
188 default:
189 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
190 }
191
192 return os;
193}
194
Alex Gildayc357c472018-03-21 13:54:09 +0000195/** Formatted output of the WeightsInfo type.
196 *
197 * @param[out] os Output stream.
198 * @param[in] weights_info Type to output.
199 *
200 * @return Modified output stream.
201 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100202inline ::std::ostream &operator<<(::std::ostream &os, const WeightsInfo &weights_info)
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100203{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100204 os << weights_info.are_reshaped() << ";";
205 os << weights_info.num_kernels() << ";" << weights_info.kernel_size().first << "," << weights_info.kernel_size().second;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100206
207 return os;
208}
209
Alex Gildayc357c472018-03-21 13:54:09 +0000210/** Formatted output of the ROIPoolingInfo type.
211 *
212 * @param[out] os Output stream.
213 * @param[in] pool_info Type to output.
214 *
215 * @return Modified output stream.
216 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100217inline ::std::ostream &operator<<(::std::ostream &os, const ROIPoolingLayerInfo &pool_info)
Sanghoon Lee70f82912017-08-24 14:21:24 +0100218{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100219 os << pool_info.pooled_width() << "x" << pool_info.pooled_height() << "~" << pool_info.spatial_scale();
Georgios Pinitasd9769582017-08-03 10:19:40 +0100220 return os;
221}
222
giuros0118870812018-09-13 09:31:40 +0100223/** Formatted output of the ROIPoolingInfo type.
224 *
225 * @param[in] pool_info Type to output.
226 *
227 * @return Formatted string.
228 */
229inline std::string to_string(const ROIPoolingLayerInfo &pool_info)
230{
231 std::stringstream str;
232 str << pool_info;
233 return str.str();
234}
235
giuros01c04a0e82018-10-03 12:44:35 +0100236/** Formatted output of the BoundingBoxTransformInfo type.
237 *
238 * @param[out] os Output stream.
239 * @param[in] bbox_info Type to output.
240 *
241 * @return Modified output stream.
242 */
243inline ::std::ostream &operator<<(::std::ostream &os, const BoundingBoxTransformInfo &bbox_info)
244{
245 auto weights = bbox_info.weights();
246 os << "(" << bbox_info.img_width() << "x" << bbox_info.img_height() << ")~" << bbox_info.scale() << "(weights = {" << weights[0] << ", " << weights[1] << ", " << weights[2] << ", " << weights[3] <<
247 "})";
248 return os;
249}
250
251/** Formatted output of the BoundingBoxTransformInfo type.
252 *
253 * @param[in] bbox_info Type to output.
254 *
255 * @return Formatted string.
256 */
257inline std::string to_string(const BoundingBoxTransformInfo &bbox_info)
258{
259 std::stringstream str;
260 str << bbox_info;
261 return str.str();
262}
263
Manuel Bottini5209be52019-02-13 16:34:56 +0000264/** Formatted output of the ComputeAnchorsInfo type.
265 *
266 * @param[out] os Output stream.
267 * @param[in] anchors_info Type to output.
268 *
269 * @return Modified output stream.
270 */
271inline ::std::ostream &operator<<(::std::ostream &os, const ComputeAnchorsInfo &anchors_info)
272{
273 os << "(" << anchors_info.feat_width() << "x" << anchors_info.feat_height() << ")~" << anchors_info.spatial_scale();
274 return os;
275}
276
277/** Formatted output of the ComputeAnchorsInfo type.
278 *
279 * @param[in] anchors_info Type to output.
280 *
281 * @return Formatted string.
282 */
283inline std::string to_string(const ComputeAnchorsInfo &anchors_info)
284{
285 std::stringstream str;
286 str << anchors_info;
287 return str.str();
288}
289
290/** Formatted output of the GenerateProposalsInfo type.
291 *
292 * @param[out] os Output stream.
293 * @param[in] proposals_info Type to output.
294 *
295 * @return Modified output stream.
296 */
297inline ::std::ostream &operator<<(::std::ostream &os, const GenerateProposalsInfo &proposals_info)
298{
299 os << "(" << proposals_info.im_width() << "x" << proposals_info.im_height() << ")~" << proposals_info.im_scale();
300 return os;
301}
302
303/** Formatted output of the GenerateProposalsInfo type.
304 *
305 * @param[in] proposals_info Type to output.
306 *
307 * @return Formatted string.
308 */
309inline std::string to_string(const GenerateProposalsInfo &proposals_info)
310{
311 std::stringstream str;
312 str << proposals_info;
313 return str.str();
314}
315
Alex Gildayc357c472018-03-21 13:54:09 +0000316/** Formatted output of the QuantizationInfo type.
317 *
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100318 * @param[out] os Output stream.
319 * @param[in] qinfo Type to output.
Alex Gildayc357c472018-03-21 13:54:09 +0000320 *
321 * @return Modified output stream.
322 */
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100323inline ::std::ostream &operator<<(::std::ostream &os, const QuantizationInfo &qinfo)
Chunosovd621bca2017-11-03 17:33:15 +0700324{
Georgios Pinitas3d13af82019-06-04 13:04:16 +0100325 const UniformQuantizationInfo uqinfo = qinfo.uniform();
326 os << "Scale:" << uqinfo.scale << "~";
327 os << "Offset:" << uqinfo.offset;
Chunosovd621bca2017-11-03 17:33:15 +0700328 return os;
329}
330
Alex Gildayc357c472018-03-21 13:54:09 +0000331/** Formatted output of the QuantizationInfo type.
332 *
333 * @param[in] quantization_info Type to output.
334 *
335 * @return Formatted string.
336 */
Chunosovd621bca2017-11-03 17:33:15 +0700337inline std::string to_string(const QuantizationInfo &quantization_info)
338{
339 std::stringstream str;
340 str << quantization_info;
341 return str.str();
342}
343
Alex Gildayc357c472018-03-21 13:54:09 +0000344/** Formatted output of the activation function type.
345 *
346 * @param[out] os Output stream.
347 * @param[in] act_function Type to output.
348 *
349 * @return Modified output stream.
350 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100351inline ::std::ostream &operator<<(::std::ostream &os, const ActivationLayerInfo::ActivationFunction &act_function)
352{
353 switch(act_function)
354 {
355 case ActivationLayerInfo::ActivationFunction::ABS:
356 os << "ABS";
357 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100358 case ActivationLayerInfo::ActivationFunction::LINEAR:
359 os << "LINEAR";
360 break;
361 case ActivationLayerInfo::ActivationFunction::LOGISTIC:
362 os << "LOGISTIC";
363 break;
364 case ActivationLayerInfo::ActivationFunction::RELU:
365 os << "RELU";
366 break;
Georgios Pinitas579c0492017-07-12 16:12:12 +0100367 case ActivationLayerInfo::ActivationFunction::BOUNDED_RELU:
368 os << "BOUNDED_RELU";
369 break;
370 case ActivationLayerInfo::ActivationFunction::LEAKY_RELU:
371 os << "LEAKY_RELU";
372 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100373 case ActivationLayerInfo::ActivationFunction::SOFT_RELU:
374 os << "SOFT_RELU";
375 break;
376 case ActivationLayerInfo::ActivationFunction::SQRT:
377 os << "SQRT";
378 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100379 case ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU:
380 os << "LU_BOUNDED_RELU";
Kevin Petitd9f80712017-12-06 12:18:48 +0000381 break;
Georgios Pinitasfb0fdcd2019-08-22 17:10:04 +0100382 case ActivationLayerInfo::ActivationFunction::ELU:
383 os << "ELU";
384 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100385 case ActivationLayerInfo::ActivationFunction::SQUARE:
386 os << "SQUARE";
387 break;
388 case ActivationLayerInfo::ActivationFunction::TANH:
389 os << "TANH";
390 break;
Usama Arif6a98a6e2019-05-10 17:07:27 +0100391 case ActivationLayerInfo::ActivationFunction::IDENTITY:
392 os << "IDENTITY";
393 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100394 default:
395 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
396 }
397
398 return os;
399}
400
Alex Gildayc357c472018-03-21 13:54:09 +0000401/** Formatted output of the activation function info type.
402 *
403 * @param[in] info Type to output.
404 *
405 * @return Formatted string.
406 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100407inline std::string to_string(const arm_compute::ActivationLayerInfo &info)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100408{
409 std::stringstream str;
Isabella Gottardi3f217ec2018-02-12 14:59:19 +0000410 if(info.enabled())
411 {
412 str << info.activation();
413 }
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100414 return str.str();
415}
416
Alex Gildayc357c472018-03-21 13:54:09 +0000417/** Formatted output of the activation function type.
418 *
419 * @param[in] function Type to output.
420 *
421 * @return Formatted string.
422 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100423inline std::string to_string(const arm_compute::ActivationLayerInfo::ActivationFunction &function)
424{
425 std::stringstream str;
426 str << function;
427 return str.str();
428}
429
Alex Gildayc357c472018-03-21 13:54:09 +0000430/** Formatted output of the NormType type.
431 *
432 * @param[out] os Output stream.
433 * @param[in] norm_type Type to output.
434 *
435 * @return Modified output stream.
436 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100437inline ::std::ostream &operator<<(::std::ostream &os, const NormType &norm_type)
438{
439 switch(norm_type)
440 {
441 case NormType::CROSS_MAP:
442 os << "CROSS_MAP";
443 break;
444 case NormType::IN_MAP_1D:
445 os << "IN_MAP_1D";
446 break;
447 case NormType::IN_MAP_2D:
448 os << "IN_MAP_2D";
449 break;
450 default:
451 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
452 }
453
454 return os;
455}
456
Alex Gildayc357c472018-03-21 13:54:09 +0000457/** Formatted output of @ref NormalizationLayerInfo.
458 *
459 * @param[in] info Type to output.
460 *
461 * @return Formatted string.
462 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100463inline std::string to_string(const arm_compute::NormalizationLayerInfo &info)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100464{
465 std::stringstream str;
Michalis Spyroud466c2d2018-01-30 10:54:39 +0000466 str << info.type() << ":NormSize=" << info.norm_size();
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100467 return str.str();
468}
469
Alex Gildayc357c472018-03-21 13:54:09 +0000470/** Formatted output of @ref NormalizationLayerInfo.
471 *
472 * @param[out] os Output stream.
473 * @param[in] info Type to output.
474 *
475 * @return Modified output stream.
476 */
Georgios Pinitas6f669f02017-09-26 12:32:57 +0100477inline ::std::ostream &operator<<(::std::ostream &os, const NormalizationLayerInfo &info)
478{
Michalis Spyroud466c2d2018-01-30 10:54:39 +0000479 os << info.type() << ":NormSize=" << info.norm_size();
Georgios Pinitas6f669f02017-09-26 12:32:57 +0100480 return os;
481}
482
Alex Gildayc357c472018-03-21 13:54:09 +0000483/** Formatted output of the PoolingType type.
484 *
485 * @param[out] os Output stream.
486 * @param[in] pool_type Type to output.
487 *
488 * @return Modified output stream.
489 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100490inline ::std::ostream &operator<<(::std::ostream &os, const PoolingType &pool_type)
491{
492 switch(pool_type)
493 {
494 case PoolingType::AVG:
495 os << "AVG";
496 break;
497 case PoolingType::MAX:
498 os << "MAX";
499 break;
Georgios Pinitascdf51452017-08-31 14:21:36 +0100500 case PoolingType::L2:
501 os << "L2";
502 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100503 default:
504 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
505 }
506
507 return os;
508}
509
Alex Gildayc357c472018-03-21 13:54:09 +0000510/** Formatted output of @ref PoolingLayerInfo.
511 *
512 * @param[out] os Output stream.
513 * @param[in] info Type to output.
514 *
515 * @return Modified output stream.
516 */
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100517inline ::std::ostream &operator<<(::std::ostream &os, const PoolingLayerInfo &info)
518{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100519 os << info.pool_type();
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100520
521 return os;
522}
523
Alex Gildayc357c472018-03-21 13:54:09 +0000524/** Formatted output of @ref RoundingPolicy.
525 *
526 * @param[in] rounding_policy Type to output.
527 *
528 * @return Formatted string.
529 */
John Richardsondd715f22017-09-18 16:10:48 +0100530inline std::string to_string(const RoundingPolicy &rounding_policy)
531{
532 std::stringstream str;
533 str << rounding_policy;
534 return str.str();
535}
536
Vidhya Sudhan Loganathand646ae12018-11-19 15:18:20 +0000537/** [Print DataLayout type] **/
Alex Gildayc357c472018-03-21 13:54:09 +0000538/** Formatted output of the DataLayout type.
539 *
540 * @param[out] os Output stream.
541 * @param[in] data_layout Type to output.
542 *
543 * @return Modified output stream.
544 */
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000545inline ::std::ostream &operator<<(::std::ostream &os, const DataLayout &data_layout)
546{
547 switch(data_layout)
548 {
549 case DataLayout::UNKNOWN:
550 os << "UNKNOWN";
551 break;
552 case DataLayout::NHWC:
553 os << "NHWC";
554 break;
555 case DataLayout::NCHW:
556 os << "NCHW";
557 break;
558 default:
559 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
560 }
561
562 return os;
563}
564
Alex Gildayc357c472018-03-21 13:54:09 +0000565/** Formatted output of the DataLayout type.
566 *
567 * @param[in] data_layout Type to output.
568 *
569 * @return Formatted string.
570 */
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000571inline std::string to_string(const arm_compute::DataLayout &data_layout)
572{
573 std::stringstream str;
574 str << data_layout;
575 return str.str();
576}
Vidhya Sudhan Loganathand646ae12018-11-19 15:18:20 +0000577/** [Print DataLayout type] **/
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000578
Georgios Pinitase2220552018-07-20 13:23:44 +0100579/** Formatted output of the DataLayoutDimension type.
580 *
581 * @param[out] os Output stream.
582 * @param[in] data_layout_dim Data layout dimension to print.
583 *
584 * @return Modified output stream.
585 */
586inline ::std::ostream &operator<<(::std::ostream &os, const DataLayoutDimension &data_layout_dim)
587{
588 switch(data_layout_dim)
589 {
590 case DataLayoutDimension::WIDTH:
591 os << "WIDTH";
592 break;
593 case DataLayoutDimension::HEIGHT:
594 os << "HEIGHT";
595 break;
596 case DataLayoutDimension::CHANNEL:
597 os << "CHANNEL";
598 break;
599 case DataLayoutDimension::BATCHES:
600 os << "BATCHES";
601 break;
602 default:
603 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
604 }
605 return os;
606}
607
Alex Gildayc357c472018-03-21 13:54:09 +0000608/** Formatted output of the DataType type.
609 *
610 * @param[out] os Output stream.
611 * @param[in] data_type Type to output.
612 *
613 * @return Modified output stream.
614 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100615inline ::std::ostream &operator<<(::std::ostream &os, const DataType &data_type)
616{
617 switch(data_type)
618 {
619 case DataType::UNKNOWN:
620 os << "UNKNOWN";
621 break;
622 case DataType::U8:
623 os << "U8";
624 break;
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100625 case DataType::QSYMM8:
626 os << "QSYMM8";
627 break;
Chunosovd621bca2017-11-03 17:33:15 +0700628 case DataType::QASYMM8:
629 os << "QASYMM8";
630 break;
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100631 case DataType::QSYMM8_PER_CHANNEL:
632 os << "QSYMM8_PER_CHANNEL";
633 break;
Michalis Spyrouc8530212019-08-22 11:44:04 +0100634 case DataType::QASYMM8_PER_CHANNEL:
635 os << "QASYMM8_PER_CHANNEL";
636 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100637 case DataType::S8:
638 os << "S8";
639 break;
640 case DataType::U16:
641 os << "U16";
642 break;
643 case DataType::S16:
644 os << "S16";
645 break;
Manuel Bottini3689fcd2019-06-14 17:18:12 +0100646 case DataType::QSYMM16:
647 os << "QSYMM16";
648 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100649 case DataType::U32:
650 os << "U32";
651 break;
652 case DataType::S32:
653 os << "S32";
654 break;
655 case DataType::U64:
656 os << "U64";
657 break;
658 case DataType::S64:
659 os << "S64";
660 break;
661 case DataType::F16:
662 os << "F16";
663 break;
664 case DataType::F32:
665 os << "F32";
666 break;
667 case DataType::F64:
668 os << "F64";
669 break;
670 case DataType::SIZET:
671 os << "SIZET";
672 break;
673 default:
674 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
675 }
676
677 return os;
678}
679
Alex Gildayc357c472018-03-21 13:54:09 +0000680/** Formatted output of the DataType type.
681 *
682 * @param[in] data_type Type to output.
683 *
684 * @return Formatted string.
685 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100686inline std::string to_string(const arm_compute::DataType &data_type)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100687{
688 std::stringstream str;
689 str << data_type;
690 return str.str();
691}
692
Alex Gildayc357c472018-03-21 13:54:09 +0000693/** Formatted output of the Format type.
694 *
695 * @param[out] os Output stream.
696 * @param[in] format Type to output.
697 *
698 * @return Modified output stream.
699 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100700inline ::std::ostream &operator<<(::std::ostream &os, const Format &format)
701{
702 switch(format)
703 {
704 case Format::UNKNOWN:
705 os << "UNKNOWN";
706 break;
707 case Format::U8:
708 os << "U8";
709 break;
710 case Format::S16:
711 os << "S16";
712 break;
713 case Format::U16:
714 os << "U16";
715 break;
716 case Format::S32:
717 os << "S32";
718 break;
719 case Format::U32:
720 os << "U32";
721 break;
722 case Format::F16:
723 os << "F16";
724 break;
725 case Format::F32:
726 os << "F32";
727 break;
728 case Format::UV88:
729 os << "UV88";
730 break;
731 case Format::RGB888:
732 os << "RGB888";
733 break;
734 case Format::RGBA8888:
735 os << "RGBA8888";
736 break;
737 case Format::YUV444:
738 os << "YUV444";
739 break;
740 case Format::YUYV422:
741 os << "YUYV422";
742 break;
743 case Format::NV12:
744 os << "NV12";
745 break;
746 case Format::NV21:
747 os << "NV21";
748 break;
749 case Format::IYUV:
750 os << "IYUV";
751 break;
752 case Format::UYVY422:
753 os << "UYVY422";
754 break;
755 default:
756 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
757 }
758
759 return os;
760}
761
Alex Gildayc357c472018-03-21 13:54:09 +0000762/** Formatted output of the Format type.
763 *
764 * @param[in] format Type to output.
765 *
766 * @return Formatted string.
767 */
Moritz Pflanzer7655a672017-09-23 11:57:33 +0100768inline std::string to_string(const Format &format)
769{
770 std::stringstream str;
771 str << format;
772 return str.str();
773}
774
Alex Gildayc357c472018-03-21 13:54:09 +0000775/** Formatted output of the Channel type.
776 *
777 * @param[out] os Output stream.
778 * @param[in] channel Type to output.
779 *
780 * @return Modified output stream.
781 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100782inline ::std::ostream &operator<<(::std::ostream &os, const Channel &channel)
783{
784 switch(channel)
785 {
786 case Channel::UNKNOWN:
787 os << "UNKNOWN";
788 break;
789 case Channel::C0:
790 os << "C0";
791 break;
792 case Channel::C1:
793 os << "C1";
794 break;
795 case Channel::C2:
796 os << "C2";
797 break;
798 case Channel::C3:
799 os << "C3";
800 break;
801 case Channel::R:
802 os << "R";
803 break;
804 case Channel::G:
805 os << "G";
806 break;
807 case Channel::B:
808 os << "B";
809 break;
810 case Channel::A:
811 os << "A";
812 break;
813 case Channel::Y:
814 os << "Y";
815 break;
816 case Channel::U:
817 os << "U";
818 break;
819 case Channel::V:
820 os << "V";
821 break;
822 default:
823 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
824 }
825
826 return os;
827}
828
Alex Gildayc357c472018-03-21 13:54:09 +0000829/** Formatted output of the Channel type.
830 *
831 * @param[in] channel Type to output.
832 *
833 * @return Formatted string.
834 */
Ioan-Cristian Szabo9414f642017-10-27 17:35:40 +0100835inline std::string to_string(const Channel &channel)
836{
837 std::stringstream str;
838 str << channel;
839 return str.str();
840}
841
Alex Gildayc357c472018-03-21 13:54:09 +0000842/** Formatted output of the BorderMode type.
843 *
844 * @param[out] os Output stream.
845 * @param[in] mode Type to output.
846 *
847 * @return Modified output stream.
848 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100849inline ::std::ostream &operator<<(::std::ostream &os, const BorderMode &mode)
850{
851 switch(mode)
852 {
853 case BorderMode::UNDEFINED:
854 os << "UNDEFINED";
855 break;
856 case BorderMode::CONSTANT:
857 os << "CONSTANT";
858 break;
859 case BorderMode::REPLICATE:
860 os << "REPLICATE";
861 break;
862 default:
863 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
864 }
865
866 return os;
867}
868
Alex Gildayc357c472018-03-21 13:54:09 +0000869/** Formatted output of the BorderSize type.
870 *
871 * @param[out] os Output stream.
872 * @param[in] border Type to output.
873 *
874 * @return Modified output stream.
875 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100876inline ::std::ostream &operator<<(::std::ostream &os, const BorderSize &border)
877{
Moritz Pflanzerc87fbf82017-07-18 14:02:10 +0100878 os << border.top << ","
879 << border.right << ","
880 << border.bottom << ","
881 << border.left;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100882
883 return os;
884}
Anthony Barbier2a07e182017-08-04 18:20:27 +0100885
Giuseppe Rossinid7647d42018-07-17 18:13:13 +0100886/** Formatted output of the PaddingList type.
887 *
888 * @param[out] os Output stream.
889 * @param[in] padding Type to output.
890 *
891 * @return Modified output stream.
892 */
893inline ::std::ostream &operator<<(::std::ostream &os, const PaddingList &padding)
894{
895 os << "{";
896 for(auto const &p : padding)
897 {
898 os << "{" << p.first << "," << p.second << "}";
899 }
900 os << "}";
901 return os;
902}
903
giuros013175fcf2018-11-21 09:59:17 +0000904/** Formatted output of the Multiples type.
905 *
906 * @param[out] os Output stream.
907 * @param[in] multiples Type to output.
908 *
909 * @return Modified output stream.
910 */
911inline ::std::ostream &operator<<(::std::ostream &os, const Multiples &multiples)
912{
913 os << "(";
914 for(size_t i = 0; i < multiples.size() - 1; i++)
915 {
916 os << multiples[i] << ", ";
917 }
918 os << multiples.back() << ")";
919 return os;
920}
921
Alex Gildayc357c472018-03-21 13:54:09 +0000922/** Formatted output of the InterpolationPolicy type.
923 *
924 * @param[out] os Output stream.
925 * @param[in] policy Type to output.
926 *
927 * @return Modified output stream.
928 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100929inline ::std::ostream &operator<<(::std::ostream &os, const InterpolationPolicy &policy)
930{
931 switch(policy)
932 {
933 case InterpolationPolicy::NEAREST_NEIGHBOR:
934 os << "NEAREST_NEIGHBOR";
935 break;
936 case InterpolationPolicy::BILINEAR:
937 os << "BILINEAR";
938 break;
939 case InterpolationPolicy::AREA:
940 os << "AREA";
941 break;
942 default:
943 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
944 }
945
946 return os;
947}
948
Alex Gildayc357c472018-03-21 13:54:09 +0000949/** Formatted output of the SamplingPolicy type.
950 *
951 * @param[out] os Output stream.
952 * @param[in] policy Type to output.
953 *
954 * @return Modified output stream.
955 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700956inline ::std::ostream &operator<<(::std::ostream &os, const SamplingPolicy &policy)
957{
958 switch(policy)
959 {
960 case SamplingPolicy::CENTER:
961 os << "CENTER";
962 break;
963 case SamplingPolicy::TOP_LEFT:
964 os << "TOP_LEFT";
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 TensorInfo type.
974 *
Anthony Barbier366628a2018-08-01 13:55:03 +0100975 * @param[out] os Output stream.
976 * @param[in] info Type to output.
977 *
978 * @return Modified output stream.
979 */
980inline ::std::ostream &operator<<(::std::ostream &os, const TensorInfo &info)
981{
982 os << "{Shape=" << info.tensor_shape() << ","
983 << "Type=" << info.data_type() << ","
984 << "Channels=" << info.num_channels() << "}";
985 return os;
986}
987/** Formatted output of the TensorInfo type.
988 *
Alex Gildayc357c472018-03-21 13:54:09 +0000989 * @param[in] info Type to output.
990 *
991 * @return Formatted string.
992 */
Georgios Pinitas3faea252017-10-30 14:13:50 +0000993inline std::string to_string(const TensorInfo &info)
994{
995 std::stringstream str;
Anthony Barbier366628a2018-08-01 13:55:03 +0100996 str << info;
Georgios Pinitas3faea252017-10-30 14:13:50 +0000997 return str.str();
998}
999
Alex Gildayc357c472018-03-21 13:54:09 +00001000/** Formatted output of the Dimensions type.
1001 *
1002 * @param[in] dimensions Type to output.
1003 *
1004 * @return Formatted string.
1005 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001006template <typename T>
1007inline std::string to_string(const Dimensions<T> &dimensions)
1008{
1009 std::stringstream str;
1010 str << dimensions;
1011 return str.str();
1012}
1013
Alex Gildayc357c472018-03-21 13:54:09 +00001014/** Formatted output of the Strides type.
1015 *
1016 * @param[in] stride Type to output.
1017 *
1018 * @return Formatted string.
1019 */
John Richardsona36eae12017-09-26 16:55:59 +01001020inline std::string to_string(const Strides &stride)
1021{
1022 std::stringstream str;
1023 str << stride;
1024 return str.str();
1025}
1026
Alex Gildayc357c472018-03-21 13:54:09 +00001027/** Formatted output of the TensorShape type.
1028 *
1029 * @param[in] shape Type to output.
1030 *
1031 * @return Formatted string.
1032 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001033inline std::string to_string(const TensorShape &shape)
1034{
1035 std::stringstream str;
1036 str << shape;
1037 return str.str();
1038}
1039
Alex Gildayc357c472018-03-21 13:54:09 +00001040/** Formatted output of the Coordinates type.
1041 *
1042 * @param[in] coord Type to output.
1043 *
1044 * @return Formatted string.
1045 */
Abe Mbise925ca0f2017-10-02 19:16:33 +01001046inline std::string to_string(const Coordinates &coord)
1047{
1048 std::stringstream str;
1049 str << coord;
1050 return str.str();
1051}
1052
Anthony Barbierb940fd62018-06-04 14:14:32 +01001053/** Formatted output of the GEMMReshapeInfo type.
1054 *
1055 * @param[out] os Output stream.
1056 * @param[in] info Type to output.
1057 *
1058 * @return Modified output stream.
1059 */
1060inline ::std::ostream &operator<<(::std::ostream &os, const GEMMReshapeInfo &info)
1061{
1062 os << "{m=" << info.m() << ",";
1063 os << "n=" << info.n() << ",";
1064 os << "k=" << info.k() << ",";
1065 os << "mult_transpose1xW_width=" << info.mult_transpose1xW_width() << ",";
1066 os << "mult_interleave4x4_height=" << info.mult_interleave4x4_height();
1067 os << "}";
1068
1069 return os;
1070}
1071
1072/** Formatted output of the GEMMInfo type.
1073 *
1074 * @param[out] os Output stream.
1075 * @param[in] info Type to output.
1076 *
1077 * @return Modified output stream.
1078 */
1079inline ::std::ostream &operator<<(::std::ostream &os, const GEMMInfo &info)
1080{
1081 os << "{is_a_reshaped=" << info.is_a_reshaped() << ",";
1082 os << "is_b_reshaped=" << info.is_b_reshaped() << ",";
1083 os << "reshape_b_only_on_first_run=" << info.reshape_b_only_on_first_run() << ",";
Anthony Barbierb940fd62018-06-04 14:14:32 +01001084 os << "}";
1085
1086 return os;
1087}
1088
1089/** Formatted output of the Window::Dimension type.
1090 *
1091 * @param[out] os Output stream.
1092 * @param[in] dim Type to output.
1093 *
1094 * @return Modified output stream.
1095 */
1096inline ::std::ostream &operator<<(::std::ostream &os, const Window::Dimension &dim)
1097{
1098 os << "{start=" << dim.start() << ", end=" << dim.end() << ", step=" << dim.step() << "}";
1099
1100 return os;
1101}
1102/** Formatted output of the Window type.
1103 *
1104 * @param[out] os Output stream.
1105 * @param[in] win Type to output.
1106 *
1107 * @return Modified output stream.
1108 */
1109inline ::std::ostream &operator<<(::std::ostream &os, const Window &win)
1110{
1111 os << "{";
1112 for(unsigned int i = 0; i < Coordinates::num_max_dimensions; i++)
1113 {
1114 if(i > 0)
1115 {
1116 os << ", ";
1117 }
1118 os << win[i];
1119 }
1120 os << "}";
1121
1122 return os;
1123}
1124
1125/** Formatted output of the WeightsInfo type.
1126 *
1127 * @param[in] info Type to output.
1128 *
1129 * @return Formatted string.
1130 */
1131inline std::string to_string(const WeightsInfo &info)
1132{
1133 std::stringstream str;
1134 str << info;
1135 return str.str();
1136}
1137
1138/** Formatted output of the GEMMReshapeInfo type.
1139 *
1140 * @param[in] info Type to output.
1141 *
1142 * @return Formatted string.
1143 */
1144inline std::string to_string(const GEMMReshapeInfo &info)
1145{
1146 std::stringstream str;
1147 str << info;
1148 return str.str();
1149}
1150
1151/** Formatted output of the GEMMInfo type.
1152 *
1153 * @param[in] info Type to output.
1154 *
1155 * @return Formatted string.
1156 */
1157inline std::string to_string(const GEMMInfo &info)
1158{
1159 std::stringstream str;
1160 str << info;
1161 return str.str();
1162}
1163
1164/** Formatted output of the Window::Dimension type.
1165 *
1166 * @param[in] dim Type to output.
1167 *
1168 * @return Formatted string.
1169 */
1170inline std::string to_string(const Window::Dimension &dim)
1171{
1172 std::stringstream str;
1173 str << dim;
1174 return str.str();
1175}
1176/** Formatted output of the Window type.
1177 *
1178 * @param[in] win Type to output.
1179 *
1180 * @return Formatted string.
1181 */
1182inline std::string to_string(const Window &win)
1183{
1184 std::stringstream str;
1185 str << win;
1186 return str.str();
1187}
1188
Alex Gildayc357c472018-03-21 13:54:09 +00001189/** Formatted output of the Rectangle type.
1190 *
1191 * @param[out] os Output stream.
1192 * @param[in] rect Type to output.
1193 *
1194 * @return Modified output stream.
1195 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001196inline ::std::ostream &operator<<(::std::ostream &os, const Rectangle &rect)
1197{
1198 os << rect.width << "x" << rect.height;
1199 os << "+" << rect.x << "+" << rect.y;
1200
1201 return os;
1202}
1203
Usama Arif8cf8c112019-03-14 15:36:54 +00001204/** Formatted output of the PaddingMode type.
1205 *
1206 * @param[out] os Output stream.
1207 * @param[in] mode Type to output.
1208 *
1209 * @return Modified output stream.
1210 */
1211inline ::std::ostream &operator<<(::std::ostream &os, const PaddingMode &mode)
1212{
1213 switch(mode)
1214 {
1215 case PaddingMode::CONSTANT:
1216 os << "CONSTANT";
1217 break;
1218 case PaddingMode::REFLECT:
1219 os << "REFLECT";
1220 break;
1221 case PaddingMode::SYMMETRIC:
1222 os << "SYMMETRIC";
1223 break;
1224 default:
1225 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1226 }
1227
1228 return os;
1229}
1230
1231/** Formatted output of the PaddingMode type.
1232 *
1233 * @param[in] mode Type to output.
1234 *
1235 * @return Formatted string.
1236 */
1237inline std::string to_string(const PaddingMode &mode)
1238{
1239 std::stringstream str;
1240 str << mode;
1241 return str.str();
1242}
1243
Alex Gildayc357c472018-03-21 13:54:09 +00001244/** Formatted output of the PadStrideInfo type.
1245 *
1246 * @param[out] os Output stream.
1247 * @param[in] pad_stride_info Type to output.
1248 *
1249 * @return Modified output stream.
1250 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001251inline ::std::ostream &operator<<(::std::ostream &os, const PadStrideInfo &pad_stride_info)
1252{
1253 os << pad_stride_info.stride().first << "," << pad_stride_info.stride().second;
1254 os << ";";
Jaroslaw Rzepeckia1ed41f2017-10-13 11:13:58 +01001255 os << pad_stride_info.pad_left() << "," << pad_stride_info.pad_right() << ","
1256 << pad_stride_info.pad_top() << "," << pad_stride_info.pad_bottom();
Anthony Barbier2a07e182017-08-04 18:20:27 +01001257
1258 return os;
1259}
1260
Alex Gildayc357c472018-03-21 13:54:09 +00001261/** Formatted output of the PadStrideInfo type.
1262 *
1263 * @param[in] pad_stride_info Type to output.
1264 *
1265 * @return Formatted string.
1266 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001267inline std::string to_string(const PadStrideInfo &pad_stride_info)
1268{
1269 std::stringstream str;
1270 str << pad_stride_info;
1271 return str.str();
1272}
1273
Alex Gildayc357c472018-03-21 13:54:09 +00001274/** Formatted output of the BorderMode type.
1275 *
1276 * @param[in] mode Type to output.
1277 *
1278 * @return Formatted string.
1279 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001280inline std::string to_string(const BorderMode &mode)
1281{
1282 std::stringstream str;
1283 str << mode;
1284 return str.str();
1285}
1286
Alex Gildayc357c472018-03-21 13:54:09 +00001287/** Formatted output of the BorderSize type.
1288 *
1289 * @param[in] border Type to output.
1290 *
1291 * @return Formatted string.
1292 */
John Richardsonb482ce12017-09-18 12:44:01 +01001293inline std::string to_string(const BorderSize &border)
1294{
1295 std::stringstream str;
1296 str << border;
1297 return str.str();
1298}
1299
Giuseppe Rossinid7647d42018-07-17 18:13:13 +01001300/** Formatted output of the PaddingList type.
1301 *
1302 * @param[in] padding Type to output.
1303 *
1304 * @return Formatted string.
1305 */
1306inline std::string to_string(const PaddingList &padding)
1307{
1308 std::stringstream str;
1309 str << padding;
1310 return str.str();
1311}
1312
giuros013175fcf2018-11-21 09:59:17 +00001313/** Formatted output of the Multiples type.
1314 *
1315 * @param[in] multiples Type to output.
1316 *
1317 * @return Formatted string.
1318 */
1319inline std::string to_string(const Multiples &multiples)
1320{
1321 std::stringstream str;
1322 str << multiples;
1323 return str.str();
1324}
1325
Alex Gildayc357c472018-03-21 13:54:09 +00001326/** Formatted output of the InterpolationPolicy type.
1327 *
1328 * @param[in] policy Type to output.
1329 *
1330 * @return Formatted string.
1331 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001332inline std::string to_string(const InterpolationPolicy &policy)
1333{
1334 std::stringstream str;
1335 str << policy;
1336 return str.str();
1337}
1338
Alex Gildayc357c472018-03-21 13:54:09 +00001339/** Formatted output of the SamplingPolicy type.
1340 *
1341 * @param[in] policy Type to output.
1342 *
1343 * @return Formatted string.
1344 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +07001345inline std::string to_string(const SamplingPolicy &policy)
1346{
1347 std::stringstream str;
1348 str << policy;
1349 return str.str();
1350}
1351
Alex Gildayc357c472018-03-21 13:54:09 +00001352/** Formatted output of the ConvertPolicy type.
1353 *
1354 * @param[out] os Output stream.
1355 * @param[in] policy Type to output.
1356 *
1357 * @return Modified output stream.
1358 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001359inline ::std::ostream &operator<<(::std::ostream &os, const ConvertPolicy &policy)
1360{
1361 switch(policy)
1362 {
1363 case ConvertPolicy::WRAP:
1364 os << "WRAP";
1365 break;
1366 case ConvertPolicy::SATURATE:
1367 os << "SATURATE";
1368 break;
1369 default:
1370 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1371 }
1372
1373 return os;
1374}
1375
1376inline std::string to_string(const ConvertPolicy &policy)
1377{
1378 std::stringstream str;
1379 str << policy;
1380 return str.str();
1381}
1382
giuros01164a2722018-11-20 18:34:46 +00001383/** Formatted output of the ArithmeticOperation type.
1384 *
1385 * @param[out] os Output stream.
1386 * @param[in] op Operation to output.
1387 *
1388 * @return Modified output stream.
1389 */
1390inline ::std::ostream &operator<<(::std::ostream &os, const ArithmeticOperation &op)
1391{
1392 switch(op)
1393 {
1394 case ArithmeticOperation::ADD:
1395 os << "ADD";
1396 break;
1397 case ArithmeticOperation::SUB:
1398 os << "SUB";
1399 break;
1400 case ArithmeticOperation::DIV:
1401 os << "DIV";
1402 break;
1403 case ArithmeticOperation::MAX:
1404 os << "MAX";
1405 break;
1406 case ArithmeticOperation::MIN:
1407 os << "MIN";
1408 break;
1409 case ArithmeticOperation::SQUARED_DIFF:
1410 os << "SQUARED_DIFF";
1411 break;
Usama Arif52c54f62019-05-14 10:22:36 +01001412 case ArithmeticOperation::POWER:
1413 os << "POWER";
1414 break;
giuros01164a2722018-11-20 18:34:46 +00001415 default:
1416 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1417 }
1418
1419 return os;
1420}
1421
1422/** Formatted output of the Arithmetic Operation
1423 *
1424 * @param[in] op Type to output.
1425 *
1426 * @return Formatted string.
1427 */
1428inline std::string to_string(const ArithmeticOperation &op)
1429{
1430 std::stringstream str;
1431 str << op;
1432 return str.str();
1433}
1434
Alex Gildayc357c472018-03-21 13:54:09 +00001435/** Formatted output of the Reduction Operations.
1436 *
1437 * @param[out] os Output stream.
1438 * @param[in] op Type to output.
1439 *
1440 * @return Modified output stream.
1441 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001442inline ::std::ostream &operator<<(::std::ostream &os, const ReductionOperation &op)
1443{
1444 switch(op)
1445 {
Michalis Spyrou7e9391b2018-10-05 14:49:28 +01001446 case ReductionOperation::SUM:
1447 os << "SUM";
1448 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +01001449 case ReductionOperation::SUM_SQUARE:
1450 os << "SUM_SQUARE";
1451 break;
Michalis Spyrou7e9391b2018-10-05 14:49:28 +01001452 case ReductionOperation::MEAN_SUM:
1453 os << "MEAN_SUM";
1454 break;
Michalis Spyrou7930db42018-11-22 17:36:28 +00001455 case ReductionOperation::ARG_IDX_MAX:
1456 os << "ARG_IDX_MAX";
1457 break;
1458 case ReductionOperation::ARG_IDX_MIN:
1459 os << "ARG_IDX_MIN";
1460 break;
Manuel Bottinib412fab2018-12-10 17:40:23 +00001461 case ReductionOperation::PROD:
1462 os << "PROD";
1463 break;
Usama Arifa4a08ad2019-05-20 12:38:33 +01001464 case ReductionOperation::MIN:
1465 os << "MIN";
1466 break;
Usama Arif28f0dd92019-05-20 13:44:34 +01001467 case ReductionOperation::MAX:
1468 os << "MAX";
1469 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +01001470 default:
1471 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1472 }
1473
1474 return os;
1475}
1476
Alex Gildayc357c472018-03-21 13:54:09 +00001477/** Formatted output of the Reduction Operations.
1478 *
1479 * @param[in] op Type to output.
1480 *
1481 * @return Formatted string.
1482 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001483inline std::string to_string(const ReductionOperation &op)
1484{
1485 std::stringstream str;
1486 str << op;
1487 return str.str();
1488}
1489
Georgios Pinitas7900a9e2018-11-23 11:44:58 +00001490/** Formatted output of the Comparison Operations.
1491 *
1492 * @param[out] os Output stream.
1493 * @param[in] op Type to output.
1494 *
1495 * @return Modified output stream.
1496 */
1497inline ::std::ostream &operator<<(::std::ostream &os, const ComparisonOperation &op)
1498{
1499 switch(op)
1500 {
1501 case ComparisonOperation::Equal:
1502 os << "Equal";
1503 break;
1504 case ComparisonOperation::NotEqual:
1505 os << "NotEqual";
1506 break;
1507 case ComparisonOperation::Greater:
1508 os << "Greater";
1509 break;
1510 case ComparisonOperation::GreaterEqual:
1511 os << "GreaterEqual";
1512 break;
1513 case ComparisonOperation::Less:
1514 os << "Less";
1515 break;
1516 case ComparisonOperation::LessEqual:
1517 os << "LessEqual";
1518 break;
1519 default:
1520 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1521 }
1522
1523 return os;
1524}
1525
Michalis Spyroue9362622018-11-23 17:41:37 +00001526/** Formatted output of the Elementwise unary Operations.
1527 *
1528 * @param[out] os Output stream.
1529 * @param[in] op Type to output.
1530 *
1531 * @return Modified output stream.
1532 */
1533inline ::std::ostream &operator<<(::std::ostream &os, const ElementWiseUnary &op)
1534{
1535 switch(op)
1536 {
1537 case ElementWiseUnary::RSQRT:
1538 os << "RSQRT";
1539 break;
1540 case ElementWiseUnary::EXP:
1541 os << "EXP";
1542 break;
Usama Arifeb312ef2019-05-13 17:45:54 +01001543 case ElementWiseUnary::NEG:
1544 os << "NEG";
1545 break;
Usama Arifac33d7e2019-05-20 14:21:40 +01001546 case ElementWiseUnary::LOG:
1547 os << "LOG";
1548 break;
Usama Arif6a4d5422019-05-24 14:53:59 +01001549 case ElementWiseUnary::ROUND:
1550 os << "ROUND";
1551 break;
Michalis Spyroue9362622018-11-23 17:41:37 +00001552 default:
1553 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1554 }
1555
1556 return os;
1557}
1558
Georgios Pinitas7900a9e2018-11-23 11:44:58 +00001559/** Formatted output of the Comparison Operations.
1560 *
1561 * @param[in] op Type to output.
1562 *
1563 * @return Formatted string.
1564 */
1565inline std::string to_string(const ComparisonOperation &op)
1566{
1567 std::stringstream str;
1568 str << op;
1569 return str.str();
1570}
1571
Michalis Spyroue9362622018-11-23 17:41:37 +00001572/** Formatted output of the Elementwise unary Operations.
1573 *
1574 * @param[in] op Type to output.
1575 *
1576 * @return Formatted string.
1577 */
1578inline std::string to_string(const ElementWiseUnary &op)
1579{
1580 std::stringstream str;
1581 str << op;
1582 return str.str();
1583}
1584
Alex Gildayc357c472018-03-21 13:54:09 +00001585/** Formatted output of the Norm Type.
1586 *
1587 * @param[in] type Type to output.
1588 *
1589 * @return Formatted string.
1590 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001591inline std::string to_string(const NormType &type)
1592{
1593 std::stringstream str;
1594 str << type;
1595 return str.str();
1596}
1597
Alex Gildayc357c472018-03-21 13:54:09 +00001598/** Formatted output of the Pooling Type.
1599 *
1600 * @param[in] type Type to output.
1601 *
1602 * @return Formatted string.
1603 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001604inline std::string to_string(const PoolingType &type)
1605{
1606 std::stringstream str;
1607 str << type;
1608 return str.str();
1609}
1610
Alex Gildayc357c472018-03-21 13:54:09 +00001611/** Formatted output of the Pooling Layer Info.
1612 *
1613 * @param[in] info Type to output.
1614 *
1615 * @return Formatted string.
1616 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001617inline std::string to_string(const PoolingLayerInfo &info)
1618{
1619 std::stringstream str;
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001620 str << "{Type=" << info.pool_type() << ","
1621 << "IsGlobalPooling=" << info.is_global_pooling();
1622 if(!info.is_global_pooling())
1623 {
1624 str << ","
Isabella Gottardi6e464c32018-01-26 12:32:45 +00001625 << "PoolSize=" << info.pool_size().width << "," << info.pool_size().height << ","
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001626 << "PadStride=" << info.pad_stride_info();
1627 }
1628 str << "}";
Anthony Barbier2a07e182017-08-04 18:20:27 +01001629 return str.str();
1630}
1631
Michalis Spyrou6c7c38e2018-08-29 16:28:11 +01001632/** Formatted output of the PriorBoxLayerInfo.
1633 *
1634 * @param[in] info Type to output.
1635 *
1636 * @return Formatted string.
1637 */
1638inline std::string to_string(const PriorBoxLayerInfo &info)
1639{
1640 std::stringstream str;
1641 str << "{";
1642 str << "Clip:" << info.clip()
1643 << "Flip:" << info.flip()
1644 << "StepX:" << info.steps()[0]
1645 << "StepY:" << info.steps()[1]
1646 << "MinSizes:" << info.min_sizes().size()
1647 << "MaxSizes:" << info.max_sizes().size()
1648 << "ImgSizeX:" << info.img_size().x
1649 << "ImgSizeY:" << info.img_size().y
1650 << "Offset:" << info.offset()
1651 << "Variances:" << info.variances().size();
1652 str << "}";
1653 return str.str();
1654}
1655
Alex Gildayc357c472018-03-21 13:54:09 +00001656/** Formatted output of the KeyPoint type.
1657 *
1658 * @param[out] os Output stream
1659 * @param[in] point Type to output.
1660 *
1661 * @return Modified output stream.
1662 */
Moritz Pflanzer6c6597c2017-09-24 12:09:41 +01001663inline ::std::ostream &operator<<(::std::ostream &os, const KeyPoint &point)
1664{
1665 os << "{x=" << point.x << ","
1666 << "y=" << point.y << ","
1667 << "strength=" << point.strength << ","
1668 << "scale=" << point.scale << ","
1669 << "orientation=" << point.orientation << ","
1670 << "tracking_status=" << point.tracking_status << ","
1671 << "error=" << point.error << "}";
1672
1673 return os;
1674}
John Richardson63e50412017-10-13 20:51:42 +01001675
Alex Gildayc357c472018-03-21 13:54:09 +00001676/** Formatted output of the PhaseType type.
1677 *
1678 * @param[out] os Output stream
1679 * @param[in] phase_type Type to output.
1680 *
1681 * @return Modified output stream.
1682 */
John Richardson63e50412017-10-13 20:51:42 +01001683inline ::std::ostream &operator<<(::std::ostream &os, const PhaseType &phase_type)
1684{
1685 switch(phase_type)
1686 {
1687 case PhaseType::SIGNED:
1688 os << "SIGNED";
1689 break;
1690 case PhaseType::UNSIGNED:
1691 os << "UNSIGNED";
1692 break;
1693 default:
1694 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1695 }
1696
1697 return os;
1698}
1699
Alex Gildayc357c472018-03-21 13:54:09 +00001700/** Formatted output of the PhaseType type.
1701 *
1702 * @param[in] type Type to output.
1703 *
1704 * @return Formatted string.
1705 */
John Richardson63e50412017-10-13 20:51:42 +01001706inline std::string to_string(const arm_compute::PhaseType &type)
1707{
1708 std::stringstream str;
1709 str << type;
1710 return str.str();
1711}
John Richardson3c5f9492017-10-04 15:27:37 +01001712
Alex Gildayc357c472018-03-21 13:54:09 +00001713/** Formatted output of the MagnitudeType type.
1714 *
1715 * @param[out] os Output stream
1716 * @param[in] magnitude_type Type to output.
1717 *
1718 * @return Modified output stream.
1719 */
John Richardson3c5f9492017-10-04 15:27:37 +01001720inline ::std::ostream &operator<<(::std::ostream &os, const MagnitudeType &magnitude_type)
1721{
1722 switch(magnitude_type)
1723 {
1724 case MagnitudeType::L1NORM:
1725 os << "L1NORM";
1726 break;
1727 case MagnitudeType::L2NORM:
1728 os << "L2NORM";
1729 break;
1730 default:
1731 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1732 }
1733
1734 return os;
1735}
1736
Alex Gildayc357c472018-03-21 13:54:09 +00001737/** Formatted output of the MagnitudeType type.
1738 *
1739 * @param[in] type Type to output.
1740 *
1741 * @return Formatted string.
1742 */
John Richardson3c5f9492017-10-04 15:27:37 +01001743inline std::string to_string(const arm_compute::MagnitudeType &type)
1744{
1745 std::stringstream str;
1746 str << type;
1747 return str.str();
1748}
John Richardson1c529922017-11-01 10:57:48 +00001749
Alex Gildayc357c472018-03-21 13:54:09 +00001750/** Formatted output of the HOGNormType type.
1751 *
1752 * @param[out] os Output stream
1753 * @param[in] norm_type Type to output
1754 *
1755 * @return Modified output stream.
1756 */
John Richardson25f23682017-11-27 14:35:09 +00001757inline ::std::ostream &operator<<(::std::ostream &os, const HOGNormType &norm_type)
1758{
1759 switch(norm_type)
1760 {
1761 case HOGNormType::L1_NORM:
1762 os << "L1_NORM";
1763 break;
1764 case HOGNormType::L2_NORM:
1765 os << "L2_NORM";
1766 break;
1767 case HOGNormType::L2HYS_NORM:
1768 os << "L2HYS_NORM";
1769 break;
1770 default:
1771 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1772 }
1773
1774 return os;
1775}
1776
Alex Gildayc357c472018-03-21 13:54:09 +00001777/** Formatted output of the HOGNormType type.
1778 *
1779 * @param[in] type Type to output
1780 *
1781 * @return Formatted string.
1782 */
John Richardson25f23682017-11-27 14:35:09 +00001783inline std::string to_string(const HOGNormType &type)
1784{
1785 std::stringstream str;
1786 str << type;
1787 return str.str();
1788}
1789
Alex Gildayc357c472018-03-21 13:54:09 +00001790/** Formatted output of the Size2D type.
1791 *
1792 * @param[out] os Output stream
1793 * @param[in] size Type to output
1794 *
1795 * @return Modified output stream.
1796 */
John Richardson25f23682017-11-27 14:35:09 +00001797inline ::std::ostream &operator<<(::std::ostream &os, const Size2D &size)
1798{
1799 os << size.width << "x" << size.height;
1800
1801 return os;
1802}
1803
Alex Gildayc357c472018-03-21 13:54:09 +00001804/** Formatted output of the Size2D type.
1805 *
1806 * @param[in] type Type to output
1807 *
1808 * @return Formatted string.
1809 */
John Richardson25f23682017-11-27 14:35:09 +00001810inline std::string to_string(const Size2D &type)
1811{
1812 std::stringstream str;
1813 str << type;
1814 return str.str();
1815}
1816
Alex Gildayc357c472018-03-21 13:54:09 +00001817/** Formatted output of the HOGInfo type.
1818 *
1819 * @param[out] os Output stream
1820 * @param[in] hog_info Type to output
1821 *
1822 * @return Modified output stream.
1823 */
John Richardson25f23682017-11-27 14:35:09 +00001824inline ::std::ostream &operator<<(::std::ostream &os, const HOGInfo &hog_info)
1825{
1826 os << "{CellSize=" << hog_info.cell_size() << ","
1827 << "BlockSize=" << hog_info.block_size() << ","
1828 << "DetectionWindowSize=" << hog_info.detection_window_size() << ","
1829 << "BlockStride=" << hog_info.block_stride() << ","
1830 << "NumBins=" << hog_info.num_bins() << ","
1831 << "NormType=" << hog_info.normalization_type() << ","
1832 << "L2HystThreshold=" << hog_info.l2_hyst_threshold() << ","
1833 << "PhaseType=" << hog_info.phase_type() << "}";
1834
1835 return os;
1836}
1837
Alex Gildayc357c472018-03-21 13:54:09 +00001838/** Formatted output of the HOGInfo type.
1839 *
1840 * @param[in] type Type to output
1841 *
1842 * @return Formatted string.
1843 */
John Richardson25f23682017-11-27 14:35:09 +00001844inline std::string to_string(const HOGInfo &type)
1845{
1846 std::stringstream str;
1847 str << type;
1848 return str.str();
1849}
1850
Alex Gildayc357c472018-03-21 13:54:09 +00001851/** Formatted output of the ConvolutionMethod type.
1852 *
1853 * @param[out] os Output stream
1854 * @param[in] conv_method Type to output
1855 *
1856 * @return Modified output stream.
1857 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001858inline ::std::ostream &operator<<(::std::ostream &os, const ConvolutionMethod &conv_method)
1859{
1860 switch(conv_method)
1861 {
1862 case ConvolutionMethod::GEMM:
1863 os << "GEMM";
1864 break;
1865 case ConvolutionMethod::DIRECT:
1866 os << "DIRECT";
1867 break;
1868 case ConvolutionMethod::WINOGRAD:
1869 os << "WINOGRAD";
1870 break;
1871 default:
1872 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1873 }
1874
1875 return os;
1876}
1877
Alex Gildayc357c472018-03-21 13:54:09 +00001878/** Formatted output of the ConvolutionMethod type.
1879 *
1880 * @param[in] conv_method Type to output
1881 *
1882 * @return Formatted string.
1883 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001884inline std::string to_string(const ConvolutionMethod &conv_method)
1885{
1886 std::stringstream str;
1887 str << conv_method;
1888 return str.str();
1889}
1890
Alex Gildayc357c472018-03-21 13:54:09 +00001891/** Formatted output of the GPUTarget type.
1892 *
1893 * @param[out] os Output stream
1894 * @param[in] gpu_target Type to output
1895 *
1896 * @return Modified output stream.
1897 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001898inline ::std::ostream &operator<<(::std::ostream &os, const GPUTarget &gpu_target)
1899{
1900 switch(gpu_target)
1901 {
1902 case GPUTarget::GPU_ARCH_MASK:
1903 os << "GPU_ARCH_MASK";
1904 break;
1905 case GPUTarget::MIDGARD:
1906 os << "MIDGARD";
1907 break;
1908 case GPUTarget::BIFROST:
1909 os << "BIFROST";
1910 break;
Georgios Pinitasd5462ff2019-07-03 19:33:57 +01001911 case GPUTarget::VALHALL:
1912 os << "VALHALL";
1913 break;
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001914 case GPUTarget::T600:
1915 os << "T600";
1916 break;
1917 case GPUTarget::T700:
1918 os << "T700";
1919 break;
1920 case GPUTarget::T800:
1921 os << "T800";
1922 break;
Michalis Spyroua9676112018-02-22 18:07:43 +00001923 case GPUTarget::G71:
1924 os << "G71";
1925 break;
1926 case GPUTarget::G72:
1927 os << "G72";
1928 break;
1929 case GPUTarget::G51:
1930 os << "G51";
1931 break;
1932 case GPUTarget::G51BIG:
1933 os << "G51BIG";
1934 break;
1935 case GPUTarget::G51LIT:
1936 os << "G51LIT";
1937 break;
Georgios Pinitasb03f7c52018-07-12 10:49:53 +01001938 case GPUTarget::G76:
1939 os << "G76";
Michalis Spyroua9676112018-02-22 18:07:43 +00001940 break;
Georgios Pinitasd5462ff2019-07-03 19:33:57 +01001941 case GPUTarget::G77:
1942 os << "G77";
Michalis Spyroua9676112018-02-22 18:07:43 +00001943 break;
1944 case GPUTarget::TBOX:
1945 os << "TBOX";
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001946 break;
Georgios Pinitasd5462ff2019-07-03 19:33:57 +01001947 case GPUTarget::TODX:
1948 os << "TODX";
1949 break;
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001950 default:
1951 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1952 }
1953
1954 return os;
1955}
1956
Alex Gildayc357c472018-03-21 13:54:09 +00001957/** Formatted output of the GPUTarget type.
1958 *
1959 * @param[in] gpu_target Type to output
1960 *
1961 * @return Formatted string.
1962 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001963inline std::string to_string(const GPUTarget &gpu_target)
1964{
1965 std::stringstream str;
1966 str << gpu_target;
1967 return str.str();
1968}
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00001969
John Richardson8de92612018-02-22 14:09:31 +00001970/** Formatted output of the DetectionWindow type.
1971 *
1972 * @param[out] os Output stream
1973 * @param[in] detection_window Type to output
1974 *
1975 * @return Modified output stream.
1976 */
John Richardson684cb0f2018-01-09 11:17:00 +00001977inline ::std::ostream &operator<<(::std::ostream &os, const DetectionWindow &detection_window)
1978{
1979 os << "{x=" << detection_window.x << ","
1980 << "y=" << detection_window.y << ","
1981 << "width=" << detection_window.width << ","
1982 << "height=" << detection_window.height << ","
1983 << "idx_class=" << detection_window.idx_class << ","
1984 << "score=" << detection_window.score << "}";
1985
1986 return os;
1987}
1988
Isabella Gottardi05e56442018-11-16 11:26:52 +00001989/** Formatted output of the DetectionOutputLayerCodeType type.
1990 *
1991 * @param[out] os Output stream
1992 * @param[in] detection_code Type to output
1993 *
1994 * @return Modified output stream.
1995 */
1996inline ::std::ostream &operator<<(::std::ostream &os, const DetectionOutputLayerCodeType &detection_code)
1997{
1998 switch(detection_code)
1999 {
2000 case DetectionOutputLayerCodeType::CENTER_SIZE:
2001 os << "CENTER_SIZE";
2002 break;
2003 case DetectionOutputLayerCodeType::CORNER:
2004 os << "CORNER";
2005 break;
2006 case DetectionOutputLayerCodeType::CORNER_SIZE:
2007 os << "CORNER_SIZE";
2008 break;
2009 case DetectionOutputLayerCodeType::TF_CENTER:
2010 os << "TF_CENTER";
2011 break;
2012 default:
2013 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2014 }
2015
2016 return os;
2017}
2018/** Formatted output of the DetectionOutputLayerCodeType type.
2019 *
2020 * @param[in] detection_code Type to output
2021 *
2022 * @return Formatted string.
2023 */
2024inline std::string to_string(const DetectionOutputLayerCodeType &detection_code)
2025{
2026 std::stringstream str;
2027 str << detection_code;
2028 return str.str();
2029}
2030
2031/** Formatted output of the DetectionOutputLayerInfo type.
2032 *
2033 * @param[out] os Output stream
2034 * @param[in] detection_info Type to output
2035 *
2036 * @return Modified output stream.
2037 */
2038inline ::std::ostream &operator<<(::std::ostream &os, const DetectionOutputLayerInfo &detection_info)
2039{
2040 os << "{Classes=" << detection_info.num_classes() << ","
2041 << "ShareLocation=" << detection_info.share_location() << ","
2042 << "CodeType=" << detection_info.code_type() << ","
2043 << "VarianceEncodedInTarget=" << detection_info.variance_encoded_in_target() << ","
2044 << "KeepTopK=" << detection_info.keep_top_k() << ","
2045 << "NMSThreshold=" << detection_info.nms_threshold() << ","
2046 << "Eta=" << detection_info.eta() << ","
2047 << "BackgroundLabelId=" << detection_info.background_label_id() << ","
2048 << "ConfidenceThreshold=" << detection_info.confidence_threshold() << ","
2049 << "TopK=" << detection_info.top_k() << ","
2050 << "NumLocClasses=" << detection_info.num_loc_classes()
2051 << "}";
2052
2053 return os;
2054}
2055
2056/** Formatted output of the DetectionOutputLayerInfo type.
2057 *
2058 * @param[in] detection_info Type to output
2059 *
2060 * @return Formatted string.
2061 */
2062inline std::string to_string(const DetectionOutputLayerInfo &detection_info)
2063{
2064 std::stringstream str;
2065 str << detection_info;
2066 return str.str();
2067}
Isabella Gottardia7acb3c2019-01-08 13:48:44 +00002068/** Formatted output of the DetectionPostProcessLayerInfo type.
2069 *
2070 * @param[out] os Output stream
2071 * @param[in] detection_info Type to output
2072 *
2073 * @return Modified output stream.
2074 */
2075inline ::std::ostream &operator<<(::std::ostream &os, const DetectionPostProcessLayerInfo &detection_info)
2076{
2077 os << "{MaxDetections=" << detection_info.max_detections() << ","
2078 << "MaxClassesPerDetection=" << detection_info.max_classes_per_detection() << ","
2079 << "NmsScoreThreshold=" << detection_info.nms_score_threshold() << ","
2080 << "NmsIouThreshold=" << detection_info.iou_threshold() << ","
2081 << "NumClasses=" << detection_info.num_classes() << ","
2082 << "ScaleValue_y=" << detection_info.scale_value_y() << ","
2083 << "ScaleValue_x=" << detection_info.scale_value_x() << ","
2084 << "ScaleValue_h=" << detection_info.scale_value_h() << ","
2085 << "ScaleValue_w=" << detection_info.scale_value_w() << ","
2086 << "UseRegularNms=" << detection_info.use_regular_nms() << ","
2087 << "DetectionPerClass=" << detection_info.detection_per_class()
2088 << "}";
2089
2090 return os;
2091}
2092
2093/** Formatted output of the DetectionPostProcessLayerInfo type.
2094 *
2095 * @param[in] detection_info Type to output
2096 *
2097 * @return Formatted string.
2098 */
2099inline std::string to_string(const DetectionPostProcessLayerInfo &detection_info)
2100{
2101 std::stringstream str;
2102 str << detection_info;
2103 return str.str();
2104}
John Richardson8de92612018-02-22 14:09:31 +00002105/** Formatted output of the DetectionWindow type.
2106 *
2107 * @param[in] detection_window Type to output
2108 *
2109 * @return Formatted string.
2110 */
2111inline std::string to_string(const DetectionWindow &detection_window)
2112{
2113 std::stringstream str;
2114 str << detection_window;
2115 return str.str();
2116}
2117
2118/** Formatted output of the Termination type.
2119 *
2120 * @param[out] os Output stream
2121 * @param[in] termination Type to output
2122 *
2123 * @return Modified output stream.
2124 */
2125inline ::std::ostream &operator<<(::std::ostream &os, const Termination &termination)
2126{
2127 switch(termination)
2128 {
2129 case Termination::TERM_CRITERIA_EPSILON:
2130 os << "TERM_CRITERIA_EPSILON";
2131 break;
2132 case Termination::TERM_CRITERIA_ITERATIONS:
2133 os << "TERM_CRITERIA_ITERATIONS";
2134 break;
2135 case Termination::TERM_CRITERIA_BOTH:
2136 os << "TERM_CRITERIA_BOTH";
2137 break;
2138 default:
2139 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2140 }
2141
2142 return os;
2143}
2144
2145/** Formatted output of the Termination type.
2146 *
2147 * @param[in] termination Type to output
2148 *
2149 * @return Formatted string.
2150 */
2151inline std::string to_string(const Termination &termination)
2152{
2153 std::stringstream str;
2154 str << termination;
2155 return str.str();
2156}
2157
Anthony Barbier8914e322018-08-10 15:28:25 +01002158/** Formatted output of the CPUModel type.
2159 *
2160 * @param[out] os Output stream
2161 * @param[in] cpu_model Model to output
2162 *
2163 * @return Modified output stream.
2164 */
2165inline ::std::ostream &operator<<(::std::ostream &os, const CPUModel &cpu_model)
2166{
2167 switch(cpu_model)
2168 {
2169 case CPUModel::GENERIC:
2170 os << "GENERIC";
2171 break;
2172 case CPUModel::GENERIC_FP16:
2173 os << "GENERIC_FP16";
2174 break;
2175 case CPUModel::GENERIC_FP16_DOT:
2176 os << "GENERIC_FP16_DOT";
2177 break;
2178 case CPUModel::A53:
2179 os << "A53";
2180 break;
2181 case CPUModel::A55r0:
2182 os << "A55r0";
2183 break;
2184 case CPUModel::A55r1:
2185 os << "A55r1";
2186 break;
2187 default:
2188 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2189 }
2190
2191 return os;
2192}
2193
2194/** Formatted output of the CPUModel type.
2195 *
2196 * @param[in] cpu_model Model to output
2197 *
2198 * @return Formatted string.
2199 */
2200inline std::string to_string(const CPUModel &cpu_model)
2201{
2202 std::stringstream str;
2203 str << cpu_model;
2204 return str.str();
2205}
Anthony Barbier671a11e2018-07-06 15:11:36 +01002206/** Formatted output of a vector of objects.
2207 *
2208 * @param[out] os Output stream
2209 * @param[in] args Vector of objects to print
2210 *
2211 * @return Modified output stream.
2212 */
2213template <typename T>
2214inline ::std::ostream &operator<<(::std::ostream &os, const std::vector<T> &args)
2215{
2216 os << "[";
2217 bool first = true;
2218 for(auto &arg : args)
2219 {
2220 if(first)
2221 {
2222 first = false;
2223 }
2224 else
2225 {
2226 os << ", ";
2227 }
2228 os << arg;
2229 }
2230 os << "]";
2231 return os;
2232}
2233
Michalis Spyrou6c7c38e2018-08-29 16:28:11 +01002234/** Formatted output of @ref PriorBoxLayerInfo.
2235 *
2236 * @param[out] os Output stream.
2237 * @param[in] info Type to output.
2238 *
2239 * @return Modified output stream.
2240 */
2241inline ::std::ostream &operator<<(::std::ostream &os, const PriorBoxLayerInfo &info)
2242{
2243 os << "Clip:" << info.clip()
2244 << "Flip:" << info.flip()
2245 << "StepX:" << info.steps()[0]
2246 << "StepY:" << info.steps()[1]
2247 << "MinSizes:" << info.min_sizes()
2248 << "MaxSizes:" << info.max_sizes()
2249 << "ImgSizeX:" << info.img_size().x
2250 << "ImgSizeY:" << info.img_size().y
2251 << "Offset:" << info.offset()
2252 << "Variances:" << info.variances();
2253
2254 return os;
2255}
2256
Anthony Barbier671a11e2018-07-06 15:11:36 +01002257/** Formatted output of a vector of objects.
2258 *
2259 * @param[in] args Vector of objects to print
2260 *
2261 * @return String representing args.
2262 */
2263template <typename T>
2264std::string to_string(const std::vector<T> &args)
2265{
2266 std::stringstream str;
2267 str << args;
2268 return str.str();
2269}
2270
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00002271/** Formatted output of the WinogradInfo type. */
2272inline ::std::ostream &operator<<(::std::ostream &os, const WinogradInfo &info)
2273{
2274 os << "{OutputTileSize=" << info.output_tile_size << ","
2275 << "KernelSize=" << info.kernel_size << ","
2276 << "PadStride=" << info.convolution_info << ","
2277 << "OutputDataLayout=" << info.output_data_layout << "}";
2278
2279 return os;
2280}
2281
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00002282inline std::string to_string(const WinogradInfo &type)
2283{
2284 std::stringstream str;
2285 str << type;
2286 return str.str();
2287}
Anthony Barbier671a11e2018-07-06 15:11:36 +01002288
2289/** Fallback method: try to use std::to_string:
2290 *
2291 * @param[in] val Value to convert to string
2292 *
2293 * @return String representing val.
2294 */
2295template <typename T>
2296inline std::string to_string(const T &val)
2297{
2298 return support::cpp11::to_string(val);
2299}
2300
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +01002301/** Convert a CLTunerMode value to a string
2302 *
2303 * @param val CLTunerMode value to be converted
2304 *
2305 * @return String representing the corresponding CLTunerMode.
2306 */
2307inline std::string to_string(const CLTunerMode val)
2308{
2309 switch(val)
2310 {
2311 case CLTunerMode::EXHAUSTIVE:
2312 {
2313 return std::string("Exhaustive");
2314 }
2315 case CLTunerMode::NORMAL:
2316 {
2317 return std::string("Normal");
2318 }
2319 case CLTunerMode::RAPID:
2320 {
2321 return std::string("Rapid");
2322 }
2323 default:
2324 {
2325 ARM_COMPUTE_ERROR("Invalid tuner mode.");
2326 return std::string("UNDEFINED");
2327 }
2328 }
2329}
2330/** [Print CLTunerMode type] **/
2331/** Formatted output of the CLTunerMode type.
2332 *
2333 * @param[out] os Output stream.
2334 * @param[in] val CLTunerMode to output.
2335 *
2336 * @return Modified output stream.
2337 */
2338inline ::std::ostream &operator<<(::std::ostream &os, const CLTunerMode &val)
2339{
2340 os << to_string(val);
2341 return os;
2342}
2343
Anthony Barbier6ff3b192017-09-04 18:44:23 +01002344} // namespace arm_compute
Anthony Barbier4dbc0a92018-08-27 13:39:47 +01002345
2346#endif /* __ARM_COMPUTE_TYPE_PRINTER_H__ */