blob: 70196882de831407e46d9df76f77558dc49c8351 [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001/*
Manuel Bottinib412fab2018-12-10 17:40:23 +00002 * Copyright (c) 2017-2019 ARM Limited.
Anthony Barbier6ff3b192017-09-04 18:44:23 +01003 *
4 * SPDX-License-Identifier: MIT
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
Anthony Barbier4dbc0a92018-08-27 13:39:47 +010024#ifndef __ARM_COMPUTE_TYPE_PRINTER_H__
25#define __ARM_COMPUTE_TYPE_PRINTER_H__
Anthony Barbier6ff3b192017-09-04 18:44:23 +010026
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
Manuel Bottini5209be52019-02-13 16:34:56 +0000264/** Formatted output of the ComputeAnchorsInfo type.
265 *
266 * @param[out] os Output stream.
267 * @param[in] anchors_info Type to output.
268 *
269 * @return Modified output stream.
270 */
271inline ::std::ostream &operator<<(::std::ostream &os, const ComputeAnchorsInfo &anchors_info)
272{
273 os << "(" << anchors_info.feat_width() << "x" << anchors_info.feat_height() << ")~" << anchors_info.spatial_scale();
274 return os;
275}
276
277/** Formatted output of the ComputeAnchorsInfo type.
278 *
279 * @param[in] anchors_info Type to output.
280 *
281 * @return Formatted string.
282 */
283inline std::string to_string(const ComputeAnchorsInfo &anchors_info)
284{
285 std::stringstream str;
286 str << anchors_info;
287 return str.str();
288}
289
290/** Formatted output of the GenerateProposalsInfo type.
291 *
292 * @param[out] os Output stream.
293 * @param[in] proposals_info Type to output.
294 *
295 * @return Modified output stream.
296 */
297inline ::std::ostream &operator<<(::std::ostream &os, const GenerateProposalsInfo &proposals_info)
298{
299 os << "(" << proposals_info.im_width() << "x" << proposals_info.im_height() << ")~" << proposals_info.im_scale();
300 return os;
301}
302
303/** Formatted output of the GenerateProposalsInfo type.
304 *
305 * @param[in] proposals_info Type to output.
306 *
307 * @return Formatted string.
308 */
309inline std::string to_string(const GenerateProposalsInfo &proposals_info)
310{
311 std::stringstream str;
312 str << proposals_info;
313 return str.str();
314}
315
Alex Gildayc357c472018-03-21 13:54:09 +0000316/** Formatted output of the QuantizationInfo type.
317 *
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
Alex Gildayc357c472018-03-21 13:54:09 +0000981/** Formatted output of the Dimensions type.
982 *
983 * @param[in] dimensions Type to output.
984 *
985 * @return Formatted string.
986 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100987template <typename T>
988inline std::string to_string(const Dimensions<T> &dimensions)
989{
990 std::stringstream str;
991 str << dimensions;
992 return str.str();
993}
994
Alex Gildayc357c472018-03-21 13:54:09 +0000995/** Formatted output of the Strides type.
996 *
997 * @param[in] stride Type to output.
998 *
999 * @return Formatted string.
1000 */
John Richardsona36eae12017-09-26 16:55:59 +01001001inline std::string to_string(const Strides &stride)
1002{
1003 std::stringstream str;
1004 str << stride;
1005 return str.str();
1006}
1007
Alex Gildayc357c472018-03-21 13:54:09 +00001008/** Formatted output of the TensorShape type.
1009 *
1010 * @param[in] shape Type to output.
1011 *
1012 * @return Formatted string.
1013 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001014inline std::string to_string(const TensorShape &shape)
1015{
1016 std::stringstream str;
1017 str << shape;
1018 return str.str();
1019}
1020
Alex Gildayc357c472018-03-21 13:54:09 +00001021/** Formatted output of the Coordinates type.
1022 *
1023 * @param[in] coord Type to output.
1024 *
1025 * @return Formatted string.
1026 */
Abe Mbise925ca0f2017-10-02 19:16:33 +01001027inline std::string to_string(const Coordinates &coord)
1028{
1029 std::stringstream str;
1030 str << coord;
1031 return str.str();
1032}
1033
Anthony Barbierb940fd62018-06-04 14:14:32 +01001034/** Formatted output of the GEMMReshapeInfo 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 GEMMReshapeInfo &info)
1042{
1043 os << "{m=" << info.m() << ",";
1044 os << "n=" << info.n() << ",";
1045 os << "k=" << info.k() << ",";
1046 os << "mult_transpose1xW_width=" << info.mult_transpose1xW_width() << ",";
1047 os << "mult_interleave4x4_height=" << info.mult_interleave4x4_height();
1048 os << "}";
1049
1050 return os;
1051}
1052
1053/** Formatted output of the GEMMInfo type.
1054 *
1055 * @param[out] os Output stream.
1056 * @param[in] info Type to output.
1057 *
1058 * @return Modified output stream.
1059 */
1060inline ::std::ostream &operator<<(::std::ostream &os, const GEMMInfo &info)
1061{
1062 os << "{is_a_reshaped=" << info.is_a_reshaped() << ",";
1063 os << "is_b_reshaped=" << info.is_b_reshaped() << ",";
1064 os << "reshape_b_only_on_first_run=" << info.reshape_b_only_on_first_run() << ",";
Anthony Barbierb940fd62018-06-04 14:14:32 +01001065 os << "}";
1066
1067 return os;
1068}
1069
1070/** Formatted output of the Window::Dimension type.
1071 *
1072 * @param[out] os Output stream.
1073 * @param[in] dim Type to output.
1074 *
1075 * @return Modified output stream.
1076 */
1077inline ::std::ostream &operator<<(::std::ostream &os, const Window::Dimension &dim)
1078{
1079 os << "{start=" << dim.start() << ", end=" << dim.end() << ", step=" << dim.step() << "}";
1080
1081 return os;
1082}
1083/** Formatted output of the Window type.
1084 *
1085 * @param[out] os Output stream.
1086 * @param[in] win Type to output.
1087 *
1088 * @return Modified output stream.
1089 */
1090inline ::std::ostream &operator<<(::std::ostream &os, const Window &win)
1091{
1092 os << "{";
1093 for(unsigned int i = 0; i < Coordinates::num_max_dimensions; i++)
1094 {
1095 if(i > 0)
1096 {
1097 os << ", ";
1098 }
1099 os << win[i];
1100 }
1101 os << "}";
1102
1103 return os;
1104}
1105
1106/** Formatted output of the WeightsInfo type.
1107 *
1108 * @param[in] info Type to output.
1109 *
1110 * @return Formatted string.
1111 */
1112inline std::string to_string(const WeightsInfo &info)
1113{
1114 std::stringstream str;
1115 str << info;
1116 return str.str();
1117}
1118
1119/** Formatted output of the GEMMReshapeInfo type.
1120 *
1121 * @param[in] info Type to output.
1122 *
1123 * @return Formatted string.
1124 */
1125inline std::string to_string(const GEMMReshapeInfo &info)
1126{
1127 std::stringstream str;
1128 str << info;
1129 return str.str();
1130}
1131
1132/** Formatted output of the GEMMInfo type.
1133 *
1134 * @param[in] info Type to output.
1135 *
1136 * @return Formatted string.
1137 */
1138inline std::string to_string(const GEMMInfo &info)
1139{
1140 std::stringstream str;
1141 str << info;
1142 return str.str();
1143}
1144
1145/** Formatted output of the Window::Dimension type.
1146 *
1147 * @param[in] dim Type to output.
1148 *
1149 * @return Formatted string.
1150 */
1151inline std::string to_string(const Window::Dimension &dim)
1152{
1153 std::stringstream str;
1154 str << dim;
1155 return str.str();
1156}
1157/** Formatted output of the Window type.
1158 *
1159 * @param[in] win Type to output.
1160 *
1161 * @return Formatted string.
1162 */
1163inline std::string to_string(const Window &win)
1164{
1165 std::stringstream str;
1166 str << win;
1167 return str.str();
1168}
1169
Alex Gildayc357c472018-03-21 13:54:09 +00001170/** Formatted output of the Rectangle type.
1171 *
1172 * @param[out] os Output stream.
1173 * @param[in] rect Type to output.
1174 *
1175 * @return Modified output stream.
1176 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001177inline ::std::ostream &operator<<(::std::ostream &os, const Rectangle &rect)
1178{
1179 os << rect.width << "x" << rect.height;
1180 os << "+" << rect.x << "+" << rect.y;
1181
1182 return os;
1183}
1184
Usama Arif8cf8c112019-03-14 15:36:54 +00001185/** Formatted output of the PaddingMode type.
1186 *
1187 * @param[out] os Output stream.
1188 * @param[in] mode Type to output.
1189 *
1190 * @return Modified output stream.
1191 */
1192inline ::std::ostream &operator<<(::std::ostream &os, const PaddingMode &mode)
1193{
1194 switch(mode)
1195 {
1196 case PaddingMode::CONSTANT:
1197 os << "CONSTANT";
1198 break;
1199 case PaddingMode::REFLECT:
1200 os << "REFLECT";
1201 break;
1202 case PaddingMode::SYMMETRIC:
1203 os << "SYMMETRIC";
1204 break;
1205 default:
1206 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1207 }
1208
1209 return os;
1210}
1211
1212/** Formatted output of the PaddingMode type.
1213 *
1214 * @param[in] mode Type to output.
1215 *
1216 * @return Formatted string.
1217 */
1218inline std::string to_string(const PaddingMode &mode)
1219{
1220 std::stringstream str;
1221 str << mode;
1222 return str.str();
1223}
1224
Alex Gildayc357c472018-03-21 13:54:09 +00001225/** Formatted output of the PadStrideInfo type.
1226 *
1227 * @param[out] os Output stream.
1228 * @param[in] pad_stride_info Type to output.
1229 *
1230 * @return Modified output stream.
1231 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001232inline ::std::ostream &operator<<(::std::ostream &os, const PadStrideInfo &pad_stride_info)
1233{
1234 os << pad_stride_info.stride().first << "," << pad_stride_info.stride().second;
1235 os << ";";
Jaroslaw Rzepeckia1ed41f2017-10-13 11:13:58 +01001236 os << pad_stride_info.pad_left() << "," << pad_stride_info.pad_right() << ","
1237 << pad_stride_info.pad_top() << "," << pad_stride_info.pad_bottom();
Anthony Barbier2a07e182017-08-04 18:20:27 +01001238
1239 return os;
1240}
1241
Alex Gildayc357c472018-03-21 13:54:09 +00001242/** Formatted output of the PadStrideInfo type.
1243 *
1244 * @param[in] pad_stride_info Type to output.
1245 *
1246 * @return Formatted string.
1247 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001248inline std::string to_string(const PadStrideInfo &pad_stride_info)
1249{
1250 std::stringstream str;
1251 str << pad_stride_info;
1252 return str.str();
1253}
1254
Alex Gildayc357c472018-03-21 13:54:09 +00001255/** Formatted output of the BorderMode type.
1256 *
1257 * @param[in] mode Type to output.
1258 *
1259 * @return Formatted string.
1260 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001261inline std::string to_string(const BorderMode &mode)
1262{
1263 std::stringstream str;
1264 str << mode;
1265 return str.str();
1266}
1267
Alex Gildayc357c472018-03-21 13:54:09 +00001268/** Formatted output of the BorderSize type.
1269 *
1270 * @param[in] border Type to output.
1271 *
1272 * @return Formatted string.
1273 */
John Richardsonb482ce12017-09-18 12:44:01 +01001274inline std::string to_string(const BorderSize &border)
1275{
1276 std::stringstream str;
1277 str << border;
1278 return str.str();
1279}
1280
Giuseppe Rossinid7647d42018-07-17 18:13:13 +01001281/** Formatted output of the PaddingList type.
1282 *
1283 * @param[in] padding Type to output.
1284 *
1285 * @return Formatted string.
1286 */
1287inline std::string to_string(const PaddingList &padding)
1288{
1289 std::stringstream str;
1290 str << padding;
1291 return str.str();
1292}
1293
giuros013175fcf2018-11-21 09:59:17 +00001294/** Formatted output of the Multiples type.
1295 *
1296 * @param[in] multiples Type to output.
1297 *
1298 * @return Formatted string.
1299 */
1300inline std::string to_string(const Multiples &multiples)
1301{
1302 std::stringstream str;
1303 str << multiples;
1304 return str.str();
1305}
1306
Alex Gildayc357c472018-03-21 13:54:09 +00001307/** Formatted output of the InterpolationPolicy type.
1308 *
1309 * @param[in] policy Type to output.
1310 *
1311 * @return Formatted string.
1312 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001313inline std::string to_string(const InterpolationPolicy &policy)
1314{
1315 std::stringstream str;
1316 str << policy;
1317 return str.str();
1318}
1319
Alex Gildayc357c472018-03-21 13:54:09 +00001320/** Formatted output of the SamplingPolicy type.
1321 *
1322 * @param[in] policy Type to output.
1323 *
1324 * @return Formatted string.
1325 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +07001326inline std::string to_string(const SamplingPolicy &policy)
1327{
1328 std::stringstream str;
1329 str << policy;
1330 return str.str();
1331}
1332
Alex Gildayc357c472018-03-21 13:54:09 +00001333/** Formatted output of the ConvertPolicy type.
1334 *
1335 * @param[out] os Output stream.
1336 * @param[in] policy Type to output.
1337 *
1338 * @return Modified output stream.
1339 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001340inline ::std::ostream &operator<<(::std::ostream &os, const ConvertPolicy &policy)
1341{
1342 switch(policy)
1343 {
1344 case ConvertPolicy::WRAP:
1345 os << "WRAP";
1346 break;
1347 case ConvertPolicy::SATURATE:
1348 os << "SATURATE";
1349 break;
1350 default:
1351 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1352 }
1353
1354 return os;
1355}
1356
1357inline std::string to_string(const ConvertPolicy &policy)
1358{
1359 std::stringstream str;
1360 str << policy;
1361 return str.str();
1362}
1363
giuros01164a2722018-11-20 18:34:46 +00001364/** Formatted output of the ArithmeticOperation type.
1365 *
1366 * @param[out] os Output stream.
1367 * @param[in] op Operation to output.
1368 *
1369 * @return Modified output stream.
1370 */
1371inline ::std::ostream &operator<<(::std::ostream &os, const ArithmeticOperation &op)
1372{
1373 switch(op)
1374 {
1375 case ArithmeticOperation::ADD:
1376 os << "ADD";
1377 break;
1378 case ArithmeticOperation::SUB:
1379 os << "SUB";
1380 break;
1381 case ArithmeticOperation::DIV:
1382 os << "DIV";
1383 break;
1384 case ArithmeticOperation::MAX:
1385 os << "MAX";
1386 break;
1387 case ArithmeticOperation::MIN:
1388 os << "MIN";
1389 break;
1390 case ArithmeticOperation::SQUARED_DIFF:
1391 os << "SQUARED_DIFF";
1392 break;
1393 default:
1394 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1395 }
1396
1397 return os;
1398}
1399
1400/** Formatted output of the Arithmetic Operation
1401 *
1402 * @param[in] op Type to output.
1403 *
1404 * @return Formatted string.
1405 */
1406inline std::string to_string(const ArithmeticOperation &op)
1407{
1408 std::stringstream str;
1409 str << op;
1410 return str.str();
1411}
1412
Alex Gildayc357c472018-03-21 13:54:09 +00001413/** Formatted output of the Reduction Operations.
1414 *
1415 * @param[out] os Output stream.
1416 * @param[in] op Type to output.
1417 *
1418 * @return Modified output stream.
1419 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001420inline ::std::ostream &operator<<(::std::ostream &os, const ReductionOperation &op)
1421{
1422 switch(op)
1423 {
Michalis Spyrou7e9391b2018-10-05 14:49:28 +01001424 case ReductionOperation::SUM:
1425 os << "SUM";
1426 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +01001427 case ReductionOperation::SUM_SQUARE:
1428 os << "SUM_SQUARE";
1429 break;
Michalis Spyrou7e9391b2018-10-05 14:49:28 +01001430 case ReductionOperation::MEAN_SUM:
1431 os << "MEAN_SUM";
1432 break;
Michalis Spyrou7930db42018-11-22 17:36:28 +00001433 case ReductionOperation::ARG_IDX_MAX:
1434 os << "ARG_IDX_MAX";
1435 break;
1436 case ReductionOperation::ARG_IDX_MIN:
1437 os << "ARG_IDX_MIN";
1438 break;
Manuel Bottinib412fab2018-12-10 17:40:23 +00001439 case ReductionOperation::PROD:
1440 os << "PROD";
1441 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +01001442 default:
1443 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1444 }
1445
1446 return os;
1447}
1448
Alex Gildayc357c472018-03-21 13:54:09 +00001449/** Formatted output of the Reduction Operations.
1450 *
1451 * @param[in] op Type to output.
1452 *
1453 * @return Formatted string.
1454 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001455inline std::string to_string(const ReductionOperation &op)
1456{
1457 std::stringstream str;
1458 str << op;
1459 return str.str();
1460}
1461
Georgios Pinitas7900a9e2018-11-23 11:44:58 +00001462/** Formatted output of the Comparison Operations.
1463 *
1464 * @param[out] os Output stream.
1465 * @param[in] op Type to output.
1466 *
1467 * @return Modified output stream.
1468 */
1469inline ::std::ostream &operator<<(::std::ostream &os, const ComparisonOperation &op)
1470{
1471 switch(op)
1472 {
1473 case ComparisonOperation::Equal:
1474 os << "Equal";
1475 break;
1476 case ComparisonOperation::NotEqual:
1477 os << "NotEqual";
1478 break;
1479 case ComparisonOperation::Greater:
1480 os << "Greater";
1481 break;
1482 case ComparisonOperation::GreaterEqual:
1483 os << "GreaterEqual";
1484 break;
1485 case ComparisonOperation::Less:
1486 os << "Less";
1487 break;
1488 case ComparisonOperation::LessEqual:
1489 os << "LessEqual";
1490 break;
1491 default:
1492 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1493 }
1494
1495 return os;
1496}
1497
Michalis Spyroue9362622018-11-23 17:41:37 +00001498/** Formatted output of the Elementwise unary Operations.
1499 *
1500 * @param[out] os Output stream.
1501 * @param[in] op Type to output.
1502 *
1503 * @return Modified output stream.
1504 */
1505inline ::std::ostream &operator<<(::std::ostream &os, const ElementWiseUnary &op)
1506{
1507 switch(op)
1508 {
1509 case ElementWiseUnary::RSQRT:
1510 os << "RSQRT";
1511 break;
1512 case ElementWiseUnary::EXP:
1513 os << "EXP";
1514 break;
1515 default:
1516 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1517 }
1518
1519 return os;
1520}
1521
Georgios Pinitas7900a9e2018-11-23 11:44:58 +00001522/** Formatted output of the Comparison Operations.
1523 *
1524 * @param[in] op Type to output.
1525 *
1526 * @return Formatted string.
1527 */
1528inline std::string to_string(const ComparisonOperation &op)
1529{
1530 std::stringstream str;
1531 str << op;
1532 return str.str();
1533}
1534
Michalis Spyroue9362622018-11-23 17:41:37 +00001535/** Formatted output of the Elementwise unary Operations.
1536 *
1537 * @param[in] op Type to output.
1538 *
1539 * @return Formatted string.
1540 */
1541inline std::string to_string(const ElementWiseUnary &op)
1542{
1543 std::stringstream str;
1544 str << op;
1545 return str.str();
1546}
1547
Alex Gildayc357c472018-03-21 13:54:09 +00001548/** Formatted output of the Norm Type.
1549 *
1550 * @param[in] type Type to output.
1551 *
1552 * @return Formatted string.
1553 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001554inline std::string to_string(const NormType &type)
1555{
1556 std::stringstream str;
1557 str << type;
1558 return str.str();
1559}
1560
Alex Gildayc357c472018-03-21 13:54:09 +00001561/** Formatted output of the Pooling Type.
1562 *
1563 * @param[in] type Type to output.
1564 *
1565 * @return Formatted string.
1566 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001567inline std::string to_string(const PoolingType &type)
1568{
1569 std::stringstream str;
1570 str << type;
1571 return str.str();
1572}
1573
Alex Gildayc357c472018-03-21 13:54:09 +00001574/** Formatted output of the Pooling Layer Info.
1575 *
1576 * @param[in] info Type to output.
1577 *
1578 * @return Formatted string.
1579 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001580inline std::string to_string(const PoolingLayerInfo &info)
1581{
1582 std::stringstream str;
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001583 str << "{Type=" << info.pool_type() << ","
1584 << "IsGlobalPooling=" << info.is_global_pooling();
1585 if(!info.is_global_pooling())
1586 {
1587 str << ","
Isabella Gottardi6e464c32018-01-26 12:32:45 +00001588 << "PoolSize=" << info.pool_size().width << "," << info.pool_size().height << ","
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001589 << "PadStride=" << info.pad_stride_info();
1590 }
1591 str << "}";
Anthony Barbier2a07e182017-08-04 18:20:27 +01001592 return str.str();
1593}
1594
Michalis Spyrou6c7c38e2018-08-29 16:28:11 +01001595/** Formatted output of the PriorBoxLayerInfo.
1596 *
1597 * @param[in] info Type to output.
1598 *
1599 * @return Formatted string.
1600 */
1601inline std::string to_string(const PriorBoxLayerInfo &info)
1602{
1603 std::stringstream str;
1604 str << "{";
1605 str << "Clip:" << info.clip()
1606 << "Flip:" << info.flip()
1607 << "StepX:" << info.steps()[0]
1608 << "StepY:" << info.steps()[1]
1609 << "MinSizes:" << info.min_sizes().size()
1610 << "MaxSizes:" << info.max_sizes().size()
1611 << "ImgSizeX:" << info.img_size().x
1612 << "ImgSizeY:" << info.img_size().y
1613 << "Offset:" << info.offset()
1614 << "Variances:" << info.variances().size();
1615 str << "}";
1616 return str.str();
1617}
1618
Alex Gildayc357c472018-03-21 13:54:09 +00001619/** Formatted output of the KeyPoint type.
1620 *
1621 * @param[out] os Output stream
1622 * @param[in] point Type to output.
1623 *
1624 * @return Modified output stream.
1625 */
Moritz Pflanzer6c6597c2017-09-24 12:09:41 +01001626inline ::std::ostream &operator<<(::std::ostream &os, const KeyPoint &point)
1627{
1628 os << "{x=" << point.x << ","
1629 << "y=" << point.y << ","
1630 << "strength=" << point.strength << ","
1631 << "scale=" << point.scale << ","
1632 << "orientation=" << point.orientation << ","
1633 << "tracking_status=" << point.tracking_status << ","
1634 << "error=" << point.error << "}";
1635
1636 return os;
1637}
John Richardson63e50412017-10-13 20:51:42 +01001638
Alex Gildayc357c472018-03-21 13:54:09 +00001639/** Formatted output of the PhaseType type.
1640 *
1641 * @param[out] os Output stream
1642 * @param[in] phase_type Type to output.
1643 *
1644 * @return Modified output stream.
1645 */
John Richardson63e50412017-10-13 20:51:42 +01001646inline ::std::ostream &operator<<(::std::ostream &os, const PhaseType &phase_type)
1647{
1648 switch(phase_type)
1649 {
1650 case PhaseType::SIGNED:
1651 os << "SIGNED";
1652 break;
1653 case PhaseType::UNSIGNED:
1654 os << "UNSIGNED";
1655 break;
1656 default:
1657 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1658 }
1659
1660 return os;
1661}
1662
Alex Gildayc357c472018-03-21 13:54:09 +00001663/** Formatted output of the PhaseType type.
1664 *
1665 * @param[in] type Type to output.
1666 *
1667 * @return Formatted string.
1668 */
John Richardson63e50412017-10-13 20:51:42 +01001669inline std::string to_string(const arm_compute::PhaseType &type)
1670{
1671 std::stringstream str;
1672 str << type;
1673 return str.str();
1674}
John Richardson3c5f9492017-10-04 15:27:37 +01001675
Alex Gildayc357c472018-03-21 13:54:09 +00001676/** Formatted output of the MagnitudeType type.
1677 *
1678 * @param[out] os Output stream
1679 * @param[in] magnitude_type Type to output.
1680 *
1681 * @return Modified output stream.
1682 */
John Richardson3c5f9492017-10-04 15:27:37 +01001683inline ::std::ostream &operator<<(::std::ostream &os, const MagnitudeType &magnitude_type)
1684{
1685 switch(magnitude_type)
1686 {
1687 case MagnitudeType::L1NORM:
1688 os << "L1NORM";
1689 break;
1690 case MagnitudeType::L2NORM:
1691 os << "L2NORM";
1692 break;
1693 default:
1694 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1695 }
1696
1697 return os;
1698}
1699
Alex Gildayc357c472018-03-21 13:54:09 +00001700/** Formatted output of the MagnitudeType type.
1701 *
1702 * @param[in] type Type to output.
1703 *
1704 * @return Formatted string.
1705 */
John Richardson3c5f9492017-10-04 15:27:37 +01001706inline std::string to_string(const arm_compute::MagnitudeType &type)
1707{
1708 std::stringstream str;
1709 str << type;
1710 return str.str();
1711}
John Richardson1c529922017-11-01 10:57:48 +00001712
Alex Gildayc357c472018-03-21 13:54:09 +00001713/** Formatted output of the HOGNormType type.
1714 *
1715 * @param[out] os Output stream
1716 * @param[in] norm_type Type to output
1717 *
1718 * @return Modified output stream.
1719 */
John Richardson25f23682017-11-27 14:35:09 +00001720inline ::std::ostream &operator<<(::std::ostream &os, const HOGNormType &norm_type)
1721{
1722 switch(norm_type)
1723 {
1724 case HOGNormType::L1_NORM:
1725 os << "L1_NORM";
1726 break;
1727 case HOGNormType::L2_NORM:
1728 os << "L2_NORM";
1729 break;
1730 case HOGNormType::L2HYS_NORM:
1731 os << "L2HYS_NORM";
1732 break;
1733 default:
1734 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1735 }
1736
1737 return os;
1738}
1739
Alex Gildayc357c472018-03-21 13:54:09 +00001740/** Formatted output of the HOGNormType type.
1741 *
1742 * @param[in] type Type to output
1743 *
1744 * @return Formatted string.
1745 */
John Richardson25f23682017-11-27 14:35:09 +00001746inline std::string to_string(const HOGNormType &type)
1747{
1748 std::stringstream str;
1749 str << type;
1750 return str.str();
1751}
1752
Alex Gildayc357c472018-03-21 13:54:09 +00001753/** Formatted output of the Size2D type.
1754 *
1755 * @param[out] os Output stream
1756 * @param[in] size Type to output
1757 *
1758 * @return Modified output stream.
1759 */
John Richardson25f23682017-11-27 14:35:09 +00001760inline ::std::ostream &operator<<(::std::ostream &os, const Size2D &size)
1761{
1762 os << size.width << "x" << size.height;
1763
1764 return os;
1765}
1766
Alex Gildayc357c472018-03-21 13:54:09 +00001767/** Formatted output of the Size2D type.
1768 *
1769 * @param[in] type Type to output
1770 *
1771 * @return Formatted string.
1772 */
John Richardson25f23682017-11-27 14:35:09 +00001773inline std::string to_string(const Size2D &type)
1774{
1775 std::stringstream str;
1776 str << type;
1777 return str.str();
1778}
1779
Alex Gildayc357c472018-03-21 13:54:09 +00001780/** Formatted output of the HOGInfo type.
1781 *
1782 * @param[out] os Output stream
1783 * @param[in] hog_info Type to output
1784 *
1785 * @return Modified output stream.
1786 */
John Richardson25f23682017-11-27 14:35:09 +00001787inline ::std::ostream &operator<<(::std::ostream &os, const HOGInfo &hog_info)
1788{
1789 os << "{CellSize=" << hog_info.cell_size() << ","
1790 << "BlockSize=" << hog_info.block_size() << ","
1791 << "DetectionWindowSize=" << hog_info.detection_window_size() << ","
1792 << "BlockStride=" << hog_info.block_stride() << ","
1793 << "NumBins=" << hog_info.num_bins() << ","
1794 << "NormType=" << hog_info.normalization_type() << ","
1795 << "L2HystThreshold=" << hog_info.l2_hyst_threshold() << ","
1796 << "PhaseType=" << hog_info.phase_type() << "}";
1797
1798 return os;
1799}
1800
Alex Gildayc357c472018-03-21 13:54:09 +00001801/** Formatted output of the HOGInfo type.
1802 *
1803 * @param[in] type Type to output
1804 *
1805 * @return Formatted string.
1806 */
John Richardson25f23682017-11-27 14:35:09 +00001807inline std::string to_string(const HOGInfo &type)
1808{
1809 std::stringstream str;
1810 str << type;
1811 return str.str();
1812}
1813
Alex Gildayc357c472018-03-21 13:54:09 +00001814/** Formatted output of the ConvolutionMethod type.
1815 *
1816 * @param[out] os Output stream
1817 * @param[in] conv_method Type to output
1818 *
1819 * @return Modified output stream.
1820 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001821inline ::std::ostream &operator<<(::std::ostream &os, const ConvolutionMethod &conv_method)
1822{
1823 switch(conv_method)
1824 {
1825 case ConvolutionMethod::GEMM:
1826 os << "GEMM";
1827 break;
1828 case ConvolutionMethod::DIRECT:
1829 os << "DIRECT";
1830 break;
1831 case ConvolutionMethod::WINOGRAD:
1832 os << "WINOGRAD";
1833 break;
1834 default:
1835 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1836 }
1837
1838 return os;
1839}
1840
Alex Gildayc357c472018-03-21 13:54:09 +00001841/** Formatted output of the ConvolutionMethod type.
1842 *
1843 * @param[in] conv_method Type to output
1844 *
1845 * @return Formatted string.
1846 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001847inline std::string to_string(const ConvolutionMethod &conv_method)
1848{
1849 std::stringstream str;
1850 str << conv_method;
1851 return str.str();
1852}
1853
Alex Gildayc357c472018-03-21 13:54:09 +00001854/** Formatted output of the GPUTarget type.
1855 *
1856 * @param[out] os Output stream
1857 * @param[in] gpu_target Type to output
1858 *
1859 * @return Modified output stream.
1860 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001861inline ::std::ostream &operator<<(::std::ostream &os, const GPUTarget &gpu_target)
1862{
1863 switch(gpu_target)
1864 {
1865 case GPUTarget::GPU_ARCH_MASK:
1866 os << "GPU_ARCH_MASK";
1867 break;
1868 case GPUTarget::MIDGARD:
1869 os << "MIDGARD";
1870 break;
1871 case GPUTarget::BIFROST:
1872 os << "BIFROST";
1873 break;
1874 case GPUTarget::T600:
1875 os << "T600";
1876 break;
1877 case GPUTarget::T700:
1878 os << "T700";
1879 break;
1880 case GPUTarget::T800:
1881 os << "T800";
1882 break;
Michalis Spyroua9676112018-02-22 18:07:43 +00001883 case GPUTarget::G71:
1884 os << "G71";
1885 break;
1886 case GPUTarget::G72:
1887 os << "G72";
1888 break;
1889 case GPUTarget::G51:
1890 os << "G51";
1891 break;
1892 case GPUTarget::G51BIG:
1893 os << "G51BIG";
1894 break;
1895 case GPUTarget::G51LIT:
1896 os << "G51LIT";
1897 break;
Georgios Pinitasb03f7c52018-07-12 10:49:53 +01001898 case GPUTarget::G76:
1899 os << "G76";
Michalis Spyroua9676112018-02-22 18:07:43 +00001900 break;
1901 case GPUTarget::TTRX:
1902 os << "TTRX";
1903 break;
1904 case GPUTarget::TBOX:
1905 os << "TBOX";
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001906 break;
1907 default:
1908 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1909 }
1910
1911 return os;
1912}
1913
Alex Gildayc357c472018-03-21 13:54:09 +00001914/** Formatted output of the GPUTarget type.
1915 *
1916 * @param[in] gpu_target Type to output
1917 *
1918 * @return Formatted string.
1919 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001920inline std::string to_string(const GPUTarget &gpu_target)
1921{
1922 std::stringstream str;
1923 str << gpu_target;
1924 return str.str();
1925}
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00001926
John Richardson8de92612018-02-22 14:09:31 +00001927/** Formatted output of the DetectionWindow type.
1928 *
1929 * @param[out] os Output stream
1930 * @param[in] detection_window Type to output
1931 *
1932 * @return Modified output stream.
1933 */
John Richardson684cb0f2018-01-09 11:17:00 +00001934inline ::std::ostream &operator<<(::std::ostream &os, const DetectionWindow &detection_window)
1935{
1936 os << "{x=" << detection_window.x << ","
1937 << "y=" << detection_window.y << ","
1938 << "width=" << detection_window.width << ","
1939 << "height=" << detection_window.height << ","
1940 << "idx_class=" << detection_window.idx_class << ","
1941 << "score=" << detection_window.score << "}";
1942
1943 return os;
1944}
1945
Isabella Gottardi05e56442018-11-16 11:26:52 +00001946/** Formatted output of the DetectionOutputLayerCodeType type.
1947 *
1948 * @param[out] os Output stream
1949 * @param[in] detection_code Type to output
1950 *
1951 * @return Modified output stream.
1952 */
1953inline ::std::ostream &operator<<(::std::ostream &os, const DetectionOutputLayerCodeType &detection_code)
1954{
1955 switch(detection_code)
1956 {
1957 case DetectionOutputLayerCodeType::CENTER_SIZE:
1958 os << "CENTER_SIZE";
1959 break;
1960 case DetectionOutputLayerCodeType::CORNER:
1961 os << "CORNER";
1962 break;
1963 case DetectionOutputLayerCodeType::CORNER_SIZE:
1964 os << "CORNER_SIZE";
1965 break;
1966 case DetectionOutputLayerCodeType::TF_CENTER:
1967 os << "TF_CENTER";
1968 break;
1969 default:
1970 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1971 }
1972
1973 return os;
1974}
1975/** Formatted output of the DetectionOutputLayerCodeType type.
1976 *
1977 * @param[in] detection_code Type to output
1978 *
1979 * @return Formatted string.
1980 */
1981inline std::string to_string(const DetectionOutputLayerCodeType &detection_code)
1982{
1983 std::stringstream str;
1984 str << detection_code;
1985 return str.str();
1986}
1987
1988/** Formatted output of the DetectionOutputLayerInfo type.
1989 *
1990 * @param[out] os Output stream
1991 * @param[in] detection_info Type to output
1992 *
1993 * @return Modified output stream.
1994 */
1995inline ::std::ostream &operator<<(::std::ostream &os, const DetectionOutputLayerInfo &detection_info)
1996{
1997 os << "{Classes=" << detection_info.num_classes() << ","
1998 << "ShareLocation=" << detection_info.share_location() << ","
1999 << "CodeType=" << detection_info.code_type() << ","
2000 << "VarianceEncodedInTarget=" << detection_info.variance_encoded_in_target() << ","
2001 << "KeepTopK=" << detection_info.keep_top_k() << ","
2002 << "NMSThreshold=" << detection_info.nms_threshold() << ","
2003 << "Eta=" << detection_info.eta() << ","
2004 << "BackgroundLabelId=" << detection_info.background_label_id() << ","
2005 << "ConfidenceThreshold=" << detection_info.confidence_threshold() << ","
2006 << "TopK=" << detection_info.top_k() << ","
2007 << "NumLocClasses=" << detection_info.num_loc_classes()
2008 << "}";
2009
2010 return os;
2011}
2012
2013/** Formatted output of the DetectionOutputLayerInfo type.
2014 *
2015 * @param[in] detection_info Type to output
2016 *
2017 * @return Formatted string.
2018 */
2019inline std::string to_string(const DetectionOutputLayerInfo &detection_info)
2020{
2021 std::stringstream str;
2022 str << detection_info;
2023 return str.str();
2024}
John Richardson8de92612018-02-22 14:09:31 +00002025/** Formatted output of the DetectionWindow type.
2026 *
2027 * @param[in] detection_window Type to output
2028 *
2029 * @return Formatted string.
2030 */
2031inline std::string to_string(const DetectionWindow &detection_window)
2032{
2033 std::stringstream str;
2034 str << detection_window;
2035 return str.str();
2036}
2037
2038/** Formatted output of the Termination type.
2039 *
2040 * @param[out] os Output stream
2041 * @param[in] termination Type to output
2042 *
2043 * @return Modified output stream.
2044 */
2045inline ::std::ostream &operator<<(::std::ostream &os, const Termination &termination)
2046{
2047 switch(termination)
2048 {
2049 case Termination::TERM_CRITERIA_EPSILON:
2050 os << "TERM_CRITERIA_EPSILON";
2051 break;
2052 case Termination::TERM_CRITERIA_ITERATIONS:
2053 os << "TERM_CRITERIA_ITERATIONS";
2054 break;
2055 case Termination::TERM_CRITERIA_BOTH:
2056 os << "TERM_CRITERIA_BOTH";
2057 break;
2058 default:
2059 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2060 }
2061
2062 return os;
2063}
2064
2065/** Formatted output of the Termination type.
2066 *
2067 * @param[in] termination Type to output
2068 *
2069 * @return Formatted string.
2070 */
2071inline std::string to_string(const Termination &termination)
2072{
2073 std::stringstream str;
2074 str << termination;
2075 return str.str();
2076}
2077
Anthony Barbier8914e322018-08-10 15:28:25 +01002078/** Formatted output of the CPUModel type.
2079 *
2080 * @param[out] os Output stream
2081 * @param[in] cpu_model Model to output
2082 *
2083 * @return Modified output stream.
2084 */
2085inline ::std::ostream &operator<<(::std::ostream &os, const CPUModel &cpu_model)
2086{
2087 switch(cpu_model)
2088 {
2089 case CPUModel::GENERIC:
2090 os << "GENERIC";
2091 break;
2092 case CPUModel::GENERIC_FP16:
2093 os << "GENERIC_FP16";
2094 break;
2095 case CPUModel::GENERIC_FP16_DOT:
2096 os << "GENERIC_FP16_DOT";
2097 break;
2098 case CPUModel::A53:
2099 os << "A53";
2100 break;
2101 case CPUModel::A55r0:
2102 os << "A55r0";
2103 break;
2104 case CPUModel::A55r1:
2105 os << "A55r1";
2106 break;
2107 default:
2108 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
2109 }
2110
2111 return os;
2112}
2113
2114/** Formatted output of the CPUModel type.
2115 *
2116 * @param[in] cpu_model Model to output
2117 *
2118 * @return Formatted string.
2119 */
2120inline std::string to_string(const CPUModel &cpu_model)
2121{
2122 std::stringstream str;
2123 str << cpu_model;
2124 return str.str();
2125}
Anthony Barbier671a11e2018-07-06 15:11:36 +01002126/** Formatted output of a vector of objects.
2127 *
2128 * @param[out] os Output stream
2129 * @param[in] args Vector of objects to print
2130 *
2131 * @return Modified output stream.
2132 */
2133template <typename T>
2134inline ::std::ostream &operator<<(::std::ostream &os, const std::vector<T> &args)
2135{
2136 os << "[";
2137 bool first = true;
2138 for(auto &arg : args)
2139 {
2140 if(first)
2141 {
2142 first = false;
2143 }
2144 else
2145 {
2146 os << ", ";
2147 }
2148 os << arg;
2149 }
2150 os << "]";
2151 return os;
2152}
2153
Michalis Spyrou6c7c38e2018-08-29 16:28:11 +01002154/** Formatted output of @ref PriorBoxLayerInfo.
2155 *
2156 * @param[out] os Output stream.
2157 * @param[in] info Type to output.
2158 *
2159 * @return Modified output stream.
2160 */
2161inline ::std::ostream &operator<<(::std::ostream &os, const PriorBoxLayerInfo &info)
2162{
2163 os << "Clip:" << info.clip()
2164 << "Flip:" << info.flip()
2165 << "StepX:" << info.steps()[0]
2166 << "StepY:" << info.steps()[1]
2167 << "MinSizes:" << info.min_sizes()
2168 << "MaxSizes:" << info.max_sizes()
2169 << "ImgSizeX:" << info.img_size().x
2170 << "ImgSizeY:" << info.img_size().y
2171 << "Offset:" << info.offset()
2172 << "Variances:" << info.variances();
2173
2174 return os;
2175}
2176
Anthony Barbier671a11e2018-07-06 15:11:36 +01002177/** Formatted output of a vector of objects.
2178 *
2179 * @param[in] args Vector of objects to print
2180 *
2181 * @return String representing args.
2182 */
2183template <typename T>
2184std::string to_string(const std::vector<T> &args)
2185{
2186 std::stringstream str;
2187 str << args;
2188 return str.str();
2189}
2190
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00002191/** Formatted output of the WinogradInfo type. */
2192inline ::std::ostream &operator<<(::std::ostream &os, const WinogradInfo &info)
2193{
2194 os << "{OutputTileSize=" << info.output_tile_size << ","
2195 << "KernelSize=" << info.kernel_size << ","
2196 << "PadStride=" << info.convolution_info << ","
2197 << "OutputDataLayout=" << info.output_data_layout << "}";
2198
2199 return os;
2200}
2201
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00002202inline std::string to_string(const WinogradInfo &type)
2203{
2204 std::stringstream str;
2205 str << type;
2206 return str.str();
2207}
Anthony Barbier671a11e2018-07-06 15:11:36 +01002208
2209/** Fallback method: try to use std::to_string:
2210 *
2211 * @param[in] val Value to convert to string
2212 *
2213 * @return String representing val.
2214 */
2215template <typename T>
2216inline std::string to_string(const T &val)
2217{
2218 return support::cpp11::to_string(val);
2219}
2220
Anthony Barbier6ff3b192017-09-04 18:44:23 +01002221} // namespace arm_compute
Anthony Barbier4dbc0a92018-08-27 13:39:47 +01002222
2223#endif /* __ARM_COMPUTE_TYPE_PRINTER_H__ */