blob: d089a5b7ea69dc3a5360baa35ab682bcbeb85ad8 [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
Alex Gildayc357c472018-03-21 13:54:09 +0000885/** Formatted output of the InterpolationPolicy type.
886 *
887 * @param[out] os Output stream.
888 * @param[in] policy Type to output.
889 *
890 * @return Modified output stream.
891 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100892inline ::std::ostream &operator<<(::std::ostream &os, const InterpolationPolicy &policy)
893{
894 switch(policy)
895 {
896 case InterpolationPolicy::NEAREST_NEIGHBOR:
897 os << "NEAREST_NEIGHBOR";
898 break;
899 case InterpolationPolicy::BILINEAR:
900 os << "BILINEAR";
901 break;
902 case InterpolationPolicy::AREA:
903 os << "AREA";
904 break;
905 default:
906 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
907 }
908
909 return os;
910}
911
Alex Gildayc357c472018-03-21 13:54:09 +0000912/** Formatted output of the SamplingPolicy type.
913 *
914 * @param[out] os Output stream.
915 * @param[in] policy Type to output.
916 *
917 * @return Modified output stream.
918 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700919inline ::std::ostream &operator<<(::std::ostream &os, const SamplingPolicy &policy)
920{
921 switch(policy)
922 {
923 case SamplingPolicy::CENTER:
924 os << "CENTER";
925 break;
926 case SamplingPolicy::TOP_LEFT:
927 os << "TOP_LEFT";
928 break;
929 default:
930 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
931 }
932
933 return os;
934}
935
Alex Gildayc357c472018-03-21 13:54:09 +0000936/** Formatted output of the TensorInfo type.
937 *
Anthony Barbier366628a2018-08-01 13:55:03 +0100938 * @param[out] os Output stream.
939 * @param[in] info Type to output.
940 *
941 * @return Modified output stream.
942 */
943inline ::std::ostream &operator<<(::std::ostream &os, const TensorInfo &info)
944{
945 os << "{Shape=" << info.tensor_shape() << ","
946 << "Type=" << info.data_type() << ","
947 << "Channels=" << info.num_channels() << "}";
948 return os;
949}
950/** Formatted output of the TensorInfo type.
951 *
Alex Gildayc357c472018-03-21 13:54:09 +0000952 * @param[in] info Type to output.
953 *
954 * @return Formatted string.
955 */
Georgios Pinitas3faea252017-10-30 14:13:50 +0000956inline std::string to_string(const TensorInfo &info)
957{
958 std::stringstream str;
Anthony Barbier366628a2018-08-01 13:55:03 +0100959 str << info;
Georgios Pinitas3faea252017-10-30 14:13:50 +0000960 return str.str();
961}
962
Abe Mbise925ca0f2017-10-02 19:16:33 +0100963//FIXME: Check why this doesn't work and the TensorShape and Coordinates overload are needed
Alex Gildayc357c472018-03-21 13:54:09 +0000964/** Formatted output of the Dimensions type.
965 *
966 * @param[in] dimensions Type to output.
967 *
968 * @return Formatted string.
969 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100970template <typename T>
971inline std::string to_string(const Dimensions<T> &dimensions)
972{
973 std::stringstream str;
974 str << dimensions;
975 return str.str();
976}
977
Alex Gildayc357c472018-03-21 13:54:09 +0000978/** Formatted output of the Strides type.
979 *
980 * @param[in] stride Type to output.
981 *
982 * @return Formatted string.
983 */
John Richardsona36eae12017-09-26 16:55:59 +0100984inline std::string to_string(const Strides &stride)
985{
986 std::stringstream str;
987 str << stride;
988 return str.str();
989}
990
Alex Gildayc357c472018-03-21 13:54:09 +0000991/** Formatted output of the TensorShape type.
992 *
993 * @param[in] shape Type to output.
994 *
995 * @return Formatted string.
996 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100997inline std::string to_string(const TensorShape &shape)
998{
999 std::stringstream str;
1000 str << shape;
1001 return str.str();
1002}
1003
Alex Gildayc357c472018-03-21 13:54:09 +00001004/** Formatted output of the Coordinates type.
1005 *
1006 * @param[in] coord Type to output.
1007 *
1008 * @return Formatted string.
1009 */
Abe Mbise925ca0f2017-10-02 19:16:33 +01001010inline std::string to_string(const Coordinates &coord)
1011{
1012 std::stringstream str;
1013 str << coord;
1014 return str.str();
1015}
1016
Anthony Barbierb940fd62018-06-04 14:14:32 +01001017/** Formatted output of the GEMMReshapeInfo type.
1018 *
1019 * @param[out] os Output stream.
1020 * @param[in] info Type to output.
1021 *
1022 * @return Modified output stream.
1023 */
1024inline ::std::ostream &operator<<(::std::ostream &os, const GEMMReshapeInfo &info)
1025{
1026 os << "{m=" << info.m() << ",";
1027 os << "n=" << info.n() << ",";
1028 os << "k=" << info.k() << ",";
1029 os << "mult_transpose1xW_width=" << info.mult_transpose1xW_width() << ",";
1030 os << "mult_interleave4x4_height=" << info.mult_interleave4x4_height();
1031 os << "}";
1032
1033 return os;
1034}
1035
1036/** Formatted output of the GEMMInfo type.
1037 *
1038 * @param[out] os Output stream.
1039 * @param[in] info Type to output.
1040 *
1041 * @return Modified output stream.
1042 */
1043inline ::std::ostream &operator<<(::std::ostream &os, const GEMMInfo &info)
1044{
1045 os << "{is_a_reshaped=" << info.is_a_reshaped() << ",";
1046 os << "is_b_reshaped=" << info.is_b_reshaped() << ",";
1047 os << "reshape_b_only_on_first_run=" << info.reshape_b_only_on_first_run() << ",";
Anthony Barbierb940fd62018-06-04 14:14:32 +01001048 os << "}";
1049
1050 return os;
1051}
1052
1053/** Formatted output of the Window::Dimension type.
1054 *
1055 * @param[out] os Output stream.
1056 * @param[in] dim Type to output.
1057 *
1058 * @return Modified output stream.
1059 */
1060inline ::std::ostream &operator<<(::std::ostream &os, const Window::Dimension &dim)
1061{
1062 os << "{start=" << dim.start() << ", end=" << dim.end() << ", step=" << dim.step() << "}";
1063
1064 return os;
1065}
1066/** Formatted output of the Window type.
1067 *
1068 * @param[out] os Output stream.
1069 * @param[in] win Type to output.
1070 *
1071 * @return Modified output stream.
1072 */
1073inline ::std::ostream &operator<<(::std::ostream &os, const Window &win)
1074{
1075 os << "{";
1076 for(unsigned int i = 0; i < Coordinates::num_max_dimensions; i++)
1077 {
1078 if(i > 0)
1079 {
1080 os << ", ";
1081 }
1082 os << win[i];
1083 }
1084 os << "}";
1085
1086 return os;
1087}
1088
1089/** Formatted output of the WeightsInfo type.
1090 *
1091 * @param[in] info Type to output.
1092 *
1093 * @return Formatted string.
1094 */
1095inline std::string to_string(const WeightsInfo &info)
1096{
1097 std::stringstream str;
1098 str << info;
1099 return str.str();
1100}
1101
1102/** Formatted output of the GEMMReshapeInfo type.
1103 *
1104 * @param[in] info Type to output.
1105 *
1106 * @return Formatted string.
1107 */
1108inline std::string to_string(const GEMMReshapeInfo &info)
1109{
1110 std::stringstream str;
1111 str << info;
1112 return str.str();
1113}
1114
1115/** Formatted output of the GEMMInfo type.
1116 *
1117 * @param[in] info Type to output.
1118 *
1119 * @return Formatted string.
1120 */
1121inline std::string to_string(const GEMMInfo &info)
1122{
1123 std::stringstream str;
1124 str << info;
1125 return str.str();
1126}
1127
1128/** Formatted output of the Window::Dimension type.
1129 *
1130 * @param[in] dim Type to output.
1131 *
1132 * @return Formatted string.
1133 */
1134inline std::string to_string(const Window::Dimension &dim)
1135{
1136 std::stringstream str;
1137 str << dim;
1138 return str.str();
1139}
1140/** Formatted output of the Window type.
1141 *
1142 * @param[in] win Type to output.
1143 *
1144 * @return Formatted string.
1145 */
1146inline std::string to_string(const Window &win)
1147{
1148 std::stringstream str;
1149 str << win;
1150 return str.str();
1151}
1152
Alex Gildayc357c472018-03-21 13:54:09 +00001153/** Formatted output of the Rectangle type.
1154 *
1155 * @param[out] os Output stream.
1156 * @param[in] rect Type to output.
1157 *
1158 * @return Modified output stream.
1159 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001160inline ::std::ostream &operator<<(::std::ostream &os, const Rectangle &rect)
1161{
1162 os << rect.width << "x" << rect.height;
1163 os << "+" << rect.x << "+" << rect.y;
1164
1165 return os;
1166}
1167
Alex Gildayc357c472018-03-21 13:54:09 +00001168/** Formatted output of the PadStrideInfo type.
1169 *
1170 * @param[out] os Output stream.
1171 * @param[in] pad_stride_info Type to output.
1172 *
1173 * @return Modified output stream.
1174 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001175inline ::std::ostream &operator<<(::std::ostream &os, const PadStrideInfo &pad_stride_info)
1176{
1177 os << pad_stride_info.stride().first << "," << pad_stride_info.stride().second;
1178 os << ";";
Jaroslaw Rzepeckia1ed41f2017-10-13 11:13:58 +01001179 os << pad_stride_info.pad_left() << "," << pad_stride_info.pad_right() << ","
1180 << pad_stride_info.pad_top() << "," << pad_stride_info.pad_bottom();
Anthony Barbier2a07e182017-08-04 18:20:27 +01001181
1182 return os;
1183}
1184
Alex Gildayc357c472018-03-21 13:54:09 +00001185/** Formatted output of the PadStrideInfo type.
1186 *
1187 * @param[in] pad_stride_info Type to output.
1188 *
1189 * @return Formatted string.
1190 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001191inline std::string to_string(const PadStrideInfo &pad_stride_info)
1192{
1193 std::stringstream str;
1194 str << pad_stride_info;
1195 return str.str();
1196}
1197
Alex Gildayc357c472018-03-21 13:54:09 +00001198/** Formatted output of the BorderMode type.
1199 *
1200 * @param[in] mode Type to output.
1201 *
1202 * @return Formatted string.
1203 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001204inline std::string to_string(const BorderMode &mode)
1205{
1206 std::stringstream str;
1207 str << mode;
1208 return str.str();
1209}
1210
Alex Gildayc357c472018-03-21 13:54:09 +00001211/** Formatted output of the BorderSize type.
1212 *
1213 * @param[in] border Type to output.
1214 *
1215 * @return Formatted string.
1216 */
John Richardsonb482ce12017-09-18 12:44:01 +01001217inline std::string to_string(const BorderSize &border)
1218{
1219 std::stringstream str;
1220 str << border;
1221 return str.str();
1222}
1223
Giuseppe Rossinid7647d42018-07-17 18:13:13 +01001224/** Formatted output of the PaddingList type.
1225 *
1226 * @param[in] padding Type to output.
1227 *
1228 * @return Formatted string.
1229 */
1230inline std::string to_string(const PaddingList &padding)
1231{
1232 std::stringstream str;
1233 str << padding;
1234 return str.str();
1235}
1236
Alex Gildayc357c472018-03-21 13:54:09 +00001237/** Formatted output of the InterpolationPolicy type.
1238 *
1239 * @param[in] policy Type to output.
1240 *
1241 * @return Formatted string.
1242 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001243inline std::string to_string(const InterpolationPolicy &policy)
1244{
1245 std::stringstream str;
1246 str << policy;
1247 return str.str();
1248}
1249
Alex Gildayc357c472018-03-21 13:54:09 +00001250/** Formatted output of the SamplingPolicy type.
1251 *
1252 * @param[in] policy Type to output.
1253 *
1254 * @return Formatted string.
1255 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +07001256inline std::string to_string(const SamplingPolicy &policy)
1257{
1258 std::stringstream str;
1259 str << policy;
1260 return str.str();
1261}
1262
Alex Gildayc357c472018-03-21 13:54:09 +00001263/** Formatted output of the ConvertPolicy type.
1264 *
1265 * @param[out] os Output stream.
1266 * @param[in] policy Type to output.
1267 *
1268 * @return Modified output stream.
1269 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001270inline ::std::ostream &operator<<(::std::ostream &os, const ConvertPolicy &policy)
1271{
1272 switch(policy)
1273 {
1274 case ConvertPolicy::WRAP:
1275 os << "WRAP";
1276 break;
1277 case ConvertPolicy::SATURATE:
1278 os << "SATURATE";
1279 break;
1280 default:
1281 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1282 }
1283
1284 return os;
1285}
1286
1287inline std::string to_string(const ConvertPolicy &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 Reduction Operations.
1295 *
1296 * @param[out] os Output stream.
1297 * @param[in] op 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 ReductionOperation &op)
1302{
1303 switch(op)
1304 {
Michalis Spyrou7e9391b2018-10-05 14:49:28 +01001305 case ReductionOperation::SUM:
1306 os << "SUM";
1307 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +01001308 case ReductionOperation::SUM_SQUARE:
1309 os << "SUM_SQUARE";
1310 break;
Michalis Spyrou7e9391b2018-10-05 14:49:28 +01001311 case ReductionOperation::MEAN_SUM:
1312 os << "MEAN_SUM";
1313 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +01001314 default:
1315 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1316 }
1317
1318 return os;
1319}
1320
Alex Gildayc357c472018-03-21 13:54:09 +00001321/** Formatted output of the Reduction Operations.
1322 *
1323 * @param[in] op Type to output.
1324 *
1325 * @return Formatted string.
1326 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001327inline std::string to_string(const ReductionOperation &op)
1328{
1329 std::stringstream str;
1330 str << op;
1331 return str.str();
1332}
1333
Alex Gildayc357c472018-03-21 13:54:09 +00001334/** Formatted output of the Norm Type.
1335 *
1336 * @param[in] type Type to output.
1337 *
1338 * @return Formatted string.
1339 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001340inline std::string to_string(const NormType &type)
1341{
1342 std::stringstream str;
1343 str << type;
1344 return str.str();
1345}
1346
Alex Gildayc357c472018-03-21 13:54:09 +00001347/** Formatted output of the Pooling Type.
1348 *
1349 * @param[in] type Type to output.
1350 *
1351 * @return Formatted string.
1352 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001353inline std::string to_string(const PoolingType &type)
1354{
1355 std::stringstream str;
1356 str << type;
1357 return str.str();
1358}
1359
Alex Gildayc357c472018-03-21 13:54:09 +00001360/** Formatted output of the Pooling Layer Info.
1361 *
1362 * @param[in] info Type to output.
1363 *
1364 * @return Formatted string.
1365 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001366inline std::string to_string(const PoolingLayerInfo &info)
1367{
1368 std::stringstream str;
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001369 str << "{Type=" << info.pool_type() << ","
1370 << "IsGlobalPooling=" << info.is_global_pooling();
1371 if(!info.is_global_pooling())
1372 {
1373 str << ","
Isabella Gottardi6e464c32018-01-26 12:32:45 +00001374 << "PoolSize=" << info.pool_size().width << "," << info.pool_size().height << ","
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001375 << "PadStride=" << info.pad_stride_info();
1376 }
1377 str << "}";
Anthony Barbier2a07e182017-08-04 18:20:27 +01001378 return str.str();
1379}
1380
Michalis Spyrou6c7c38e2018-08-29 16:28:11 +01001381/** Formatted output of the PriorBoxLayerInfo.
1382 *
1383 * @param[in] info Type to output.
1384 *
1385 * @return Formatted string.
1386 */
1387inline std::string to_string(const PriorBoxLayerInfo &info)
1388{
1389 std::stringstream str;
1390 str << "{";
1391 str << "Clip:" << info.clip()
1392 << "Flip:" << info.flip()
1393 << "StepX:" << info.steps()[0]
1394 << "StepY:" << info.steps()[1]
1395 << "MinSizes:" << info.min_sizes().size()
1396 << "MaxSizes:" << info.max_sizes().size()
1397 << "ImgSizeX:" << info.img_size().x
1398 << "ImgSizeY:" << info.img_size().y
1399 << "Offset:" << info.offset()
1400 << "Variances:" << info.variances().size();
1401 str << "}";
1402 return str.str();
1403}
1404
Alex Gildayc357c472018-03-21 13:54:09 +00001405/** Formatted output of the KeyPoint type.
1406 *
1407 * @param[out] os Output stream
1408 * @param[in] point Type to output.
1409 *
1410 * @return Modified output stream.
1411 */
Moritz Pflanzer6c6597c2017-09-24 12:09:41 +01001412inline ::std::ostream &operator<<(::std::ostream &os, const KeyPoint &point)
1413{
1414 os << "{x=" << point.x << ","
1415 << "y=" << point.y << ","
1416 << "strength=" << point.strength << ","
1417 << "scale=" << point.scale << ","
1418 << "orientation=" << point.orientation << ","
1419 << "tracking_status=" << point.tracking_status << ","
1420 << "error=" << point.error << "}";
1421
1422 return os;
1423}
John Richardson63e50412017-10-13 20:51:42 +01001424
Alex Gildayc357c472018-03-21 13:54:09 +00001425/** Formatted output of the PhaseType type.
1426 *
1427 * @param[out] os Output stream
1428 * @param[in] phase_type Type to output.
1429 *
1430 * @return Modified output stream.
1431 */
John Richardson63e50412017-10-13 20:51:42 +01001432inline ::std::ostream &operator<<(::std::ostream &os, const PhaseType &phase_type)
1433{
1434 switch(phase_type)
1435 {
1436 case PhaseType::SIGNED:
1437 os << "SIGNED";
1438 break;
1439 case PhaseType::UNSIGNED:
1440 os << "UNSIGNED";
1441 break;
1442 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 PhaseType type.
1450 *
1451 * @param[in] type Type to output.
1452 *
1453 * @return Formatted string.
1454 */
John Richardson63e50412017-10-13 20:51:42 +01001455inline std::string to_string(const arm_compute::PhaseType &type)
1456{
1457 std::stringstream str;
1458 str << type;
1459 return str.str();
1460}
John Richardson3c5f9492017-10-04 15:27:37 +01001461
Alex Gildayc357c472018-03-21 13:54:09 +00001462/** Formatted output of the MagnitudeType type.
1463 *
1464 * @param[out] os Output stream
1465 * @param[in] magnitude_type Type to output.
1466 *
1467 * @return Modified output stream.
1468 */
John Richardson3c5f9492017-10-04 15:27:37 +01001469inline ::std::ostream &operator<<(::std::ostream &os, const MagnitudeType &magnitude_type)
1470{
1471 switch(magnitude_type)
1472 {
1473 case MagnitudeType::L1NORM:
1474 os << "L1NORM";
1475 break;
1476 case MagnitudeType::L2NORM:
1477 os << "L2NORM";
1478 break;
1479 default:
1480 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1481 }
1482
1483 return os;
1484}
1485
Alex Gildayc357c472018-03-21 13:54:09 +00001486/** Formatted output of the MagnitudeType type.
1487 *
1488 * @param[in] type Type to output.
1489 *
1490 * @return Formatted string.
1491 */
John Richardson3c5f9492017-10-04 15:27:37 +01001492inline std::string to_string(const arm_compute::MagnitudeType &type)
1493{
1494 std::stringstream str;
1495 str << type;
1496 return str.str();
1497}
John Richardson1c529922017-11-01 10:57:48 +00001498
Alex Gildayc357c472018-03-21 13:54:09 +00001499/** Formatted output of the HOGNormType type.
1500 *
1501 * @param[out] os Output stream
1502 * @param[in] norm_type Type to output
1503 *
1504 * @return Modified output stream.
1505 */
John Richardson25f23682017-11-27 14:35:09 +00001506inline ::std::ostream &operator<<(::std::ostream &os, const HOGNormType &norm_type)
1507{
1508 switch(norm_type)
1509 {
1510 case HOGNormType::L1_NORM:
1511 os << "L1_NORM";
1512 break;
1513 case HOGNormType::L2_NORM:
1514 os << "L2_NORM";
1515 break;
1516 case HOGNormType::L2HYS_NORM:
1517 os << "L2HYS_NORM";
1518 break;
1519 default:
1520 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1521 }
1522
1523 return os;
1524}
1525
Alex Gildayc357c472018-03-21 13:54:09 +00001526/** Formatted output of the HOGNormType type.
1527 *
1528 * @param[in] type Type to output
1529 *
1530 * @return Formatted string.
1531 */
John Richardson25f23682017-11-27 14:35:09 +00001532inline std::string to_string(const HOGNormType &type)
1533{
1534 std::stringstream str;
1535 str << type;
1536 return str.str();
1537}
1538
Alex Gildayc357c472018-03-21 13:54:09 +00001539/** Formatted output of the Size2D type.
1540 *
1541 * @param[out] os Output stream
1542 * @param[in] size Type to output
1543 *
1544 * @return Modified output stream.
1545 */
John Richardson25f23682017-11-27 14:35:09 +00001546inline ::std::ostream &operator<<(::std::ostream &os, const Size2D &size)
1547{
1548 os << size.width << "x" << size.height;
1549
1550 return os;
1551}
1552
Alex Gildayc357c472018-03-21 13:54:09 +00001553/** Formatted output of the Size2D type.
1554 *
1555 * @param[in] type Type to output
1556 *
1557 * @return Formatted string.
1558 */
John Richardson25f23682017-11-27 14:35:09 +00001559inline std::string to_string(const Size2D &type)
1560{
1561 std::stringstream str;
1562 str << type;
1563 return str.str();
1564}
1565
Alex Gildayc357c472018-03-21 13:54:09 +00001566/** Formatted output of the HOGInfo type.
1567 *
1568 * @param[out] os Output stream
1569 * @param[in] hog_info Type to output
1570 *
1571 * @return Modified output stream.
1572 */
John Richardson25f23682017-11-27 14:35:09 +00001573inline ::std::ostream &operator<<(::std::ostream &os, const HOGInfo &hog_info)
1574{
1575 os << "{CellSize=" << hog_info.cell_size() << ","
1576 << "BlockSize=" << hog_info.block_size() << ","
1577 << "DetectionWindowSize=" << hog_info.detection_window_size() << ","
1578 << "BlockStride=" << hog_info.block_stride() << ","
1579 << "NumBins=" << hog_info.num_bins() << ","
1580 << "NormType=" << hog_info.normalization_type() << ","
1581 << "L2HystThreshold=" << hog_info.l2_hyst_threshold() << ","
1582 << "PhaseType=" << hog_info.phase_type() << "}";
1583
1584 return os;
1585}
1586
Alex Gildayc357c472018-03-21 13:54:09 +00001587/** Formatted output of the HOGInfo type.
1588 *
1589 * @param[in] type Type to output
1590 *
1591 * @return Formatted string.
1592 */
John Richardson25f23682017-11-27 14:35:09 +00001593inline std::string to_string(const HOGInfo &type)
1594{
1595 std::stringstream str;
1596 str << type;
1597 return str.str();
1598}
1599
Alex Gildayc357c472018-03-21 13:54:09 +00001600/** Formatted output of the ConvolutionMethod type.
1601 *
1602 * @param[out] os Output stream
1603 * @param[in] conv_method Type to output
1604 *
1605 * @return Modified output stream.
1606 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001607inline ::std::ostream &operator<<(::std::ostream &os, const ConvolutionMethod &conv_method)
1608{
1609 switch(conv_method)
1610 {
1611 case ConvolutionMethod::GEMM:
1612 os << "GEMM";
1613 break;
1614 case ConvolutionMethod::DIRECT:
1615 os << "DIRECT";
1616 break;
1617 case ConvolutionMethod::WINOGRAD:
1618 os << "WINOGRAD";
1619 break;
1620 default:
1621 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1622 }
1623
1624 return os;
1625}
1626
Alex Gildayc357c472018-03-21 13:54:09 +00001627/** Formatted output of the ConvolutionMethod type.
1628 *
1629 * @param[in] conv_method Type to output
1630 *
1631 * @return Formatted string.
1632 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001633inline std::string to_string(const ConvolutionMethod &conv_method)
1634{
1635 std::stringstream str;
1636 str << conv_method;
1637 return str.str();
1638}
1639
Alex Gildayc357c472018-03-21 13:54:09 +00001640/** Formatted output of the GPUTarget type.
1641 *
1642 * @param[out] os Output stream
1643 * @param[in] gpu_target Type to output
1644 *
1645 * @return Modified output stream.
1646 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001647inline ::std::ostream &operator<<(::std::ostream &os, const GPUTarget &gpu_target)
1648{
1649 switch(gpu_target)
1650 {
1651 case GPUTarget::GPU_ARCH_MASK:
1652 os << "GPU_ARCH_MASK";
1653 break;
1654 case GPUTarget::MIDGARD:
1655 os << "MIDGARD";
1656 break;
1657 case GPUTarget::BIFROST:
1658 os << "BIFROST";
1659 break;
1660 case GPUTarget::T600:
1661 os << "T600";
1662 break;
1663 case GPUTarget::T700:
1664 os << "T700";
1665 break;
1666 case GPUTarget::T800:
1667 os << "T800";
1668 break;
Michalis Spyroua9676112018-02-22 18:07:43 +00001669 case GPUTarget::G71:
1670 os << "G71";
1671 break;
1672 case GPUTarget::G72:
1673 os << "G72";
1674 break;
1675 case GPUTarget::G51:
1676 os << "G51";
1677 break;
1678 case GPUTarget::G51BIG:
1679 os << "G51BIG";
1680 break;
1681 case GPUTarget::G51LIT:
1682 os << "G51LIT";
1683 break;
Georgios Pinitasb03f7c52018-07-12 10:49:53 +01001684 case GPUTarget::G76:
1685 os << "G76";
Michalis Spyroua9676112018-02-22 18:07:43 +00001686 break;
1687 case GPUTarget::TTRX:
1688 os << "TTRX";
1689 break;
1690 case GPUTarget::TBOX:
1691 os << "TBOX";
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001692 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 GPUTarget type.
1701 *
1702 * @param[in] gpu_target Type to output
1703 *
1704 * @return Formatted string.
1705 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001706inline std::string to_string(const GPUTarget &gpu_target)
1707{
1708 std::stringstream str;
1709 str << gpu_target;
1710 return str.str();
1711}
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00001712
John Richardson8de92612018-02-22 14:09:31 +00001713/** Formatted output of the DetectionWindow type.
1714 *
1715 * @param[out] os Output stream
1716 * @param[in] detection_window Type to output
1717 *
1718 * @return Modified output stream.
1719 */
John Richardson684cb0f2018-01-09 11:17:00 +00001720inline ::std::ostream &operator<<(::std::ostream &os, const DetectionWindow &detection_window)
1721{
1722 os << "{x=" << detection_window.x << ","
1723 << "y=" << detection_window.y << ","
1724 << "width=" << detection_window.width << ","
1725 << "height=" << detection_window.height << ","
1726 << "idx_class=" << detection_window.idx_class << ","
1727 << "score=" << detection_window.score << "}";
1728
1729 return os;
1730}
1731
John Richardson8de92612018-02-22 14:09:31 +00001732/** Formatted output of the DetectionWindow type.
1733 *
1734 * @param[in] detection_window Type to output
1735 *
1736 * @return Formatted string.
1737 */
1738inline std::string to_string(const DetectionWindow &detection_window)
1739{
1740 std::stringstream str;
1741 str << detection_window;
1742 return str.str();
1743}
1744
1745/** Formatted output of the Termination type.
1746 *
1747 * @param[out] os Output stream
1748 * @param[in] termination Type to output
1749 *
1750 * @return Modified output stream.
1751 */
1752inline ::std::ostream &operator<<(::std::ostream &os, const Termination &termination)
1753{
1754 switch(termination)
1755 {
1756 case Termination::TERM_CRITERIA_EPSILON:
1757 os << "TERM_CRITERIA_EPSILON";
1758 break;
1759 case Termination::TERM_CRITERIA_ITERATIONS:
1760 os << "TERM_CRITERIA_ITERATIONS";
1761 break;
1762 case Termination::TERM_CRITERIA_BOTH:
1763 os << "TERM_CRITERIA_BOTH";
1764 break;
1765 default:
1766 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1767 }
1768
1769 return os;
1770}
1771
1772/** Formatted output of the Termination type.
1773 *
1774 * @param[in] termination Type to output
1775 *
1776 * @return Formatted string.
1777 */
1778inline std::string to_string(const Termination &termination)
1779{
1780 std::stringstream str;
1781 str << termination;
1782 return str.str();
1783}
1784
Anthony Barbier8914e322018-08-10 15:28:25 +01001785/** Formatted output of the CPUModel type.
1786 *
1787 * @param[out] os Output stream
1788 * @param[in] cpu_model Model to output
1789 *
1790 * @return Modified output stream.
1791 */
1792inline ::std::ostream &operator<<(::std::ostream &os, const CPUModel &cpu_model)
1793{
1794 switch(cpu_model)
1795 {
1796 case CPUModel::GENERIC:
1797 os << "GENERIC";
1798 break;
1799 case CPUModel::GENERIC_FP16:
1800 os << "GENERIC_FP16";
1801 break;
1802 case CPUModel::GENERIC_FP16_DOT:
1803 os << "GENERIC_FP16_DOT";
1804 break;
1805 case CPUModel::A53:
1806 os << "A53";
1807 break;
1808 case CPUModel::A55r0:
1809 os << "A55r0";
1810 break;
1811 case CPUModel::A55r1:
1812 os << "A55r1";
1813 break;
1814 default:
1815 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1816 }
1817
1818 return os;
1819}
1820
1821/** Formatted output of the CPUModel type.
1822 *
1823 * @param[in] cpu_model Model to output
1824 *
1825 * @return Formatted string.
1826 */
1827inline std::string to_string(const CPUModel &cpu_model)
1828{
1829 std::stringstream str;
1830 str << cpu_model;
1831 return str.str();
1832}
Anthony Barbier671a11e2018-07-06 15:11:36 +01001833/** Formatted output of a vector of objects.
1834 *
1835 * @param[out] os Output stream
1836 * @param[in] args Vector of objects to print
1837 *
1838 * @return Modified output stream.
1839 */
1840template <typename T>
1841inline ::std::ostream &operator<<(::std::ostream &os, const std::vector<T> &args)
1842{
1843 os << "[";
1844 bool first = true;
1845 for(auto &arg : args)
1846 {
1847 if(first)
1848 {
1849 first = false;
1850 }
1851 else
1852 {
1853 os << ", ";
1854 }
1855 os << arg;
1856 }
1857 os << "]";
1858 return os;
1859}
1860
Michalis Spyrou6c7c38e2018-08-29 16:28:11 +01001861/** Formatted output of @ref PriorBoxLayerInfo.
1862 *
1863 * @param[out] os Output stream.
1864 * @param[in] info Type to output.
1865 *
1866 * @return Modified output stream.
1867 */
1868inline ::std::ostream &operator<<(::std::ostream &os, const PriorBoxLayerInfo &info)
1869{
1870 os << "Clip:" << info.clip()
1871 << "Flip:" << info.flip()
1872 << "StepX:" << info.steps()[0]
1873 << "StepY:" << info.steps()[1]
1874 << "MinSizes:" << info.min_sizes()
1875 << "MaxSizes:" << info.max_sizes()
1876 << "ImgSizeX:" << info.img_size().x
1877 << "ImgSizeY:" << info.img_size().y
1878 << "Offset:" << info.offset()
1879 << "Variances:" << info.variances();
1880
1881 return os;
1882}
1883
Anthony Barbier671a11e2018-07-06 15:11:36 +01001884/** Formatted output of a vector of objects.
1885 *
1886 * @param[in] args Vector of objects to print
1887 *
1888 * @return String representing args.
1889 */
1890template <typename T>
1891std::string to_string(const std::vector<T> &args)
1892{
1893 std::stringstream str;
1894 str << args;
1895 return str.str();
1896}
1897
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00001898/** Formatted output of the WinogradInfo type. */
1899inline ::std::ostream &operator<<(::std::ostream &os, const WinogradInfo &info)
1900{
1901 os << "{OutputTileSize=" << info.output_tile_size << ","
1902 << "KernelSize=" << info.kernel_size << ","
1903 << "PadStride=" << info.convolution_info << ","
1904 << "OutputDataLayout=" << info.output_data_layout << "}";
1905
1906 return os;
1907}
1908
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00001909inline std::string to_string(const WinogradInfo &type)
1910{
1911 std::stringstream str;
1912 str << type;
1913 return str.str();
1914}
Anthony Barbier671a11e2018-07-06 15:11:36 +01001915
1916/** Fallback method: try to use std::to_string:
1917 *
1918 * @param[in] val Value to convert to string
1919 *
1920 * @return String representing val.
1921 */
1922template <typename T>
1923inline std::string to_string(const T &val)
1924{
1925 return support::cpp11::to_string(val);
1926}
1927
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001928} // namespace arm_compute
Anthony Barbier4dbc0a92018-08-27 13:39:47 +01001929
1930#endif /* __ARM_COMPUTE_TYPE_PRINTER_H__ */