blob: 58162000a6d1e4fecf9e8a4eb7f97d905c8d9297 [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001/*
Michalis Spyroud466c2d2018-01-30 10:54:39 +00002 * Copyright (c) 2017-2018 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
Isabella Gottardif07d28d2018-02-06 14:52:43 +000027#include "arm_compute/core/CL/CLTypes.h"
Anthony Barbier8914e322018-08-10 15:28:25 +010028#include "arm_compute/core/CPP/CPPTypes.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010029#include "arm_compute/core/Dimensions.h"
30#include "arm_compute/core/Error.h"
Michele Di Giorgiob8fc60f2018-04-25 11:58:07 +010031#include "arm_compute/core/GPUTarget.h"
John Richardson25f23682017-11-27 14:35:09 +000032#include "arm_compute/core/HOGInfo.h"
33#include "arm_compute/core/Size2D.h"
John Richardsona36eae12017-09-26 16:55:59 +010034#include "arm_compute/core/Strides.h"
Georgios Pinitas3faea252017-10-30 14:13:50 +000035#include "arm_compute/core/TensorInfo.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010036#include "arm_compute/core/Types.h"
37
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
giuros01cd96a262018-10-03 12:44:35 +0100264/** 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 *
318 * @param[out] os Output stream.
319 * @param[in] quantization_info Type to output.
320 *
321 * @return Modified output stream.
322 */
Chunosovd621bca2017-11-03 17:33:15 +0700323inline ::std::ostream &operator<<(::std::ostream &os, const QuantizationInfo &quantization_info)
324{
325 os << "Scale:" << quantization_info.scale << "~"
326 << "Offset:" << quantization_info.offset;
327 return os;
328}
329
Alex Gildayc357c472018-03-21 13:54:09 +0000330/** Formatted output of the QuantizationInfo type.
331 *
332 * @param[in] quantization_info Type to output.
333 *
334 * @return Formatted string.
335 */
Chunosovd621bca2017-11-03 17:33:15 +0700336inline std::string to_string(const QuantizationInfo &quantization_info)
337{
338 std::stringstream str;
339 str << quantization_info;
340 return str.str();
341}
342
Alex Gildayc357c472018-03-21 13:54:09 +0000343/** Formatted output of the activation function type.
344 *
345 * @param[out] os Output stream.
346 * @param[in] act_function Type to output.
347 *
348 * @return Modified output stream.
349 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100350inline ::std::ostream &operator<<(::std::ostream &os, const ActivationLayerInfo::ActivationFunction &act_function)
351{
352 switch(act_function)
353 {
354 case ActivationLayerInfo::ActivationFunction::ABS:
355 os << "ABS";
356 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100357 case ActivationLayerInfo::ActivationFunction::LINEAR:
358 os << "LINEAR";
359 break;
360 case ActivationLayerInfo::ActivationFunction::LOGISTIC:
361 os << "LOGISTIC";
362 break;
363 case ActivationLayerInfo::ActivationFunction::RELU:
364 os << "RELU";
365 break;
Georgios Pinitas579c0492017-07-12 16:12:12 +0100366 case ActivationLayerInfo::ActivationFunction::BOUNDED_RELU:
367 os << "BOUNDED_RELU";
368 break;
369 case ActivationLayerInfo::ActivationFunction::LEAKY_RELU:
370 os << "LEAKY_RELU";
371 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100372 case ActivationLayerInfo::ActivationFunction::SOFT_RELU:
373 os << "SOFT_RELU";
374 break;
375 case ActivationLayerInfo::ActivationFunction::SQRT:
376 os << "SQRT";
377 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100378 case ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU:
379 os << "LU_BOUNDED_RELU";
Kevin Petitd9f80712017-12-06 12:18:48 +0000380 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100381 case ActivationLayerInfo::ActivationFunction::SQUARE:
382 os << "SQUARE";
383 break;
384 case ActivationLayerInfo::ActivationFunction::TANH:
385 os << "TANH";
386 break;
387 default:
388 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
389 }
390
391 return os;
392}
393
Alex Gildayc357c472018-03-21 13:54:09 +0000394/** Formatted output of the activation function info type.
395 *
396 * @param[in] info Type to output.
397 *
398 * @return Formatted string.
399 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100400inline std::string to_string(const arm_compute::ActivationLayerInfo &info)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100401{
402 std::stringstream str;
Isabella Gottardi3f217ec2018-02-12 14:59:19 +0000403 if(info.enabled())
404 {
405 str << info.activation();
406 }
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100407 return str.str();
408}
409
Alex Gildayc357c472018-03-21 13:54:09 +0000410/** Formatted output of the activation function type.
411 *
412 * @param[in] function Type to output.
413 *
414 * @return Formatted string.
415 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100416inline std::string to_string(const arm_compute::ActivationLayerInfo::ActivationFunction &function)
417{
418 std::stringstream str;
419 str << function;
420 return str.str();
421}
422
Alex Gildayc357c472018-03-21 13:54:09 +0000423/** Formatted output of the NormType type.
424 *
425 * @param[out] os Output stream.
426 * @param[in] norm_type Type to output.
427 *
428 * @return Modified output stream.
429 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100430inline ::std::ostream &operator<<(::std::ostream &os, const NormType &norm_type)
431{
432 switch(norm_type)
433 {
434 case NormType::CROSS_MAP:
435 os << "CROSS_MAP";
436 break;
437 case NormType::IN_MAP_1D:
438 os << "IN_MAP_1D";
439 break;
440 case NormType::IN_MAP_2D:
441 os << "IN_MAP_2D";
442 break;
443 default:
444 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
445 }
446
447 return os;
448}
449
Alex Gildayc357c472018-03-21 13:54:09 +0000450/** Formatted output of @ref NormalizationLayerInfo.
451 *
452 * @param[in] info Type to output.
453 *
454 * @return Formatted string.
455 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100456inline std::string to_string(const arm_compute::NormalizationLayerInfo &info)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100457{
458 std::stringstream str;
Michalis Spyroud466c2d2018-01-30 10:54:39 +0000459 str << info.type() << ":NormSize=" << info.norm_size();
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100460 return str.str();
461}
462
Alex Gildayc357c472018-03-21 13:54:09 +0000463/** Formatted output of @ref NormalizationLayerInfo.
464 *
465 * @param[out] os Output stream.
466 * @param[in] info Type to output.
467 *
468 * @return Modified output stream.
469 */
Georgios Pinitas6f669f02017-09-26 12:32:57 +0100470inline ::std::ostream &operator<<(::std::ostream &os, const NormalizationLayerInfo &info)
471{
Michalis Spyroud466c2d2018-01-30 10:54:39 +0000472 os << info.type() << ":NormSize=" << info.norm_size();
Georgios Pinitas6f669f02017-09-26 12:32:57 +0100473 return os;
474}
475
Alex Gildayc357c472018-03-21 13:54:09 +0000476/** Formatted output of the PoolingType type.
477 *
478 * @param[out] os Output stream.
479 * @param[in] pool_type Type to output.
480 *
481 * @return Modified output stream.
482 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100483inline ::std::ostream &operator<<(::std::ostream &os, const PoolingType &pool_type)
484{
485 switch(pool_type)
486 {
487 case PoolingType::AVG:
488 os << "AVG";
489 break;
490 case PoolingType::MAX:
491 os << "MAX";
492 break;
Georgios Pinitascdf51452017-08-31 14:21:36 +0100493 case PoolingType::L2:
494 os << "L2";
495 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100496 default:
497 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
498 }
499
500 return os;
501}
502
Alex Gildayc357c472018-03-21 13:54:09 +0000503/** Formatted output of @ref PoolingLayerInfo.
504 *
505 * @param[out] os Output stream.
506 * @param[in] info Type to output.
507 *
508 * @return Modified output stream.
509 */
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100510inline ::std::ostream &operator<<(::std::ostream &os, const PoolingLayerInfo &info)
511{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100512 os << info.pool_type();
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100513
514 return os;
515}
516
Alex Gildayc357c472018-03-21 13:54:09 +0000517/** Formatted output of @ref RoundingPolicy.
518 *
519 * @param[in] rounding_policy Type to output.
520 *
521 * @return Formatted string.
522 */
John Richardsondd715f22017-09-18 16:10:48 +0100523inline std::string to_string(const RoundingPolicy &rounding_policy)
524{
525 std::stringstream str;
526 str << rounding_policy;
527 return str.str();
528}
529
Alex Gildayc357c472018-03-21 13:54:09 +0000530/** Formatted output of the DataLayout type.
531 *
532 * @param[out] os Output stream.
533 * @param[in] data_layout Type to output.
534 *
535 * @return Modified output stream.
536 */
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000537inline ::std::ostream &operator<<(::std::ostream &os, const DataLayout &data_layout)
538{
539 switch(data_layout)
540 {
541 case DataLayout::UNKNOWN:
542 os << "UNKNOWN";
543 break;
544 case DataLayout::NHWC:
545 os << "NHWC";
546 break;
547 case DataLayout::NCHW:
548 os << "NCHW";
549 break;
550 default:
551 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
552 }
553
554 return os;
555}
556
Alex Gildayc357c472018-03-21 13:54:09 +0000557/** Formatted output of the DataLayout type.
558 *
559 * @param[in] data_layout Type to output.
560 *
561 * @return Formatted string.
562 */
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000563inline std::string to_string(const arm_compute::DataLayout &data_layout)
564{
565 std::stringstream str;
566 str << data_layout;
567 return str.str();
568}
569
Georgios Pinitase2220552018-07-20 13:23:44 +0100570/** Formatted output of the DataLayoutDimension type.
571 *
572 * @param[out] os Output stream.
573 * @param[in] data_layout_dim Data layout dimension to print.
574 *
575 * @return Modified output stream.
576 */
577inline ::std::ostream &operator<<(::std::ostream &os, const DataLayoutDimension &data_layout_dim)
578{
579 switch(data_layout_dim)
580 {
581 case DataLayoutDimension::WIDTH:
582 os << "WIDTH";
583 break;
584 case DataLayoutDimension::HEIGHT:
585 os << "HEIGHT";
586 break;
587 case DataLayoutDimension::CHANNEL:
588 os << "CHANNEL";
589 break;
590 case DataLayoutDimension::BATCHES:
591 os << "BATCHES";
592 break;
593 default:
594 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
595 }
596 return os;
597}
598
Alex Gildayc357c472018-03-21 13:54:09 +0000599/** Formatted output of the DataType type.
600 *
601 * @param[out] os Output stream.
602 * @param[in] data_type Type to output.
603 *
604 * @return Modified output stream.
605 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100606inline ::std::ostream &operator<<(::std::ostream &os, const DataType &data_type)
607{
608 switch(data_type)
609 {
610 case DataType::UNKNOWN:
611 os << "UNKNOWN";
612 break;
613 case DataType::U8:
614 os << "U8";
615 break;
Chunosovd621bca2017-11-03 17:33:15 +0700616 case DataType::QASYMM8:
617 os << "QASYMM8";
618 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100619 case DataType::S8:
620 os << "S8";
621 break;
622 case DataType::U16:
623 os << "U16";
624 break;
625 case DataType::S16:
626 os << "S16";
627 break;
628 case DataType::U32:
629 os << "U32";
630 break;
631 case DataType::S32:
632 os << "S32";
633 break;
634 case DataType::U64:
635 os << "U64";
636 break;
637 case DataType::S64:
638 os << "S64";
639 break;
640 case DataType::F16:
641 os << "F16";
642 break;
643 case DataType::F32:
644 os << "F32";
645 break;
646 case DataType::F64:
647 os << "F64";
648 break;
649 case DataType::SIZET:
650 os << "SIZET";
651 break;
652 default:
653 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
654 }
655
656 return os;
657}
658
Alex Gildayc357c472018-03-21 13:54:09 +0000659/** Formatted output of the DataType type.
660 *
661 * @param[in] data_type Type to output.
662 *
663 * @return Formatted string.
664 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100665inline std::string to_string(const arm_compute::DataType &data_type)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100666{
667 std::stringstream str;
668 str << data_type;
669 return str.str();
670}
671
Alex Gildayc357c472018-03-21 13:54:09 +0000672/** Formatted output of the Format type.
673 *
674 * @param[out] os Output stream.
675 * @param[in] format Type to output.
676 *
677 * @return Modified output stream.
678 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100679inline ::std::ostream &operator<<(::std::ostream &os, const Format &format)
680{
681 switch(format)
682 {
683 case Format::UNKNOWN:
684 os << "UNKNOWN";
685 break;
686 case Format::U8:
687 os << "U8";
688 break;
689 case Format::S16:
690 os << "S16";
691 break;
692 case Format::U16:
693 os << "U16";
694 break;
695 case Format::S32:
696 os << "S32";
697 break;
698 case Format::U32:
699 os << "U32";
700 break;
701 case Format::F16:
702 os << "F16";
703 break;
704 case Format::F32:
705 os << "F32";
706 break;
707 case Format::UV88:
708 os << "UV88";
709 break;
710 case Format::RGB888:
711 os << "RGB888";
712 break;
713 case Format::RGBA8888:
714 os << "RGBA8888";
715 break;
716 case Format::YUV444:
717 os << "YUV444";
718 break;
719 case Format::YUYV422:
720 os << "YUYV422";
721 break;
722 case Format::NV12:
723 os << "NV12";
724 break;
725 case Format::NV21:
726 os << "NV21";
727 break;
728 case Format::IYUV:
729 os << "IYUV";
730 break;
731 case Format::UYVY422:
732 os << "UYVY422";
733 break;
734 default:
735 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
736 }
737
738 return os;
739}
740
Alex Gildayc357c472018-03-21 13:54:09 +0000741/** Formatted output of the Format type.
742 *
743 * @param[in] format Type to output.
744 *
745 * @return Formatted string.
746 */
Moritz Pflanzer7655a672017-09-23 11:57:33 +0100747inline std::string to_string(const Format &format)
748{
749 std::stringstream str;
750 str << format;
751 return str.str();
752}
753
Alex Gildayc357c472018-03-21 13:54:09 +0000754/** Formatted output of the Channel type.
755 *
756 * @param[out] os Output stream.
757 * @param[in] channel Type to output.
758 *
759 * @return Modified output stream.
760 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100761inline ::std::ostream &operator<<(::std::ostream &os, const Channel &channel)
762{
763 switch(channel)
764 {
765 case Channel::UNKNOWN:
766 os << "UNKNOWN";
767 break;
768 case Channel::C0:
769 os << "C0";
770 break;
771 case Channel::C1:
772 os << "C1";
773 break;
774 case Channel::C2:
775 os << "C2";
776 break;
777 case Channel::C3:
778 os << "C3";
779 break;
780 case Channel::R:
781 os << "R";
782 break;
783 case Channel::G:
784 os << "G";
785 break;
786 case Channel::B:
787 os << "B";
788 break;
789 case Channel::A:
790 os << "A";
791 break;
792 case Channel::Y:
793 os << "Y";
794 break;
795 case Channel::U:
796 os << "U";
797 break;
798 case Channel::V:
799 os << "V";
800 break;
801 default:
802 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
803 }
804
805 return os;
806}
807
Alex Gildayc357c472018-03-21 13:54:09 +0000808/** Formatted output of the Channel type.
809 *
810 * @param[in] channel Type to output.
811 *
812 * @return Formatted string.
813 */
Ioan-Cristian Szabo9414f642017-10-27 17:35:40 +0100814inline std::string to_string(const Channel &channel)
815{
816 std::stringstream str;
817 str << channel;
818 return str.str();
819}
820
Alex Gildayc357c472018-03-21 13:54:09 +0000821/** Formatted output of the BorderMode type.
822 *
823 * @param[out] os Output stream.
824 * @param[in] mode Type to output.
825 *
826 * @return Modified output stream.
827 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100828inline ::std::ostream &operator<<(::std::ostream &os, const BorderMode &mode)
829{
830 switch(mode)
831 {
832 case BorderMode::UNDEFINED:
833 os << "UNDEFINED";
834 break;
835 case BorderMode::CONSTANT:
836 os << "CONSTANT";
837 break;
838 case BorderMode::REPLICATE:
839 os << "REPLICATE";
840 break;
841 default:
842 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
843 }
844
845 return os;
846}
847
Alex Gildayc357c472018-03-21 13:54:09 +0000848/** Formatted output of the BorderSize type.
849 *
850 * @param[out] os Output stream.
851 * @param[in] border Type to output.
852 *
853 * @return Modified output stream.
854 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100855inline ::std::ostream &operator<<(::std::ostream &os, const BorderSize &border)
856{
Moritz Pflanzerc87fbf82017-07-18 14:02:10 +0100857 os << border.top << ","
858 << border.right << ","
859 << border.bottom << ","
860 << border.left;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100861
862 return os;
863}
Anthony Barbier2a07e182017-08-04 18:20:27 +0100864
Giuseppe Rossinid7647d42018-07-17 18:13:13 +0100865/** Formatted output of the PaddingList type.
866 *
867 * @param[out] os Output stream.
868 * @param[in] padding Type to output.
869 *
870 * @return Modified output stream.
871 */
872inline ::std::ostream &operator<<(::std::ostream &os, const PaddingList &padding)
873{
874 os << "{";
875 for(auto const &p : padding)
876 {
877 os << "{" << p.first << "," << p.second << "}";
878 }
879 os << "}";
880 return os;
881}
882
Alex Gildayc357c472018-03-21 13:54:09 +0000883/** Formatted output of the InterpolationPolicy type.
884 *
885 * @param[out] os Output stream.
886 * @param[in] policy Type to output.
887 *
888 * @return Modified output stream.
889 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100890inline ::std::ostream &operator<<(::std::ostream &os, const InterpolationPolicy &policy)
891{
892 switch(policy)
893 {
894 case InterpolationPolicy::NEAREST_NEIGHBOR:
895 os << "NEAREST_NEIGHBOR";
896 break;
897 case InterpolationPolicy::BILINEAR:
898 os << "BILINEAR";
899 break;
900 case InterpolationPolicy::AREA:
901 os << "AREA";
902 break;
903 default:
904 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
905 }
906
907 return os;
908}
909
Alex Gildayc357c472018-03-21 13:54:09 +0000910/** Formatted output of the SamplingPolicy type.
911 *
912 * @param[out] os Output stream.
913 * @param[in] policy Type to output.
914 *
915 * @return Modified output stream.
916 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700917inline ::std::ostream &operator<<(::std::ostream &os, const SamplingPolicy &policy)
918{
919 switch(policy)
920 {
921 case SamplingPolicy::CENTER:
922 os << "CENTER";
923 break;
924 case SamplingPolicy::TOP_LEFT:
925 os << "TOP_LEFT";
926 break;
927 default:
928 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
929 }
930
931 return os;
932}
933
Alex Gildayc357c472018-03-21 13:54:09 +0000934/** Formatted output of the TensorInfo type.
935 *
Anthony Barbier366628a2018-08-01 13:55:03 +0100936 * @param[out] os Output stream.
937 * @param[in] info Type to output.
938 *
939 * @return Modified output stream.
940 */
941inline ::std::ostream &operator<<(::std::ostream &os, const TensorInfo &info)
942{
943 os << "{Shape=" << info.tensor_shape() << ","
944 << "Type=" << info.data_type() << ","
945 << "Channels=" << info.num_channels() << "}";
946 return os;
947}
948/** Formatted output of the TensorInfo type.
949 *
Alex Gildayc357c472018-03-21 13:54:09 +0000950 * @param[in] info Type to output.
951 *
952 * @return Formatted string.
953 */
Georgios Pinitas3faea252017-10-30 14:13:50 +0000954inline std::string to_string(const TensorInfo &info)
955{
956 std::stringstream str;
Anthony Barbier366628a2018-08-01 13:55:03 +0100957 str << info;
Georgios Pinitas3faea252017-10-30 14:13:50 +0000958 return str.str();
959}
960
Abe Mbise925ca0f2017-10-02 19:16:33 +0100961//FIXME: Check why this doesn't work and the TensorShape and Coordinates overload are needed
Alex Gildayc357c472018-03-21 13:54:09 +0000962/** Formatted output of the Dimensions type.
963 *
964 * @param[in] dimensions Type to output.
965 *
966 * @return Formatted string.
967 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100968template <typename T>
969inline std::string to_string(const Dimensions<T> &dimensions)
970{
971 std::stringstream str;
972 str << dimensions;
973 return str.str();
974}
975
Alex Gildayc357c472018-03-21 13:54:09 +0000976/** Formatted output of the Strides type.
977 *
978 * @param[in] stride Type to output.
979 *
980 * @return Formatted string.
981 */
John Richardsona36eae12017-09-26 16:55:59 +0100982inline std::string to_string(const Strides &stride)
983{
984 std::stringstream str;
985 str << stride;
986 return str.str();
987}
988
Alex Gildayc357c472018-03-21 13:54:09 +0000989/** Formatted output of the TensorShape type.
990 *
991 * @param[in] shape Type to output.
992 *
993 * @return Formatted string.
994 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100995inline std::string to_string(const TensorShape &shape)
996{
997 std::stringstream str;
998 str << shape;
999 return str.str();
1000}
1001
Alex Gildayc357c472018-03-21 13:54:09 +00001002/** Formatted output of the Coordinates type.
1003 *
1004 * @param[in] coord Type to output.
1005 *
1006 * @return Formatted string.
1007 */
Abe Mbise925ca0f2017-10-02 19:16:33 +01001008inline std::string to_string(const Coordinates &coord)
1009{
1010 std::stringstream str;
1011 str << coord;
1012 return str.str();
1013}
1014
Anthony Barbierb940fd62018-06-04 14:14:32 +01001015/** Formatted output of the GEMMReshapeInfo type.
1016 *
1017 * @param[out] os Output stream.
1018 * @param[in] info Type to output.
1019 *
1020 * @return Modified output stream.
1021 */
1022inline ::std::ostream &operator<<(::std::ostream &os, const GEMMReshapeInfo &info)
1023{
1024 os << "{m=" << info.m() << ",";
1025 os << "n=" << info.n() << ",";
1026 os << "k=" << info.k() << ",";
1027 os << "mult_transpose1xW_width=" << info.mult_transpose1xW_width() << ",";
1028 os << "mult_interleave4x4_height=" << info.mult_interleave4x4_height();
1029 os << "}";
1030
1031 return os;
1032}
1033
1034/** Formatted output of the GEMMInfo type.
1035 *
1036 * @param[out] os Output stream.
1037 * @param[in] info Type to output.
1038 *
1039 * @return Modified output stream.
1040 */
1041inline ::std::ostream &operator<<(::std::ostream &os, const GEMMInfo &info)
1042{
1043 os << "{is_a_reshaped=" << info.is_a_reshaped() << ",";
1044 os << "is_b_reshaped=" << info.is_b_reshaped() << ",";
1045 os << "reshape_b_only_on_first_run=" << info.reshape_b_only_on_first_run() << ",";
Anthony Barbierb940fd62018-06-04 14:14:32 +01001046 os << "}";
1047
1048 return os;
1049}
1050
1051/** Formatted output of the Window::Dimension type.
1052 *
1053 * @param[out] os Output stream.
1054 * @param[in] dim Type to output.
1055 *
1056 * @return Modified output stream.
1057 */
1058inline ::std::ostream &operator<<(::std::ostream &os, const Window::Dimension &dim)
1059{
1060 os << "{start=" << dim.start() << ", end=" << dim.end() << ", step=" << dim.step() << "}";
1061
1062 return os;
1063}
1064/** Formatted output of the Window type.
1065 *
1066 * @param[out] os Output stream.
1067 * @param[in] win Type to output.
1068 *
1069 * @return Modified output stream.
1070 */
1071inline ::std::ostream &operator<<(::std::ostream &os, const Window &win)
1072{
1073 os << "{";
1074 for(unsigned int i = 0; i < Coordinates::num_max_dimensions; i++)
1075 {
1076 if(i > 0)
1077 {
1078 os << ", ";
1079 }
1080 os << win[i];
1081 }
1082 os << "}";
1083
1084 return os;
1085}
1086
1087/** Formatted output of the WeightsInfo type.
1088 *
1089 * @param[in] info Type to output.
1090 *
1091 * @return Formatted string.
1092 */
1093inline std::string to_string(const WeightsInfo &info)
1094{
1095 std::stringstream str;
1096 str << info;
1097 return str.str();
1098}
1099
1100/** Formatted output of the GEMMReshapeInfo type.
1101 *
1102 * @param[in] info Type to output.
1103 *
1104 * @return Formatted string.
1105 */
1106inline std::string to_string(const GEMMReshapeInfo &info)
1107{
1108 std::stringstream str;
1109 str << info;
1110 return str.str();
1111}
1112
1113/** Formatted output of the GEMMInfo type.
1114 *
1115 * @param[in] info Type to output.
1116 *
1117 * @return Formatted string.
1118 */
1119inline std::string to_string(const GEMMInfo &info)
1120{
1121 std::stringstream str;
1122 str << info;
1123 return str.str();
1124}
1125
1126/** Formatted output of the Window::Dimension type.
1127 *
1128 * @param[in] dim Type to output.
1129 *
1130 * @return Formatted string.
1131 */
1132inline std::string to_string(const Window::Dimension &dim)
1133{
1134 std::stringstream str;
1135 str << dim;
1136 return str.str();
1137}
1138/** Formatted output of the Window type.
1139 *
1140 * @param[in] win Type to output.
1141 *
1142 * @return Formatted string.
1143 */
1144inline std::string to_string(const Window &win)
1145{
1146 std::stringstream str;
1147 str << win;
1148 return str.str();
1149}
1150
Alex Gildayc357c472018-03-21 13:54:09 +00001151/** Formatted output of the Rectangle type.
1152 *
1153 * @param[out] os Output stream.
1154 * @param[in] rect Type to output.
1155 *
1156 * @return Modified output stream.
1157 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001158inline ::std::ostream &operator<<(::std::ostream &os, const Rectangle &rect)
1159{
1160 os << rect.width << "x" << rect.height;
1161 os << "+" << rect.x << "+" << rect.y;
1162
1163 return os;
1164}
1165
Alex Gildayc357c472018-03-21 13:54:09 +00001166/** Formatted output of the PadStrideInfo type.
1167 *
1168 * @param[out] os Output stream.
1169 * @param[in] pad_stride_info Type to output.
1170 *
1171 * @return Modified output stream.
1172 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001173inline ::std::ostream &operator<<(::std::ostream &os, const PadStrideInfo &pad_stride_info)
1174{
1175 os << pad_stride_info.stride().first << "," << pad_stride_info.stride().second;
1176 os << ";";
Jaroslaw Rzepeckia1ed41f2017-10-13 11:13:58 +01001177 os << pad_stride_info.pad_left() << "," << pad_stride_info.pad_right() << ","
1178 << pad_stride_info.pad_top() << "," << pad_stride_info.pad_bottom();
Anthony Barbier2a07e182017-08-04 18:20:27 +01001179
1180 return os;
1181}
1182
Alex Gildayc357c472018-03-21 13:54:09 +00001183/** Formatted output of the PadStrideInfo type.
1184 *
1185 * @param[in] pad_stride_info Type to output.
1186 *
1187 * @return Formatted string.
1188 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001189inline std::string to_string(const PadStrideInfo &pad_stride_info)
1190{
1191 std::stringstream str;
1192 str << pad_stride_info;
1193 return str.str();
1194}
1195
Alex Gildayc357c472018-03-21 13:54:09 +00001196/** Formatted output of the BorderMode type.
1197 *
1198 * @param[in] mode Type to output.
1199 *
1200 * @return Formatted string.
1201 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001202inline std::string to_string(const BorderMode &mode)
1203{
1204 std::stringstream str;
1205 str << mode;
1206 return str.str();
1207}
1208
Alex Gildayc357c472018-03-21 13:54:09 +00001209/** Formatted output of the BorderSize type.
1210 *
1211 * @param[in] border Type to output.
1212 *
1213 * @return Formatted string.
1214 */
John Richardsonb482ce12017-09-18 12:44:01 +01001215inline std::string to_string(const BorderSize &border)
1216{
1217 std::stringstream str;
1218 str << border;
1219 return str.str();
1220}
1221
Giuseppe Rossinid7647d42018-07-17 18:13:13 +01001222/** Formatted output of the PaddingList type.
1223 *
1224 * @param[in] padding Type to output.
1225 *
1226 * @return Formatted string.
1227 */
1228inline std::string to_string(const PaddingList &padding)
1229{
1230 std::stringstream str;
1231 str << padding;
1232 return str.str();
1233}
1234
Alex Gildayc357c472018-03-21 13:54:09 +00001235/** Formatted output of the InterpolationPolicy type.
1236 *
1237 * @param[in] policy Type to output.
1238 *
1239 * @return Formatted string.
1240 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001241inline std::string to_string(const InterpolationPolicy &policy)
1242{
1243 std::stringstream str;
1244 str << policy;
1245 return str.str();
1246}
1247
Alex Gildayc357c472018-03-21 13:54:09 +00001248/** Formatted output of the SamplingPolicy type.
1249 *
1250 * @param[in] policy Type to output.
1251 *
1252 * @return Formatted string.
1253 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +07001254inline std::string to_string(const SamplingPolicy &policy)
1255{
1256 std::stringstream str;
1257 str << policy;
1258 return str.str();
1259}
1260
Alex Gildayc357c472018-03-21 13:54:09 +00001261/** Formatted output of the ConvertPolicy type.
1262 *
1263 * @param[out] os Output stream.
1264 * @param[in] policy Type to output.
1265 *
1266 * @return Modified output stream.
1267 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001268inline ::std::ostream &operator<<(::std::ostream &os, const ConvertPolicy &policy)
1269{
1270 switch(policy)
1271 {
1272 case ConvertPolicy::WRAP:
1273 os << "WRAP";
1274 break;
1275 case ConvertPolicy::SATURATE:
1276 os << "SATURATE";
1277 break;
1278 default:
1279 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1280 }
1281
1282 return os;
1283}
1284
1285inline std::string to_string(const ConvertPolicy &policy)
1286{
1287 std::stringstream str;
1288 str << policy;
1289 return str.str();
1290}
1291
Alex Gildayc357c472018-03-21 13:54:09 +00001292/** Formatted output of the Reduction Operations.
1293 *
1294 * @param[out] os Output stream.
1295 * @param[in] op Type to output.
1296 *
1297 * @return Modified output stream.
1298 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001299inline ::std::ostream &operator<<(::std::ostream &os, const ReductionOperation &op)
1300{
1301 switch(op)
1302 {
Michalis Spyrou7e9391b2018-10-05 14:49:28 +01001303 case ReductionOperation::SUM:
1304 os << "SUM";
1305 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +01001306 case ReductionOperation::SUM_SQUARE:
1307 os << "SUM_SQUARE";
1308 break;
Michalis Spyrou7e9391b2018-10-05 14:49:28 +01001309 case ReductionOperation::MEAN_SUM:
1310 os << "MEAN_SUM";
1311 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +01001312 default:
1313 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1314 }
1315
1316 return os;
1317}
1318
Alex Gildayc357c472018-03-21 13:54:09 +00001319/** Formatted output of the Reduction Operations.
1320 *
1321 * @param[in] op Type to output.
1322 *
1323 * @return Formatted string.
1324 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001325inline std::string to_string(const ReductionOperation &op)
1326{
1327 std::stringstream str;
1328 str << op;
1329 return str.str();
1330}
1331
Alex Gildayc357c472018-03-21 13:54:09 +00001332/** Formatted output of the Norm Type.
1333 *
1334 * @param[in] type Type to output.
1335 *
1336 * @return Formatted string.
1337 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001338inline std::string to_string(const NormType &type)
1339{
1340 std::stringstream str;
1341 str << type;
1342 return str.str();
1343}
1344
Alex Gildayc357c472018-03-21 13:54:09 +00001345/** Formatted output of the Pooling Type.
1346 *
1347 * @param[in] type Type to output.
1348 *
1349 * @return Formatted string.
1350 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001351inline std::string to_string(const PoolingType &type)
1352{
1353 std::stringstream str;
1354 str << type;
1355 return str.str();
1356}
1357
Alex Gildayc357c472018-03-21 13:54:09 +00001358/** Formatted output of the Pooling Layer Info.
1359 *
1360 * @param[in] info Type to output.
1361 *
1362 * @return Formatted string.
1363 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001364inline std::string to_string(const PoolingLayerInfo &info)
1365{
1366 std::stringstream str;
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001367 str << "{Type=" << info.pool_type() << ","
1368 << "IsGlobalPooling=" << info.is_global_pooling();
1369 if(!info.is_global_pooling())
1370 {
1371 str << ","
Isabella Gottardi6e464c32018-01-26 12:32:45 +00001372 << "PoolSize=" << info.pool_size().width << "," << info.pool_size().height << ","
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001373 << "PadStride=" << info.pad_stride_info();
1374 }
1375 str << "}";
Anthony Barbier2a07e182017-08-04 18:20:27 +01001376 return str.str();
1377}
1378
Michalis Spyrou6c7c38e2018-08-29 16:28:11 +01001379/** Formatted output of the PriorBoxLayerInfo.
1380 *
1381 * @param[in] info Type to output.
1382 *
1383 * @return Formatted string.
1384 */
1385inline std::string to_string(const PriorBoxLayerInfo &info)
1386{
1387 std::stringstream str;
1388 str << "{";
1389 str << "Clip:" << info.clip()
1390 << "Flip:" << info.flip()
1391 << "StepX:" << info.steps()[0]
1392 << "StepY:" << info.steps()[1]
1393 << "MinSizes:" << info.min_sizes().size()
1394 << "MaxSizes:" << info.max_sizes().size()
1395 << "ImgSizeX:" << info.img_size().x
1396 << "ImgSizeY:" << info.img_size().y
1397 << "Offset:" << info.offset()
1398 << "Variances:" << info.variances().size();
1399 str << "}";
1400 return str.str();
1401}
1402
Alex Gildayc357c472018-03-21 13:54:09 +00001403/** Formatted output of the KeyPoint type.
1404 *
1405 * @param[out] os Output stream
1406 * @param[in] point Type to output.
1407 *
1408 * @return Modified output stream.
1409 */
Moritz Pflanzer6c6597c2017-09-24 12:09:41 +01001410inline ::std::ostream &operator<<(::std::ostream &os, const KeyPoint &point)
1411{
1412 os << "{x=" << point.x << ","
1413 << "y=" << point.y << ","
1414 << "strength=" << point.strength << ","
1415 << "scale=" << point.scale << ","
1416 << "orientation=" << point.orientation << ","
1417 << "tracking_status=" << point.tracking_status << ","
1418 << "error=" << point.error << "}";
1419
1420 return os;
1421}
John Richardson63e50412017-10-13 20:51:42 +01001422
Alex Gildayc357c472018-03-21 13:54:09 +00001423/** Formatted output of the PhaseType type.
1424 *
1425 * @param[out] os Output stream
1426 * @param[in] phase_type Type to output.
1427 *
1428 * @return Modified output stream.
1429 */
John Richardson63e50412017-10-13 20:51:42 +01001430inline ::std::ostream &operator<<(::std::ostream &os, const PhaseType &phase_type)
1431{
1432 switch(phase_type)
1433 {
1434 case PhaseType::SIGNED:
1435 os << "SIGNED";
1436 break;
1437 case PhaseType::UNSIGNED:
1438 os << "UNSIGNED";
1439 break;
1440 default:
1441 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1442 }
1443
1444 return os;
1445}
1446
Alex Gildayc357c472018-03-21 13:54:09 +00001447/** Formatted output of the PhaseType type.
1448 *
1449 * @param[in] type Type to output.
1450 *
1451 * @return Formatted string.
1452 */
John Richardson63e50412017-10-13 20:51:42 +01001453inline std::string to_string(const arm_compute::PhaseType &type)
1454{
1455 std::stringstream str;
1456 str << type;
1457 return str.str();
1458}
John Richardson3c5f9492017-10-04 15:27:37 +01001459
Alex Gildayc357c472018-03-21 13:54:09 +00001460/** Formatted output of the MagnitudeType type.
1461 *
1462 * @param[out] os Output stream
1463 * @param[in] magnitude_type Type to output.
1464 *
1465 * @return Modified output stream.
1466 */
John Richardson3c5f9492017-10-04 15:27:37 +01001467inline ::std::ostream &operator<<(::std::ostream &os, const MagnitudeType &magnitude_type)
1468{
1469 switch(magnitude_type)
1470 {
1471 case MagnitudeType::L1NORM:
1472 os << "L1NORM";
1473 break;
1474 case MagnitudeType::L2NORM:
1475 os << "L2NORM";
1476 break;
1477 default:
1478 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1479 }
1480
1481 return os;
1482}
1483
Alex Gildayc357c472018-03-21 13:54:09 +00001484/** Formatted output of the MagnitudeType type.
1485 *
1486 * @param[in] type Type to output.
1487 *
1488 * @return Formatted string.
1489 */
John Richardson3c5f9492017-10-04 15:27:37 +01001490inline std::string to_string(const arm_compute::MagnitudeType &type)
1491{
1492 std::stringstream str;
1493 str << type;
1494 return str.str();
1495}
John Richardson1c529922017-11-01 10:57:48 +00001496
Alex Gildayc357c472018-03-21 13:54:09 +00001497/** Formatted output of the HOGNormType type.
1498 *
1499 * @param[out] os Output stream
1500 * @param[in] norm_type Type to output
1501 *
1502 * @return Modified output stream.
1503 */
John Richardson25f23682017-11-27 14:35:09 +00001504inline ::std::ostream &operator<<(::std::ostream &os, const HOGNormType &norm_type)
1505{
1506 switch(norm_type)
1507 {
1508 case HOGNormType::L1_NORM:
1509 os << "L1_NORM";
1510 break;
1511 case HOGNormType::L2_NORM:
1512 os << "L2_NORM";
1513 break;
1514 case HOGNormType::L2HYS_NORM:
1515 os << "L2HYS_NORM";
1516 break;
1517 default:
1518 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1519 }
1520
1521 return os;
1522}
1523
Alex Gildayc357c472018-03-21 13:54:09 +00001524/** Formatted output of the HOGNormType type.
1525 *
1526 * @param[in] type Type to output
1527 *
1528 * @return Formatted string.
1529 */
John Richardson25f23682017-11-27 14:35:09 +00001530inline std::string to_string(const HOGNormType &type)
1531{
1532 std::stringstream str;
1533 str << type;
1534 return str.str();
1535}
1536
Alex Gildayc357c472018-03-21 13:54:09 +00001537/** Formatted output of the Size2D type.
1538 *
1539 * @param[out] os Output stream
1540 * @param[in] size Type to output
1541 *
1542 * @return Modified output stream.
1543 */
John Richardson25f23682017-11-27 14:35:09 +00001544inline ::std::ostream &operator<<(::std::ostream &os, const Size2D &size)
1545{
1546 os << size.width << "x" << size.height;
1547
1548 return os;
1549}
1550
Alex Gildayc357c472018-03-21 13:54:09 +00001551/** Formatted output of the Size2D type.
1552 *
1553 * @param[in] type Type to output
1554 *
1555 * @return Formatted string.
1556 */
John Richardson25f23682017-11-27 14:35:09 +00001557inline std::string to_string(const Size2D &type)
1558{
1559 std::stringstream str;
1560 str << type;
1561 return str.str();
1562}
1563
Alex Gildayc357c472018-03-21 13:54:09 +00001564/** Formatted output of the HOGInfo type.
1565 *
1566 * @param[out] os Output stream
1567 * @param[in] hog_info Type to output
1568 *
1569 * @return Modified output stream.
1570 */
John Richardson25f23682017-11-27 14:35:09 +00001571inline ::std::ostream &operator<<(::std::ostream &os, const HOGInfo &hog_info)
1572{
1573 os << "{CellSize=" << hog_info.cell_size() << ","
1574 << "BlockSize=" << hog_info.block_size() << ","
1575 << "DetectionWindowSize=" << hog_info.detection_window_size() << ","
1576 << "BlockStride=" << hog_info.block_stride() << ","
1577 << "NumBins=" << hog_info.num_bins() << ","
1578 << "NormType=" << hog_info.normalization_type() << ","
1579 << "L2HystThreshold=" << hog_info.l2_hyst_threshold() << ","
1580 << "PhaseType=" << hog_info.phase_type() << "}";
1581
1582 return os;
1583}
1584
Alex Gildayc357c472018-03-21 13:54:09 +00001585/** Formatted output of the HOGInfo type.
1586 *
1587 * @param[in] type Type to output
1588 *
1589 * @return Formatted string.
1590 */
John Richardson25f23682017-11-27 14:35:09 +00001591inline std::string to_string(const HOGInfo &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 ConvolutionMethod type.
1599 *
1600 * @param[out] os Output stream
1601 * @param[in] conv_method Type to output
1602 *
1603 * @return Modified output stream.
1604 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001605inline ::std::ostream &operator<<(::std::ostream &os, const ConvolutionMethod &conv_method)
1606{
1607 switch(conv_method)
1608 {
1609 case ConvolutionMethod::GEMM:
1610 os << "GEMM";
1611 break;
1612 case ConvolutionMethod::DIRECT:
1613 os << "DIRECT";
1614 break;
1615 case ConvolutionMethod::WINOGRAD:
1616 os << "WINOGRAD";
1617 break;
1618 default:
1619 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1620 }
1621
1622 return os;
1623}
1624
Alex Gildayc357c472018-03-21 13:54:09 +00001625/** Formatted output of the ConvolutionMethod type.
1626 *
1627 * @param[in] conv_method Type to output
1628 *
1629 * @return Formatted string.
1630 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001631inline std::string to_string(const ConvolutionMethod &conv_method)
1632{
1633 std::stringstream str;
1634 str << conv_method;
1635 return str.str();
1636}
1637
Alex Gildayc357c472018-03-21 13:54:09 +00001638/** Formatted output of the GPUTarget type.
1639 *
1640 * @param[out] os Output stream
1641 * @param[in] gpu_target Type to output
1642 *
1643 * @return Modified output stream.
1644 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001645inline ::std::ostream &operator<<(::std::ostream &os, const GPUTarget &gpu_target)
1646{
1647 switch(gpu_target)
1648 {
1649 case GPUTarget::GPU_ARCH_MASK:
1650 os << "GPU_ARCH_MASK";
1651 break;
1652 case GPUTarget::MIDGARD:
1653 os << "MIDGARD";
1654 break;
1655 case GPUTarget::BIFROST:
1656 os << "BIFROST";
1657 break;
1658 case GPUTarget::T600:
1659 os << "T600";
1660 break;
1661 case GPUTarget::T700:
1662 os << "T700";
1663 break;
1664 case GPUTarget::T800:
1665 os << "T800";
1666 break;
Michalis Spyroua9676112018-02-22 18:07:43 +00001667 case GPUTarget::G71:
1668 os << "G71";
1669 break;
1670 case GPUTarget::G72:
1671 os << "G72";
1672 break;
1673 case GPUTarget::G51:
1674 os << "G51";
1675 break;
1676 case GPUTarget::G51BIG:
1677 os << "G51BIG";
1678 break;
1679 case GPUTarget::G51LIT:
1680 os << "G51LIT";
1681 break;
Georgios Pinitasb03f7c52018-07-12 10:49:53 +01001682 case GPUTarget::G76:
1683 os << "G76";
Michalis Spyroua9676112018-02-22 18:07:43 +00001684 break;
1685 case GPUTarget::TTRX:
1686 os << "TTRX";
1687 break;
1688 case GPUTarget::TBOX:
1689 os << "TBOX";
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001690 break;
1691 default:
1692 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1693 }
1694
1695 return os;
1696}
1697
Alex Gildayc357c472018-03-21 13:54:09 +00001698/** Formatted output of the GPUTarget type.
1699 *
1700 * @param[in] gpu_target Type to output
1701 *
1702 * @return Formatted string.
1703 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001704inline std::string to_string(const GPUTarget &gpu_target)
1705{
1706 std::stringstream str;
1707 str << gpu_target;
1708 return str.str();
1709}
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00001710
John Richardson8de92612018-02-22 14:09:31 +00001711/** Formatted output of the DetectionWindow type.
1712 *
1713 * @param[out] os Output stream
1714 * @param[in] detection_window Type to output
1715 *
1716 * @return Modified output stream.
1717 */
John Richardson684cb0f2018-01-09 11:17:00 +00001718inline ::std::ostream &operator<<(::std::ostream &os, const DetectionWindow &detection_window)
1719{
1720 os << "{x=" << detection_window.x << ","
1721 << "y=" << detection_window.y << ","
1722 << "width=" << detection_window.width << ","
1723 << "height=" << detection_window.height << ","
1724 << "idx_class=" << detection_window.idx_class << ","
1725 << "score=" << detection_window.score << "}";
1726
1727 return os;
1728}
1729
John Richardson8de92612018-02-22 14:09:31 +00001730/** Formatted output of the DetectionWindow type.
1731 *
1732 * @param[in] detection_window Type to output
1733 *
1734 * @return Formatted string.
1735 */
1736inline std::string to_string(const DetectionWindow &detection_window)
1737{
1738 std::stringstream str;
1739 str << detection_window;
1740 return str.str();
1741}
1742
1743/** Formatted output of the Termination type.
1744 *
1745 * @param[out] os Output stream
1746 * @param[in] termination Type to output
1747 *
1748 * @return Modified output stream.
1749 */
1750inline ::std::ostream &operator<<(::std::ostream &os, const Termination &termination)
1751{
1752 switch(termination)
1753 {
1754 case Termination::TERM_CRITERIA_EPSILON:
1755 os << "TERM_CRITERIA_EPSILON";
1756 break;
1757 case Termination::TERM_CRITERIA_ITERATIONS:
1758 os << "TERM_CRITERIA_ITERATIONS";
1759 break;
1760 case Termination::TERM_CRITERIA_BOTH:
1761 os << "TERM_CRITERIA_BOTH";
1762 break;
1763 default:
1764 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1765 }
1766
1767 return os;
1768}
1769
1770/** Formatted output of the Termination type.
1771 *
1772 * @param[in] termination Type to output
1773 *
1774 * @return Formatted string.
1775 */
1776inline std::string to_string(const Termination &termination)
1777{
1778 std::stringstream str;
1779 str << termination;
1780 return str.str();
1781}
1782
Anthony Barbier8914e322018-08-10 15:28:25 +01001783/** Formatted output of the CPUModel type.
1784 *
1785 * @param[out] os Output stream
1786 * @param[in] cpu_model Model to output
1787 *
1788 * @return Modified output stream.
1789 */
1790inline ::std::ostream &operator<<(::std::ostream &os, const CPUModel &cpu_model)
1791{
1792 switch(cpu_model)
1793 {
1794 case CPUModel::GENERIC:
1795 os << "GENERIC";
1796 break;
1797 case CPUModel::GENERIC_FP16:
1798 os << "GENERIC_FP16";
1799 break;
1800 case CPUModel::GENERIC_FP16_DOT:
1801 os << "GENERIC_FP16_DOT";
1802 break;
1803 case CPUModel::A53:
1804 os << "A53";
1805 break;
1806 case CPUModel::A55r0:
1807 os << "A55r0";
1808 break;
1809 case CPUModel::A55r1:
1810 os << "A55r1";
1811 break;
1812 default:
1813 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1814 }
1815
1816 return os;
1817}
1818
1819/** Formatted output of the CPUModel type.
1820 *
1821 * @param[in] cpu_model Model to output
1822 *
1823 * @return Formatted string.
1824 */
1825inline std::string to_string(const CPUModel &cpu_model)
1826{
1827 std::stringstream str;
1828 str << cpu_model;
1829 return str.str();
1830}
Anthony Barbier671a11e2018-07-06 15:11:36 +01001831/** Formatted output of a vector of objects.
1832 *
1833 * @param[out] os Output stream
1834 * @param[in] args Vector of objects to print
1835 *
1836 * @return Modified output stream.
1837 */
1838template <typename T>
1839inline ::std::ostream &operator<<(::std::ostream &os, const std::vector<T> &args)
1840{
1841 os << "[";
1842 bool first = true;
1843 for(auto &arg : args)
1844 {
1845 if(first)
1846 {
1847 first = false;
1848 }
1849 else
1850 {
1851 os << ", ";
1852 }
1853 os << arg;
1854 }
1855 os << "]";
1856 return os;
1857}
1858
Michalis Spyrou6c7c38e2018-08-29 16:28:11 +01001859/** Formatted output of @ref PriorBoxLayerInfo.
1860 *
1861 * @param[out] os Output stream.
1862 * @param[in] info Type to output.
1863 *
1864 * @return Modified output stream.
1865 */
1866inline ::std::ostream &operator<<(::std::ostream &os, const PriorBoxLayerInfo &info)
1867{
1868 os << "Clip:" << info.clip()
1869 << "Flip:" << info.flip()
1870 << "StepX:" << info.steps()[0]
1871 << "StepY:" << info.steps()[1]
1872 << "MinSizes:" << info.min_sizes()
1873 << "MaxSizes:" << info.max_sizes()
1874 << "ImgSizeX:" << info.img_size().x
1875 << "ImgSizeY:" << info.img_size().y
1876 << "Offset:" << info.offset()
1877 << "Variances:" << info.variances();
1878
1879 return os;
1880}
1881
Anthony Barbier671a11e2018-07-06 15:11:36 +01001882/** Formatted output of a vector of objects.
1883 *
1884 * @param[in] args Vector of objects to print
1885 *
1886 * @return String representing args.
1887 */
1888template <typename T>
1889std::string to_string(const std::vector<T> &args)
1890{
1891 std::stringstream str;
1892 str << args;
1893 return str.str();
1894}
1895
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00001896/** Formatted output of the WinogradInfo type. */
1897inline ::std::ostream &operator<<(::std::ostream &os, const WinogradInfo &info)
1898{
1899 os << "{OutputTileSize=" << info.output_tile_size << ","
1900 << "KernelSize=" << info.kernel_size << ","
1901 << "PadStride=" << info.convolution_info << ","
1902 << "OutputDataLayout=" << info.output_data_layout << "}";
1903
1904 return os;
1905}
1906
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00001907inline std::string to_string(const WinogradInfo &type)
1908{
1909 std::stringstream str;
1910 str << type;
1911 return str.str();
1912}
Anthony Barbier671a11e2018-07-06 15:11:36 +01001913
1914/** Fallback method: try to use std::to_string:
1915 *
1916 * @param[in] val Value to convert to string
1917 *
1918 * @return String representing val.
1919 */
1920template <typename T>
1921inline std::string to_string(const T &val)
1922{
1923 return support::cpp11::to_string(val);
1924}
1925
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001926} // namespace arm_compute
Anthony Barbier4dbc0a92018-08-27 13:39:47 +01001927
1928#endif /* __ARM_COMPUTE_TYPE_PRINTER_H__ */