blob: d9b971d993d53a7c59da680221ab4419bfe3447b [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 *
Anthony Barbier366628a2018-08-01 13:55:03 +0100826 * @param[out] os Output stream.
827 * @param[in] info Type to output.
828 *
829 * @return Modified output stream.
830 */
831inline ::std::ostream &operator<<(::std::ostream &os, const TensorInfo &info)
832{
833 os << "{Shape=" << info.tensor_shape() << ","
834 << "Type=" << info.data_type() << ","
835 << "Channels=" << info.num_channels() << "}";
836 return os;
837}
838/** Formatted output of the TensorInfo type.
839 *
Alex Gildayc357c472018-03-21 13:54:09 +0000840 * @param[in] info Type to output.
841 *
842 * @return Formatted string.
843 */
Georgios Pinitas3faea252017-10-30 14:13:50 +0000844inline std::string to_string(const TensorInfo &info)
845{
846 std::stringstream str;
Anthony Barbier366628a2018-08-01 13:55:03 +0100847 str << info;
Georgios Pinitas3faea252017-10-30 14:13:50 +0000848 return str.str();
849}
850
Abe Mbise925ca0f2017-10-02 19:16:33 +0100851//FIXME: Check why this doesn't work and the TensorShape and Coordinates overload are needed
Alex Gildayc357c472018-03-21 13:54:09 +0000852/** Formatted output of the Dimensions type.
853 *
854 * @param[in] dimensions Type to output.
855 *
856 * @return Formatted string.
857 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100858template <typename T>
859inline std::string to_string(const Dimensions<T> &dimensions)
860{
861 std::stringstream str;
862 str << dimensions;
863 return str.str();
864}
865
Alex Gildayc357c472018-03-21 13:54:09 +0000866/** Formatted output of the Strides type.
867 *
868 * @param[in] stride Type to output.
869 *
870 * @return Formatted string.
871 */
John Richardsona36eae12017-09-26 16:55:59 +0100872inline std::string to_string(const Strides &stride)
873{
874 std::stringstream str;
875 str << stride;
876 return str.str();
877}
878
Alex Gildayc357c472018-03-21 13:54:09 +0000879/** Formatted output of the TensorShape type.
880 *
881 * @param[in] shape Type to output.
882 *
883 * @return Formatted string.
884 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100885inline std::string to_string(const TensorShape &shape)
886{
887 std::stringstream str;
888 str << shape;
889 return str.str();
890}
891
Alex Gildayc357c472018-03-21 13:54:09 +0000892/** Formatted output of the Coordinates type.
893 *
894 * @param[in] coord Type to output.
895 *
896 * @return Formatted string.
897 */
Abe Mbise925ca0f2017-10-02 19:16:33 +0100898inline std::string to_string(const Coordinates &coord)
899{
900 std::stringstream str;
901 str << coord;
902 return str.str();
903}
904
Anthony Barbierb940fd62018-06-04 14:14:32 +0100905/** Formatted output of the GEMMReshapeInfo type.
906 *
907 * @param[out] os Output stream.
908 * @param[in] info Type to output.
909 *
910 * @return Modified output stream.
911 */
912inline ::std::ostream &operator<<(::std::ostream &os, const GEMMReshapeInfo &info)
913{
914 os << "{m=" << info.m() << ",";
915 os << "n=" << info.n() << ",";
916 os << "k=" << info.k() << ",";
917 os << "mult_transpose1xW_width=" << info.mult_transpose1xW_width() << ",";
918 os << "mult_interleave4x4_height=" << info.mult_interleave4x4_height();
919 os << "}";
920
921 return os;
922}
923
924/** Formatted output of the GEMMInfo type.
925 *
926 * @param[out] os Output stream.
927 * @param[in] info Type to output.
928 *
929 * @return Modified output stream.
930 */
931inline ::std::ostream &operator<<(::std::ostream &os, const GEMMInfo &info)
932{
933 os << "{is_a_reshaped=" << info.is_a_reshaped() << ",";
934 os << "is_b_reshaped=" << info.is_b_reshaped() << ",";
935 os << "reshape_b_only_on_first_run=" << info.reshape_b_only_on_first_run() << ",";
Anthony Barbierb940fd62018-06-04 14:14:32 +0100936 os << "}";
937
938 return os;
939}
940
941/** Formatted output of the Window::Dimension type.
942 *
943 * @param[out] os Output stream.
944 * @param[in] dim Type to output.
945 *
946 * @return Modified output stream.
947 */
948inline ::std::ostream &operator<<(::std::ostream &os, const Window::Dimension &dim)
949{
950 os << "{start=" << dim.start() << ", end=" << dim.end() << ", step=" << dim.step() << "}";
951
952 return os;
953}
954/** Formatted output of the Window type.
955 *
956 * @param[out] os Output stream.
957 * @param[in] win Type to output.
958 *
959 * @return Modified output stream.
960 */
961inline ::std::ostream &operator<<(::std::ostream &os, const Window &win)
962{
963 os << "{";
964 for(unsigned int i = 0; i < Coordinates::num_max_dimensions; i++)
965 {
966 if(i > 0)
967 {
968 os << ", ";
969 }
970 os << win[i];
971 }
972 os << "}";
973
974 return os;
975}
976
977/** Formatted output of the WeightsInfo type.
978 *
979 * @param[in] info Type to output.
980 *
981 * @return Formatted string.
982 */
983inline std::string to_string(const WeightsInfo &info)
984{
985 std::stringstream str;
986 str << info;
987 return str.str();
988}
989
990/** Formatted output of the GEMMReshapeInfo type.
991 *
992 * @param[in] info Type to output.
993 *
994 * @return Formatted string.
995 */
996inline std::string to_string(const GEMMReshapeInfo &info)
997{
998 std::stringstream str;
999 str << info;
1000 return str.str();
1001}
1002
1003/** Formatted output of the GEMMInfo type.
1004 *
1005 * @param[in] info Type to output.
1006 *
1007 * @return Formatted string.
1008 */
1009inline std::string to_string(const GEMMInfo &info)
1010{
1011 std::stringstream str;
1012 str << info;
1013 return str.str();
1014}
1015
1016/** Formatted output of the Window::Dimension type.
1017 *
1018 * @param[in] dim Type to output.
1019 *
1020 * @return Formatted string.
1021 */
1022inline std::string to_string(const Window::Dimension &dim)
1023{
1024 std::stringstream str;
1025 str << dim;
1026 return str.str();
1027}
1028/** Formatted output of the Window type.
1029 *
1030 * @param[in] win Type to output.
1031 *
1032 * @return Formatted string.
1033 */
1034inline std::string to_string(const Window &win)
1035{
1036 std::stringstream str;
1037 str << win;
1038 return str.str();
1039}
1040
Alex Gildayc357c472018-03-21 13:54:09 +00001041/** Formatted output of the Rectangle type.
1042 *
1043 * @param[out] os Output stream.
1044 * @param[in] rect Type to output.
1045 *
1046 * @return Modified output stream.
1047 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001048inline ::std::ostream &operator<<(::std::ostream &os, const Rectangle &rect)
1049{
1050 os << rect.width << "x" << rect.height;
1051 os << "+" << rect.x << "+" << rect.y;
1052
1053 return os;
1054}
1055
Alex Gildayc357c472018-03-21 13:54:09 +00001056/** Formatted output of the PadStrideInfo type.
1057 *
1058 * @param[out] os Output stream.
1059 * @param[in] pad_stride_info Type to output.
1060 *
1061 * @return Modified output stream.
1062 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001063inline ::std::ostream &operator<<(::std::ostream &os, const PadStrideInfo &pad_stride_info)
1064{
1065 os << pad_stride_info.stride().first << "," << pad_stride_info.stride().second;
1066 os << ";";
Jaroslaw Rzepeckia1ed41f2017-10-13 11:13:58 +01001067 os << pad_stride_info.pad_left() << "," << pad_stride_info.pad_right() << ","
1068 << pad_stride_info.pad_top() << "," << pad_stride_info.pad_bottom();
Anthony Barbier2a07e182017-08-04 18:20:27 +01001069
1070 return os;
1071}
1072
Alex Gildayc357c472018-03-21 13:54:09 +00001073/** Formatted output of the PadStrideInfo type.
1074 *
1075 * @param[in] pad_stride_info Type to output.
1076 *
1077 * @return Formatted string.
1078 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001079inline std::string to_string(const PadStrideInfo &pad_stride_info)
1080{
1081 std::stringstream str;
1082 str << pad_stride_info;
1083 return str.str();
1084}
1085
Alex Gildayc357c472018-03-21 13:54:09 +00001086/** Formatted output of the BorderMode type.
1087 *
1088 * @param[in] mode Type to output.
1089 *
1090 * @return Formatted string.
1091 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001092inline std::string to_string(const BorderMode &mode)
1093{
1094 std::stringstream str;
1095 str << mode;
1096 return str.str();
1097}
1098
Alex Gildayc357c472018-03-21 13:54:09 +00001099/** Formatted output of the BorderSize type.
1100 *
1101 * @param[in] border Type to output.
1102 *
1103 * @return Formatted string.
1104 */
John Richardsonb482ce12017-09-18 12:44:01 +01001105inline std::string to_string(const BorderSize &border)
1106{
1107 std::stringstream str;
1108 str << border;
1109 return str.str();
1110}
1111
Alex Gildayc357c472018-03-21 13:54:09 +00001112/** Formatted output of the InterpolationPolicy type.
1113 *
1114 * @param[in] policy Type to output.
1115 *
1116 * @return Formatted string.
1117 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001118inline std::string to_string(const InterpolationPolicy &policy)
1119{
1120 std::stringstream str;
1121 str << policy;
1122 return str.str();
1123}
1124
Alex Gildayc357c472018-03-21 13:54:09 +00001125/** Formatted output of the SamplingPolicy type.
1126 *
1127 * @param[in] policy Type to output.
1128 *
1129 * @return Formatted string.
1130 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +07001131inline std::string to_string(const SamplingPolicy &policy)
1132{
1133 std::stringstream str;
1134 str << policy;
1135 return str.str();
1136}
1137
Alex Gildayc357c472018-03-21 13:54:09 +00001138/** Formatted output of the ConvertPolicy type.
1139 *
1140 * @param[out] os Output stream.
1141 * @param[in] policy Type to output.
1142 *
1143 * @return Modified output stream.
1144 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001145inline ::std::ostream &operator<<(::std::ostream &os, const ConvertPolicy &policy)
1146{
1147 switch(policy)
1148 {
1149 case ConvertPolicy::WRAP:
1150 os << "WRAP";
1151 break;
1152 case ConvertPolicy::SATURATE:
1153 os << "SATURATE";
1154 break;
1155 default:
1156 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1157 }
1158
1159 return os;
1160}
1161
1162inline std::string to_string(const ConvertPolicy &policy)
1163{
1164 std::stringstream str;
1165 str << policy;
1166 return str.str();
1167}
1168
Alex Gildayc357c472018-03-21 13:54:09 +00001169/** Formatted output of the Reduction Operations.
1170 *
1171 * @param[out] os Output stream.
1172 * @param[in] op Type to output.
1173 *
1174 * @return Modified output stream.
1175 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001176inline ::std::ostream &operator<<(::std::ostream &os, const ReductionOperation &op)
1177{
1178 switch(op)
1179 {
1180 case ReductionOperation::SUM_SQUARE:
1181 os << "SUM_SQUARE";
1182 break;
1183 default:
1184 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1185 }
1186
1187 return os;
1188}
1189
Alex Gildayc357c472018-03-21 13:54:09 +00001190/** Formatted output of the Reduction Operations.
1191 *
1192 * @param[in] op Type to output.
1193 *
1194 * @return Formatted string.
1195 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001196inline std::string to_string(const ReductionOperation &op)
1197{
1198 std::stringstream str;
1199 str << op;
1200 return str.str();
1201}
1202
Alex Gildayc357c472018-03-21 13:54:09 +00001203/** Formatted output of the Norm Type.
1204 *
1205 * @param[in] type Type to output.
1206 *
1207 * @return Formatted string.
1208 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001209inline std::string to_string(const NormType &type)
1210{
1211 std::stringstream str;
1212 str << type;
1213 return str.str();
1214}
1215
Alex Gildayc357c472018-03-21 13:54:09 +00001216/** Formatted output of the Pooling Type.
1217 *
1218 * @param[in] type Type to output.
1219 *
1220 * @return Formatted string.
1221 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001222inline std::string to_string(const PoolingType &type)
1223{
1224 std::stringstream str;
1225 str << type;
1226 return str.str();
1227}
1228
Alex Gildayc357c472018-03-21 13:54:09 +00001229/** Formatted output of the Pooling Layer Info.
1230 *
1231 * @param[in] info Type to output.
1232 *
1233 * @return Formatted string.
1234 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001235inline std::string to_string(const PoolingLayerInfo &info)
1236{
1237 std::stringstream str;
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001238 str << "{Type=" << info.pool_type() << ","
1239 << "IsGlobalPooling=" << info.is_global_pooling();
1240 if(!info.is_global_pooling())
1241 {
1242 str << ","
Isabella Gottardi6e464c32018-01-26 12:32:45 +00001243 << "PoolSize=" << info.pool_size().width << "," << info.pool_size().height << ","
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001244 << "PadStride=" << info.pad_stride_info();
1245 }
1246 str << "}";
Anthony Barbier2a07e182017-08-04 18:20:27 +01001247 return str.str();
1248}
1249
Alex Gildayc357c472018-03-21 13:54:09 +00001250/** Formatted output of the KeyPoint type.
1251 *
1252 * @param[out] os Output stream
1253 * @param[in] point Type to output.
1254 *
1255 * @return Modified output stream.
1256 */
Moritz Pflanzer6c6597c2017-09-24 12:09:41 +01001257inline ::std::ostream &operator<<(::std::ostream &os, const KeyPoint &point)
1258{
1259 os << "{x=" << point.x << ","
1260 << "y=" << point.y << ","
1261 << "strength=" << point.strength << ","
1262 << "scale=" << point.scale << ","
1263 << "orientation=" << point.orientation << ","
1264 << "tracking_status=" << point.tracking_status << ","
1265 << "error=" << point.error << "}";
1266
1267 return os;
1268}
John Richardson63e50412017-10-13 20:51:42 +01001269
Alex Gildayc357c472018-03-21 13:54:09 +00001270/** Formatted output of the PhaseType type.
1271 *
1272 * @param[out] os Output stream
1273 * @param[in] phase_type Type to output.
1274 *
1275 * @return Modified output stream.
1276 */
John Richardson63e50412017-10-13 20:51:42 +01001277inline ::std::ostream &operator<<(::std::ostream &os, const PhaseType &phase_type)
1278{
1279 switch(phase_type)
1280 {
1281 case PhaseType::SIGNED:
1282 os << "SIGNED";
1283 break;
1284 case PhaseType::UNSIGNED:
1285 os << "UNSIGNED";
1286 break;
1287 default:
1288 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1289 }
1290
1291 return os;
1292}
1293
Alex Gildayc357c472018-03-21 13:54:09 +00001294/** Formatted output of the PhaseType type.
1295 *
1296 * @param[in] type Type to output.
1297 *
1298 * @return Formatted string.
1299 */
John Richardson63e50412017-10-13 20:51:42 +01001300inline std::string to_string(const arm_compute::PhaseType &type)
1301{
1302 std::stringstream str;
1303 str << type;
1304 return str.str();
1305}
John Richardson3c5f9492017-10-04 15:27:37 +01001306
Alex Gildayc357c472018-03-21 13:54:09 +00001307/** Formatted output of the MagnitudeType type.
1308 *
1309 * @param[out] os Output stream
1310 * @param[in] magnitude_type Type to output.
1311 *
1312 * @return Modified output stream.
1313 */
John Richardson3c5f9492017-10-04 15:27:37 +01001314inline ::std::ostream &operator<<(::std::ostream &os, const MagnitudeType &magnitude_type)
1315{
1316 switch(magnitude_type)
1317 {
1318 case MagnitudeType::L1NORM:
1319 os << "L1NORM";
1320 break;
1321 case MagnitudeType::L2NORM:
1322 os << "L2NORM";
1323 break;
1324 default:
1325 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1326 }
1327
1328 return os;
1329}
1330
Alex Gildayc357c472018-03-21 13:54:09 +00001331/** Formatted output of the MagnitudeType type.
1332 *
1333 * @param[in] type Type to output.
1334 *
1335 * @return Formatted string.
1336 */
John Richardson3c5f9492017-10-04 15:27:37 +01001337inline std::string to_string(const arm_compute::MagnitudeType &type)
1338{
1339 std::stringstream str;
1340 str << type;
1341 return str.str();
1342}
John Richardson1c529922017-11-01 10:57:48 +00001343
Alex Gildayc357c472018-03-21 13:54:09 +00001344/** Formatted output of the GradientDimension type.
1345 *
1346 * @param[out] os Output stream
1347 * @param[in] dim Type to output
1348 *
1349 * @return Modified output stream.
1350 */
John Richardson1c529922017-11-01 10:57:48 +00001351inline ::std::ostream &operator<<(::std::ostream &os, const GradientDimension &dim)
1352{
1353 switch(dim)
1354 {
1355 case GradientDimension::GRAD_X:
1356 os << "GRAD_X";
1357 break;
1358 case GradientDimension::GRAD_Y:
1359 os << "GRAD_Y";
1360 break;
1361 case GradientDimension::GRAD_XY:
1362 os << "GRAD_XY";
1363 break;
1364 default:
1365 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1366 }
1367
1368 return os;
1369}
1370
Alex Gildayc357c472018-03-21 13:54:09 +00001371/** Formatted output of the GradientDimension type.
1372 *
1373 * @param[in] type Type to output
1374 *
1375 * @return Formatted string.
1376 */
John Richardson1c529922017-11-01 10:57:48 +00001377inline std::string to_string(const arm_compute::GradientDimension &type)
1378{
1379 std::stringstream str;
1380 str << type;
1381 return str.str();
1382}
John Richardson25f23682017-11-27 14:35:09 +00001383
Alex Gildayc357c472018-03-21 13:54:09 +00001384/** Formatted output of the HOGNormType type.
1385 *
1386 * @param[out] os Output stream
1387 * @param[in] norm_type Type to output
1388 *
1389 * @return Modified output stream.
1390 */
John Richardson25f23682017-11-27 14:35:09 +00001391inline ::std::ostream &operator<<(::std::ostream &os, const HOGNormType &norm_type)
1392{
1393 switch(norm_type)
1394 {
1395 case HOGNormType::L1_NORM:
1396 os << "L1_NORM";
1397 break;
1398 case HOGNormType::L2_NORM:
1399 os << "L2_NORM";
1400 break;
1401 case HOGNormType::L2HYS_NORM:
1402 os << "L2HYS_NORM";
1403 break;
1404 default:
1405 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1406 }
1407
1408 return os;
1409}
1410
Alex Gildayc357c472018-03-21 13:54:09 +00001411/** Formatted output of the HOGNormType type.
1412 *
1413 * @param[in] type Type to output
1414 *
1415 * @return Formatted string.
1416 */
John Richardson25f23682017-11-27 14:35:09 +00001417inline std::string to_string(const HOGNormType &type)
1418{
1419 std::stringstream str;
1420 str << type;
1421 return str.str();
1422}
1423
Alex Gildayc357c472018-03-21 13:54:09 +00001424/** Formatted output of the Size2D type.
1425 *
1426 * @param[out] os Output stream
1427 * @param[in] size Type to output
1428 *
1429 * @return Modified output stream.
1430 */
John Richardson25f23682017-11-27 14:35:09 +00001431inline ::std::ostream &operator<<(::std::ostream &os, const Size2D &size)
1432{
1433 os << size.width << "x" << size.height;
1434
1435 return os;
1436}
1437
Alex Gildayc357c472018-03-21 13:54:09 +00001438/** Formatted output of the Size2D type.
1439 *
1440 * @param[in] type Type to output
1441 *
1442 * @return Formatted string.
1443 */
John Richardson25f23682017-11-27 14:35:09 +00001444inline std::string to_string(const Size2D &type)
1445{
1446 std::stringstream str;
1447 str << type;
1448 return str.str();
1449}
1450
Alex Gildayc357c472018-03-21 13:54:09 +00001451/** Formatted output of the HOGInfo type.
1452 *
1453 * @param[out] os Output stream
1454 * @param[in] hog_info Type to output
1455 *
1456 * @return Modified output stream.
1457 */
John Richardson25f23682017-11-27 14:35:09 +00001458inline ::std::ostream &operator<<(::std::ostream &os, const HOGInfo &hog_info)
1459{
1460 os << "{CellSize=" << hog_info.cell_size() << ","
1461 << "BlockSize=" << hog_info.block_size() << ","
1462 << "DetectionWindowSize=" << hog_info.detection_window_size() << ","
1463 << "BlockStride=" << hog_info.block_stride() << ","
1464 << "NumBins=" << hog_info.num_bins() << ","
1465 << "NormType=" << hog_info.normalization_type() << ","
1466 << "L2HystThreshold=" << hog_info.l2_hyst_threshold() << ","
1467 << "PhaseType=" << hog_info.phase_type() << "}";
1468
1469 return os;
1470}
1471
Alex Gildayc357c472018-03-21 13:54:09 +00001472/** Formatted output of the HOGInfo type.
1473 *
1474 * @param[in] type Type to output
1475 *
1476 * @return Formatted string.
1477 */
John Richardson25f23682017-11-27 14:35:09 +00001478inline std::string to_string(const HOGInfo &type)
1479{
1480 std::stringstream str;
1481 str << type;
1482 return str.str();
1483}
1484
Alex Gildayc357c472018-03-21 13:54:09 +00001485/** Formatted output of the ConvolutionMethod type.
1486 *
1487 * @param[out] os Output stream
1488 * @param[in] conv_method Type to output
1489 *
1490 * @return Modified output stream.
1491 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001492inline ::std::ostream &operator<<(::std::ostream &os, const ConvolutionMethod &conv_method)
1493{
1494 switch(conv_method)
1495 {
1496 case ConvolutionMethod::GEMM:
1497 os << "GEMM";
1498 break;
1499 case ConvolutionMethod::DIRECT:
1500 os << "DIRECT";
1501 break;
1502 case ConvolutionMethod::WINOGRAD:
1503 os << "WINOGRAD";
1504 break;
1505 default:
1506 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1507 }
1508
1509 return os;
1510}
1511
Alex Gildayc357c472018-03-21 13:54:09 +00001512/** Formatted output of the ConvolutionMethod type.
1513 *
1514 * @param[in] conv_method Type to output
1515 *
1516 * @return Formatted string.
1517 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001518inline std::string to_string(const ConvolutionMethod &conv_method)
1519{
1520 std::stringstream str;
1521 str << conv_method;
1522 return str.str();
1523}
1524
Alex Gildayc357c472018-03-21 13:54:09 +00001525/** Formatted output of the GPUTarget type.
1526 *
1527 * @param[out] os Output stream
1528 * @param[in] gpu_target Type to output
1529 *
1530 * @return Modified output stream.
1531 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001532inline ::std::ostream &operator<<(::std::ostream &os, const GPUTarget &gpu_target)
1533{
1534 switch(gpu_target)
1535 {
1536 case GPUTarget::GPU_ARCH_MASK:
1537 os << "GPU_ARCH_MASK";
1538 break;
1539 case GPUTarget::MIDGARD:
1540 os << "MIDGARD";
1541 break;
1542 case GPUTarget::BIFROST:
1543 os << "BIFROST";
1544 break;
1545 case GPUTarget::T600:
1546 os << "T600";
1547 break;
1548 case GPUTarget::T700:
1549 os << "T700";
1550 break;
1551 case GPUTarget::T800:
1552 os << "T800";
1553 break;
Michalis Spyroua9676112018-02-22 18:07:43 +00001554 case GPUTarget::G71:
1555 os << "G71";
1556 break;
1557 case GPUTarget::G72:
1558 os << "G72";
1559 break;
1560 case GPUTarget::G51:
1561 os << "G51";
1562 break;
1563 case GPUTarget::G51BIG:
1564 os << "G51BIG";
1565 break;
1566 case GPUTarget::G51LIT:
1567 os << "G51LIT";
1568 break;
Georgios Pinitasb03f7c52018-07-12 10:49:53 +01001569 case GPUTarget::G76:
1570 os << "G76";
Michalis Spyroua9676112018-02-22 18:07:43 +00001571 break;
1572 case GPUTarget::TTRX:
1573 os << "TTRX";
1574 break;
1575 case GPUTarget::TBOX:
1576 os << "TBOX";
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001577 break;
1578 default:
1579 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1580 }
1581
1582 return os;
1583}
1584
Alex Gildayc357c472018-03-21 13:54:09 +00001585/** Formatted output of the GPUTarget type.
1586 *
1587 * @param[in] gpu_target Type to output
1588 *
1589 * @return Formatted string.
1590 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001591inline std::string to_string(const GPUTarget &gpu_target)
1592{
1593 std::stringstream str;
1594 str << gpu_target;
1595 return str.str();
1596}
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00001597
John Richardson8de92612018-02-22 14:09:31 +00001598/** Formatted output of the DetectionWindow type.
1599 *
1600 * @param[out] os Output stream
1601 * @param[in] detection_window Type to output
1602 *
1603 * @return Modified output stream.
1604 */
John Richardson684cb0f2018-01-09 11:17:00 +00001605inline ::std::ostream &operator<<(::std::ostream &os, const DetectionWindow &detection_window)
1606{
1607 os << "{x=" << detection_window.x << ","
1608 << "y=" << detection_window.y << ","
1609 << "width=" << detection_window.width << ","
1610 << "height=" << detection_window.height << ","
1611 << "idx_class=" << detection_window.idx_class << ","
1612 << "score=" << detection_window.score << "}";
1613
1614 return os;
1615}
1616
John Richardson8de92612018-02-22 14:09:31 +00001617/** Formatted output of the DetectionWindow type.
1618 *
1619 * @param[in] detection_window Type to output
1620 *
1621 * @return Formatted string.
1622 */
1623inline std::string to_string(const DetectionWindow &detection_window)
1624{
1625 std::stringstream str;
1626 str << detection_window;
1627 return str.str();
1628}
1629
1630/** Formatted output of the Termination type.
1631 *
1632 * @param[out] os Output stream
1633 * @param[in] termination Type to output
1634 *
1635 * @return Modified output stream.
1636 */
1637inline ::std::ostream &operator<<(::std::ostream &os, const Termination &termination)
1638{
1639 switch(termination)
1640 {
1641 case Termination::TERM_CRITERIA_EPSILON:
1642 os << "TERM_CRITERIA_EPSILON";
1643 break;
1644 case Termination::TERM_CRITERIA_ITERATIONS:
1645 os << "TERM_CRITERIA_ITERATIONS";
1646 break;
1647 case Termination::TERM_CRITERIA_BOTH:
1648 os << "TERM_CRITERIA_BOTH";
1649 break;
1650 default:
1651 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1652 }
1653
1654 return os;
1655}
1656
1657/** Formatted output of the Termination type.
1658 *
1659 * @param[in] termination Type to output
1660 *
1661 * @return Formatted string.
1662 */
1663inline std::string to_string(const Termination &termination)
1664{
1665 std::stringstream str;
1666 str << termination;
1667 return str.str();
1668}
1669
Anthony Barbier671a11e2018-07-06 15:11:36 +01001670/** Formatted output of a vector of objects.
1671 *
1672 * @param[out] os Output stream
1673 * @param[in] args Vector of objects to print
1674 *
1675 * @return Modified output stream.
1676 */
1677template <typename T>
1678inline ::std::ostream &operator<<(::std::ostream &os, const std::vector<T> &args)
1679{
1680 os << "[";
1681 bool first = true;
1682 for(auto &arg : args)
1683 {
1684 if(first)
1685 {
1686 first = false;
1687 }
1688 else
1689 {
1690 os << ", ";
1691 }
1692 os << arg;
1693 }
1694 os << "]";
1695 return os;
1696}
1697
1698/** Formatted output of a vector of objects.
1699 *
1700 * @param[in] args Vector of objects to print
1701 *
1702 * @return String representing args.
1703 */
1704template <typename T>
1705std::string to_string(const std::vector<T> &args)
1706{
1707 std::stringstream str;
1708 str << args;
1709 return str.str();
1710}
1711
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00001712/** Formatted output of the WinogradInfo type. */
1713inline ::std::ostream &operator<<(::std::ostream &os, const WinogradInfo &info)
1714{
1715 os << "{OutputTileSize=" << info.output_tile_size << ","
1716 << "KernelSize=" << info.kernel_size << ","
1717 << "PadStride=" << info.convolution_info << ","
1718 << "OutputDataLayout=" << info.output_data_layout << "}";
1719
1720 return os;
1721}
1722
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00001723inline std::string to_string(const WinogradInfo &type)
1724{
1725 std::stringstream str;
1726 str << type;
1727 return str.str();
1728}
Anthony Barbier671a11e2018-07-06 15:11:36 +01001729
1730/** Fallback method: try to use std::to_string:
1731 *
1732 * @param[in] val Value to convert to string
1733 *
1734 * @return String representing val.
1735 */
1736template <typename T>
1737inline std::string to_string(const T &val)
1738{
1739 return support::cpp11::to_string(val);
1740}
1741
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001742} // namespace arm_compute
John Richardson8de92612018-02-22 14:09:31 +00001743#endif /* __ARM_COMPUTE_TEST_TYPE_PRINTER_H__ */