blob: 3f638d7e973ec7b3a9974095f726138f3eddf94b [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 Pinitas448a81f2019-11-21 14:10:25 +0000631 case DataType::QASYMM8_SIGNED:
632 os << "QASYMM8_SIGNED";
633 break;
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100634 case DataType::QSYMM8_PER_CHANNEL:
635 os << "QSYMM8_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;
Michele Di Giorgio35ea9a72019-08-23 12:02:06 +0100649 case DataType::QASYMM16:
650 os << "QASYMM16";
651 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100652 case DataType::U32:
653 os << "U32";
654 break;
655 case DataType::S32:
656 os << "S32";
657 break;
658 case DataType::U64:
659 os << "U64";
660 break;
661 case DataType::S64:
662 os << "S64";
663 break;
664 case DataType::F16:
665 os << "F16";
666 break;
667 case DataType::F32:
668 os << "F32";
669 break;
670 case DataType::F64:
671 os << "F64";
672 break;
673 case DataType::SIZET:
674 os << "SIZET";
675 break;
676 default:
677 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
678 }
679
680 return os;
681}
682
Alex Gildayc357c472018-03-21 13:54:09 +0000683/** Formatted output of the DataType type.
684 *
685 * @param[in] data_type Type to output.
686 *
687 * @return Formatted string.
688 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100689inline std::string to_string(const arm_compute::DataType &data_type)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100690{
691 std::stringstream str;
692 str << data_type;
693 return str.str();
694}
695
Alex Gildayc357c472018-03-21 13:54:09 +0000696/** Formatted output of the Format type.
697 *
698 * @param[out] os Output stream.
699 * @param[in] format Type to output.
700 *
701 * @return Modified output stream.
702 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100703inline ::std::ostream &operator<<(::std::ostream &os, const Format &format)
704{
705 switch(format)
706 {
707 case Format::UNKNOWN:
708 os << "UNKNOWN";
709 break;
710 case Format::U8:
711 os << "U8";
712 break;
713 case Format::S16:
714 os << "S16";
715 break;
716 case Format::U16:
717 os << "U16";
718 break;
719 case Format::S32:
720 os << "S32";
721 break;
722 case Format::U32:
723 os << "U32";
724 break;
725 case Format::F16:
726 os << "F16";
727 break;
728 case Format::F32:
729 os << "F32";
730 break;
731 case Format::UV88:
732 os << "UV88";
733 break;
734 case Format::RGB888:
735 os << "RGB888";
736 break;
737 case Format::RGBA8888:
738 os << "RGBA8888";
739 break;
740 case Format::YUV444:
741 os << "YUV444";
742 break;
743 case Format::YUYV422:
744 os << "YUYV422";
745 break;
746 case Format::NV12:
747 os << "NV12";
748 break;
749 case Format::NV21:
750 os << "NV21";
751 break;
752 case Format::IYUV:
753 os << "IYUV";
754 break;
755 case Format::UYVY422:
756 os << "UYVY422";
757 break;
758 default:
759 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
760 }
761
762 return os;
763}
764
Alex Gildayc357c472018-03-21 13:54:09 +0000765/** Formatted output of the Format type.
766 *
767 * @param[in] format Type to output.
768 *
769 * @return Formatted string.
770 */
Moritz Pflanzer7655a672017-09-23 11:57:33 +0100771inline std::string to_string(const Format &format)
772{
773 std::stringstream str;
774 str << format;
775 return str.str();
776}
777
Alex Gildayc357c472018-03-21 13:54:09 +0000778/** Formatted output of the Channel type.
779 *
780 * @param[out] os Output stream.
781 * @param[in] channel Type to output.
782 *
783 * @return Modified output stream.
784 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100785inline ::std::ostream &operator<<(::std::ostream &os, const Channel &channel)
786{
787 switch(channel)
788 {
789 case Channel::UNKNOWN:
790 os << "UNKNOWN";
791 break;
792 case Channel::C0:
793 os << "C0";
794 break;
795 case Channel::C1:
796 os << "C1";
797 break;
798 case Channel::C2:
799 os << "C2";
800 break;
801 case Channel::C3:
802 os << "C3";
803 break;
804 case Channel::R:
805 os << "R";
806 break;
807 case Channel::G:
808 os << "G";
809 break;
810 case Channel::B:
811 os << "B";
812 break;
813 case Channel::A:
814 os << "A";
815 break;
816 case Channel::Y:
817 os << "Y";
818 break;
819 case Channel::U:
820 os << "U";
821 break;
822 case Channel::V:
823 os << "V";
824 break;
825 default:
826 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
827 }
828
829 return os;
830}
831
Alex Gildayc357c472018-03-21 13:54:09 +0000832/** Formatted output of the Channel type.
833 *
834 * @param[in] channel Type to output.
835 *
836 * @return Formatted string.
837 */
Ioan-Cristian Szabo9414f642017-10-27 17:35:40 +0100838inline std::string to_string(const Channel &channel)
839{
840 std::stringstream str;
841 str << channel;
842 return str.str();
843}
844
Alex Gildayc357c472018-03-21 13:54:09 +0000845/** Formatted output of the BorderMode type.
846 *
847 * @param[out] os Output stream.
848 * @param[in] mode Type to output.
849 *
850 * @return Modified output stream.
851 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100852inline ::std::ostream &operator<<(::std::ostream &os, const BorderMode &mode)
853{
854 switch(mode)
855 {
856 case BorderMode::UNDEFINED:
857 os << "UNDEFINED";
858 break;
859 case BorderMode::CONSTANT:
860 os << "CONSTANT";
861 break;
862 case BorderMode::REPLICATE:
863 os << "REPLICATE";
864 break;
865 default:
866 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
867 }
868
869 return os;
870}
871
Alex Gildayc357c472018-03-21 13:54:09 +0000872/** Formatted output of the BorderSize type.
873 *
874 * @param[out] os Output stream.
875 * @param[in] border Type to output.
876 *
877 * @return Modified output stream.
878 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100879inline ::std::ostream &operator<<(::std::ostream &os, const BorderSize &border)
880{
Moritz Pflanzerc87fbf82017-07-18 14:02:10 +0100881 os << border.top << ","
882 << border.right << ","
883 << border.bottom << ","
884 << border.left;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100885
886 return os;
887}
Anthony Barbier2a07e182017-08-04 18:20:27 +0100888
Giuseppe Rossinid7647d42018-07-17 18:13:13 +0100889/** Formatted output of the PaddingList type.
890 *
891 * @param[out] os Output stream.
892 * @param[in] padding Type to output.
893 *
894 * @return Modified output stream.
895 */
896inline ::std::ostream &operator<<(::std::ostream &os, const PaddingList &padding)
897{
898 os << "{";
899 for(auto const &p : padding)
900 {
901 os << "{" << p.first << "," << p.second << "}";
902 }
903 os << "}";
904 return os;
905}
906
giuros013175fcf2018-11-21 09:59:17 +0000907/** Formatted output of the Multiples type.
908 *
909 * @param[out] os Output stream.
910 * @param[in] multiples Type to output.
911 *
912 * @return Modified output stream.
913 */
914inline ::std::ostream &operator<<(::std::ostream &os, const Multiples &multiples)
915{
916 os << "(";
917 for(size_t i = 0; i < multiples.size() - 1; i++)
918 {
919 os << multiples[i] << ", ";
920 }
921 os << multiples.back() << ")";
922 return os;
923}
924
Alex Gildayc357c472018-03-21 13:54:09 +0000925/** Formatted output of the InterpolationPolicy type.
926 *
927 * @param[out] os Output stream.
928 * @param[in] policy Type to output.
929 *
930 * @return Modified output stream.
931 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100932inline ::std::ostream &operator<<(::std::ostream &os, const InterpolationPolicy &policy)
933{
934 switch(policy)
935 {
936 case InterpolationPolicy::NEAREST_NEIGHBOR:
937 os << "NEAREST_NEIGHBOR";
938 break;
939 case InterpolationPolicy::BILINEAR:
940 os << "BILINEAR";
941 break;
942 case InterpolationPolicy::AREA:
943 os << "AREA";
944 break;
945 default:
946 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
947 }
948
949 return os;
950}
951
Alex Gildayc357c472018-03-21 13:54:09 +0000952/** Formatted output of the SamplingPolicy type.
953 *
954 * @param[out] os Output stream.
955 * @param[in] policy Type to output.
956 *
957 * @return Modified output stream.
958 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700959inline ::std::ostream &operator<<(::std::ostream &os, const SamplingPolicy &policy)
960{
961 switch(policy)
962 {
963 case SamplingPolicy::CENTER:
964 os << "CENTER";
965 break;
966 case SamplingPolicy::TOP_LEFT:
967 os << "TOP_LEFT";
968 break;
969 default:
970 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
971 }
972
973 return os;
974}
975
Alex Gildayc357c472018-03-21 13:54:09 +0000976/** Formatted output of the TensorInfo type.
977 *
Anthony Barbier366628a2018-08-01 13:55:03 +0100978 * @param[out] os Output stream.
979 * @param[in] info Type to output.
980 *
981 * @return Modified output stream.
982 */
983inline ::std::ostream &operator<<(::std::ostream &os, const TensorInfo &info)
984{
985 os << "{Shape=" << info.tensor_shape() << ","
986 << "Type=" << info.data_type() << ","
987 << "Channels=" << info.num_channels() << "}";
988 return os;
989}
990/** Formatted output of the TensorInfo type.
991 *
Alex Gildayc357c472018-03-21 13:54:09 +0000992 * @param[in] info Type to output.
993 *
994 * @return Formatted string.
995 */
Georgios Pinitas3faea252017-10-30 14:13:50 +0000996inline std::string to_string(const TensorInfo &info)
997{
998 std::stringstream str;
Anthony Barbier366628a2018-08-01 13:55:03 +0100999 str << info;
Georgios Pinitas3faea252017-10-30 14:13:50 +00001000 return str.str();
1001}
1002
Alex Gildayc357c472018-03-21 13:54:09 +00001003/** Formatted output of the Dimensions type.
1004 *
1005 * @param[in] dimensions Type to output.
1006 *
1007 * @return Formatted string.
1008 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001009template <typename T>
1010inline std::string to_string(const Dimensions<T> &dimensions)
1011{
1012 std::stringstream str;
1013 str << dimensions;
1014 return str.str();
1015}
1016
Alex Gildayc357c472018-03-21 13:54:09 +00001017/** Formatted output of the Strides type.
1018 *
1019 * @param[in] stride Type to output.
1020 *
1021 * @return Formatted string.
1022 */
John Richardsona36eae12017-09-26 16:55:59 +01001023inline std::string to_string(const Strides &stride)
1024{
1025 std::stringstream str;
1026 str << stride;
1027 return str.str();
1028}
1029
Alex Gildayc357c472018-03-21 13:54:09 +00001030/** Formatted output of the TensorShape type.
1031 *
1032 * @param[in] shape Type to output.
1033 *
1034 * @return Formatted string.
1035 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001036inline std::string to_string(const TensorShape &shape)
1037{
1038 std::stringstream str;
1039 str << shape;
1040 return str.str();
1041}
1042
Alex Gildayc357c472018-03-21 13:54:09 +00001043/** Formatted output of the Coordinates type.
1044 *
1045 * @param[in] coord Type to output.
1046 *
1047 * @return Formatted string.
1048 */
Abe Mbise925ca0f2017-10-02 19:16:33 +01001049inline std::string to_string(const Coordinates &coord)
1050{
1051 std::stringstream str;
1052 str << coord;
1053 return str.str();
1054}
1055
Anthony Barbierb940fd62018-06-04 14:14:32 +01001056/** Formatted output of the GEMMReshapeInfo type.
1057 *
1058 * @param[out] os Output stream.
1059 * @param[in] info Type to output.
1060 *
1061 * @return Modified output stream.
1062 */
1063inline ::std::ostream &operator<<(::std::ostream &os, const GEMMReshapeInfo &info)
1064{
1065 os << "{m=" << info.m() << ",";
1066 os << "n=" << info.n() << ",";
1067 os << "k=" << info.k() << ",";
1068 os << "mult_transpose1xW_width=" << info.mult_transpose1xW_width() << ",";
1069 os << "mult_interleave4x4_height=" << info.mult_interleave4x4_height();
1070 os << "}";
1071
1072 return os;
1073}
1074
1075/** Formatted output of the GEMMInfo type.
1076 *
1077 * @param[out] os Output stream.
1078 * @param[in] info Type to output.
1079 *
1080 * @return Modified output stream.
1081 */
1082inline ::std::ostream &operator<<(::std::ostream &os, const GEMMInfo &info)
1083{
1084 os << "{is_a_reshaped=" << info.is_a_reshaped() << ",";
1085 os << "is_b_reshaped=" << info.is_b_reshaped() << ",";
1086 os << "reshape_b_only_on_first_run=" << info.reshape_b_only_on_first_run() << ",";
Anthony Barbierb940fd62018-06-04 14:14:32 +01001087 os << "}";
1088
1089 return os;
1090}
1091
1092/** Formatted output of the Window::Dimension type.
1093 *
1094 * @param[out] os Output stream.
1095 * @param[in] dim Type to output.
1096 *
1097 * @return Modified output stream.
1098 */
1099inline ::std::ostream &operator<<(::std::ostream &os, const Window::Dimension &dim)
1100{
1101 os << "{start=" << dim.start() << ", end=" << dim.end() << ", step=" << dim.step() << "}";
1102
1103 return os;
1104}
1105/** Formatted output of the Window type.
1106 *
1107 * @param[out] os Output stream.
1108 * @param[in] win Type to output.
1109 *
1110 * @return Modified output stream.
1111 */
1112inline ::std::ostream &operator<<(::std::ostream &os, const Window &win)
1113{
1114 os << "{";
1115 for(unsigned int i = 0; i < Coordinates::num_max_dimensions; i++)
1116 {
1117 if(i > 0)
1118 {
1119 os << ", ";
1120 }
1121 os << win[i];
1122 }
1123 os << "}";
1124
1125 return os;
1126}
1127
1128/** Formatted output of the WeightsInfo type.
1129 *
1130 * @param[in] info Type to output.
1131 *
1132 * @return Formatted string.
1133 */
1134inline std::string to_string(const WeightsInfo &info)
1135{
1136 std::stringstream str;
1137 str << info;
1138 return str.str();
1139}
1140
1141/** Formatted output of the GEMMReshapeInfo type.
1142 *
1143 * @param[in] info Type to output.
1144 *
1145 * @return Formatted string.
1146 */
1147inline std::string to_string(const GEMMReshapeInfo &info)
1148{
1149 std::stringstream str;
1150 str << info;
1151 return str.str();
1152}
1153
1154/** Formatted output of the GEMMInfo type.
1155 *
1156 * @param[in] info Type to output.
1157 *
1158 * @return Formatted string.
1159 */
1160inline std::string to_string(const GEMMInfo &info)
1161{
1162 std::stringstream str;
1163 str << info;
1164 return str.str();
1165}
1166
1167/** Formatted output of the Window::Dimension type.
1168 *
1169 * @param[in] dim Type to output.
1170 *
1171 * @return Formatted string.
1172 */
1173inline std::string to_string(const Window::Dimension &dim)
1174{
1175 std::stringstream str;
1176 str << dim;
1177 return str.str();
1178}
1179/** Formatted output of the Window type.
1180 *
1181 * @param[in] win Type to output.
1182 *
1183 * @return Formatted string.
1184 */
1185inline std::string to_string(const Window &win)
1186{
1187 std::stringstream str;
1188 str << win;
1189 return str.str();
1190}
1191
Alex Gildayc357c472018-03-21 13:54:09 +00001192/** Formatted output of the Rectangle type.
1193 *
1194 * @param[out] os Output stream.
1195 * @param[in] rect Type to output.
1196 *
1197 * @return Modified output stream.
1198 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001199inline ::std::ostream &operator<<(::std::ostream &os, const Rectangle &rect)
1200{
1201 os << rect.width << "x" << rect.height;
1202 os << "+" << rect.x << "+" << rect.y;
1203
1204 return os;
1205}
1206
Usama Arif8cf8c112019-03-14 15:36:54 +00001207/** Formatted output of the PaddingMode type.
1208 *
1209 * @param[out] os Output stream.
1210 * @param[in] mode Type to output.
1211 *
1212 * @return Modified output stream.
1213 */
1214inline ::std::ostream &operator<<(::std::ostream &os, const PaddingMode &mode)
1215{
1216 switch(mode)
1217 {
1218 case PaddingMode::CONSTANT:
1219 os << "CONSTANT";
1220 break;
1221 case PaddingMode::REFLECT:
1222 os << "REFLECT";
1223 break;
1224 case PaddingMode::SYMMETRIC:
1225 os << "SYMMETRIC";
1226 break;
1227 default:
1228 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1229 }
1230
1231 return os;
1232}
1233
1234/** Formatted output of the PaddingMode type.
1235 *
1236 * @param[in] mode Type to output.
1237 *
1238 * @return Formatted string.
1239 */
1240inline std::string to_string(const PaddingMode &mode)
1241{
1242 std::stringstream str;
1243 str << mode;
1244 return str.str();
1245}
1246
Alex Gildayc357c472018-03-21 13:54:09 +00001247/** Formatted output of the PadStrideInfo type.
1248 *
1249 * @param[out] os Output stream.
1250 * @param[in] pad_stride_info Type to output.
1251 *
1252 * @return Modified output stream.
1253 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001254inline ::std::ostream &operator<<(::std::ostream &os, const PadStrideInfo &pad_stride_info)
1255{
1256 os << pad_stride_info.stride().first << "," << pad_stride_info.stride().second;
1257 os << ";";
Jaroslaw Rzepeckia1ed41f2017-10-13 11:13:58 +01001258 os << pad_stride_info.pad_left() << "," << pad_stride_info.pad_right() << ","
1259 << pad_stride_info.pad_top() << "," << pad_stride_info.pad_bottom();
Anthony Barbier2a07e182017-08-04 18:20:27 +01001260
1261 return os;
1262}
1263
Alex Gildayc357c472018-03-21 13:54:09 +00001264/** Formatted output of the PadStrideInfo type.
1265 *
1266 * @param[in] pad_stride_info Type to output.
1267 *
1268 * @return Formatted string.
1269 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001270inline std::string to_string(const PadStrideInfo &pad_stride_info)
1271{
1272 std::stringstream str;
1273 str << pad_stride_info;
1274 return str.str();
1275}
1276
Alex Gildayc357c472018-03-21 13:54:09 +00001277/** Formatted output of the BorderMode type.
1278 *
1279 * @param[in] mode Type to output.
1280 *
1281 * @return Formatted string.
1282 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001283inline std::string to_string(const BorderMode &mode)
1284{
1285 std::stringstream str;
1286 str << mode;
1287 return str.str();
1288}
1289
Alex Gildayc357c472018-03-21 13:54:09 +00001290/** Formatted output of the BorderSize type.
1291 *
1292 * @param[in] border Type to output.
1293 *
1294 * @return Formatted string.
1295 */
John Richardsonb482ce12017-09-18 12:44:01 +01001296inline std::string to_string(const BorderSize &border)
1297{
1298 std::stringstream str;
1299 str << border;
1300 return str.str();
1301}
1302
Giuseppe Rossinid7647d42018-07-17 18:13:13 +01001303/** Formatted output of the PaddingList type.
1304 *
1305 * @param[in] padding Type to output.
1306 *
1307 * @return Formatted string.
1308 */
1309inline std::string to_string(const PaddingList &padding)
1310{
1311 std::stringstream str;
1312 str << padding;
1313 return str.str();
1314}
1315
giuros013175fcf2018-11-21 09:59:17 +00001316/** Formatted output of the Multiples type.
1317 *
1318 * @param[in] multiples Type to output.
1319 *
1320 * @return Formatted string.
1321 */
1322inline std::string to_string(const Multiples &multiples)
1323{
1324 std::stringstream str;
1325 str << multiples;
1326 return str.str();
1327}
1328
Alex Gildayc357c472018-03-21 13:54:09 +00001329/** Formatted output of the InterpolationPolicy type.
1330 *
1331 * @param[in] policy Type to output.
1332 *
1333 * @return Formatted string.
1334 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001335inline std::string to_string(const InterpolationPolicy &policy)
1336{
1337 std::stringstream str;
1338 str << policy;
1339 return str.str();
1340}
1341
Alex Gildayc357c472018-03-21 13:54:09 +00001342/** Formatted output of the SamplingPolicy type.
1343 *
1344 * @param[in] policy Type to output.
1345 *
1346 * @return Formatted string.
1347 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +07001348inline std::string to_string(const SamplingPolicy &policy)
1349{
1350 std::stringstream str;
1351 str << policy;
1352 return str.str();
1353}
1354
Alex Gildayc357c472018-03-21 13:54:09 +00001355/** Formatted output of the ConvertPolicy type.
1356 *
1357 * @param[out] os Output stream.
1358 * @param[in] policy Type to output.
1359 *
1360 * @return Modified output stream.
1361 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001362inline ::std::ostream &operator<<(::std::ostream &os, const ConvertPolicy &policy)
1363{
1364 switch(policy)
1365 {
1366 case ConvertPolicy::WRAP:
1367 os << "WRAP";
1368 break;
1369 case ConvertPolicy::SATURATE:
1370 os << "SATURATE";
1371 break;
1372 default:
1373 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1374 }
1375
1376 return os;
1377}
1378
1379inline std::string to_string(const ConvertPolicy &policy)
1380{
1381 std::stringstream str;
1382 str << policy;
1383 return str.str();
1384}
1385
giuros01164a2722018-11-20 18:34:46 +00001386/** Formatted output of the ArithmeticOperation type.
1387 *
1388 * @param[out] os Output stream.
1389 * @param[in] op Operation to output.
1390 *
1391 * @return Modified output stream.
1392 */
1393inline ::std::ostream &operator<<(::std::ostream &os, const ArithmeticOperation &op)
1394{
1395 switch(op)
1396 {
1397 case ArithmeticOperation::ADD:
1398 os << "ADD";
1399 break;
1400 case ArithmeticOperation::SUB:
1401 os << "SUB";
1402 break;
1403 case ArithmeticOperation::DIV:
1404 os << "DIV";
1405 break;
1406 case ArithmeticOperation::MAX:
1407 os << "MAX";
1408 break;
1409 case ArithmeticOperation::MIN:
1410 os << "MIN";
1411 break;
1412 case ArithmeticOperation::SQUARED_DIFF:
1413 os << "SQUARED_DIFF";
1414 break;
Usama Arif52c54f62019-05-14 10:22:36 +01001415 case ArithmeticOperation::POWER:
1416 os << "POWER";
1417 break;
giuros01164a2722018-11-20 18:34:46 +00001418 default:
1419 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1420 }
1421
1422 return os;
1423}
1424
1425/** Formatted output of the Arithmetic Operation
1426 *
1427 * @param[in] op Type to output.
1428 *
1429 * @return Formatted string.
1430 */
1431inline std::string to_string(const ArithmeticOperation &op)
1432{
1433 std::stringstream str;
1434 str << op;
1435 return str.str();
1436}
1437
Alex Gildayc357c472018-03-21 13:54:09 +00001438/** Formatted output of the Reduction Operations.
1439 *
1440 * @param[out] os Output stream.
1441 * @param[in] op Type to output.
1442 *
1443 * @return Modified output stream.
1444 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001445inline ::std::ostream &operator<<(::std::ostream &os, const ReductionOperation &op)
1446{
1447 switch(op)
1448 {
Michalis Spyrou7e9391b2018-10-05 14:49:28 +01001449 case ReductionOperation::SUM:
1450 os << "SUM";
1451 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +01001452 case ReductionOperation::SUM_SQUARE:
1453 os << "SUM_SQUARE";
1454 break;
Michalis Spyrou7e9391b2018-10-05 14:49:28 +01001455 case ReductionOperation::MEAN_SUM:
1456 os << "MEAN_SUM";
1457 break;
Michalis Spyrou7930db42018-11-22 17:36:28 +00001458 case ReductionOperation::ARG_IDX_MAX:
1459 os << "ARG_IDX_MAX";
1460 break;
1461 case ReductionOperation::ARG_IDX_MIN:
1462 os << "ARG_IDX_MIN";
1463 break;
Manuel Bottinib412fab2018-12-10 17:40:23 +00001464 case ReductionOperation::PROD:
1465 os << "PROD";
1466 break;
Usama Arifa4a08ad2019-05-20 12:38:33 +01001467 case ReductionOperation::MIN:
1468 os << "MIN";
1469 break;
Usama Arif28f0dd92019-05-20 13:44:34 +01001470 case ReductionOperation::MAX:
1471 os << "MAX";
1472 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +01001473 default:
1474 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1475 }
1476
1477 return os;
1478}
1479
Alex Gildayc357c472018-03-21 13:54:09 +00001480/** Formatted output of the Reduction Operations.
1481 *
1482 * @param[in] op Type to output.
1483 *
1484 * @return Formatted string.
1485 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001486inline std::string to_string(const ReductionOperation &op)
1487{
1488 std::stringstream str;
1489 str << op;
1490 return str.str();
1491}
1492
Georgios Pinitas7900a9e2018-11-23 11:44:58 +00001493/** Formatted output of the Comparison Operations.
1494 *
1495 * @param[out] os Output stream.
1496 * @param[in] op Type to output.
1497 *
1498 * @return Modified output stream.
1499 */
1500inline ::std::ostream &operator<<(::std::ostream &os, const ComparisonOperation &op)
1501{
1502 switch(op)
1503 {
1504 case ComparisonOperation::Equal:
1505 os << "Equal";
1506 break;
1507 case ComparisonOperation::NotEqual:
1508 os << "NotEqual";
1509 break;
1510 case ComparisonOperation::Greater:
1511 os << "Greater";
1512 break;
1513 case ComparisonOperation::GreaterEqual:
1514 os << "GreaterEqual";
1515 break;
1516 case ComparisonOperation::Less:
1517 os << "Less";
1518 break;
1519 case ComparisonOperation::LessEqual:
1520 os << "LessEqual";
1521 break;
1522 default:
1523 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1524 }
1525
1526 return os;
1527}
1528
Michalis Spyroue9362622018-11-23 17:41:37 +00001529/** Formatted output of the Elementwise unary Operations.
1530 *
1531 * @param[out] os Output stream.
1532 * @param[in] op Type to output.
1533 *
1534 * @return Modified output stream.
1535 */
1536inline ::std::ostream &operator<<(::std::ostream &os, const ElementWiseUnary &op)
1537{
1538 switch(op)
1539 {
1540 case ElementWiseUnary::RSQRT:
1541 os << "RSQRT";
1542 break;
1543 case ElementWiseUnary::EXP:
1544 os << "EXP";
1545 break;
Usama Arifeb312ef2019-05-13 17:45:54 +01001546 case ElementWiseUnary::NEG:
1547 os << "NEG";
1548 break;
Usama Arifac33d7e2019-05-20 14:21:40 +01001549 case ElementWiseUnary::LOG:
1550 os << "LOG";
1551 break;
Usama Arif6a4d5422019-05-24 14:53:59 +01001552 case ElementWiseUnary::ROUND:
1553 os << "ROUND";
1554 break;
Michalis Spyroue9362622018-11-23 17:41:37 +00001555 default:
1556 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1557 }
1558
1559 return os;
1560}
1561
Georgios Pinitas7900a9e2018-11-23 11:44:58 +00001562/** Formatted output of the Comparison Operations.
1563 *
1564 * @param[in] op Type to output.
1565 *
1566 * @return Formatted string.
1567 */
1568inline std::string to_string(const ComparisonOperation &op)
1569{
1570 std::stringstream str;
1571 str << op;
1572 return str.str();
1573}
1574
Michalis Spyroue9362622018-11-23 17:41:37 +00001575/** Formatted output of the Elementwise unary Operations.
1576 *
1577 * @param[in] op Type to output.
1578 *
1579 * @return Formatted string.
1580 */
1581inline std::string to_string(const ElementWiseUnary &op)
1582{
1583 std::stringstream str;
1584 str << op;
1585 return str.str();
1586}
1587
Alex Gildayc357c472018-03-21 13:54:09 +00001588/** Formatted output of the Norm Type.
1589 *
1590 * @param[in] type Type to output.
1591 *
1592 * @return Formatted string.
1593 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001594inline std::string to_string(const NormType &type)
1595{
1596 std::stringstream str;
1597 str << type;
1598 return str.str();
1599}
1600
Alex Gildayc357c472018-03-21 13:54:09 +00001601/** Formatted output of the Pooling Type.
1602 *
1603 * @param[in] type Type to output.
1604 *
1605 * @return Formatted string.
1606 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001607inline std::string to_string(const PoolingType &type)
1608{
1609 std::stringstream str;
1610 str << type;
1611 return str.str();
1612}
1613
Alex Gildayc357c472018-03-21 13:54:09 +00001614/** Formatted output of the Pooling Layer Info.
1615 *
1616 * @param[in] info Type to output.
1617 *
1618 * @return Formatted string.
1619 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001620inline std::string to_string(const PoolingLayerInfo &info)
1621{
1622 std::stringstream str;
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001623 str << "{Type=" << info.pool_type() << ","
1624 << "IsGlobalPooling=" << info.is_global_pooling();
1625 if(!info.is_global_pooling())
1626 {
1627 str << ","
Isabella Gottardi6e464c32018-01-26 12:32:45 +00001628 << "PoolSize=" << info.pool_size().width << "," << info.pool_size().height << ","
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001629 << "PadStride=" << info.pad_stride_info();
1630 }
1631 str << "}";
Anthony Barbier2a07e182017-08-04 18:20:27 +01001632 return str.str();
1633}
1634
Michalis Spyrou6c7c38e2018-08-29 16:28:11 +01001635/** Formatted output of the PriorBoxLayerInfo.
1636 *
1637 * @param[in] info Type to output.
1638 *
1639 * @return Formatted string.
1640 */
1641inline std::string to_string(const PriorBoxLayerInfo &info)
1642{
1643 std::stringstream str;
1644 str << "{";
1645 str << "Clip:" << info.clip()
1646 << "Flip:" << info.flip()
1647 << "StepX:" << info.steps()[0]
1648 << "StepY:" << info.steps()[1]
1649 << "MinSizes:" << info.min_sizes().size()
1650 << "MaxSizes:" << info.max_sizes().size()
1651 << "ImgSizeX:" << info.img_size().x
1652 << "ImgSizeY:" << info.img_size().y
1653 << "Offset:" << info.offset()
1654 << "Variances:" << info.variances().size();
1655 str << "}";
1656 return str.str();
1657}
1658
Alex Gildayc357c472018-03-21 13:54:09 +00001659/** Formatted output of the KeyPoint type.
1660 *
1661 * @param[out] os Output stream
1662 * @param[in] point Type to output.
1663 *
1664 * @return Modified output stream.
1665 */
Moritz Pflanzer6c6597c2017-09-24 12:09:41 +01001666inline ::std::ostream &operator<<(::std::ostream &os, const KeyPoint &point)
1667{
1668 os << "{x=" << point.x << ","
1669 << "y=" << point.y << ","
1670 << "strength=" << point.strength << ","
1671 << "scale=" << point.scale << ","
1672 << "orientation=" << point.orientation << ","
1673 << "tracking_status=" << point.tracking_status << ","
1674 << "error=" << point.error << "}";
1675
1676 return os;
1677}
John Richardson63e50412017-10-13 20:51:42 +01001678
Alex Gildayc357c472018-03-21 13:54:09 +00001679/** Formatted output of the PhaseType type.
1680 *
1681 * @param[out] os Output stream
1682 * @param[in] phase_type Type to output.
1683 *
1684 * @return Modified output stream.
1685 */
John Richardson63e50412017-10-13 20:51:42 +01001686inline ::std::ostream &operator<<(::std::ostream &os, const PhaseType &phase_type)
1687{
1688 switch(phase_type)
1689 {
1690 case PhaseType::SIGNED:
1691 os << "SIGNED";
1692 break;
1693 case PhaseType::UNSIGNED:
1694 os << "UNSIGNED";
1695 break;
1696 default:
1697 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1698 }
1699
1700 return os;
1701}
1702
Alex Gildayc357c472018-03-21 13:54:09 +00001703/** Formatted output of the PhaseType type.
1704 *
1705 * @param[in] type Type to output.
1706 *
1707 * @return Formatted string.
1708 */
John Richardson63e50412017-10-13 20:51:42 +01001709inline std::string to_string(const arm_compute::PhaseType &type)
1710{
1711 std::stringstream str;
1712 str << type;
1713 return str.str();
1714}
John Richardson3c5f9492017-10-04 15:27:37 +01001715
Alex Gildayc357c472018-03-21 13:54:09 +00001716/** Formatted output of the MagnitudeType type.
1717 *
1718 * @param[out] os Output stream
1719 * @param[in] magnitude_type Type to output.
1720 *
1721 * @return Modified output stream.
1722 */
John Richardson3c5f9492017-10-04 15:27:37 +01001723inline ::std::ostream &operator<<(::std::ostream &os, const MagnitudeType &magnitude_type)
1724{
1725 switch(magnitude_type)
1726 {
1727 case MagnitudeType::L1NORM:
1728 os << "L1NORM";
1729 break;
1730 case MagnitudeType::L2NORM:
1731 os << "L2NORM";
1732 break;
1733 default:
1734 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1735 }
1736
1737 return os;
1738}
1739
Alex Gildayc357c472018-03-21 13:54:09 +00001740/** Formatted output of the MagnitudeType type.
1741 *
1742 * @param[in] type Type to output.
1743 *
1744 * @return Formatted string.
1745 */
John Richardson3c5f9492017-10-04 15:27:37 +01001746inline std::string to_string(const arm_compute::MagnitudeType &type)
1747{
1748 std::stringstream str;
1749 str << type;
1750 return str.str();
1751}
John Richardson1c529922017-11-01 10:57:48 +00001752
Alex Gildayc357c472018-03-21 13:54:09 +00001753/** Formatted output of the HOGNormType type.
1754 *
1755 * @param[out] os Output stream
1756 * @param[in] norm_type Type to output
1757 *
1758 * @return Modified output stream.
1759 */
John Richardson25f23682017-11-27 14:35:09 +00001760inline ::std::ostream &operator<<(::std::ostream &os, const HOGNormType &norm_type)
1761{
1762 switch(norm_type)
1763 {
1764 case HOGNormType::L1_NORM:
1765 os << "L1_NORM";
1766 break;
1767 case HOGNormType::L2_NORM:
1768 os << "L2_NORM";
1769 break;
1770 case HOGNormType::L2HYS_NORM:
1771 os << "L2HYS_NORM";
1772 break;
1773 default:
1774 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1775 }
1776
1777 return os;
1778}
1779
Alex Gildayc357c472018-03-21 13:54:09 +00001780/** Formatted output of the HOGNormType type.
1781 *
1782 * @param[in] type Type to output
1783 *
1784 * @return Formatted string.
1785 */
John Richardson25f23682017-11-27 14:35:09 +00001786inline std::string to_string(const HOGNormType &type)
1787{
1788 std::stringstream str;
1789 str << type;
1790 return str.str();
1791}
1792
Alex Gildayc357c472018-03-21 13:54:09 +00001793/** Formatted output of the Size2D type.
1794 *
1795 * @param[out] os Output stream
1796 * @param[in] size Type to output
1797 *
1798 * @return Modified output stream.
1799 */
John Richardson25f23682017-11-27 14:35:09 +00001800inline ::std::ostream &operator<<(::std::ostream &os, const Size2D &size)
1801{
1802 os << size.width << "x" << size.height;
1803
1804 return os;
1805}
1806
Alex Gildayc357c472018-03-21 13:54:09 +00001807/** Formatted output of the Size2D type.
1808 *
1809 * @param[in] type Type to output
1810 *
1811 * @return Formatted string.
1812 */
John Richardson25f23682017-11-27 14:35:09 +00001813inline std::string to_string(const Size2D &type)
1814{
1815 std::stringstream str;
1816 str << type;
1817 return str.str();
1818}
1819
Alex Gildayc357c472018-03-21 13:54:09 +00001820/** Formatted output of the HOGInfo type.
1821 *
1822 * @param[out] os Output stream
1823 * @param[in] hog_info Type to output
1824 *
1825 * @return Modified output stream.
1826 */
John Richardson25f23682017-11-27 14:35:09 +00001827inline ::std::ostream &operator<<(::std::ostream &os, const HOGInfo &hog_info)
1828{
1829 os << "{CellSize=" << hog_info.cell_size() << ","
1830 << "BlockSize=" << hog_info.block_size() << ","
1831 << "DetectionWindowSize=" << hog_info.detection_window_size() << ","
1832 << "BlockStride=" << hog_info.block_stride() << ","
1833 << "NumBins=" << hog_info.num_bins() << ","
1834 << "NormType=" << hog_info.normalization_type() << ","
1835 << "L2HystThreshold=" << hog_info.l2_hyst_threshold() << ","
1836 << "PhaseType=" << hog_info.phase_type() << "}";
1837
1838 return os;
1839}
1840
Alex Gildayc357c472018-03-21 13:54:09 +00001841/** Formatted output of the HOGInfo type.
1842 *
1843 * @param[in] type Type to output
1844 *
1845 * @return Formatted string.
1846 */
John Richardson25f23682017-11-27 14:35:09 +00001847inline std::string to_string(const HOGInfo &type)
1848{
1849 std::stringstream str;
1850 str << type;
1851 return str.str();
1852}
1853
Alex Gildayc357c472018-03-21 13:54:09 +00001854/** Formatted output of the ConvolutionMethod type.
1855 *
1856 * @param[out] os Output stream
1857 * @param[in] conv_method Type to output
1858 *
1859 * @return Modified output stream.
1860 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001861inline ::std::ostream &operator<<(::std::ostream &os, const ConvolutionMethod &conv_method)
1862{
1863 switch(conv_method)
1864 {
1865 case ConvolutionMethod::GEMM:
1866 os << "GEMM";
1867 break;
1868 case ConvolutionMethod::DIRECT:
1869 os << "DIRECT";
1870 break;
1871 case ConvolutionMethod::WINOGRAD:
1872 os << "WINOGRAD";
1873 break;
1874 default:
1875 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1876 }
1877
1878 return os;
1879}
1880
Alex Gildayc357c472018-03-21 13:54:09 +00001881/** Formatted output of the ConvolutionMethod type.
1882 *
1883 * @param[in] conv_method Type to output
1884 *
1885 * @return Formatted string.
1886 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001887inline std::string to_string(const ConvolutionMethod &conv_method)
1888{
1889 std::stringstream str;
1890 str << conv_method;
1891 return str.str();
1892}
1893
Alex Gildayc357c472018-03-21 13:54:09 +00001894/** Formatted output of the GPUTarget type.
1895 *
1896 * @param[out] os Output stream
1897 * @param[in] gpu_target Type to output
1898 *
1899 * @return Modified output stream.
1900 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001901inline ::std::ostream &operator<<(::std::ostream &os, const GPUTarget &gpu_target)
1902{
1903 switch(gpu_target)
1904 {
1905 case GPUTarget::GPU_ARCH_MASK:
1906 os << "GPU_ARCH_MASK";
1907 break;
1908 case GPUTarget::MIDGARD:
1909 os << "MIDGARD";
1910 break;
1911 case GPUTarget::BIFROST:
1912 os << "BIFROST";
1913 break;
Georgios Pinitasd5462ff2019-07-03 19:33:57 +01001914 case GPUTarget::VALHALL:
1915 os << "VALHALL";
1916 break;
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001917 case GPUTarget::T600:
1918 os << "T600";
1919 break;
1920 case GPUTarget::T700:
1921 os << "T700";
1922 break;
1923 case GPUTarget::T800:
1924 os << "T800";
1925 break;
Michalis Spyroua9676112018-02-22 18:07:43 +00001926 case GPUTarget::G71:
1927 os << "G71";
1928 break;
1929 case GPUTarget::G72:
1930 os << "G72";
1931 break;
1932 case GPUTarget::G51:
1933 os << "G51";
1934 break;
1935 case GPUTarget::G51BIG:
1936 os << "G51BIG";
1937 break;
1938 case GPUTarget::G51LIT:
1939 os << "G51LIT";
1940 break;
Georgios Pinitasb03f7c52018-07-12 10:49:53 +01001941 case GPUTarget::G76:
1942 os << "G76";
Michalis Spyroua9676112018-02-22 18:07:43 +00001943 break;
Georgios Pinitasd5462ff2019-07-03 19:33:57 +01001944 case GPUTarget::G77:
1945 os << "G77";
Michalis Spyroua9676112018-02-22 18:07:43 +00001946 break;
1947 case GPUTarget::TBOX:
1948 os << "TBOX";
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001949 break;
Georgios Pinitasd5462ff2019-07-03 19:33:57 +01001950 case GPUTarget::TODX:
1951 os << "TODX";
1952 break;
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001953 default:
1954 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1955 }
1956
1957 return os;
1958}
1959
Alex Gildayc357c472018-03-21 13:54:09 +00001960/** Formatted output of the GPUTarget type.
1961 *
1962 * @param[in] gpu_target Type to output
1963 *
1964 * @return Formatted string.
1965 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001966inline std::string to_string(const GPUTarget &gpu_target)
1967{
1968 std::stringstream str;
1969 str << gpu_target;
1970 return str.str();
1971}
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00001972
John Richardson8de92612018-02-22 14:09:31 +00001973/** Formatted output of the DetectionWindow type.
1974 *
1975 * @param[out] os Output stream
1976 * @param[in] detection_window Type to output
1977 *
1978 * @return Modified output stream.
1979 */
John Richardson684cb0f2018-01-09 11:17:00 +00001980inline ::std::ostream &operator<<(::std::ostream &os, const DetectionWindow &detection_window)
1981{
1982 os << "{x=" << detection_window.x << ","
1983 << "y=" << detection_window.y << ","
1984 << "width=" << detection_window.width << ","
1985 << "height=" << detection_window.height << ","
1986 << "idx_class=" << detection_window.idx_class << ","
1987 << "score=" << detection_window.score << "}";
1988
1989 return os;
1990}
1991
Isabella Gottardi05e56442018-11-16 11:26:52 +00001992/** Formatted output of the DetectionOutputLayerCodeType type.
1993 *
1994 * @param[out] os Output stream
1995 * @param[in] detection_code Type to output
1996 *
1997 * @return Modified output stream.
1998 */
1999inline ::std::ostream &operator<<(::std::ostream &os, const DetectionOutputLayerCodeType &detection_code)
2000{
2001 switch(detection_code)
2002 {
2003 case DetectionOutputLayerCodeType::CENTER_SIZE:
2004 os << "CENTER_SIZE";
2005 break;
2006 case DetectionOutputLayerCodeType::CORNER:
2007 os << "CORNER";
2008 break;
2009 case DetectionOutputLayerCodeType::CORNER_SIZE:
2010 os << "CORNER_SIZE";
2011 break;
2012 case DetectionOutputLayerCodeType::TF_CENTER:
2013 os << "TF_CENTER";
2014 break;
2015 default:
2016 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2017 }
2018
2019 return os;
2020}
2021/** Formatted output of the DetectionOutputLayerCodeType type.
2022 *
2023 * @param[in] detection_code Type to output
2024 *
2025 * @return Formatted string.
2026 */
2027inline std::string to_string(const DetectionOutputLayerCodeType &detection_code)
2028{
2029 std::stringstream str;
2030 str << detection_code;
2031 return str.str();
2032}
2033
2034/** Formatted output of the DetectionOutputLayerInfo type.
2035 *
2036 * @param[out] os Output stream
2037 * @param[in] detection_info Type to output
2038 *
2039 * @return Modified output stream.
2040 */
2041inline ::std::ostream &operator<<(::std::ostream &os, const DetectionOutputLayerInfo &detection_info)
2042{
2043 os << "{Classes=" << detection_info.num_classes() << ","
2044 << "ShareLocation=" << detection_info.share_location() << ","
2045 << "CodeType=" << detection_info.code_type() << ","
2046 << "VarianceEncodedInTarget=" << detection_info.variance_encoded_in_target() << ","
2047 << "KeepTopK=" << detection_info.keep_top_k() << ","
2048 << "NMSThreshold=" << detection_info.nms_threshold() << ","
2049 << "Eta=" << detection_info.eta() << ","
2050 << "BackgroundLabelId=" << detection_info.background_label_id() << ","
2051 << "ConfidenceThreshold=" << detection_info.confidence_threshold() << ","
2052 << "TopK=" << detection_info.top_k() << ","
2053 << "NumLocClasses=" << detection_info.num_loc_classes()
2054 << "}";
2055
2056 return os;
2057}
2058
2059/** Formatted output of the DetectionOutputLayerInfo type.
2060 *
2061 * @param[in] detection_info Type to output
2062 *
2063 * @return Formatted string.
2064 */
2065inline std::string to_string(const DetectionOutputLayerInfo &detection_info)
2066{
2067 std::stringstream str;
2068 str << detection_info;
2069 return str.str();
2070}
Isabella Gottardia7acb3c2019-01-08 13:48:44 +00002071/** Formatted output of the DetectionPostProcessLayerInfo type.
2072 *
2073 * @param[out] os Output stream
2074 * @param[in] detection_info Type to output
2075 *
2076 * @return Modified output stream.
2077 */
2078inline ::std::ostream &operator<<(::std::ostream &os, const DetectionPostProcessLayerInfo &detection_info)
2079{
2080 os << "{MaxDetections=" << detection_info.max_detections() << ","
2081 << "MaxClassesPerDetection=" << detection_info.max_classes_per_detection() << ","
2082 << "NmsScoreThreshold=" << detection_info.nms_score_threshold() << ","
2083 << "NmsIouThreshold=" << detection_info.iou_threshold() << ","
2084 << "NumClasses=" << detection_info.num_classes() << ","
2085 << "ScaleValue_y=" << detection_info.scale_value_y() << ","
2086 << "ScaleValue_x=" << detection_info.scale_value_x() << ","
2087 << "ScaleValue_h=" << detection_info.scale_value_h() << ","
2088 << "ScaleValue_w=" << detection_info.scale_value_w() << ","
2089 << "UseRegularNms=" << detection_info.use_regular_nms() << ","
2090 << "DetectionPerClass=" << detection_info.detection_per_class()
2091 << "}";
2092
2093 return os;
2094}
2095
2096/** Formatted output of the DetectionPostProcessLayerInfo type.
2097 *
2098 * @param[in] detection_info Type to output
2099 *
2100 * @return Formatted string.
2101 */
2102inline std::string to_string(const DetectionPostProcessLayerInfo &detection_info)
2103{
2104 std::stringstream str;
2105 str << detection_info;
2106 return str.str();
2107}
John Richardson8de92612018-02-22 14:09:31 +00002108/** Formatted output of the DetectionWindow type.
2109 *
2110 * @param[in] detection_window Type to output
2111 *
2112 * @return Formatted string.
2113 */
2114inline std::string to_string(const DetectionWindow &detection_window)
2115{
2116 std::stringstream str;
2117 str << detection_window;
2118 return str.str();
2119}
2120
2121/** Formatted output of the Termination type.
2122 *
2123 * @param[out] os Output stream
2124 * @param[in] termination Type to output
2125 *
2126 * @return Modified output stream.
2127 */
2128inline ::std::ostream &operator<<(::std::ostream &os, const Termination &termination)
2129{
2130 switch(termination)
2131 {
2132 case Termination::TERM_CRITERIA_EPSILON:
2133 os << "TERM_CRITERIA_EPSILON";
2134 break;
2135 case Termination::TERM_CRITERIA_ITERATIONS:
2136 os << "TERM_CRITERIA_ITERATIONS";
2137 break;
2138 case Termination::TERM_CRITERIA_BOTH:
2139 os << "TERM_CRITERIA_BOTH";
2140 break;
2141 default:
2142 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2143 }
2144
2145 return os;
2146}
2147
2148/** Formatted output of the Termination type.
2149 *
2150 * @param[in] termination Type to output
2151 *
2152 * @return Formatted string.
2153 */
2154inline std::string to_string(const Termination &termination)
2155{
2156 std::stringstream str;
2157 str << termination;
2158 return str.str();
2159}
2160
Anthony Barbier8914e322018-08-10 15:28:25 +01002161/** Formatted output of the CPUModel type.
2162 *
2163 * @param[out] os Output stream
2164 * @param[in] cpu_model Model to output
2165 *
2166 * @return Modified output stream.
2167 */
2168inline ::std::ostream &operator<<(::std::ostream &os, const CPUModel &cpu_model)
2169{
2170 switch(cpu_model)
2171 {
2172 case CPUModel::GENERIC:
2173 os << "GENERIC";
2174 break;
2175 case CPUModel::GENERIC_FP16:
2176 os << "GENERIC_FP16";
2177 break;
2178 case CPUModel::GENERIC_FP16_DOT:
2179 os << "GENERIC_FP16_DOT";
2180 break;
2181 case CPUModel::A53:
2182 os << "A53";
2183 break;
2184 case CPUModel::A55r0:
2185 os << "A55r0";
2186 break;
2187 case CPUModel::A55r1:
2188 os << "A55r1";
2189 break;
2190 default:
2191 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2192 }
2193
2194 return os;
2195}
2196
2197/** Formatted output of the CPUModel type.
2198 *
2199 * @param[in] cpu_model Model to output
2200 *
2201 * @return Formatted string.
2202 */
2203inline std::string to_string(const CPUModel &cpu_model)
2204{
2205 std::stringstream str;
2206 str << cpu_model;
2207 return str.str();
2208}
Anthony Barbier671a11e2018-07-06 15:11:36 +01002209/** Formatted output of a vector of objects.
2210 *
2211 * @param[out] os Output stream
2212 * @param[in] args Vector of objects to print
2213 *
2214 * @return Modified output stream.
2215 */
2216template <typename T>
2217inline ::std::ostream &operator<<(::std::ostream &os, const std::vector<T> &args)
2218{
2219 os << "[";
2220 bool first = true;
2221 for(auto &arg : args)
2222 {
2223 if(first)
2224 {
2225 first = false;
2226 }
2227 else
2228 {
2229 os << ", ";
2230 }
2231 os << arg;
2232 }
2233 os << "]";
2234 return os;
2235}
2236
Michalis Spyrou6c7c38e2018-08-29 16:28:11 +01002237/** Formatted output of @ref PriorBoxLayerInfo.
2238 *
2239 * @param[out] os Output stream.
2240 * @param[in] info Type to output.
2241 *
2242 * @return Modified output stream.
2243 */
2244inline ::std::ostream &operator<<(::std::ostream &os, const PriorBoxLayerInfo &info)
2245{
2246 os << "Clip:" << info.clip()
2247 << "Flip:" << info.flip()
2248 << "StepX:" << info.steps()[0]
2249 << "StepY:" << info.steps()[1]
2250 << "MinSizes:" << info.min_sizes()
2251 << "MaxSizes:" << info.max_sizes()
2252 << "ImgSizeX:" << info.img_size().x
2253 << "ImgSizeY:" << info.img_size().y
2254 << "Offset:" << info.offset()
2255 << "Variances:" << info.variances();
2256
2257 return os;
2258}
2259
Anthony Barbier671a11e2018-07-06 15:11:36 +01002260/** Formatted output of a vector of objects.
2261 *
2262 * @param[in] args Vector of objects to print
2263 *
2264 * @return String representing args.
2265 */
2266template <typename T>
2267std::string to_string(const std::vector<T> &args)
2268{
2269 std::stringstream str;
2270 str << args;
2271 return str.str();
2272}
2273
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00002274/** Formatted output of the WinogradInfo type. */
2275inline ::std::ostream &operator<<(::std::ostream &os, const WinogradInfo &info)
2276{
2277 os << "{OutputTileSize=" << info.output_tile_size << ","
2278 << "KernelSize=" << info.kernel_size << ","
2279 << "PadStride=" << info.convolution_info << ","
2280 << "OutputDataLayout=" << info.output_data_layout << "}";
2281
2282 return os;
2283}
2284
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00002285inline std::string to_string(const WinogradInfo &type)
2286{
2287 std::stringstream str;
2288 str << type;
2289 return str.str();
2290}
Anthony Barbier671a11e2018-07-06 15:11:36 +01002291
2292/** Fallback method: try to use std::to_string:
2293 *
2294 * @param[in] val Value to convert to string
2295 *
2296 * @return String representing val.
2297 */
2298template <typename T>
2299inline std::string to_string(const T &val)
2300{
2301 return support::cpp11::to_string(val);
2302}
2303
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +01002304/** Convert a CLTunerMode value to a string
2305 *
2306 * @param val CLTunerMode value to be converted
2307 *
2308 * @return String representing the corresponding CLTunerMode.
2309 */
2310inline std::string to_string(const CLTunerMode val)
2311{
2312 switch(val)
2313 {
2314 case CLTunerMode::EXHAUSTIVE:
2315 {
2316 return std::string("Exhaustive");
2317 }
2318 case CLTunerMode::NORMAL:
2319 {
2320 return std::string("Normal");
2321 }
2322 case CLTunerMode::RAPID:
2323 {
2324 return std::string("Rapid");
2325 }
2326 default:
2327 {
2328 ARM_COMPUTE_ERROR("Invalid tuner mode.");
2329 return std::string("UNDEFINED");
2330 }
2331 }
2332}
2333/** [Print CLTunerMode type] **/
2334/** Formatted output of the CLTunerMode type.
2335 *
2336 * @param[out] os Output stream.
2337 * @param[in] val CLTunerMode to output.
2338 *
2339 * @return Modified output stream.
2340 */
2341inline ::std::ostream &operator<<(::std::ostream &os, const CLTunerMode &val)
2342{
2343 os << to_string(val);
2344 return os;
2345}
2346
Anthony Barbier6ff3b192017-09-04 18:44:23 +01002347} // namespace arm_compute
Anthony Barbier4dbc0a92018-08-27 13:39:47 +01002348
2349#endif /* __ARM_COMPUTE_TYPE_PRINTER_H__ */