blob: 8bfdba9725dc4a9122c65bc291d498bfe4ba225c [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
Georgios Pinitase2220552018-07-20 13:23:44 +0100478/** Formatted output of the DataLayoutDimension type.
479 *
480 * @param[out] os Output stream.
481 * @param[in] data_layout_dim Data layout dimension to print.
482 *
483 * @return Modified output stream.
484 */
485inline ::std::ostream &operator<<(::std::ostream &os, const DataLayoutDimension &data_layout_dim)
486{
487 switch(data_layout_dim)
488 {
489 case DataLayoutDimension::WIDTH:
490 os << "WIDTH";
491 break;
492 case DataLayoutDimension::HEIGHT:
493 os << "HEIGHT";
494 break;
495 case DataLayoutDimension::CHANNEL:
496 os << "CHANNEL";
497 break;
498 case DataLayoutDimension::BATCHES:
499 os << "BATCHES";
500 break;
501 default:
502 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
503 }
504 return os;
505}
506
Alex Gildayc357c472018-03-21 13:54:09 +0000507/** Formatted output of the DataType type.
508 *
509 * @param[out] os Output stream.
510 * @param[in] data_type Type to output.
511 *
512 * @return Modified output stream.
513 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100514inline ::std::ostream &operator<<(::std::ostream &os, const DataType &data_type)
515{
516 switch(data_type)
517 {
518 case DataType::UNKNOWN:
519 os << "UNKNOWN";
520 break;
521 case DataType::U8:
522 os << "U8";
523 break;
Chunosovd621bca2017-11-03 17:33:15 +0700524 case DataType::QASYMM8:
525 os << "QASYMM8";
526 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100527 case DataType::S8:
528 os << "S8";
529 break;
530 case DataType::U16:
531 os << "U16";
532 break;
533 case DataType::S16:
534 os << "S16";
535 break;
536 case DataType::U32:
537 os << "U32";
538 break;
539 case DataType::S32:
540 os << "S32";
541 break;
542 case DataType::U64:
543 os << "U64";
544 break;
545 case DataType::S64:
546 os << "S64";
547 break;
548 case DataType::F16:
549 os << "F16";
550 break;
551 case DataType::F32:
552 os << "F32";
553 break;
554 case DataType::F64:
555 os << "F64";
556 break;
557 case DataType::SIZET:
558 os << "SIZET";
559 break;
560 default:
561 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
562 }
563
564 return os;
565}
566
Alex Gildayc357c472018-03-21 13:54:09 +0000567/** Formatted output of the DataType type.
568 *
569 * @param[in] data_type Type to output.
570 *
571 * @return Formatted string.
572 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100573inline std::string to_string(const arm_compute::DataType &data_type)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100574{
575 std::stringstream str;
576 str << data_type;
577 return str.str();
578}
579
Alex Gildayc357c472018-03-21 13:54:09 +0000580/** Formatted output of the Format type.
581 *
582 * @param[out] os Output stream.
583 * @param[in] format Type to output.
584 *
585 * @return Modified output stream.
586 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100587inline ::std::ostream &operator<<(::std::ostream &os, const Format &format)
588{
589 switch(format)
590 {
591 case Format::UNKNOWN:
592 os << "UNKNOWN";
593 break;
594 case Format::U8:
595 os << "U8";
596 break;
597 case Format::S16:
598 os << "S16";
599 break;
600 case Format::U16:
601 os << "U16";
602 break;
603 case Format::S32:
604 os << "S32";
605 break;
606 case Format::U32:
607 os << "U32";
608 break;
609 case Format::F16:
610 os << "F16";
611 break;
612 case Format::F32:
613 os << "F32";
614 break;
615 case Format::UV88:
616 os << "UV88";
617 break;
618 case Format::RGB888:
619 os << "RGB888";
620 break;
621 case Format::RGBA8888:
622 os << "RGBA8888";
623 break;
624 case Format::YUV444:
625 os << "YUV444";
626 break;
627 case Format::YUYV422:
628 os << "YUYV422";
629 break;
630 case Format::NV12:
631 os << "NV12";
632 break;
633 case Format::NV21:
634 os << "NV21";
635 break;
636 case Format::IYUV:
637 os << "IYUV";
638 break;
639 case Format::UYVY422:
640 os << "UYVY422";
641 break;
642 default:
643 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
644 }
645
646 return os;
647}
648
Alex Gildayc357c472018-03-21 13:54:09 +0000649/** Formatted output of the Format type.
650 *
651 * @param[in] format Type to output.
652 *
653 * @return Formatted string.
654 */
Moritz Pflanzer7655a672017-09-23 11:57:33 +0100655inline std::string to_string(const Format &format)
656{
657 std::stringstream str;
658 str << format;
659 return str.str();
660}
661
Alex Gildayc357c472018-03-21 13:54:09 +0000662/** Formatted output of the Channel type.
663 *
664 * @param[out] os Output stream.
665 * @param[in] channel Type to output.
666 *
667 * @return Modified output stream.
668 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100669inline ::std::ostream &operator<<(::std::ostream &os, const Channel &channel)
670{
671 switch(channel)
672 {
673 case Channel::UNKNOWN:
674 os << "UNKNOWN";
675 break;
676 case Channel::C0:
677 os << "C0";
678 break;
679 case Channel::C1:
680 os << "C1";
681 break;
682 case Channel::C2:
683 os << "C2";
684 break;
685 case Channel::C3:
686 os << "C3";
687 break;
688 case Channel::R:
689 os << "R";
690 break;
691 case Channel::G:
692 os << "G";
693 break;
694 case Channel::B:
695 os << "B";
696 break;
697 case Channel::A:
698 os << "A";
699 break;
700 case Channel::Y:
701 os << "Y";
702 break;
703 case Channel::U:
704 os << "U";
705 break;
706 case Channel::V:
707 os << "V";
708 break;
709 default:
710 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
711 }
712
713 return os;
714}
715
Alex Gildayc357c472018-03-21 13:54:09 +0000716/** Formatted output of the Channel type.
717 *
718 * @param[in] channel Type to output.
719 *
720 * @return Formatted string.
721 */
Ioan-Cristian Szabo9414f642017-10-27 17:35:40 +0100722inline std::string to_string(const Channel &channel)
723{
724 std::stringstream str;
725 str << channel;
726 return str.str();
727}
728
Alex Gildayc357c472018-03-21 13:54:09 +0000729/** Formatted output of the BorderMode type.
730 *
731 * @param[out] os Output stream.
732 * @param[in] mode Type to output.
733 *
734 * @return Modified output stream.
735 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100736inline ::std::ostream &operator<<(::std::ostream &os, const BorderMode &mode)
737{
738 switch(mode)
739 {
740 case BorderMode::UNDEFINED:
741 os << "UNDEFINED";
742 break;
743 case BorderMode::CONSTANT:
744 os << "CONSTANT";
745 break;
746 case BorderMode::REPLICATE:
747 os << "REPLICATE";
748 break;
749 default:
750 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
751 }
752
753 return os;
754}
755
Alex Gildayc357c472018-03-21 13:54:09 +0000756/** Formatted output of the BorderSize type.
757 *
758 * @param[out] os Output stream.
759 * @param[in] border 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 BorderSize &border)
764{
Moritz Pflanzerc87fbf82017-07-18 14:02:10 +0100765 os << border.top << ","
766 << border.right << ","
767 << border.bottom << ","
768 << border.left;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100769
770 return os;
771}
Anthony Barbier2a07e182017-08-04 18:20:27 +0100772
Alex Gildayc357c472018-03-21 13:54:09 +0000773/** Formatted output of the InterpolationPolicy type.
774 *
775 * @param[out] os Output stream.
776 * @param[in] policy Type to output.
777 *
778 * @return Modified output stream.
779 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100780inline ::std::ostream &operator<<(::std::ostream &os, const InterpolationPolicy &policy)
781{
782 switch(policy)
783 {
784 case InterpolationPolicy::NEAREST_NEIGHBOR:
785 os << "NEAREST_NEIGHBOR";
786 break;
787 case InterpolationPolicy::BILINEAR:
788 os << "BILINEAR";
789 break;
790 case InterpolationPolicy::AREA:
791 os << "AREA";
792 break;
793 default:
794 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
795 }
796
797 return os;
798}
799
Alex Gildayc357c472018-03-21 13:54:09 +0000800/** Formatted output of the SamplingPolicy type.
801 *
802 * @param[out] os Output stream.
803 * @param[in] policy Type to output.
804 *
805 * @return Modified output stream.
806 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700807inline ::std::ostream &operator<<(::std::ostream &os, const SamplingPolicy &policy)
808{
809 switch(policy)
810 {
811 case SamplingPolicy::CENTER:
812 os << "CENTER";
813 break;
814 case SamplingPolicy::TOP_LEFT:
815 os << "TOP_LEFT";
816 break;
817 default:
818 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
819 }
820
821 return os;
822}
823
Alex Gildayc357c472018-03-21 13:54:09 +0000824/** Formatted output of the TensorInfo type.
825 *
826 * @param[in] info Type to output.
827 *
828 * @return Formatted string.
829 */
Georgios Pinitas3faea252017-10-30 14:13:50 +0000830inline std::string to_string(const TensorInfo &info)
831{
832 std::stringstream str;
833 str << "{Shape=" << info.tensor_shape() << ","
834 << "Type=" << info.data_type() << ","
Vidhya Sudhan Loganathan7485d5a2018-07-04 09:34:00 +0100835 << "Channels=" << info.num_channels() << "}";
Georgios Pinitas3faea252017-10-30 14:13:50 +0000836 return str.str();
837}
838
Abe Mbise925ca0f2017-10-02 19:16:33 +0100839//FIXME: Check why this doesn't work and the TensorShape and Coordinates overload are needed
Alex Gildayc357c472018-03-21 13:54:09 +0000840/** Formatted output of the Dimensions type.
841 *
842 * @param[in] dimensions Type to output.
843 *
844 * @return Formatted string.
845 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100846template <typename T>
847inline std::string to_string(const Dimensions<T> &dimensions)
848{
849 std::stringstream str;
850 str << dimensions;
851 return str.str();
852}
853
Alex Gildayc357c472018-03-21 13:54:09 +0000854/** Formatted output of the Strides type.
855 *
856 * @param[in] stride Type to output.
857 *
858 * @return Formatted string.
859 */
John Richardsona36eae12017-09-26 16:55:59 +0100860inline std::string to_string(const Strides &stride)
861{
862 std::stringstream str;
863 str << stride;
864 return str.str();
865}
866
Alex Gildayc357c472018-03-21 13:54:09 +0000867/** Formatted output of the TensorShape type.
868 *
869 * @param[in] shape Type to output.
870 *
871 * @return Formatted string.
872 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100873inline std::string to_string(const TensorShape &shape)
874{
875 std::stringstream str;
876 str << shape;
877 return str.str();
878}
879
Alex Gildayc357c472018-03-21 13:54:09 +0000880/** Formatted output of the Coordinates type.
881 *
882 * @param[in] coord Type to output.
883 *
884 * @return Formatted string.
885 */
Abe Mbise925ca0f2017-10-02 19:16:33 +0100886inline std::string to_string(const Coordinates &coord)
887{
888 std::stringstream str;
889 str << coord;
890 return str.str();
891}
892
Anthony Barbierb940fd62018-06-04 14:14:32 +0100893/** Formatted output of the GEMMReshapeInfo type.
894 *
895 * @param[out] os Output stream.
896 * @param[in] info Type to output.
897 *
898 * @return Modified output stream.
899 */
900inline ::std::ostream &operator<<(::std::ostream &os, const GEMMReshapeInfo &info)
901{
902 os << "{m=" << info.m() << ",";
903 os << "n=" << info.n() << ",";
904 os << "k=" << info.k() << ",";
905 os << "mult_transpose1xW_width=" << info.mult_transpose1xW_width() << ",";
906 os << "mult_interleave4x4_height=" << info.mult_interleave4x4_height();
907 os << "}";
908
909 return os;
910}
911
912/** Formatted output of the GEMMInfo type.
913 *
914 * @param[out] os Output stream.
915 * @param[in] info Type to output.
916 *
917 * @return Modified output stream.
918 */
919inline ::std::ostream &operator<<(::std::ostream &os, const GEMMInfo &info)
920{
921 os << "{is_a_reshaped=" << info.is_a_reshaped() << ",";
922 os << "is_b_reshaped=" << info.is_b_reshaped() << ",";
923 os << "reshape_b_only_on_first_run=" << info.reshape_b_only_on_first_run() << ",";
Anthony Barbierb940fd62018-06-04 14:14:32 +0100924 os << "}";
925
926 return os;
927}
928
929/** Formatted output of the Window::Dimension type.
930 *
931 * @param[out] os Output stream.
932 * @param[in] dim Type to output.
933 *
934 * @return Modified output stream.
935 */
936inline ::std::ostream &operator<<(::std::ostream &os, const Window::Dimension &dim)
937{
938 os << "{start=" << dim.start() << ", end=" << dim.end() << ", step=" << dim.step() << "}";
939
940 return os;
941}
942/** Formatted output of the Window type.
943 *
944 * @param[out] os Output stream.
945 * @param[in] win Type to output.
946 *
947 * @return Modified output stream.
948 */
949inline ::std::ostream &operator<<(::std::ostream &os, const Window &win)
950{
951 os << "{";
952 for(unsigned int i = 0; i < Coordinates::num_max_dimensions; i++)
953 {
954 if(i > 0)
955 {
956 os << ", ";
957 }
958 os << win[i];
959 }
960 os << "}";
961
962 return os;
963}
964
965/** Formatted output of the WeightsInfo type.
966 *
967 * @param[in] info Type to output.
968 *
969 * @return Formatted string.
970 */
971inline std::string to_string(const WeightsInfo &info)
972{
973 std::stringstream str;
974 str << info;
975 return str.str();
976}
977
978/** Formatted output of the GEMMReshapeInfo type.
979 *
980 * @param[in] info Type to output.
981 *
982 * @return Formatted string.
983 */
984inline std::string to_string(const GEMMReshapeInfo &info)
985{
986 std::stringstream str;
987 str << info;
988 return str.str();
989}
990
991/** Formatted output of the GEMMInfo type.
992 *
993 * @param[in] info Type to output.
994 *
995 * @return Formatted string.
996 */
997inline std::string to_string(const GEMMInfo &info)
998{
999 std::stringstream str;
1000 str << info;
1001 return str.str();
1002}
1003
1004/** Formatted output of the Window::Dimension type.
1005 *
1006 * @param[in] dim Type to output.
1007 *
1008 * @return Formatted string.
1009 */
1010inline std::string to_string(const Window::Dimension &dim)
1011{
1012 std::stringstream str;
1013 str << dim;
1014 return str.str();
1015}
1016/** Formatted output of the Window type.
1017 *
1018 * @param[in] win Type to output.
1019 *
1020 * @return Formatted string.
1021 */
1022inline std::string to_string(const Window &win)
1023{
1024 std::stringstream str;
1025 str << win;
1026 return str.str();
1027}
1028
Alex Gildayc357c472018-03-21 13:54:09 +00001029/** Formatted output of the Rectangle type.
1030 *
1031 * @param[out] os Output stream.
1032 * @param[in] rect Type to output.
1033 *
1034 * @return Modified output stream.
1035 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001036inline ::std::ostream &operator<<(::std::ostream &os, const Rectangle &rect)
1037{
1038 os << rect.width << "x" << rect.height;
1039 os << "+" << rect.x << "+" << rect.y;
1040
1041 return os;
1042}
1043
Alex Gildayc357c472018-03-21 13:54:09 +00001044/** Formatted output of the PadStrideInfo type.
1045 *
1046 * @param[out] os Output stream.
1047 * @param[in] pad_stride_info Type to output.
1048 *
1049 * @return Modified output stream.
1050 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001051inline ::std::ostream &operator<<(::std::ostream &os, const PadStrideInfo &pad_stride_info)
1052{
1053 os << pad_stride_info.stride().first << "," << pad_stride_info.stride().second;
1054 os << ";";
Jaroslaw Rzepeckia1ed41f2017-10-13 11:13:58 +01001055 os << pad_stride_info.pad_left() << "," << pad_stride_info.pad_right() << ","
1056 << pad_stride_info.pad_top() << "," << pad_stride_info.pad_bottom();
Anthony Barbier2a07e182017-08-04 18:20:27 +01001057
1058 return os;
1059}
1060
Alex Gildayc357c472018-03-21 13:54:09 +00001061/** Formatted output of the PadStrideInfo type.
1062 *
1063 * @param[in] pad_stride_info Type to output.
1064 *
1065 * @return Formatted string.
1066 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001067inline std::string to_string(const PadStrideInfo &pad_stride_info)
1068{
1069 std::stringstream str;
1070 str << pad_stride_info;
1071 return str.str();
1072}
1073
Alex Gildayc357c472018-03-21 13:54:09 +00001074/** Formatted output of the BorderMode type.
1075 *
1076 * @param[in] mode Type to output.
1077 *
1078 * @return Formatted string.
1079 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001080inline std::string to_string(const BorderMode &mode)
1081{
1082 std::stringstream str;
1083 str << mode;
1084 return str.str();
1085}
1086
Alex Gildayc357c472018-03-21 13:54:09 +00001087/** Formatted output of the BorderSize type.
1088 *
1089 * @param[in] border Type to output.
1090 *
1091 * @return Formatted string.
1092 */
John Richardsonb482ce12017-09-18 12:44:01 +01001093inline std::string to_string(const BorderSize &border)
1094{
1095 std::stringstream str;
1096 str << border;
1097 return str.str();
1098}
1099
Alex Gildayc357c472018-03-21 13:54:09 +00001100/** Formatted output of the InterpolationPolicy type.
1101 *
1102 * @param[in] policy Type to output.
1103 *
1104 * @return Formatted string.
1105 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001106inline std::string to_string(const InterpolationPolicy &policy)
1107{
1108 std::stringstream str;
1109 str << policy;
1110 return str.str();
1111}
1112
Alex Gildayc357c472018-03-21 13:54:09 +00001113/** Formatted output of the SamplingPolicy type.
1114 *
1115 * @param[in] policy Type to output.
1116 *
1117 * @return Formatted string.
1118 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +07001119inline std::string to_string(const SamplingPolicy &policy)
1120{
1121 std::stringstream str;
1122 str << policy;
1123 return str.str();
1124}
1125
Alex Gildayc357c472018-03-21 13:54:09 +00001126/** Formatted output of the ConvertPolicy type.
1127 *
1128 * @param[out] os Output stream.
1129 * @param[in] policy Type to output.
1130 *
1131 * @return Modified output stream.
1132 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001133inline ::std::ostream &operator<<(::std::ostream &os, const ConvertPolicy &policy)
1134{
1135 switch(policy)
1136 {
1137 case ConvertPolicy::WRAP:
1138 os << "WRAP";
1139 break;
1140 case ConvertPolicy::SATURATE:
1141 os << "SATURATE";
1142 break;
1143 default:
1144 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1145 }
1146
1147 return os;
1148}
1149
1150inline std::string to_string(const ConvertPolicy &policy)
1151{
1152 std::stringstream str;
1153 str << policy;
1154 return str.str();
1155}
1156
Alex Gildayc357c472018-03-21 13:54:09 +00001157/** Formatted output of the Reduction Operations.
1158 *
1159 * @param[out] os Output stream.
1160 * @param[in] op Type to output.
1161 *
1162 * @return Modified output stream.
1163 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001164inline ::std::ostream &operator<<(::std::ostream &os, const ReductionOperation &op)
1165{
1166 switch(op)
1167 {
1168 case ReductionOperation::SUM_SQUARE:
1169 os << "SUM_SQUARE";
1170 break;
1171 default:
1172 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1173 }
1174
1175 return os;
1176}
1177
Alex Gildayc357c472018-03-21 13:54:09 +00001178/** Formatted output of the Reduction Operations.
1179 *
1180 * @param[in] op Type to output.
1181 *
1182 * @return Formatted string.
1183 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001184inline std::string to_string(const ReductionOperation &op)
1185{
1186 std::stringstream str;
1187 str << op;
1188 return str.str();
1189}
1190
Alex Gildayc357c472018-03-21 13:54:09 +00001191/** Formatted output of the Norm Type.
1192 *
1193 * @param[in] type Type to output.
1194 *
1195 * @return Formatted string.
1196 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001197inline std::string to_string(const NormType &type)
1198{
1199 std::stringstream str;
1200 str << type;
1201 return str.str();
1202}
1203
Alex Gildayc357c472018-03-21 13:54:09 +00001204/** Formatted output of the Pooling Type.
1205 *
1206 * @param[in] type Type to output.
1207 *
1208 * @return Formatted string.
1209 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001210inline std::string to_string(const PoolingType &type)
1211{
1212 std::stringstream str;
1213 str << type;
1214 return str.str();
1215}
1216
Alex Gildayc357c472018-03-21 13:54:09 +00001217/** Formatted output of the Pooling Layer Info.
1218 *
1219 * @param[in] info Type to output.
1220 *
1221 * @return Formatted string.
1222 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001223inline std::string to_string(const PoolingLayerInfo &info)
1224{
1225 std::stringstream str;
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001226 str << "{Type=" << info.pool_type() << ","
1227 << "IsGlobalPooling=" << info.is_global_pooling();
1228 if(!info.is_global_pooling())
1229 {
1230 str << ","
Isabella Gottardi6e464c32018-01-26 12:32:45 +00001231 << "PoolSize=" << info.pool_size().width << "," << info.pool_size().height << ","
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001232 << "PadStride=" << info.pad_stride_info();
1233 }
1234 str << "}";
Anthony Barbier2a07e182017-08-04 18:20:27 +01001235 return str.str();
1236}
1237
Alex Gildayc357c472018-03-21 13:54:09 +00001238/** Formatted output of the KeyPoint type.
1239 *
1240 * @param[out] os Output stream
1241 * @param[in] point Type to output.
1242 *
1243 * @return Modified output stream.
1244 */
Moritz Pflanzer6c6597c2017-09-24 12:09:41 +01001245inline ::std::ostream &operator<<(::std::ostream &os, const KeyPoint &point)
1246{
1247 os << "{x=" << point.x << ","
1248 << "y=" << point.y << ","
1249 << "strength=" << point.strength << ","
1250 << "scale=" << point.scale << ","
1251 << "orientation=" << point.orientation << ","
1252 << "tracking_status=" << point.tracking_status << ","
1253 << "error=" << point.error << "}";
1254
1255 return os;
1256}
John Richardson63e50412017-10-13 20:51:42 +01001257
Alex Gildayc357c472018-03-21 13:54:09 +00001258/** Formatted output of the PhaseType type.
1259 *
1260 * @param[out] os Output stream
1261 * @param[in] phase_type Type to output.
1262 *
1263 * @return Modified output stream.
1264 */
John Richardson63e50412017-10-13 20:51:42 +01001265inline ::std::ostream &operator<<(::std::ostream &os, const PhaseType &phase_type)
1266{
1267 switch(phase_type)
1268 {
1269 case PhaseType::SIGNED:
1270 os << "SIGNED";
1271 break;
1272 case PhaseType::UNSIGNED:
1273 os << "UNSIGNED";
1274 break;
1275 default:
1276 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1277 }
1278
1279 return os;
1280}
1281
Alex Gildayc357c472018-03-21 13:54:09 +00001282/** Formatted output of the PhaseType type.
1283 *
1284 * @param[in] type Type to output.
1285 *
1286 * @return Formatted string.
1287 */
John Richardson63e50412017-10-13 20:51:42 +01001288inline std::string to_string(const arm_compute::PhaseType &type)
1289{
1290 std::stringstream str;
1291 str << type;
1292 return str.str();
1293}
John Richardson3c5f9492017-10-04 15:27:37 +01001294
Alex Gildayc357c472018-03-21 13:54:09 +00001295/** Formatted output of the MagnitudeType type.
1296 *
1297 * @param[out] os Output stream
1298 * @param[in] magnitude_type Type to output.
1299 *
1300 * @return Modified output stream.
1301 */
John Richardson3c5f9492017-10-04 15:27:37 +01001302inline ::std::ostream &operator<<(::std::ostream &os, const MagnitudeType &magnitude_type)
1303{
1304 switch(magnitude_type)
1305 {
1306 case MagnitudeType::L1NORM:
1307 os << "L1NORM";
1308 break;
1309 case MagnitudeType::L2NORM:
1310 os << "L2NORM";
1311 break;
1312 default:
1313 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1314 }
1315
1316 return os;
1317}
1318
Alex Gildayc357c472018-03-21 13:54:09 +00001319/** Formatted output of the MagnitudeType type.
1320 *
1321 * @param[in] type Type to output.
1322 *
1323 * @return Formatted string.
1324 */
John Richardson3c5f9492017-10-04 15:27:37 +01001325inline std::string to_string(const arm_compute::MagnitudeType &type)
1326{
1327 std::stringstream str;
1328 str << type;
1329 return str.str();
1330}
John Richardson1c529922017-11-01 10:57:48 +00001331
Alex Gildayc357c472018-03-21 13:54:09 +00001332/** Formatted output of the GradientDimension type.
1333 *
1334 * @param[out] os Output stream
1335 * @param[in] dim Type to output
1336 *
1337 * @return Modified output stream.
1338 */
John Richardson1c529922017-11-01 10:57:48 +00001339inline ::std::ostream &operator<<(::std::ostream &os, const GradientDimension &dim)
1340{
1341 switch(dim)
1342 {
1343 case GradientDimension::GRAD_X:
1344 os << "GRAD_X";
1345 break;
1346 case GradientDimension::GRAD_Y:
1347 os << "GRAD_Y";
1348 break;
1349 case GradientDimension::GRAD_XY:
1350 os << "GRAD_XY";
1351 break;
1352 default:
1353 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1354 }
1355
1356 return os;
1357}
1358
Alex Gildayc357c472018-03-21 13:54:09 +00001359/** Formatted output of the GradientDimension type.
1360 *
1361 * @param[in] type Type to output
1362 *
1363 * @return Formatted string.
1364 */
John Richardson1c529922017-11-01 10:57:48 +00001365inline std::string to_string(const arm_compute::GradientDimension &type)
1366{
1367 std::stringstream str;
1368 str << type;
1369 return str.str();
1370}
John Richardson25f23682017-11-27 14:35:09 +00001371
Alex Gildayc357c472018-03-21 13:54:09 +00001372/** Formatted output of the HOGNormType type.
1373 *
1374 * @param[out] os Output stream
1375 * @param[in] norm_type Type to output
1376 *
1377 * @return Modified output stream.
1378 */
John Richardson25f23682017-11-27 14:35:09 +00001379inline ::std::ostream &operator<<(::std::ostream &os, const HOGNormType &norm_type)
1380{
1381 switch(norm_type)
1382 {
1383 case HOGNormType::L1_NORM:
1384 os << "L1_NORM";
1385 break;
1386 case HOGNormType::L2_NORM:
1387 os << "L2_NORM";
1388 break;
1389 case HOGNormType::L2HYS_NORM:
1390 os << "L2HYS_NORM";
1391 break;
1392 default:
1393 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1394 }
1395
1396 return os;
1397}
1398
Alex Gildayc357c472018-03-21 13:54:09 +00001399/** Formatted output of the HOGNormType type.
1400 *
1401 * @param[in] type Type to output
1402 *
1403 * @return Formatted string.
1404 */
John Richardson25f23682017-11-27 14:35:09 +00001405inline std::string to_string(const HOGNormType &type)
1406{
1407 std::stringstream str;
1408 str << type;
1409 return str.str();
1410}
1411
Alex Gildayc357c472018-03-21 13:54:09 +00001412/** Formatted output of the Size2D type.
1413 *
1414 * @param[out] os Output stream
1415 * @param[in] size Type to output
1416 *
1417 * @return Modified output stream.
1418 */
John Richardson25f23682017-11-27 14:35:09 +00001419inline ::std::ostream &operator<<(::std::ostream &os, const Size2D &size)
1420{
1421 os << size.width << "x" << size.height;
1422
1423 return os;
1424}
1425
Alex Gildayc357c472018-03-21 13:54:09 +00001426/** Formatted output of the Size2D type.
1427 *
1428 * @param[in] type Type to output
1429 *
1430 * @return Formatted string.
1431 */
John Richardson25f23682017-11-27 14:35:09 +00001432inline std::string to_string(const Size2D &type)
1433{
1434 std::stringstream str;
1435 str << type;
1436 return str.str();
1437}
1438
Alex Gildayc357c472018-03-21 13:54:09 +00001439/** Formatted output of the HOGInfo type.
1440 *
1441 * @param[out] os Output stream
1442 * @param[in] hog_info Type to output
1443 *
1444 * @return Modified output stream.
1445 */
John Richardson25f23682017-11-27 14:35:09 +00001446inline ::std::ostream &operator<<(::std::ostream &os, const HOGInfo &hog_info)
1447{
1448 os << "{CellSize=" << hog_info.cell_size() << ","
1449 << "BlockSize=" << hog_info.block_size() << ","
1450 << "DetectionWindowSize=" << hog_info.detection_window_size() << ","
1451 << "BlockStride=" << hog_info.block_stride() << ","
1452 << "NumBins=" << hog_info.num_bins() << ","
1453 << "NormType=" << hog_info.normalization_type() << ","
1454 << "L2HystThreshold=" << hog_info.l2_hyst_threshold() << ","
1455 << "PhaseType=" << hog_info.phase_type() << "}";
1456
1457 return os;
1458}
1459
Alex Gildayc357c472018-03-21 13:54:09 +00001460/** Formatted output of the HOGInfo type.
1461 *
1462 * @param[in] type Type to output
1463 *
1464 * @return Formatted string.
1465 */
John Richardson25f23682017-11-27 14:35:09 +00001466inline std::string to_string(const HOGInfo &type)
1467{
1468 std::stringstream str;
1469 str << type;
1470 return str.str();
1471}
1472
Alex Gildayc357c472018-03-21 13:54:09 +00001473/** Formatted output of the ConvolutionMethod type.
1474 *
1475 * @param[out] os Output stream
1476 * @param[in] conv_method Type to output
1477 *
1478 * @return Modified output stream.
1479 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001480inline ::std::ostream &operator<<(::std::ostream &os, const ConvolutionMethod &conv_method)
1481{
1482 switch(conv_method)
1483 {
1484 case ConvolutionMethod::GEMM:
1485 os << "GEMM";
1486 break;
1487 case ConvolutionMethod::DIRECT:
1488 os << "DIRECT";
1489 break;
1490 case ConvolutionMethod::WINOGRAD:
1491 os << "WINOGRAD";
1492 break;
1493 default:
1494 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1495 }
1496
1497 return os;
1498}
1499
Alex Gildayc357c472018-03-21 13:54:09 +00001500/** Formatted output of the ConvolutionMethod type.
1501 *
1502 * @param[in] conv_method Type to output
1503 *
1504 * @return Formatted string.
1505 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001506inline std::string to_string(const ConvolutionMethod &conv_method)
1507{
1508 std::stringstream str;
1509 str << conv_method;
1510 return str.str();
1511}
1512
Alex Gildayc357c472018-03-21 13:54:09 +00001513/** Formatted output of the GPUTarget type.
1514 *
1515 * @param[out] os Output stream
1516 * @param[in] gpu_target Type to output
1517 *
1518 * @return Modified output stream.
1519 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001520inline ::std::ostream &operator<<(::std::ostream &os, const GPUTarget &gpu_target)
1521{
1522 switch(gpu_target)
1523 {
1524 case GPUTarget::GPU_ARCH_MASK:
1525 os << "GPU_ARCH_MASK";
1526 break;
1527 case GPUTarget::MIDGARD:
1528 os << "MIDGARD";
1529 break;
1530 case GPUTarget::BIFROST:
1531 os << "BIFROST";
1532 break;
1533 case GPUTarget::T600:
1534 os << "T600";
1535 break;
1536 case GPUTarget::T700:
1537 os << "T700";
1538 break;
1539 case GPUTarget::T800:
1540 os << "T800";
1541 break;
Michalis Spyroua9676112018-02-22 18:07:43 +00001542 case GPUTarget::G71:
1543 os << "G71";
1544 break;
1545 case GPUTarget::G72:
1546 os << "G72";
1547 break;
1548 case GPUTarget::G51:
1549 os << "G51";
1550 break;
1551 case GPUTarget::G51BIG:
1552 os << "G51BIG";
1553 break;
1554 case GPUTarget::G51LIT:
1555 os << "G51LIT";
1556 break;
Georgios Pinitasb03f7c52018-07-12 10:49:53 +01001557 case GPUTarget::G76:
1558 os << "G76";
Michalis Spyroua9676112018-02-22 18:07:43 +00001559 break;
1560 case GPUTarget::TTRX:
1561 os << "TTRX";
1562 break;
1563 case GPUTarget::TBOX:
1564 os << "TBOX";
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001565 break;
1566 default:
1567 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1568 }
1569
1570 return os;
1571}
1572
Alex Gildayc357c472018-03-21 13:54:09 +00001573/** Formatted output of the GPUTarget type.
1574 *
1575 * @param[in] gpu_target Type to output
1576 *
1577 * @return Formatted string.
1578 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001579inline std::string to_string(const GPUTarget &gpu_target)
1580{
1581 std::stringstream str;
1582 str << gpu_target;
1583 return str.str();
1584}
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00001585
John Richardson8de92612018-02-22 14:09:31 +00001586/** Formatted output of the DetectionWindow type.
1587 *
1588 * @param[out] os Output stream
1589 * @param[in] detection_window Type to output
1590 *
1591 * @return Modified output stream.
1592 */
John Richardson684cb0f2018-01-09 11:17:00 +00001593inline ::std::ostream &operator<<(::std::ostream &os, const DetectionWindow &detection_window)
1594{
1595 os << "{x=" << detection_window.x << ","
1596 << "y=" << detection_window.y << ","
1597 << "width=" << detection_window.width << ","
1598 << "height=" << detection_window.height << ","
1599 << "idx_class=" << detection_window.idx_class << ","
1600 << "score=" << detection_window.score << "}";
1601
1602 return os;
1603}
1604
John Richardson8de92612018-02-22 14:09:31 +00001605/** Formatted output of the DetectionWindow type.
1606 *
1607 * @param[in] detection_window Type to output
1608 *
1609 * @return Formatted string.
1610 */
1611inline std::string to_string(const DetectionWindow &detection_window)
1612{
1613 std::stringstream str;
1614 str << detection_window;
1615 return str.str();
1616}
1617
1618/** Formatted output of the Termination type.
1619 *
1620 * @param[out] os Output stream
1621 * @param[in] termination Type to output
1622 *
1623 * @return Modified output stream.
1624 */
1625inline ::std::ostream &operator<<(::std::ostream &os, const Termination &termination)
1626{
1627 switch(termination)
1628 {
1629 case Termination::TERM_CRITERIA_EPSILON:
1630 os << "TERM_CRITERIA_EPSILON";
1631 break;
1632 case Termination::TERM_CRITERIA_ITERATIONS:
1633 os << "TERM_CRITERIA_ITERATIONS";
1634 break;
1635 case Termination::TERM_CRITERIA_BOTH:
1636 os << "TERM_CRITERIA_BOTH";
1637 break;
1638 default:
1639 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1640 }
1641
1642 return os;
1643}
1644
1645/** Formatted output of the Termination type.
1646 *
1647 * @param[in] termination Type to output
1648 *
1649 * @return Formatted string.
1650 */
1651inline std::string to_string(const Termination &termination)
1652{
1653 std::stringstream str;
1654 str << termination;
1655 return str.str();
1656}
1657
Anthony Barbier671a11e2018-07-06 15:11:36 +01001658/** Formatted output of a vector of objects.
1659 *
1660 * @param[out] os Output stream
1661 * @param[in] args Vector of objects to print
1662 *
1663 * @return Modified output stream.
1664 */
1665template <typename T>
1666inline ::std::ostream &operator<<(::std::ostream &os, const std::vector<T> &args)
1667{
1668 os << "[";
1669 bool first = true;
1670 for(auto &arg : args)
1671 {
1672 if(first)
1673 {
1674 first = false;
1675 }
1676 else
1677 {
1678 os << ", ";
1679 }
1680 os << arg;
1681 }
1682 os << "]";
1683 return os;
1684}
1685
1686/** Formatted output of a vector of objects.
1687 *
1688 * @param[in] args Vector of objects to print
1689 *
1690 * @return String representing args.
1691 */
1692template <typename T>
1693std::string to_string(const std::vector<T> &args)
1694{
1695 std::stringstream str;
1696 str << args;
1697 return str.str();
1698}
1699
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00001700/** Formatted output of the WinogradInfo type. */
1701inline ::std::ostream &operator<<(::std::ostream &os, const WinogradInfo &info)
1702{
1703 os << "{OutputTileSize=" << info.output_tile_size << ","
1704 << "KernelSize=" << info.kernel_size << ","
1705 << "PadStride=" << info.convolution_info << ","
1706 << "OutputDataLayout=" << info.output_data_layout << "}";
1707
1708 return os;
1709}
1710
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00001711inline std::string to_string(const WinogradInfo &type)
1712{
1713 std::stringstream str;
1714 str << type;
1715 return str.str();
1716}
Anthony Barbier671a11e2018-07-06 15:11:36 +01001717
1718/** Fallback method: try to use std::to_string:
1719 *
1720 * @param[in] val Value to convert to string
1721 *
1722 * @return String representing val.
1723 */
1724template <typename T>
1725inline std::string to_string(const T &val)
1726{
1727 return support::cpp11::to_string(val);
1728}
1729
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001730} // namespace arm_compute
John Richardson8de92612018-02-22 14:09:31 +00001731#endif /* __ARM_COMPUTE_TEST_TYPE_PRINTER_H__ */