blob: 9bd8c2a667315fd572ddd4917706715c1898b9f0 [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 */
24#ifndef __ARM_COMPUTE_TEST_TYPE_PRINTER_H__
25#define __ARM_COMPUTE_TEST_TYPE_PRINTER_H__
26
Isabella Gottardif07d28d2018-02-06 14:52:43 +000027#include "arm_compute/core/CL/CLTypes.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010028#include "arm_compute/core/Dimensions.h"
29#include "arm_compute/core/Error.h"
Michele Di Giorgiob8fc60f2018-04-25 11:58:07 +010030#include "arm_compute/core/GPUTarget.h"
John Richardson25f23682017-11-27 14:35:09 +000031#include "arm_compute/core/HOGInfo.h"
32#include "arm_compute/core/Size2D.h"
John Richardsona36eae12017-09-26 16:55:59 +010033#include "arm_compute/core/Strides.h"
Georgios Pinitas3faea252017-10-30 14:13:50 +000034#include "arm_compute/core/TensorInfo.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010035#include "arm_compute/core/Types.h"
36
Abe Mbise4bd2cb82017-09-27 18:39:19 +010037#include "tests/Types.h"
38
Anthony Barbier6ff3b192017-09-04 18:44:23 +010039#include <ostream>
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010040#include <sstream>
41#include <string>
Anthony Barbier6ff3b192017-09-04 18:44:23 +010042
43namespace arm_compute
44{
Anthony Barbierb940fd62018-06-04 14:14:32 +010045/** Formatted output if arg is not null
46 *
47 * @param[in] arg Object to print
48 *
49 * @return String representing arg.
50 */
51template <typename T>
52std::string to_string_if_not_null(T *arg)
53{
54 if(arg == nullptr)
55 {
56 return "nullptr";
57 }
58 else
59 {
60 return to_string(*arg);
61 }
62}
Alex Gildayc357c472018-03-21 13:54:09 +000063/** Formatted output of the Dimensions type.
64 *
65 * @param[out] os Output stream.
66 * @param[in] dimensions Type to output.
67 *
68 * @return Modified output stream.
69 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +010070template <typename T>
71inline ::std::ostream &operator<<(::std::ostream &os, const Dimensions<T> &dimensions)
72{
Anthony Barbier6ff3b192017-09-04 18:44:23 +010073 if(dimensions.num_dimensions() > 0)
74 {
75 os << dimensions[0];
76
77 for(unsigned int d = 1; d < dimensions.num_dimensions(); ++d)
78 {
Moritz Pflanzerc87fbf82017-07-18 14:02:10 +010079 os << "x" << dimensions[d];
Anthony Barbier6ff3b192017-09-04 18:44:23 +010080 }
81 }
82
Anthony Barbier6ff3b192017-09-04 18:44:23 +010083 return os;
84}
85
Alex Gildayc357c472018-03-21 13:54:09 +000086/** Formatted output of the NonLinearFilterFunction type.
87 *
88 * @param[out] os Output stream.
89 * @param[in] function Type to output.
90 *
91 * @return Modified output stream.
92 */
Isabella Gottardi3b77e9d2017-06-22 11:05:41 +010093inline ::std::ostream &operator<<(::std::ostream &os, const NonLinearFilterFunction &function)
94{
95 switch(function)
96 {
97 case NonLinearFilterFunction::MAX:
98 os << "MAX";
99 break;
100 case NonLinearFilterFunction::MEDIAN:
101 os << "MEDIAN";
102 break;
103 case NonLinearFilterFunction::MIN:
104 os << "MIN";
105 break;
106 default:
107 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
108 }
109
110 return os;
111}
112
Alex Gildayc357c472018-03-21 13:54:09 +0000113/** Formatted output of the NonLinearFilterFunction type.
114 *
115 * @param[in] function Type to output.
116 *
117 * @return Formatted string.
118 */
John Richardson6f4d49f2017-09-07 11:21:10 +0100119inline std::string to_string(const NonLinearFilterFunction &function)
120{
121 std::stringstream str;
122 str << function;
123 return str.str();
124}
125
Alex Gildayc357c472018-03-21 13:54:09 +0000126/** Formatted output of the MatrixPattern type.
127 *
128 * @param[out] os Output stream.
129 * @param[in] pattern Type to output.
130 *
131 * @return Modified output stream.
132 */
Isabella Gottardi3b77e9d2017-06-22 11:05:41 +0100133inline ::std::ostream &operator<<(::std::ostream &os, const MatrixPattern &pattern)
134{
135 switch(pattern)
136 {
137 case MatrixPattern::BOX:
138 os << "BOX";
139 break;
140 case MatrixPattern::CROSS:
141 os << "CROSS";
142 break;
143 case MatrixPattern::DISK:
144 os << "DISK";
145 break;
146 case MatrixPattern::OTHER:
147 os << "OTHER";
148 break;
149 default:
150 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
151 }
152
153 return os;
154}
155
Alex Gildayc357c472018-03-21 13:54:09 +0000156/** Formatted output of the MatrixPattern type.
157 *
158 * @param[in] pattern Type to output.
159 *
160 * @return Formatted string.
161 */
John Richardson6f4d49f2017-09-07 11:21:10 +0100162inline std::string to_string(const MatrixPattern &pattern)
163{
164 std::stringstream str;
165 str << pattern;
166 return str.str();
167}
168
Alex Gildayc357c472018-03-21 13:54:09 +0000169/** Formatted output of the RoundingPolicy type.
170 *
171 * @param[out] os Output stream.
172 * @param[in] rounding_policy Type to output.
173 *
174 * @return Modified output stream.
175 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100176inline ::std::ostream &operator<<(::std::ostream &os, const RoundingPolicy &rounding_policy)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100177{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100178 switch(rounding_policy)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100179 {
Anthony Barbier2a07e182017-08-04 18:20:27 +0100180 case RoundingPolicy::TO_ZERO:
181 os << "TO_ZERO";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100182 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100183 case RoundingPolicy::TO_NEAREST_UP:
184 os << "TO_NEAREST_UP";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100185 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100186 case RoundingPolicy::TO_NEAREST_EVEN:
187 os << "TO_NEAREST_EVEN";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100188 break;
189 default:
190 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
191 }
192
193 return os;
194}
195
Alex Gildayc357c472018-03-21 13:54:09 +0000196/** Formatted output of the WeightsInfo type.
197 *
198 * @param[out] os Output stream.
199 * @param[in] weights_info Type to output.
200 *
201 * @return Modified output stream.
202 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100203inline ::std::ostream &operator<<(::std::ostream &os, const WeightsInfo &weights_info)
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100204{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100205 os << weights_info.are_reshaped() << ";";
206 os << weights_info.num_kernels() << ";" << weights_info.kernel_size().first << "," << weights_info.kernel_size().second;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100207
208 return os;
209}
210
Alex Gildayc357c472018-03-21 13:54:09 +0000211/** Formatted output of the ROIPoolingInfo type.
212 *
213 * @param[out] os Output stream.
214 * @param[in] pool_info Type to output.
215 *
216 * @return Modified output stream.
217 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100218inline ::std::ostream &operator<<(::std::ostream &os, const ROIPoolingLayerInfo &pool_info)
Sanghoon Lee70f82912017-08-24 14:21:24 +0100219{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100220 os << pool_info.pooled_width() << "x" << pool_info.pooled_height() << "~" << pool_info.spatial_scale();
Georgios Pinitasd9769582017-08-03 10:19:40 +0100221 return os;
222}
223
Alex Gildayc357c472018-03-21 13:54:09 +0000224/** Formatted output of the QuantizationInfo type.
225 *
226 * @param[out] os Output stream.
227 * @param[in] quantization_info Type to output.
228 *
229 * @return Modified output stream.
230 */
Chunosovd621bca2017-11-03 17:33:15 +0700231inline ::std::ostream &operator<<(::std::ostream &os, const QuantizationInfo &quantization_info)
232{
233 os << "Scale:" << quantization_info.scale << "~"
234 << "Offset:" << quantization_info.offset;
235 return os;
236}
237
Alex Gildayc357c472018-03-21 13:54:09 +0000238/** Formatted output of the QuantizationInfo type.
239 *
240 * @param[in] quantization_info Type to output.
241 *
242 * @return Formatted string.
243 */
Chunosovd621bca2017-11-03 17:33:15 +0700244inline std::string to_string(const QuantizationInfo &quantization_info)
245{
246 std::stringstream str;
247 str << quantization_info;
248 return str.str();
249}
250
Alex Gildayc357c472018-03-21 13:54:09 +0000251/** Formatted output of the activation function type.
252 *
253 * @param[out] os Output stream.
254 * @param[in] act_function Type to output.
255 *
256 * @return Modified output stream.
257 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100258inline ::std::ostream &operator<<(::std::ostream &os, const ActivationLayerInfo::ActivationFunction &act_function)
259{
260 switch(act_function)
261 {
262 case ActivationLayerInfo::ActivationFunction::ABS:
263 os << "ABS";
264 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100265 case ActivationLayerInfo::ActivationFunction::LINEAR:
266 os << "LINEAR";
267 break;
268 case ActivationLayerInfo::ActivationFunction::LOGISTIC:
269 os << "LOGISTIC";
270 break;
271 case ActivationLayerInfo::ActivationFunction::RELU:
272 os << "RELU";
273 break;
Georgios Pinitas579c0492017-07-12 16:12:12 +0100274 case ActivationLayerInfo::ActivationFunction::BOUNDED_RELU:
275 os << "BOUNDED_RELU";
276 break;
277 case ActivationLayerInfo::ActivationFunction::LEAKY_RELU:
278 os << "LEAKY_RELU";
279 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100280 case ActivationLayerInfo::ActivationFunction::SOFT_RELU:
281 os << "SOFT_RELU";
282 break;
283 case ActivationLayerInfo::ActivationFunction::SQRT:
284 os << "SQRT";
285 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100286 case ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU:
287 os << "LU_BOUNDED_RELU";
Kevin Petitd9f80712017-12-06 12:18:48 +0000288 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100289 case ActivationLayerInfo::ActivationFunction::SQUARE:
290 os << "SQUARE";
291 break;
292 case ActivationLayerInfo::ActivationFunction::TANH:
293 os << "TANH";
294 break;
295 default:
296 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
297 }
298
299 return os;
300}
301
Alex Gildayc357c472018-03-21 13:54:09 +0000302/** Formatted output of the activation function info type.
303 *
304 * @param[in] info Type to output.
305 *
306 * @return Formatted string.
307 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100308inline std::string to_string(const arm_compute::ActivationLayerInfo &info)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100309{
310 std::stringstream str;
Isabella Gottardi3f217ec2018-02-12 14:59:19 +0000311 if(info.enabled())
312 {
313 str << info.activation();
314 }
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100315 return str.str();
316}
317
Alex Gildayc357c472018-03-21 13:54:09 +0000318/** Formatted output of the activation function type.
319 *
320 * @param[in] function Type to output.
321 *
322 * @return Formatted string.
323 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100324inline std::string to_string(const arm_compute::ActivationLayerInfo::ActivationFunction &function)
325{
326 std::stringstream str;
327 str << function;
328 return str.str();
329}
330
Alex Gildayc357c472018-03-21 13:54:09 +0000331/** Formatted output of the NormType type.
332 *
333 * @param[out] os Output stream.
334 * @param[in] norm_type Type to output.
335 *
336 * @return Modified output stream.
337 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100338inline ::std::ostream &operator<<(::std::ostream &os, const NormType &norm_type)
339{
340 switch(norm_type)
341 {
342 case NormType::CROSS_MAP:
343 os << "CROSS_MAP";
344 break;
345 case NormType::IN_MAP_1D:
346 os << "IN_MAP_1D";
347 break;
348 case NormType::IN_MAP_2D:
349 os << "IN_MAP_2D";
350 break;
351 default:
352 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
353 }
354
355 return os;
356}
357
Alex Gildayc357c472018-03-21 13:54:09 +0000358/** Formatted output of @ref NormalizationLayerInfo.
359 *
360 * @param[in] info Type to output.
361 *
362 * @return Formatted string.
363 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100364inline std::string to_string(const arm_compute::NormalizationLayerInfo &info)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100365{
366 std::stringstream str;
Michalis Spyroud466c2d2018-01-30 10:54:39 +0000367 str << info.type() << ":NormSize=" << info.norm_size();
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100368 return str.str();
369}
370
Alex Gildayc357c472018-03-21 13:54:09 +0000371/** Formatted output of @ref NormalizationLayerInfo.
372 *
373 * @param[out] os Output stream.
374 * @param[in] info Type to output.
375 *
376 * @return Modified output stream.
377 */
Georgios Pinitas6f669f02017-09-26 12:32:57 +0100378inline ::std::ostream &operator<<(::std::ostream &os, const NormalizationLayerInfo &info)
379{
Michalis Spyroud466c2d2018-01-30 10:54:39 +0000380 os << info.type() << ":NormSize=" << info.norm_size();
Georgios Pinitas6f669f02017-09-26 12:32:57 +0100381 return os;
382}
383
Alex Gildayc357c472018-03-21 13:54:09 +0000384/** Formatted output of the PoolingType type.
385 *
386 * @param[out] os Output stream.
387 * @param[in] pool_type Type to output.
388 *
389 * @return Modified output stream.
390 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100391inline ::std::ostream &operator<<(::std::ostream &os, const PoolingType &pool_type)
392{
393 switch(pool_type)
394 {
395 case PoolingType::AVG:
396 os << "AVG";
397 break;
398 case PoolingType::MAX:
399 os << "MAX";
400 break;
Georgios Pinitascdf51452017-08-31 14:21:36 +0100401 case PoolingType::L2:
402 os << "L2";
403 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100404 default:
405 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
406 }
407
408 return os;
409}
410
Alex Gildayc357c472018-03-21 13:54:09 +0000411/** Formatted output of @ref PoolingLayerInfo.
412 *
413 * @param[out] os Output stream.
414 * @param[in] info Type to output.
415 *
416 * @return Modified output stream.
417 */
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100418inline ::std::ostream &operator<<(::std::ostream &os, const PoolingLayerInfo &info)
419{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100420 os << info.pool_type();
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100421
422 return os;
423}
424
Alex Gildayc357c472018-03-21 13:54:09 +0000425/** Formatted output of @ref RoundingPolicy.
426 *
427 * @param[in] rounding_policy Type to output.
428 *
429 * @return Formatted string.
430 */
John Richardsondd715f22017-09-18 16:10:48 +0100431inline std::string to_string(const RoundingPolicy &rounding_policy)
432{
433 std::stringstream str;
434 str << rounding_policy;
435 return str.str();
436}
437
Alex Gildayc357c472018-03-21 13:54:09 +0000438/** Formatted output of the DataLayout type.
439 *
440 * @param[out] os Output stream.
441 * @param[in] data_layout Type to output.
442 *
443 * @return Modified output stream.
444 */
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000445inline ::std::ostream &operator<<(::std::ostream &os, const DataLayout &data_layout)
446{
447 switch(data_layout)
448 {
449 case DataLayout::UNKNOWN:
450 os << "UNKNOWN";
451 break;
452 case DataLayout::NHWC:
453 os << "NHWC";
454 break;
455 case DataLayout::NCHW:
456 os << "NCHW";
457 break;
458 default:
459 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
460 }
461
462 return os;
463}
464
Alex Gildayc357c472018-03-21 13:54:09 +0000465/** Formatted output of the DataLayout type.
466 *
467 * @param[in] data_layout Type to output.
468 *
469 * @return Formatted string.
470 */
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000471inline std::string to_string(const arm_compute::DataLayout &data_layout)
472{
473 std::stringstream str;
474 str << data_layout;
475 return str.str();
476}
477
Alex Gildayc357c472018-03-21 13:54:09 +0000478/** Formatted output of the DataType type.
479 *
480 * @param[out] os Output stream.
481 * @param[in] data_type Type to output.
482 *
483 * @return Modified output stream.
484 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100485inline ::std::ostream &operator<<(::std::ostream &os, const DataType &data_type)
486{
487 switch(data_type)
488 {
489 case DataType::UNKNOWN:
490 os << "UNKNOWN";
491 break;
492 case DataType::U8:
493 os << "U8";
494 break;
Chunosovd621bca2017-11-03 17:33:15 +0700495 case DataType::QASYMM8:
496 os << "QASYMM8";
497 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100498 case DataType::S8:
499 os << "S8";
500 break;
501 case DataType::U16:
502 os << "U16";
503 break;
504 case DataType::S16:
505 os << "S16";
506 break;
507 case DataType::U32:
508 os << "U32";
509 break;
510 case DataType::S32:
511 os << "S32";
512 break;
513 case DataType::U64:
514 os << "U64";
515 break;
516 case DataType::S64:
517 os << "S64";
518 break;
519 case DataType::F16:
520 os << "F16";
521 break;
522 case DataType::F32:
523 os << "F32";
524 break;
525 case DataType::F64:
526 os << "F64";
527 break;
528 case DataType::SIZET:
529 os << "SIZET";
530 break;
531 default:
532 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
533 }
534
535 return os;
536}
537
Alex Gildayc357c472018-03-21 13:54:09 +0000538/** Formatted output of the DataType type.
539 *
540 * @param[in] data_type Type to output.
541 *
542 * @return Formatted string.
543 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100544inline std::string to_string(const arm_compute::DataType &data_type)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100545{
546 std::stringstream str;
547 str << data_type;
548 return str.str();
549}
550
Alex Gildayc357c472018-03-21 13:54:09 +0000551/** Formatted output of the Format type.
552 *
553 * @param[out] os Output stream.
554 * @param[in] format Type to output.
555 *
556 * @return Modified output stream.
557 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100558inline ::std::ostream &operator<<(::std::ostream &os, const Format &format)
559{
560 switch(format)
561 {
562 case Format::UNKNOWN:
563 os << "UNKNOWN";
564 break;
565 case Format::U8:
566 os << "U8";
567 break;
568 case Format::S16:
569 os << "S16";
570 break;
571 case Format::U16:
572 os << "U16";
573 break;
574 case Format::S32:
575 os << "S32";
576 break;
577 case Format::U32:
578 os << "U32";
579 break;
580 case Format::F16:
581 os << "F16";
582 break;
583 case Format::F32:
584 os << "F32";
585 break;
586 case Format::UV88:
587 os << "UV88";
588 break;
589 case Format::RGB888:
590 os << "RGB888";
591 break;
592 case Format::RGBA8888:
593 os << "RGBA8888";
594 break;
595 case Format::YUV444:
596 os << "YUV444";
597 break;
598 case Format::YUYV422:
599 os << "YUYV422";
600 break;
601 case Format::NV12:
602 os << "NV12";
603 break;
604 case Format::NV21:
605 os << "NV21";
606 break;
607 case Format::IYUV:
608 os << "IYUV";
609 break;
610 case Format::UYVY422:
611 os << "UYVY422";
612 break;
613 default:
614 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
615 }
616
617 return os;
618}
619
Alex Gildayc357c472018-03-21 13:54:09 +0000620/** Formatted output of the Format type.
621 *
622 * @param[in] format Type to output.
623 *
624 * @return Formatted string.
625 */
Moritz Pflanzer7655a672017-09-23 11:57:33 +0100626inline std::string to_string(const Format &format)
627{
628 std::stringstream str;
629 str << format;
630 return str.str();
631}
632
Alex Gildayc357c472018-03-21 13:54:09 +0000633/** Formatted output of the Channel type.
634 *
635 * @param[out] os Output stream.
636 * @param[in] channel Type to output.
637 *
638 * @return Modified output stream.
639 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100640inline ::std::ostream &operator<<(::std::ostream &os, const Channel &channel)
641{
642 switch(channel)
643 {
644 case Channel::UNKNOWN:
645 os << "UNKNOWN";
646 break;
647 case Channel::C0:
648 os << "C0";
649 break;
650 case Channel::C1:
651 os << "C1";
652 break;
653 case Channel::C2:
654 os << "C2";
655 break;
656 case Channel::C3:
657 os << "C3";
658 break;
659 case Channel::R:
660 os << "R";
661 break;
662 case Channel::G:
663 os << "G";
664 break;
665 case Channel::B:
666 os << "B";
667 break;
668 case Channel::A:
669 os << "A";
670 break;
671 case Channel::Y:
672 os << "Y";
673 break;
674 case Channel::U:
675 os << "U";
676 break;
677 case Channel::V:
678 os << "V";
679 break;
680 default:
681 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
682 }
683
684 return os;
685}
686
Alex Gildayc357c472018-03-21 13:54:09 +0000687/** Formatted output of the Channel type.
688 *
689 * @param[in] channel Type to output.
690 *
691 * @return Formatted string.
692 */
Ioan-Cristian Szabo9414f642017-10-27 17:35:40 +0100693inline std::string to_string(const Channel &channel)
694{
695 std::stringstream str;
696 str << channel;
697 return str.str();
698}
699
Alex Gildayc357c472018-03-21 13:54:09 +0000700/** Formatted output of the BorderMode type.
701 *
702 * @param[out] os Output stream.
703 * @param[in] mode Type to output.
704 *
705 * @return Modified output stream.
706 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100707inline ::std::ostream &operator<<(::std::ostream &os, const BorderMode &mode)
708{
709 switch(mode)
710 {
711 case BorderMode::UNDEFINED:
712 os << "UNDEFINED";
713 break;
714 case BorderMode::CONSTANT:
715 os << "CONSTANT";
716 break;
717 case BorderMode::REPLICATE:
718 os << "REPLICATE";
719 break;
720 default:
721 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
722 }
723
724 return os;
725}
726
Alex Gildayc357c472018-03-21 13:54:09 +0000727/** Formatted output of the BorderSize type.
728 *
729 * @param[out] os Output stream.
730 * @param[in] border Type to output.
731 *
732 * @return Modified output stream.
733 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100734inline ::std::ostream &operator<<(::std::ostream &os, const BorderSize &border)
735{
Moritz Pflanzerc87fbf82017-07-18 14:02:10 +0100736 os << border.top << ","
737 << border.right << ","
738 << border.bottom << ","
739 << border.left;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100740
741 return os;
742}
Anthony Barbier2a07e182017-08-04 18:20:27 +0100743
Alex Gildayc357c472018-03-21 13:54:09 +0000744/** Formatted output of the InterpolationPolicy type.
745 *
746 * @param[out] os Output stream.
747 * @param[in] policy Type to output.
748 *
749 * @return Modified output stream.
750 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100751inline ::std::ostream &operator<<(::std::ostream &os, const InterpolationPolicy &policy)
752{
753 switch(policy)
754 {
755 case InterpolationPolicy::NEAREST_NEIGHBOR:
756 os << "NEAREST_NEIGHBOR";
757 break;
758 case InterpolationPolicy::BILINEAR:
759 os << "BILINEAR";
760 break;
761 case InterpolationPolicy::AREA:
762 os << "AREA";
763 break;
764 default:
765 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
766 }
767
768 return os;
769}
770
Alex Gildayc357c472018-03-21 13:54:09 +0000771/** Formatted output of the SamplingPolicy type.
772 *
773 * @param[out] os Output stream.
774 * @param[in] policy Type to output.
775 *
776 * @return Modified output stream.
777 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700778inline ::std::ostream &operator<<(::std::ostream &os, const SamplingPolicy &policy)
779{
780 switch(policy)
781 {
782 case SamplingPolicy::CENTER:
783 os << "CENTER";
784 break;
785 case SamplingPolicy::TOP_LEFT:
786 os << "TOP_LEFT";
787 break;
788 default:
789 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
790 }
791
792 return os;
793}
794
Alex Gildayc357c472018-03-21 13:54:09 +0000795/** Formatted output of the TensorInfo type.
796 *
797 * @param[in] info Type to output.
798 *
799 * @return Formatted string.
800 */
Georgios Pinitas3faea252017-10-30 14:13:50 +0000801inline std::string to_string(const TensorInfo &info)
802{
803 std::stringstream str;
804 str << "{Shape=" << info.tensor_shape() << ","
805 << "Type=" << info.data_type() << ","
Vidhya Sudhan Loganathan7485d5a2018-07-04 09:34:00 +0100806 << "Channels=" << info.num_channels() << "}";
Georgios Pinitas3faea252017-10-30 14:13:50 +0000807 return str.str();
808}
809
Abe Mbise925ca0f2017-10-02 19:16:33 +0100810//FIXME: Check why this doesn't work and the TensorShape and Coordinates overload are needed
Alex Gildayc357c472018-03-21 13:54:09 +0000811/** Formatted output of the Dimensions type.
812 *
813 * @param[in] dimensions Type to output.
814 *
815 * @return Formatted string.
816 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100817template <typename T>
818inline std::string to_string(const Dimensions<T> &dimensions)
819{
820 std::stringstream str;
821 str << dimensions;
822 return str.str();
823}
824
Alex Gildayc357c472018-03-21 13:54:09 +0000825/** Formatted output of the Strides type.
826 *
827 * @param[in] stride Type to output.
828 *
829 * @return Formatted string.
830 */
John Richardsona36eae12017-09-26 16:55:59 +0100831inline std::string to_string(const Strides &stride)
832{
833 std::stringstream str;
834 str << stride;
835 return str.str();
836}
837
Alex Gildayc357c472018-03-21 13:54:09 +0000838/** Formatted output of the TensorShape type.
839 *
840 * @param[in] shape Type to output.
841 *
842 * @return Formatted string.
843 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100844inline std::string to_string(const TensorShape &shape)
845{
846 std::stringstream str;
847 str << shape;
848 return str.str();
849}
850
Alex Gildayc357c472018-03-21 13:54:09 +0000851/** Formatted output of the Coordinates type.
852 *
853 * @param[in] coord Type to output.
854 *
855 * @return Formatted string.
856 */
Abe Mbise925ca0f2017-10-02 19:16:33 +0100857inline std::string to_string(const Coordinates &coord)
858{
859 std::stringstream str;
860 str << coord;
861 return str.str();
862}
863
Anthony Barbierb940fd62018-06-04 14:14:32 +0100864/** Formatted output of the GEMMReshapeInfo type.
865 *
866 * @param[out] os Output stream.
867 * @param[in] info Type to output.
868 *
869 * @return Modified output stream.
870 */
871inline ::std::ostream &operator<<(::std::ostream &os, const GEMMReshapeInfo &info)
872{
873 os << "{m=" << info.m() << ",";
874 os << "n=" << info.n() << ",";
875 os << "k=" << info.k() << ",";
876 os << "mult_transpose1xW_width=" << info.mult_transpose1xW_width() << ",";
877 os << "mult_interleave4x4_height=" << info.mult_interleave4x4_height();
878 os << "}";
879
880 return os;
881}
882
883/** Formatted output of the GEMMInfo type.
884 *
885 * @param[out] os Output stream.
886 * @param[in] info Type to output.
887 *
888 * @return Modified output stream.
889 */
890inline ::std::ostream &operator<<(::std::ostream &os, const GEMMInfo &info)
891{
892 os << "{is_a_reshaped=" << info.is_a_reshaped() << ",";
893 os << "is_b_reshaped=" << info.is_b_reshaped() << ",";
894 os << "reshape_b_only_on_first_run=" << info.reshape_b_only_on_first_run() << ",";
Anthony Barbierb940fd62018-06-04 14:14:32 +0100895 os << "}";
896
897 return os;
898}
899
900/** Formatted output of the Window::Dimension type.
901 *
902 * @param[out] os Output stream.
903 * @param[in] dim Type to output.
904 *
905 * @return Modified output stream.
906 */
907inline ::std::ostream &operator<<(::std::ostream &os, const Window::Dimension &dim)
908{
909 os << "{start=" << dim.start() << ", end=" << dim.end() << ", step=" << dim.step() << "}";
910
911 return os;
912}
913/** Formatted output of the Window type.
914 *
915 * @param[out] os Output stream.
916 * @param[in] win Type to output.
917 *
918 * @return Modified output stream.
919 */
920inline ::std::ostream &operator<<(::std::ostream &os, const Window &win)
921{
922 os << "{";
923 for(unsigned int i = 0; i < Coordinates::num_max_dimensions; i++)
924 {
925 if(i > 0)
926 {
927 os << ", ";
928 }
929 os << win[i];
930 }
931 os << "}";
932
933 return os;
934}
935
936/** Formatted output of the WeightsInfo type.
937 *
938 * @param[in] info Type to output.
939 *
940 * @return Formatted string.
941 */
942inline std::string to_string(const WeightsInfo &info)
943{
944 std::stringstream str;
945 str << info;
946 return str.str();
947}
948
949/** Formatted output of the GEMMReshapeInfo type.
950 *
951 * @param[in] info Type to output.
952 *
953 * @return Formatted string.
954 */
955inline std::string to_string(const GEMMReshapeInfo &info)
956{
957 std::stringstream str;
958 str << info;
959 return str.str();
960}
961
962/** Formatted output of the GEMMInfo type.
963 *
964 * @param[in] info Type to output.
965 *
966 * @return Formatted string.
967 */
968inline std::string to_string(const GEMMInfo &info)
969{
970 std::stringstream str;
971 str << info;
972 return str.str();
973}
974
975/** Formatted output of the Window::Dimension type.
976 *
977 * @param[in] dim Type to output.
978 *
979 * @return Formatted string.
980 */
981inline std::string to_string(const Window::Dimension &dim)
982{
983 std::stringstream str;
984 str << dim;
985 return str.str();
986}
987/** Formatted output of the Window type.
988 *
989 * @param[in] win Type to output.
990 *
991 * @return Formatted string.
992 */
993inline std::string to_string(const Window &win)
994{
995 std::stringstream str;
996 str << win;
997 return str.str();
998}
999
Alex Gildayc357c472018-03-21 13:54:09 +00001000/** Formatted output of the Rectangle type.
1001 *
1002 * @param[out] os Output stream.
1003 * @param[in] rect Type to output.
1004 *
1005 * @return Modified output stream.
1006 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001007inline ::std::ostream &operator<<(::std::ostream &os, const Rectangle &rect)
1008{
1009 os << rect.width << "x" << rect.height;
1010 os << "+" << rect.x << "+" << rect.y;
1011
1012 return os;
1013}
1014
Alex Gildayc357c472018-03-21 13:54:09 +00001015/** Formatted output of the PadStrideInfo type.
1016 *
1017 * @param[out] os Output stream.
1018 * @param[in] pad_stride_info Type to output.
1019 *
1020 * @return Modified output stream.
1021 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001022inline ::std::ostream &operator<<(::std::ostream &os, const PadStrideInfo &pad_stride_info)
1023{
1024 os << pad_stride_info.stride().first << "," << pad_stride_info.stride().second;
1025 os << ";";
Jaroslaw Rzepeckia1ed41f2017-10-13 11:13:58 +01001026 os << pad_stride_info.pad_left() << "," << pad_stride_info.pad_right() << ","
1027 << pad_stride_info.pad_top() << "," << pad_stride_info.pad_bottom();
Anthony Barbier2a07e182017-08-04 18:20:27 +01001028
1029 return os;
1030}
1031
Alex Gildayc357c472018-03-21 13:54:09 +00001032/** Formatted output of the PadStrideInfo type.
1033 *
1034 * @param[in] pad_stride_info Type to output.
1035 *
1036 * @return Formatted string.
1037 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001038inline std::string to_string(const PadStrideInfo &pad_stride_info)
1039{
1040 std::stringstream str;
1041 str << pad_stride_info;
1042 return str.str();
1043}
1044
Alex Gildayc357c472018-03-21 13:54:09 +00001045/** Formatted output of the BorderMode type.
1046 *
1047 * @param[in] mode Type to output.
1048 *
1049 * @return Formatted string.
1050 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001051inline std::string to_string(const BorderMode &mode)
1052{
1053 std::stringstream str;
1054 str << mode;
1055 return str.str();
1056}
1057
Alex Gildayc357c472018-03-21 13:54:09 +00001058/** Formatted output of the BorderSize type.
1059 *
1060 * @param[in] border Type to output.
1061 *
1062 * @return Formatted string.
1063 */
John Richardsonb482ce12017-09-18 12:44:01 +01001064inline std::string to_string(const BorderSize &border)
1065{
1066 std::stringstream str;
1067 str << border;
1068 return str.str();
1069}
1070
Alex Gildayc357c472018-03-21 13:54:09 +00001071/** Formatted output of the InterpolationPolicy type.
1072 *
1073 * @param[in] policy Type to output.
1074 *
1075 * @return Formatted string.
1076 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001077inline std::string to_string(const InterpolationPolicy &policy)
1078{
1079 std::stringstream str;
1080 str << policy;
1081 return str.str();
1082}
1083
Alex Gildayc357c472018-03-21 13:54:09 +00001084/** Formatted output of the SamplingPolicy type.
1085 *
1086 * @param[in] policy Type to output.
1087 *
1088 * @return Formatted string.
1089 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +07001090inline std::string to_string(const SamplingPolicy &policy)
1091{
1092 std::stringstream str;
1093 str << policy;
1094 return str.str();
1095}
1096
Alex Gildayc357c472018-03-21 13:54:09 +00001097/** Formatted output of the ConvertPolicy type.
1098 *
1099 * @param[out] os Output stream.
1100 * @param[in] policy Type to output.
1101 *
1102 * @return Modified output stream.
1103 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001104inline ::std::ostream &operator<<(::std::ostream &os, const ConvertPolicy &policy)
1105{
1106 switch(policy)
1107 {
1108 case ConvertPolicy::WRAP:
1109 os << "WRAP";
1110 break;
1111 case ConvertPolicy::SATURATE:
1112 os << "SATURATE";
1113 break;
1114 default:
1115 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1116 }
1117
1118 return os;
1119}
1120
1121inline std::string to_string(const ConvertPolicy &policy)
1122{
1123 std::stringstream str;
1124 str << policy;
1125 return str.str();
1126}
1127
Alex Gildayc357c472018-03-21 13:54:09 +00001128/** Formatted output of the Reduction Operations.
1129 *
1130 * @param[out] os Output stream.
1131 * @param[in] op Type to output.
1132 *
1133 * @return Modified output stream.
1134 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001135inline ::std::ostream &operator<<(::std::ostream &os, const ReductionOperation &op)
1136{
1137 switch(op)
1138 {
1139 case ReductionOperation::SUM_SQUARE:
1140 os << "SUM_SQUARE";
1141 break;
1142 default:
1143 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1144 }
1145
1146 return os;
1147}
1148
Alex Gildayc357c472018-03-21 13:54:09 +00001149/** Formatted output of the Reduction Operations.
1150 *
1151 * @param[in] op Type to output.
1152 *
1153 * @return Formatted string.
1154 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001155inline std::string to_string(const ReductionOperation &op)
1156{
1157 std::stringstream str;
1158 str << op;
1159 return str.str();
1160}
1161
Alex Gildayc357c472018-03-21 13:54:09 +00001162/** Formatted output of the Norm Type.
1163 *
1164 * @param[in] type Type to output.
1165 *
1166 * @return Formatted string.
1167 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001168inline std::string to_string(const NormType &type)
1169{
1170 std::stringstream str;
1171 str << type;
1172 return str.str();
1173}
1174
Alex Gildayc357c472018-03-21 13:54:09 +00001175/** Formatted output of the Pooling Type.
1176 *
1177 * @param[in] type Type to output.
1178 *
1179 * @return Formatted string.
1180 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001181inline std::string to_string(const PoolingType &type)
1182{
1183 std::stringstream str;
1184 str << type;
1185 return str.str();
1186}
1187
Alex Gildayc357c472018-03-21 13:54:09 +00001188/** Formatted output of the Pooling Layer Info.
1189 *
1190 * @param[in] info Type to output.
1191 *
1192 * @return Formatted string.
1193 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001194inline std::string to_string(const PoolingLayerInfo &info)
1195{
1196 std::stringstream str;
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001197 str << "{Type=" << info.pool_type() << ","
1198 << "IsGlobalPooling=" << info.is_global_pooling();
1199 if(!info.is_global_pooling())
1200 {
1201 str << ","
Isabella Gottardi6e464c32018-01-26 12:32:45 +00001202 << "PoolSize=" << info.pool_size().width << "," << info.pool_size().height << ","
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001203 << "PadStride=" << info.pad_stride_info();
1204 }
1205 str << "}";
Anthony Barbier2a07e182017-08-04 18:20:27 +01001206 return str.str();
1207}
1208
Alex Gildayc357c472018-03-21 13:54:09 +00001209/** Formatted output of the KeyPoint type.
1210 *
1211 * @param[out] os Output stream
1212 * @param[in] point Type to output.
1213 *
1214 * @return Modified output stream.
1215 */
Moritz Pflanzer6c6597c2017-09-24 12:09:41 +01001216inline ::std::ostream &operator<<(::std::ostream &os, const KeyPoint &point)
1217{
1218 os << "{x=" << point.x << ","
1219 << "y=" << point.y << ","
1220 << "strength=" << point.strength << ","
1221 << "scale=" << point.scale << ","
1222 << "orientation=" << point.orientation << ","
1223 << "tracking_status=" << point.tracking_status << ","
1224 << "error=" << point.error << "}";
1225
1226 return os;
1227}
John Richardson63e50412017-10-13 20:51:42 +01001228
Alex Gildayc357c472018-03-21 13:54:09 +00001229/** Formatted output of the PhaseType type.
1230 *
1231 * @param[out] os Output stream
1232 * @param[in] phase_type Type to output.
1233 *
1234 * @return Modified output stream.
1235 */
John Richardson63e50412017-10-13 20:51:42 +01001236inline ::std::ostream &operator<<(::std::ostream &os, const PhaseType &phase_type)
1237{
1238 switch(phase_type)
1239 {
1240 case PhaseType::SIGNED:
1241 os << "SIGNED";
1242 break;
1243 case PhaseType::UNSIGNED:
1244 os << "UNSIGNED";
1245 break;
1246 default:
1247 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1248 }
1249
1250 return os;
1251}
1252
Alex Gildayc357c472018-03-21 13:54:09 +00001253/** Formatted output of the PhaseType type.
1254 *
1255 * @param[in] type Type to output.
1256 *
1257 * @return Formatted string.
1258 */
John Richardson63e50412017-10-13 20:51:42 +01001259inline std::string to_string(const arm_compute::PhaseType &type)
1260{
1261 std::stringstream str;
1262 str << type;
1263 return str.str();
1264}
John Richardson3c5f9492017-10-04 15:27:37 +01001265
Alex Gildayc357c472018-03-21 13:54:09 +00001266/** Formatted output of the MagnitudeType type.
1267 *
1268 * @param[out] os Output stream
1269 * @param[in] magnitude_type Type to output.
1270 *
1271 * @return Modified output stream.
1272 */
John Richardson3c5f9492017-10-04 15:27:37 +01001273inline ::std::ostream &operator<<(::std::ostream &os, const MagnitudeType &magnitude_type)
1274{
1275 switch(magnitude_type)
1276 {
1277 case MagnitudeType::L1NORM:
1278 os << "L1NORM";
1279 break;
1280 case MagnitudeType::L2NORM:
1281 os << "L2NORM";
1282 break;
1283 default:
1284 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1285 }
1286
1287 return os;
1288}
1289
Alex Gildayc357c472018-03-21 13:54:09 +00001290/** Formatted output of the MagnitudeType type.
1291 *
1292 * @param[in] type Type to output.
1293 *
1294 * @return Formatted string.
1295 */
John Richardson3c5f9492017-10-04 15:27:37 +01001296inline std::string to_string(const arm_compute::MagnitudeType &type)
1297{
1298 std::stringstream str;
1299 str << type;
1300 return str.str();
1301}
John Richardson1c529922017-11-01 10:57:48 +00001302
Alex Gildayc357c472018-03-21 13:54:09 +00001303/** Formatted output of the GradientDimension type.
1304 *
1305 * @param[out] os Output stream
1306 * @param[in] dim Type to output
1307 *
1308 * @return Modified output stream.
1309 */
John Richardson1c529922017-11-01 10:57:48 +00001310inline ::std::ostream &operator<<(::std::ostream &os, const GradientDimension &dim)
1311{
1312 switch(dim)
1313 {
1314 case GradientDimension::GRAD_X:
1315 os << "GRAD_X";
1316 break;
1317 case GradientDimension::GRAD_Y:
1318 os << "GRAD_Y";
1319 break;
1320 case GradientDimension::GRAD_XY:
1321 os << "GRAD_XY";
1322 break;
1323 default:
1324 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1325 }
1326
1327 return os;
1328}
1329
Alex Gildayc357c472018-03-21 13:54:09 +00001330/** Formatted output of the GradientDimension type.
1331 *
1332 * @param[in] type Type to output
1333 *
1334 * @return Formatted string.
1335 */
John Richardson1c529922017-11-01 10:57:48 +00001336inline std::string to_string(const arm_compute::GradientDimension &type)
1337{
1338 std::stringstream str;
1339 str << type;
1340 return str.str();
1341}
John Richardson25f23682017-11-27 14:35:09 +00001342
Alex Gildayc357c472018-03-21 13:54:09 +00001343/** Formatted output of the HOGNormType type.
1344 *
1345 * @param[out] os Output stream
1346 * @param[in] norm_type Type to output
1347 *
1348 * @return Modified output stream.
1349 */
John Richardson25f23682017-11-27 14:35:09 +00001350inline ::std::ostream &operator<<(::std::ostream &os, const HOGNormType &norm_type)
1351{
1352 switch(norm_type)
1353 {
1354 case HOGNormType::L1_NORM:
1355 os << "L1_NORM";
1356 break;
1357 case HOGNormType::L2_NORM:
1358 os << "L2_NORM";
1359 break;
1360 case HOGNormType::L2HYS_NORM:
1361 os << "L2HYS_NORM";
1362 break;
1363 default:
1364 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1365 }
1366
1367 return os;
1368}
1369
Alex Gildayc357c472018-03-21 13:54:09 +00001370/** Formatted output of the HOGNormType type.
1371 *
1372 * @param[in] type Type to output
1373 *
1374 * @return Formatted string.
1375 */
John Richardson25f23682017-11-27 14:35:09 +00001376inline std::string to_string(const HOGNormType &type)
1377{
1378 std::stringstream str;
1379 str << type;
1380 return str.str();
1381}
1382
Alex Gildayc357c472018-03-21 13:54:09 +00001383/** Formatted output of the Size2D type.
1384 *
1385 * @param[out] os Output stream
1386 * @param[in] size Type to output
1387 *
1388 * @return Modified output stream.
1389 */
John Richardson25f23682017-11-27 14:35:09 +00001390inline ::std::ostream &operator<<(::std::ostream &os, const Size2D &size)
1391{
1392 os << size.width << "x" << size.height;
1393
1394 return os;
1395}
1396
Alex Gildayc357c472018-03-21 13:54:09 +00001397/** Formatted output of the Size2D type.
1398 *
1399 * @param[in] type Type to output
1400 *
1401 * @return Formatted string.
1402 */
John Richardson25f23682017-11-27 14:35:09 +00001403inline std::string to_string(const Size2D &type)
1404{
1405 std::stringstream str;
1406 str << type;
1407 return str.str();
1408}
1409
Alex Gildayc357c472018-03-21 13:54:09 +00001410/** Formatted output of the HOGInfo type.
1411 *
1412 * @param[out] os Output stream
1413 * @param[in] hog_info Type to output
1414 *
1415 * @return Modified output stream.
1416 */
John Richardson25f23682017-11-27 14:35:09 +00001417inline ::std::ostream &operator<<(::std::ostream &os, const HOGInfo &hog_info)
1418{
1419 os << "{CellSize=" << hog_info.cell_size() << ","
1420 << "BlockSize=" << hog_info.block_size() << ","
1421 << "DetectionWindowSize=" << hog_info.detection_window_size() << ","
1422 << "BlockStride=" << hog_info.block_stride() << ","
1423 << "NumBins=" << hog_info.num_bins() << ","
1424 << "NormType=" << hog_info.normalization_type() << ","
1425 << "L2HystThreshold=" << hog_info.l2_hyst_threshold() << ","
1426 << "PhaseType=" << hog_info.phase_type() << "}";
1427
1428 return os;
1429}
1430
Alex Gildayc357c472018-03-21 13:54:09 +00001431/** Formatted output of the HOGInfo type.
1432 *
1433 * @param[in] type Type to output
1434 *
1435 * @return Formatted string.
1436 */
John Richardson25f23682017-11-27 14:35:09 +00001437inline std::string to_string(const HOGInfo &type)
1438{
1439 std::stringstream str;
1440 str << type;
1441 return str.str();
1442}
1443
Alex Gildayc357c472018-03-21 13:54:09 +00001444/** Formatted output of the ConvolutionMethod type.
1445 *
1446 * @param[out] os Output stream
1447 * @param[in] conv_method Type to output
1448 *
1449 * @return Modified output stream.
1450 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001451inline ::std::ostream &operator<<(::std::ostream &os, const ConvolutionMethod &conv_method)
1452{
1453 switch(conv_method)
1454 {
1455 case ConvolutionMethod::GEMM:
1456 os << "GEMM";
1457 break;
1458 case ConvolutionMethod::DIRECT:
1459 os << "DIRECT";
1460 break;
1461 case ConvolutionMethod::WINOGRAD:
1462 os << "WINOGRAD";
1463 break;
1464 default:
1465 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1466 }
1467
1468 return os;
1469}
1470
Alex Gildayc357c472018-03-21 13:54:09 +00001471/** Formatted output of the ConvolutionMethod type.
1472 *
1473 * @param[in] conv_method Type to output
1474 *
1475 * @return Formatted string.
1476 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001477inline std::string to_string(const ConvolutionMethod &conv_method)
1478{
1479 std::stringstream str;
1480 str << conv_method;
1481 return str.str();
1482}
1483
Alex Gildayc357c472018-03-21 13:54:09 +00001484/** Formatted output of the GPUTarget type.
1485 *
1486 * @param[out] os Output stream
1487 * @param[in] gpu_target Type to output
1488 *
1489 * @return Modified output stream.
1490 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001491inline ::std::ostream &operator<<(::std::ostream &os, const GPUTarget &gpu_target)
1492{
1493 switch(gpu_target)
1494 {
1495 case GPUTarget::GPU_ARCH_MASK:
1496 os << "GPU_ARCH_MASK";
1497 break;
1498 case GPUTarget::MIDGARD:
1499 os << "MIDGARD";
1500 break;
1501 case GPUTarget::BIFROST:
1502 os << "BIFROST";
1503 break;
1504 case GPUTarget::T600:
1505 os << "T600";
1506 break;
1507 case GPUTarget::T700:
1508 os << "T700";
1509 break;
1510 case GPUTarget::T800:
1511 os << "T800";
1512 break;
Michalis Spyroua9676112018-02-22 18:07:43 +00001513 case GPUTarget::G71:
1514 os << "G71";
1515 break;
1516 case GPUTarget::G72:
1517 os << "G72";
1518 break;
1519 case GPUTarget::G51:
1520 os << "G51";
1521 break;
1522 case GPUTarget::G51BIG:
1523 os << "G51BIG";
1524 break;
1525 case GPUTarget::G51LIT:
1526 os << "G51LIT";
1527 break;
1528 case GPUTarget::TNOX:
1529 os << "TNOX";
1530 break;
1531 case GPUTarget::TTRX:
1532 os << "TTRX";
1533 break;
1534 case GPUTarget::TBOX:
1535 os << "TBOX";
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001536 break;
1537 default:
1538 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1539 }
1540
1541 return os;
1542}
1543
Alex Gildayc357c472018-03-21 13:54:09 +00001544/** Formatted output of the GPUTarget type.
1545 *
1546 * @param[in] gpu_target Type to output
1547 *
1548 * @return Formatted string.
1549 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001550inline std::string to_string(const GPUTarget &gpu_target)
1551{
1552 std::stringstream str;
1553 str << gpu_target;
1554 return str.str();
1555}
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00001556
John Richardson8de92612018-02-22 14:09:31 +00001557/** Formatted output of the DetectionWindow type.
1558 *
1559 * @param[out] os Output stream
1560 * @param[in] detection_window Type to output
1561 *
1562 * @return Modified output stream.
1563 */
John Richardson684cb0f2018-01-09 11:17:00 +00001564inline ::std::ostream &operator<<(::std::ostream &os, const DetectionWindow &detection_window)
1565{
1566 os << "{x=" << detection_window.x << ","
1567 << "y=" << detection_window.y << ","
1568 << "width=" << detection_window.width << ","
1569 << "height=" << detection_window.height << ","
1570 << "idx_class=" << detection_window.idx_class << ","
1571 << "score=" << detection_window.score << "}";
1572
1573 return os;
1574}
1575
John Richardson8de92612018-02-22 14:09:31 +00001576/** Formatted output of the DetectionWindow type.
1577 *
1578 * @param[in] detection_window Type to output
1579 *
1580 * @return Formatted string.
1581 */
1582inline std::string to_string(const DetectionWindow &detection_window)
1583{
1584 std::stringstream str;
1585 str << detection_window;
1586 return str.str();
1587}
1588
1589/** Formatted output of the Termination type.
1590 *
1591 * @param[out] os Output stream
1592 * @param[in] termination Type to output
1593 *
1594 * @return Modified output stream.
1595 */
1596inline ::std::ostream &operator<<(::std::ostream &os, const Termination &termination)
1597{
1598 switch(termination)
1599 {
1600 case Termination::TERM_CRITERIA_EPSILON:
1601 os << "TERM_CRITERIA_EPSILON";
1602 break;
1603 case Termination::TERM_CRITERIA_ITERATIONS:
1604 os << "TERM_CRITERIA_ITERATIONS";
1605 break;
1606 case Termination::TERM_CRITERIA_BOTH:
1607 os << "TERM_CRITERIA_BOTH";
1608 break;
1609 default:
1610 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1611 }
1612
1613 return os;
1614}
1615
1616/** Formatted output of the Termination type.
1617 *
1618 * @param[in] termination Type to output
1619 *
1620 * @return Formatted string.
1621 */
1622inline std::string to_string(const Termination &termination)
1623{
1624 std::stringstream str;
1625 str << termination;
1626 return str.str();
1627}
1628
Anthony Barbier671a11e2018-07-06 15:11:36 +01001629/** Formatted output of a vector of objects.
1630 *
1631 * @param[out] os Output stream
1632 * @param[in] args Vector of objects to print
1633 *
1634 * @return Modified output stream.
1635 */
1636template <typename T>
1637inline ::std::ostream &operator<<(::std::ostream &os, const std::vector<T> &args)
1638{
1639 os << "[";
1640 bool first = true;
1641 for(auto &arg : args)
1642 {
1643 if(first)
1644 {
1645 first = false;
1646 }
1647 else
1648 {
1649 os << ", ";
1650 }
1651 os << arg;
1652 }
1653 os << "]";
1654 return os;
1655}
1656
1657/** Formatted output of a vector of objects.
1658 *
1659 * @param[in] args Vector of objects to print
1660 *
1661 * @return String representing args.
1662 */
1663template <typename T>
1664std::string to_string(const std::vector<T> &args)
1665{
1666 std::stringstream str;
1667 str << args;
1668 return str.str();
1669}
1670
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00001671/** Formatted output of the WinogradInfo type. */
1672inline ::std::ostream &operator<<(::std::ostream &os, const WinogradInfo &info)
1673{
1674 os << "{OutputTileSize=" << info.output_tile_size << ","
1675 << "KernelSize=" << info.kernel_size << ","
1676 << "PadStride=" << info.convolution_info << ","
1677 << "OutputDataLayout=" << info.output_data_layout << "}";
1678
1679 return os;
1680}
1681
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00001682inline std::string to_string(const WinogradInfo &type)
1683{
1684 std::stringstream str;
1685 str << type;
1686 return str.str();
1687}
Anthony Barbier671a11e2018-07-06 15:11:36 +01001688
1689/** Fallback method: try to use std::to_string:
1690 *
1691 * @param[in] val Value to convert to string
1692 *
1693 * @return String representing val.
1694 */
1695template <typename T>
1696inline std::string to_string(const T &val)
1697{
1698 return support::cpp11::to_string(val);
1699}
1700
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001701} // namespace arm_compute
John Richardson8de92612018-02-22 14:09:31 +00001702#endif /* __ARM_COMPUTE_TEST_TYPE_PRINTER_H__ */