blob: 52bda2cfb3568bd651028323cac25ea6bcf2d9c0 [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
Vidhya Sudhan Loganathand646ae12018-11-19 15:18:20 +0000530/** [Print DataLayout type] **/
Alex Gildayc357c472018-03-21 13:54:09 +0000531/** Formatted output of the DataLayout type.
532 *
533 * @param[out] os Output stream.
534 * @param[in] data_layout Type to output.
535 *
536 * @return Modified output stream.
537 */
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000538inline ::std::ostream &operator<<(::std::ostream &os, const DataLayout &data_layout)
539{
540 switch(data_layout)
541 {
542 case DataLayout::UNKNOWN:
543 os << "UNKNOWN";
544 break;
545 case DataLayout::NHWC:
546 os << "NHWC";
547 break;
548 case DataLayout::NCHW:
549 os << "NCHW";
550 break;
551 default:
552 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
553 }
554
555 return os;
556}
557
Alex Gildayc357c472018-03-21 13:54:09 +0000558/** Formatted output of the DataLayout type.
559 *
560 * @param[in] data_layout Type to output.
561 *
562 * @return Formatted string.
563 */
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000564inline std::string to_string(const arm_compute::DataLayout &data_layout)
565{
566 std::stringstream str;
567 str << data_layout;
568 return str.str();
569}
Vidhya Sudhan Loganathand646ae12018-11-19 15:18:20 +0000570/** [Print DataLayout type] **/
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000571
Georgios Pinitase2220552018-07-20 13:23:44 +0100572/** Formatted output of the DataLayoutDimension type.
573 *
574 * @param[out] os Output stream.
575 * @param[in] data_layout_dim Data layout dimension to print.
576 *
577 * @return Modified output stream.
578 */
579inline ::std::ostream &operator<<(::std::ostream &os, const DataLayoutDimension &data_layout_dim)
580{
581 switch(data_layout_dim)
582 {
583 case DataLayoutDimension::WIDTH:
584 os << "WIDTH";
585 break;
586 case DataLayoutDimension::HEIGHT:
587 os << "HEIGHT";
588 break;
589 case DataLayoutDimension::CHANNEL:
590 os << "CHANNEL";
591 break;
592 case DataLayoutDimension::BATCHES:
593 os << "BATCHES";
594 break;
595 default:
596 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
597 }
598 return os;
599}
600
Alex Gildayc357c472018-03-21 13:54:09 +0000601/** Formatted output of the DataType type.
602 *
603 * @param[out] os Output stream.
604 * @param[in] data_type Type to output.
605 *
606 * @return Modified output stream.
607 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100608inline ::std::ostream &operator<<(::std::ostream &os, const DataType &data_type)
609{
610 switch(data_type)
611 {
612 case DataType::UNKNOWN:
613 os << "UNKNOWN";
614 break;
615 case DataType::U8:
616 os << "U8";
617 break;
Chunosovd621bca2017-11-03 17:33:15 +0700618 case DataType::QASYMM8:
619 os << "QASYMM8";
620 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100621 case DataType::S8:
622 os << "S8";
623 break;
624 case DataType::U16:
625 os << "U16";
626 break;
627 case DataType::S16:
628 os << "S16";
629 break;
630 case DataType::U32:
631 os << "U32";
632 break;
633 case DataType::S32:
634 os << "S32";
635 break;
636 case DataType::U64:
637 os << "U64";
638 break;
639 case DataType::S64:
640 os << "S64";
641 break;
642 case DataType::F16:
643 os << "F16";
644 break;
645 case DataType::F32:
646 os << "F32";
647 break;
648 case DataType::F64:
649 os << "F64";
650 break;
651 case DataType::SIZET:
652 os << "SIZET";
653 break;
654 default:
655 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
656 }
657
658 return os;
659}
660
Alex Gildayc357c472018-03-21 13:54:09 +0000661/** Formatted output of the DataType type.
662 *
663 * @param[in] data_type Type to output.
664 *
665 * @return Formatted string.
666 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100667inline std::string to_string(const arm_compute::DataType &data_type)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100668{
669 std::stringstream str;
670 str << data_type;
671 return str.str();
672}
673
Alex Gildayc357c472018-03-21 13:54:09 +0000674/** Formatted output of the Format type.
675 *
676 * @param[out] os Output stream.
677 * @param[in] format Type to output.
678 *
679 * @return Modified output stream.
680 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100681inline ::std::ostream &operator<<(::std::ostream &os, const Format &format)
682{
683 switch(format)
684 {
685 case Format::UNKNOWN:
686 os << "UNKNOWN";
687 break;
688 case Format::U8:
689 os << "U8";
690 break;
691 case Format::S16:
692 os << "S16";
693 break;
694 case Format::U16:
695 os << "U16";
696 break;
697 case Format::S32:
698 os << "S32";
699 break;
700 case Format::U32:
701 os << "U32";
702 break;
703 case Format::F16:
704 os << "F16";
705 break;
706 case Format::F32:
707 os << "F32";
708 break;
709 case Format::UV88:
710 os << "UV88";
711 break;
712 case Format::RGB888:
713 os << "RGB888";
714 break;
715 case Format::RGBA8888:
716 os << "RGBA8888";
717 break;
718 case Format::YUV444:
719 os << "YUV444";
720 break;
721 case Format::YUYV422:
722 os << "YUYV422";
723 break;
724 case Format::NV12:
725 os << "NV12";
726 break;
727 case Format::NV21:
728 os << "NV21";
729 break;
730 case Format::IYUV:
731 os << "IYUV";
732 break;
733 case Format::UYVY422:
734 os << "UYVY422";
735 break;
736 default:
737 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
738 }
739
740 return os;
741}
742
Alex Gildayc357c472018-03-21 13:54:09 +0000743/** Formatted output of the Format type.
744 *
745 * @param[in] format Type to output.
746 *
747 * @return Formatted string.
748 */
Moritz Pflanzer7655a672017-09-23 11:57:33 +0100749inline std::string to_string(const Format &format)
750{
751 std::stringstream str;
752 str << format;
753 return str.str();
754}
755
Alex Gildayc357c472018-03-21 13:54:09 +0000756/** Formatted output of the Channel type.
757 *
758 * @param[out] os Output stream.
759 * @param[in] channel Type to output.
760 *
761 * @return Modified output stream.
762 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100763inline ::std::ostream &operator<<(::std::ostream &os, const Channel &channel)
764{
765 switch(channel)
766 {
767 case Channel::UNKNOWN:
768 os << "UNKNOWN";
769 break;
770 case Channel::C0:
771 os << "C0";
772 break;
773 case Channel::C1:
774 os << "C1";
775 break;
776 case Channel::C2:
777 os << "C2";
778 break;
779 case Channel::C3:
780 os << "C3";
781 break;
782 case Channel::R:
783 os << "R";
784 break;
785 case Channel::G:
786 os << "G";
787 break;
788 case Channel::B:
789 os << "B";
790 break;
791 case Channel::A:
792 os << "A";
793 break;
794 case Channel::Y:
795 os << "Y";
796 break;
797 case Channel::U:
798 os << "U";
799 break;
800 case Channel::V:
801 os << "V";
802 break;
803 default:
804 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
805 }
806
807 return os;
808}
809
Alex Gildayc357c472018-03-21 13:54:09 +0000810/** Formatted output of the Channel type.
811 *
812 * @param[in] channel Type to output.
813 *
814 * @return Formatted string.
815 */
Ioan-Cristian Szabo9414f642017-10-27 17:35:40 +0100816inline std::string to_string(const Channel &channel)
817{
818 std::stringstream str;
819 str << channel;
820 return str.str();
821}
822
Alex Gildayc357c472018-03-21 13:54:09 +0000823/** Formatted output of the BorderMode type.
824 *
825 * @param[out] os Output stream.
826 * @param[in] mode Type to output.
827 *
828 * @return Modified output stream.
829 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100830inline ::std::ostream &operator<<(::std::ostream &os, const BorderMode &mode)
831{
832 switch(mode)
833 {
834 case BorderMode::UNDEFINED:
835 os << "UNDEFINED";
836 break;
837 case BorderMode::CONSTANT:
838 os << "CONSTANT";
839 break;
840 case BorderMode::REPLICATE:
841 os << "REPLICATE";
842 break;
843 default:
844 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
845 }
846
847 return os;
848}
849
Alex Gildayc357c472018-03-21 13:54:09 +0000850/** Formatted output of the BorderSize type.
851 *
852 * @param[out] os Output stream.
853 * @param[in] border Type to output.
854 *
855 * @return Modified output stream.
856 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100857inline ::std::ostream &operator<<(::std::ostream &os, const BorderSize &border)
858{
Moritz Pflanzerc87fbf82017-07-18 14:02:10 +0100859 os << border.top << ","
860 << border.right << ","
861 << border.bottom << ","
862 << border.left;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100863
864 return os;
865}
Anthony Barbier2a07e182017-08-04 18:20:27 +0100866
Giuseppe Rossinid7647d42018-07-17 18:13:13 +0100867/** Formatted output of the PaddingList type.
868 *
869 * @param[out] os Output stream.
870 * @param[in] padding Type to output.
871 *
872 * @return Modified output stream.
873 */
874inline ::std::ostream &operator<<(::std::ostream &os, const PaddingList &padding)
875{
876 os << "{";
877 for(auto const &p : padding)
878 {
879 os << "{" << p.first << "," << p.second << "}";
880 }
881 os << "}";
882 return os;
883}
884
giuros013175fcf2018-11-21 09:59:17 +0000885/** Formatted output of the Multiples type.
886 *
887 * @param[out] os Output stream.
888 * @param[in] multiples Type to output.
889 *
890 * @return Modified output stream.
891 */
892inline ::std::ostream &operator<<(::std::ostream &os, const Multiples &multiples)
893{
894 os << "(";
895 for(size_t i = 0; i < multiples.size() - 1; i++)
896 {
897 os << multiples[i] << ", ";
898 }
899 os << multiples.back() << ")";
900 return os;
901}
902
Alex Gildayc357c472018-03-21 13:54:09 +0000903/** Formatted output of the InterpolationPolicy type.
904 *
905 * @param[out] os Output stream.
906 * @param[in] policy Type to output.
907 *
908 * @return Modified output stream.
909 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100910inline ::std::ostream &operator<<(::std::ostream &os, const InterpolationPolicy &policy)
911{
912 switch(policy)
913 {
914 case InterpolationPolicy::NEAREST_NEIGHBOR:
915 os << "NEAREST_NEIGHBOR";
916 break;
917 case InterpolationPolicy::BILINEAR:
918 os << "BILINEAR";
919 break;
920 case InterpolationPolicy::AREA:
921 os << "AREA";
922 break;
923 default:
924 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
925 }
926
927 return os;
928}
929
Alex Gildayc357c472018-03-21 13:54:09 +0000930/** Formatted output of the SamplingPolicy type.
931 *
932 * @param[out] os Output stream.
933 * @param[in] policy Type to output.
934 *
935 * @return Modified output stream.
936 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700937inline ::std::ostream &operator<<(::std::ostream &os, const SamplingPolicy &policy)
938{
939 switch(policy)
940 {
941 case SamplingPolicy::CENTER:
942 os << "CENTER";
943 break;
944 case SamplingPolicy::TOP_LEFT:
945 os << "TOP_LEFT";
946 break;
947 default:
948 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
949 }
950
951 return os;
952}
953
Alex Gildayc357c472018-03-21 13:54:09 +0000954/** Formatted output of the TensorInfo type.
955 *
Anthony Barbier366628a2018-08-01 13:55:03 +0100956 * @param[out] os Output stream.
957 * @param[in] info Type to output.
958 *
959 * @return Modified output stream.
960 */
961inline ::std::ostream &operator<<(::std::ostream &os, const TensorInfo &info)
962{
963 os << "{Shape=" << info.tensor_shape() << ","
964 << "Type=" << info.data_type() << ","
965 << "Channels=" << info.num_channels() << "}";
966 return os;
967}
968/** Formatted output of the TensorInfo type.
969 *
Alex Gildayc357c472018-03-21 13:54:09 +0000970 * @param[in] info Type to output.
971 *
972 * @return Formatted string.
973 */
Georgios Pinitas3faea252017-10-30 14:13:50 +0000974inline std::string to_string(const TensorInfo &info)
975{
976 std::stringstream str;
Anthony Barbier366628a2018-08-01 13:55:03 +0100977 str << info;
Georgios Pinitas3faea252017-10-30 14:13:50 +0000978 return str.str();
979}
980
Abe Mbise925ca0f2017-10-02 19:16:33 +0100981//FIXME: Check why this doesn't work and the TensorShape and Coordinates overload are needed
Alex Gildayc357c472018-03-21 13:54:09 +0000982/** Formatted output of the Dimensions type.
983 *
984 * @param[in] dimensions Type to output.
985 *
986 * @return Formatted string.
987 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100988template <typename T>
989inline std::string to_string(const Dimensions<T> &dimensions)
990{
991 std::stringstream str;
992 str << dimensions;
993 return str.str();
994}
995
Alex Gildayc357c472018-03-21 13:54:09 +0000996/** Formatted output of the Strides type.
997 *
998 * @param[in] stride Type to output.
999 *
1000 * @return Formatted string.
1001 */
John Richardsona36eae12017-09-26 16:55:59 +01001002inline std::string to_string(const Strides &stride)
1003{
1004 std::stringstream str;
1005 str << stride;
1006 return str.str();
1007}
1008
Alex Gildayc357c472018-03-21 13:54:09 +00001009/** Formatted output of the TensorShape type.
1010 *
1011 * @param[in] shape Type to output.
1012 *
1013 * @return Formatted string.
1014 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001015inline std::string to_string(const TensorShape &shape)
1016{
1017 std::stringstream str;
1018 str << shape;
1019 return str.str();
1020}
1021
Alex Gildayc357c472018-03-21 13:54:09 +00001022/** Formatted output of the Coordinates type.
1023 *
1024 * @param[in] coord Type to output.
1025 *
1026 * @return Formatted string.
1027 */
Abe Mbise925ca0f2017-10-02 19:16:33 +01001028inline std::string to_string(const Coordinates &coord)
1029{
1030 std::stringstream str;
1031 str << coord;
1032 return str.str();
1033}
1034
Anthony Barbierb940fd62018-06-04 14:14:32 +01001035/** Formatted output of the GEMMReshapeInfo type.
1036 *
1037 * @param[out] os Output stream.
1038 * @param[in] info Type to output.
1039 *
1040 * @return Modified output stream.
1041 */
1042inline ::std::ostream &operator<<(::std::ostream &os, const GEMMReshapeInfo &info)
1043{
1044 os << "{m=" << info.m() << ",";
1045 os << "n=" << info.n() << ",";
1046 os << "k=" << info.k() << ",";
1047 os << "mult_transpose1xW_width=" << info.mult_transpose1xW_width() << ",";
1048 os << "mult_interleave4x4_height=" << info.mult_interleave4x4_height();
1049 os << "}";
1050
1051 return os;
1052}
1053
1054/** Formatted output of the GEMMInfo type.
1055 *
1056 * @param[out] os Output stream.
1057 * @param[in] info Type to output.
1058 *
1059 * @return Modified output stream.
1060 */
1061inline ::std::ostream &operator<<(::std::ostream &os, const GEMMInfo &info)
1062{
1063 os << "{is_a_reshaped=" << info.is_a_reshaped() << ",";
1064 os << "is_b_reshaped=" << info.is_b_reshaped() << ",";
1065 os << "reshape_b_only_on_first_run=" << info.reshape_b_only_on_first_run() << ",";
Anthony Barbierb940fd62018-06-04 14:14:32 +01001066 os << "}";
1067
1068 return os;
1069}
1070
1071/** Formatted output of the Window::Dimension type.
1072 *
1073 * @param[out] os Output stream.
1074 * @param[in] dim Type to output.
1075 *
1076 * @return Modified output stream.
1077 */
1078inline ::std::ostream &operator<<(::std::ostream &os, const Window::Dimension &dim)
1079{
1080 os << "{start=" << dim.start() << ", end=" << dim.end() << ", step=" << dim.step() << "}";
1081
1082 return os;
1083}
1084/** Formatted output of the Window type.
1085 *
1086 * @param[out] os Output stream.
1087 * @param[in] win Type to output.
1088 *
1089 * @return Modified output stream.
1090 */
1091inline ::std::ostream &operator<<(::std::ostream &os, const Window &win)
1092{
1093 os << "{";
1094 for(unsigned int i = 0; i < Coordinates::num_max_dimensions; i++)
1095 {
1096 if(i > 0)
1097 {
1098 os << ", ";
1099 }
1100 os << win[i];
1101 }
1102 os << "}";
1103
1104 return os;
1105}
1106
1107/** Formatted output of the WeightsInfo type.
1108 *
1109 * @param[in] info Type to output.
1110 *
1111 * @return Formatted string.
1112 */
1113inline std::string to_string(const WeightsInfo &info)
1114{
1115 std::stringstream str;
1116 str << info;
1117 return str.str();
1118}
1119
1120/** Formatted output of the GEMMReshapeInfo type.
1121 *
1122 * @param[in] info Type to output.
1123 *
1124 * @return Formatted string.
1125 */
1126inline std::string to_string(const GEMMReshapeInfo &info)
1127{
1128 std::stringstream str;
1129 str << info;
1130 return str.str();
1131}
1132
1133/** Formatted output of the GEMMInfo type.
1134 *
1135 * @param[in] info Type to output.
1136 *
1137 * @return Formatted string.
1138 */
1139inline std::string to_string(const GEMMInfo &info)
1140{
1141 std::stringstream str;
1142 str << info;
1143 return str.str();
1144}
1145
1146/** Formatted output of the Window::Dimension type.
1147 *
1148 * @param[in] dim Type to output.
1149 *
1150 * @return Formatted string.
1151 */
1152inline std::string to_string(const Window::Dimension &dim)
1153{
1154 std::stringstream str;
1155 str << dim;
1156 return str.str();
1157}
1158/** Formatted output of the Window type.
1159 *
1160 * @param[in] win Type to output.
1161 *
1162 * @return Formatted string.
1163 */
1164inline std::string to_string(const Window &win)
1165{
1166 std::stringstream str;
1167 str << win;
1168 return str.str();
1169}
1170
Alex Gildayc357c472018-03-21 13:54:09 +00001171/** Formatted output of the Rectangle type.
1172 *
1173 * @param[out] os Output stream.
1174 * @param[in] rect Type to output.
1175 *
1176 * @return Modified output stream.
1177 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001178inline ::std::ostream &operator<<(::std::ostream &os, const Rectangle &rect)
1179{
1180 os << rect.width << "x" << rect.height;
1181 os << "+" << rect.x << "+" << rect.y;
1182
1183 return os;
1184}
1185
Alex Gildayc357c472018-03-21 13:54:09 +00001186/** Formatted output of the PadStrideInfo type.
1187 *
1188 * @param[out] os Output stream.
1189 * @param[in] pad_stride_info Type to output.
1190 *
1191 * @return Modified output stream.
1192 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001193inline ::std::ostream &operator<<(::std::ostream &os, const PadStrideInfo &pad_stride_info)
1194{
1195 os << pad_stride_info.stride().first << "," << pad_stride_info.stride().second;
1196 os << ";";
Jaroslaw Rzepeckia1ed41f2017-10-13 11:13:58 +01001197 os << pad_stride_info.pad_left() << "," << pad_stride_info.pad_right() << ","
1198 << pad_stride_info.pad_top() << "," << pad_stride_info.pad_bottom();
Anthony Barbier2a07e182017-08-04 18:20:27 +01001199
1200 return os;
1201}
1202
Alex Gildayc357c472018-03-21 13:54:09 +00001203/** Formatted output of the PadStrideInfo type.
1204 *
1205 * @param[in] pad_stride_info Type to output.
1206 *
1207 * @return Formatted string.
1208 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001209inline std::string to_string(const PadStrideInfo &pad_stride_info)
1210{
1211 std::stringstream str;
1212 str << pad_stride_info;
1213 return str.str();
1214}
1215
Alex Gildayc357c472018-03-21 13:54:09 +00001216/** Formatted output of the BorderMode type.
1217 *
1218 * @param[in] mode Type to output.
1219 *
1220 * @return Formatted string.
1221 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001222inline std::string to_string(const BorderMode &mode)
1223{
1224 std::stringstream str;
1225 str << mode;
1226 return str.str();
1227}
1228
Alex Gildayc357c472018-03-21 13:54:09 +00001229/** Formatted output of the BorderSize type.
1230 *
1231 * @param[in] border Type to output.
1232 *
1233 * @return Formatted string.
1234 */
John Richardsonb482ce12017-09-18 12:44:01 +01001235inline std::string to_string(const BorderSize &border)
1236{
1237 std::stringstream str;
1238 str << border;
1239 return str.str();
1240}
1241
Giuseppe Rossinid7647d42018-07-17 18:13:13 +01001242/** Formatted output of the PaddingList type.
1243 *
1244 * @param[in] padding Type to output.
1245 *
1246 * @return Formatted string.
1247 */
1248inline std::string to_string(const PaddingList &padding)
1249{
1250 std::stringstream str;
1251 str << padding;
1252 return str.str();
1253}
1254
giuros013175fcf2018-11-21 09:59:17 +00001255/** Formatted output of the Multiples type.
1256 *
1257 * @param[in] multiples Type to output.
1258 *
1259 * @return Formatted string.
1260 */
1261inline std::string to_string(const Multiples &multiples)
1262{
1263 std::stringstream str;
1264 str << multiples;
1265 return str.str();
1266}
1267
Alex Gildayc357c472018-03-21 13:54:09 +00001268/** Formatted output of the InterpolationPolicy type.
1269 *
1270 * @param[in] policy Type to output.
1271 *
1272 * @return Formatted string.
1273 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001274inline std::string to_string(const InterpolationPolicy &policy)
1275{
1276 std::stringstream str;
1277 str << policy;
1278 return str.str();
1279}
1280
Alex Gildayc357c472018-03-21 13:54:09 +00001281/** Formatted output of the SamplingPolicy type.
1282 *
1283 * @param[in] policy Type to output.
1284 *
1285 * @return Formatted string.
1286 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +07001287inline std::string to_string(const SamplingPolicy &policy)
1288{
1289 std::stringstream str;
1290 str << policy;
1291 return str.str();
1292}
1293
Alex Gildayc357c472018-03-21 13:54:09 +00001294/** Formatted output of the ConvertPolicy type.
1295 *
1296 * @param[out] os Output stream.
1297 * @param[in] policy Type to output.
1298 *
1299 * @return Modified output stream.
1300 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001301inline ::std::ostream &operator<<(::std::ostream &os, const ConvertPolicy &policy)
1302{
1303 switch(policy)
1304 {
1305 case ConvertPolicy::WRAP:
1306 os << "WRAP";
1307 break;
1308 case ConvertPolicy::SATURATE:
1309 os << "SATURATE";
1310 break;
1311 default:
1312 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1313 }
1314
1315 return os;
1316}
1317
1318inline std::string to_string(const ConvertPolicy &policy)
1319{
1320 std::stringstream str;
1321 str << policy;
1322 return str.str();
1323}
1324
Alex Gildayc357c472018-03-21 13:54:09 +00001325/** Formatted output of the Reduction Operations.
1326 *
1327 * @param[out] os Output stream.
1328 * @param[in] op Type to output.
1329 *
1330 * @return Modified output stream.
1331 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001332inline ::std::ostream &operator<<(::std::ostream &os, const ReductionOperation &op)
1333{
1334 switch(op)
1335 {
Michalis Spyrou7e9391b2018-10-05 14:49:28 +01001336 case ReductionOperation::SUM:
1337 os << "SUM";
1338 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +01001339 case ReductionOperation::SUM_SQUARE:
1340 os << "SUM_SQUARE";
1341 break;
Michalis Spyrou7e9391b2018-10-05 14:49:28 +01001342 case ReductionOperation::MEAN_SUM:
1343 os << "MEAN_SUM";
1344 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +01001345 default:
1346 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1347 }
1348
1349 return os;
1350}
1351
Alex Gildayc357c472018-03-21 13:54:09 +00001352/** Formatted output of the Reduction Operations.
1353 *
1354 * @param[in] op Type to output.
1355 *
1356 * @return Formatted string.
1357 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001358inline std::string to_string(const ReductionOperation &op)
1359{
1360 std::stringstream str;
1361 str << op;
1362 return str.str();
1363}
1364
Alex Gildayc357c472018-03-21 13:54:09 +00001365/** Formatted output of the Norm Type.
1366 *
1367 * @param[in] type Type to output.
1368 *
1369 * @return Formatted string.
1370 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001371inline std::string to_string(const NormType &type)
1372{
1373 std::stringstream str;
1374 str << type;
1375 return str.str();
1376}
1377
Alex Gildayc357c472018-03-21 13:54:09 +00001378/** Formatted output of the Pooling Type.
1379 *
1380 * @param[in] type Type to output.
1381 *
1382 * @return Formatted string.
1383 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001384inline std::string to_string(const PoolingType &type)
1385{
1386 std::stringstream str;
1387 str << type;
1388 return str.str();
1389}
1390
Alex Gildayc357c472018-03-21 13:54:09 +00001391/** Formatted output of the Pooling Layer Info.
1392 *
1393 * @param[in] info Type to output.
1394 *
1395 * @return Formatted string.
1396 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001397inline std::string to_string(const PoolingLayerInfo &info)
1398{
1399 std::stringstream str;
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001400 str << "{Type=" << info.pool_type() << ","
1401 << "IsGlobalPooling=" << info.is_global_pooling();
1402 if(!info.is_global_pooling())
1403 {
1404 str << ","
Isabella Gottardi6e464c32018-01-26 12:32:45 +00001405 << "PoolSize=" << info.pool_size().width << "," << info.pool_size().height << ","
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001406 << "PadStride=" << info.pad_stride_info();
1407 }
1408 str << "}";
Anthony Barbier2a07e182017-08-04 18:20:27 +01001409 return str.str();
1410}
1411
Michalis Spyrou6c7c38e2018-08-29 16:28:11 +01001412/** Formatted output of the PriorBoxLayerInfo.
1413 *
1414 * @param[in] info Type to output.
1415 *
1416 * @return Formatted string.
1417 */
1418inline std::string to_string(const PriorBoxLayerInfo &info)
1419{
1420 std::stringstream str;
1421 str << "{";
1422 str << "Clip:" << info.clip()
1423 << "Flip:" << info.flip()
1424 << "StepX:" << info.steps()[0]
1425 << "StepY:" << info.steps()[1]
1426 << "MinSizes:" << info.min_sizes().size()
1427 << "MaxSizes:" << info.max_sizes().size()
1428 << "ImgSizeX:" << info.img_size().x
1429 << "ImgSizeY:" << info.img_size().y
1430 << "Offset:" << info.offset()
1431 << "Variances:" << info.variances().size();
1432 str << "}";
1433 return str.str();
1434}
1435
Alex Gildayc357c472018-03-21 13:54:09 +00001436/** Formatted output of the KeyPoint type.
1437 *
1438 * @param[out] os Output stream
1439 * @param[in] point Type to output.
1440 *
1441 * @return Modified output stream.
1442 */
Moritz Pflanzer6c6597c2017-09-24 12:09:41 +01001443inline ::std::ostream &operator<<(::std::ostream &os, const KeyPoint &point)
1444{
1445 os << "{x=" << point.x << ","
1446 << "y=" << point.y << ","
1447 << "strength=" << point.strength << ","
1448 << "scale=" << point.scale << ","
1449 << "orientation=" << point.orientation << ","
1450 << "tracking_status=" << point.tracking_status << ","
1451 << "error=" << point.error << "}";
1452
1453 return os;
1454}
John Richardson63e50412017-10-13 20:51:42 +01001455
Alex Gildayc357c472018-03-21 13:54:09 +00001456/** Formatted output of the PhaseType type.
1457 *
1458 * @param[out] os Output stream
1459 * @param[in] phase_type Type to output.
1460 *
1461 * @return Modified output stream.
1462 */
John Richardson63e50412017-10-13 20:51:42 +01001463inline ::std::ostream &operator<<(::std::ostream &os, const PhaseType &phase_type)
1464{
1465 switch(phase_type)
1466 {
1467 case PhaseType::SIGNED:
1468 os << "SIGNED";
1469 break;
1470 case PhaseType::UNSIGNED:
1471 os << "UNSIGNED";
1472 break;
1473 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 PhaseType type.
1481 *
1482 * @param[in] type Type to output.
1483 *
1484 * @return Formatted string.
1485 */
John Richardson63e50412017-10-13 20:51:42 +01001486inline std::string to_string(const arm_compute::PhaseType &type)
1487{
1488 std::stringstream str;
1489 str << type;
1490 return str.str();
1491}
John Richardson3c5f9492017-10-04 15:27:37 +01001492
Alex Gildayc357c472018-03-21 13:54:09 +00001493/** Formatted output of the MagnitudeType type.
1494 *
1495 * @param[out] os Output stream
1496 * @param[in] magnitude_type Type to output.
1497 *
1498 * @return Modified output stream.
1499 */
John Richardson3c5f9492017-10-04 15:27:37 +01001500inline ::std::ostream &operator<<(::std::ostream &os, const MagnitudeType &magnitude_type)
1501{
1502 switch(magnitude_type)
1503 {
1504 case MagnitudeType::L1NORM:
1505 os << "L1NORM";
1506 break;
1507 case MagnitudeType::L2NORM:
1508 os << "L2NORM";
1509 break;
1510 default:
1511 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1512 }
1513
1514 return os;
1515}
1516
Alex Gildayc357c472018-03-21 13:54:09 +00001517/** Formatted output of the MagnitudeType type.
1518 *
1519 * @param[in] type Type to output.
1520 *
1521 * @return Formatted string.
1522 */
John Richardson3c5f9492017-10-04 15:27:37 +01001523inline std::string to_string(const arm_compute::MagnitudeType &type)
1524{
1525 std::stringstream str;
1526 str << type;
1527 return str.str();
1528}
John Richardson1c529922017-11-01 10:57:48 +00001529
Alex Gildayc357c472018-03-21 13:54:09 +00001530/** Formatted output of the HOGNormType type.
1531 *
1532 * @param[out] os Output stream
1533 * @param[in] norm_type Type to output
1534 *
1535 * @return Modified output stream.
1536 */
John Richardson25f23682017-11-27 14:35:09 +00001537inline ::std::ostream &operator<<(::std::ostream &os, const HOGNormType &norm_type)
1538{
1539 switch(norm_type)
1540 {
1541 case HOGNormType::L1_NORM:
1542 os << "L1_NORM";
1543 break;
1544 case HOGNormType::L2_NORM:
1545 os << "L2_NORM";
1546 break;
1547 case HOGNormType::L2HYS_NORM:
1548 os << "L2HYS_NORM";
1549 break;
1550 default:
1551 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1552 }
1553
1554 return os;
1555}
1556
Alex Gildayc357c472018-03-21 13:54:09 +00001557/** Formatted output of the HOGNormType type.
1558 *
1559 * @param[in] type Type to output
1560 *
1561 * @return Formatted string.
1562 */
John Richardson25f23682017-11-27 14:35:09 +00001563inline std::string to_string(const HOGNormType &type)
1564{
1565 std::stringstream str;
1566 str << type;
1567 return str.str();
1568}
1569
Alex Gildayc357c472018-03-21 13:54:09 +00001570/** Formatted output of the Size2D type.
1571 *
1572 * @param[out] os Output stream
1573 * @param[in] size Type to output
1574 *
1575 * @return Modified output stream.
1576 */
John Richardson25f23682017-11-27 14:35:09 +00001577inline ::std::ostream &operator<<(::std::ostream &os, const Size2D &size)
1578{
1579 os << size.width << "x" << size.height;
1580
1581 return os;
1582}
1583
Alex Gildayc357c472018-03-21 13:54:09 +00001584/** Formatted output of the Size2D type.
1585 *
1586 * @param[in] type Type to output
1587 *
1588 * @return Formatted string.
1589 */
John Richardson25f23682017-11-27 14:35:09 +00001590inline std::string to_string(const Size2D &type)
1591{
1592 std::stringstream str;
1593 str << type;
1594 return str.str();
1595}
1596
Alex Gildayc357c472018-03-21 13:54:09 +00001597/** Formatted output of the HOGInfo type.
1598 *
1599 * @param[out] os Output stream
1600 * @param[in] hog_info Type to output
1601 *
1602 * @return Modified output stream.
1603 */
John Richardson25f23682017-11-27 14:35:09 +00001604inline ::std::ostream &operator<<(::std::ostream &os, const HOGInfo &hog_info)
1605{
1606 os << "{CellSize=" << hog_info.cell_size() << ","
1607 << "BlockSize=" << hog_info.block_size() << ","
1608 << "DetectionWindowSize=" << hog_info.detection_window_size() << ","
1609 << "BlockStride=" << hog_info.block_stride() << ","
1610 << "NumBins=" << hog_info.num_bins() << ","
1611 << "NormType=" << hog_info.normalization_type() << ","
1612 << "L2HystThreshold=" << hog_info.l2_hyst_threshold() << ","
1613 << "PhaseType=" << hog_info.phase_type() << "}";
1614
1615 return os;
1616}
1617
Alex Gildayc357c472018-03-21 13:54:09 +00001618/** Formatted output of the HOGInfo type.
1619 *
1620 * @param[in] type Type to output
1621 *
1622 * @return Formatted string.
1623 */
John Richardson25f23682017-11-27 14:35:09 +00001624inline std::string to_string(const HOGInfo &type)
1625{
1626 std::stringstream str;
1627 str << type;
1628 return str.str();
1629}
1630
Alex Gildayc357c472018-03-21 13:54:09 +00001631/** Formatted output of the ConvolutionMethod type.
1632 *
1633 * @param[out] os Output stream
1634 * @param[in] conv_method Type to output
1635 *
1636 * @return Modified output stream.
1637 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001638inline ::std::ostream &operator<<(::std::ostream &os, const ConvolutionMethod &conv_method)
1639{
1640 switch(conv_method)
1641 {
1642 case ConvolutionMethod::GEMM:
1643 os << "GEMM";
1644 break;
1645 case ConvolutionMethod::DIRECT:
1646 os << "DIRECT";
1647 break;
1648 case ConvolutionMethod::WINOGRAD:
1649 os << "WINOGRAD";
1650 break;
1651 default:
1652 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1653 }
1654
1655 return os;
1656}
1657
Alex Gildayc357c472018-03-21 13:54:09 +00001658/** Formatted output of the ConvolutionMethod type.
1659 *
1660 * @param[in] conv_method Type to output
1661 *
1662 * @return Formatted string.
1663 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001664inline std::string to_string(const ConvolutionMethod &conv_method)
1665{
1666 std::stringstream str;
1667 str << conv_method;
1668 return str.str();
1669}
1670
Alex Gildayc357c472018-03-21 13:54:09 +00001671/** Formatted output of the GPUTarget type.
1672 *
1673 * @param[out] os Output stream
1674 * @param[in] gpu_target Type to output
1675 *
1676 * @return Modified output stream.
1677 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001678inline ::std::ostream &operator<<(::std::ostream &os, const GPUTarget &gpu_target)
1679{
1680 switch(gpu_target)
1681 {
1682 case GPUTarget::GPU_ARCH_MASK:
1683 os << "GPU_ARCH_MASK";
1684 break;
1685 case GPUTarget::MIDGARD:
1686 os << "MIDGARD";
1687 break;
1688 case GPUTarget::BIFROST:
1689 os << "BIFROST";
1690 break;
1691 case GPUTarget::T600:
1692 os << "T600";
1693 break;
1694 case GPUTarget::T700:
1695 os << "T700";
1696 break;
1697 case GPUTarget::T800:
1698 os << "T800";
1699 break;
Michalis Spyroua9676112018-02-22 18:07:43 +00001700 case GPUTarget::G71:
1701 os << "G71";
1702 break;
1703 case GPUTarget::G72:
1704 os << "G72";
1705 break;
1706 case GPUTarget::G51:
1707 os << "G51";
1708 break;
1709 case GPUTarget::G51BIG:
1710 os << "G51BIG";
1711 break;
1712 case GPUTarget::G51LIT:
1713 os << "G51LIT";
1714 break;
Georgios Pinitasb03f7c52018-07-12 10:49:53 +01001715 case GPUTarget::G76:
1716 os << "G76";
Michalis Spyroua9676112018-02-22 18:07:43 +00001717 break;
1718 case GPUTarget::TTRX:
1719 os << "TTRX";
1720 break;
1721 case GPUTarget::TBOX:
1722 os << "TBOX";
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001723 break;
1724 default:
1725 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1726 }
1727
1728 return os;
1729}
1730
Alex Gildayc357c472018-03-21 13:54:09 +00001731/** Formatted output of the GPUTarget type.
1732 *
1733 * @param[in] gpu_target Type to output
1734 *
1735 * @return Formatted string.
1736 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001737inline std::string to_string(const GPUTarget &gpu_target)
1738{
1739 std::stringstream str;
1740 str << gpu_target;
1741 return str.str();
1742}
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00001743
John Richardson8de92612018-02-22 14:09:31 +00001744/** Formatted output of the DetectionWindow type.
1745 *
1746 * @param[out] os Output stream
1747 * @param[in] detection_window Type to output
1748 *
1749 * @return Modified output stream.
1750 */
John Richardson684cb0f2018-01-09 11:17:00 +00001751inline ::std::ostream &operator<<(::std::ostream &os, const DetectionWindow &detection_window)
1752{
1753 os << "{x=" << detection_window.x << ","
1754 << "y=" << detection_window.y << ","
1755 << "width=" << detection_window.width << ","
1756 << "height=" << detection_window.height << ","
1757 << "idx_class=" << detection_window.idx_class << ","
1758 << "score=" << detection_window.score << "}";
1759
1760 return os;
1761}
1762
John Richardson8de92612018-02-22 14:09:31 +00001763/** Formatted output of the DetectionWindow type.
1764 *
1765 * @param[in] detection_window Type to output
1766 *
1767 * @return Formatted string.
1768 */
1769inline std::string to_string(const DetectionWindow &detection_window)
1770{
1771 std::stringstream str;
1772 str << detection_window;
1773 return str.str();
1774}
1775
1776/** Formatted output of the Termination type.
1777 *
1778 * @param[out] os Output stream
1779 * @param[in] termination Type to output
1780 *
1781 * @return Modified output stream.
1782 */
1783inline ::std::ostream &operator<<(::std::ostream &os, const Termination &termination)
1784{
1785 switch(termination)
1786 {
1787 case Termination::TERM_CRITERIA_EPSILON:
1788 os << "TERM_CRITERIA_EPSILON";
1789 break;
1790 case Termination::TERM_CRITERIA_ITERATIONS:
1791 os << "TERM_CRITERIA_ITERATIONS";
1792 break;
1793 case Termination::TERM_CRITERIA_BOTH:
1794 os << "TERM_CRITERIA_BOTH";
1795 break;
1796 default:
1797 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1798 }
1799
1800 return os;
1801}
1802
1803/** Formatted output of the Termination type.
1804 *
1805 * @param[in] termination Type to output
1806 *
1807 * @return Formatted string.
1808 */
1809inline std::string to_string(const Termination &termination)
1810{
1811 std::stringstream str;
1812 str << termination;
1813 return str.str();
1814}
1815
Anthony Barbier8914e322018-08-10 15:28:25 +01001816/** Formatted output of the CPUModel type.
1817 *
1818 * @param[out] os Output stream
1819 * @param[in] cpu_model Model to output
1820 *
1821 * @return Modified output stream.
1822 */
1823inline ::std::ostream &operator<<(::std::ostream &os, const CPUModel &cpu_model)
1824{
1825 switch(cpu_model)
1826 {
1827 case CPUModel::GENERIC:
1828 os << "GENERIC";
1829 break;
1830 case CPUModel::GENERIC_FP16:
1831 os << "GENERIC_FP16";
1832 break;
1833 case CPUModel::GENERIC_FP16_DOT:
1834 os << "GENERIC_FP16_DOT";
1835 break;
1836 case CPUModel::A53:
1837 os << "A53";
1838 break;
1839 case CPUModel::A55r0:
1840 os << "A55r0";
1841 break;
1842 case CPUModel::A55r1:
1843 os << "A55r1";
1844 break;
1845 default:
1846 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1847 }
1848
1849 return os;
1850}
1851
1852/** Formatted output of the CPUModel type.
1853 *
1854 * @param[in] cpu_model Model to output
1855 *
1856 * @return Formatted string.
1857 */
1858inline std::string to_string(const CPUModel &cpu_model)
1859{
1860 std::stringstream str;
1861 str << cpu_model;
1862 return str.str();
1863}
Anthony Barbier671a11e2018-07-06 15:11:36 +01001864/** Formatted output of a vector of objects.
1865 *
1866 * @param[out] os Output stream
1867 * @param[in] args Vector of objects to print
1868 *
1869 * @return Modified output stream.
1870 */
1871template <typename T>
1872inline ::std::ostream &operator<<(::std::ostream &os, const std::vector<T> &args)
1873{
1874 os << "[";
1875 bool first = true;
1876 for(auto &arg : args)
1877 {
1878 if(first)
1879 {
1880 first = false;
1881 }
1882 else
1883 {
1884 os << ", ";
1885 }
1886 os << arg;
1887 }
1888 os << "]";
1889 return os;
1890}
1891
Michalis Spyrou6c7c38e2018-08-29 16:28:11 +01001892/** Formatted output of @ref PriorBoxLayerInfo.
1893 *
1894 * @param[out] os Output stream.
1895 * @param[in] info Type to output.
1896 *
1897 * @return Modified output stream.
1898 */
1899inline ::std::ostream &operator<<(::std::ostream &os, const PriorBoxLayerInfo &info)
1900{
1901 os << "Clip:" << info.clip()
1902 << "Flip:" << info.flip()
1903 << "StepX:" << info.steps()[0]
1904 << "StepY:" << info.steps()[1]
1905 << "MinSizes:" << info.min_sizes()
1906 << "MaxSizes:" << info.max_sizes()
1907 << "ImgSizeX:" << info.img_size().x
1908 << "ImgSizeY:" << info.img_size().y
1909 << "Offset:" << info.offset()
1910 << "Variances:" << info.variances();
1911
1912 return os;
1913}
1914
Anthony Barbier671a11e2018-07-06 15:11:36 +01001915/** Formatted output of a vector of objects.
1916 *
1917 * @param[in] args Vector of objects to print
1918 *
1919 * @return String representing args.
1920 */
1921template <typename T>
1922std::string to_string(const std::vector<T> &args)
1923{
1924 std::stringstream str;
1925 str << args;
1926 return str.str();
1927}
1928
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00001929/** Formatted output of the WinogradInfo type. */
1930inline ::std::ostream &operator<<(::std::ostream &os, const WinogradInfo &info)
1931{
1932 os << "{OutputTileSize=" << info.output_tile_size << ","
1933 << "KernelSize=" << info.kernel_size << ","
1934 << "PadStride=" << info.convolution_info << ","
1935 << "OutputDataLayout=" << info.output_data_layout << "}";
1936
1937 return os;
1938}
1939
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00001940inline std::string to_string(const WinogradInfo &type)
1941{
1942 std::stringstream str;
1943 str << type;
1944 return str.str();
1945}
Anthony Barbier671a11e2018-07-06 15:11:36 +01001946
1947/** Fallback method: try to use std::to_string:
1948 *
1949 * @param[in] val Value to convert to string
1950 *
1951 * @return String representing val.
1952 */
1953template <typename T>
1954inline std::string to_string(const T &val)
1955{
1956 return support::cpp11::to_string(val);
1957}
1958
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001959} // namespace arm_compute
Anthony Barbier4dbc0a92018-08-27 13:39:47 +01001960
1961#endif /* __ARM_COMPUTE_TYPE_PRINTER_H__ */