blob: 5d57dda201f6c754b3342a47f77dde267bc7ee94 [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 Barbier8914e322018-08-10 15:28:25 +010028#include "arm_compute/core/CPP/CPPTypes.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010029#include "arm_compute/core/Dimensions.h"
30#include "arm_compute/core/Error.h"
Michele Di Giorgiob8fc60f2018-04-25 11:58:07 +010031#include "arm_compute/core/GPUTarget.h"
John Richardson25f23682017-11-27 14:35:09 +000032#include "arm_compute/core/HOGInfo.h"
33#include "arm_compute/core/Size2D.h"
John Richardsona36eae12017-09-26 16:55:59 +010034#include "arm_compute/core/Strides.h"
Georgios Pinitas3faea252017-10-30 14:13:50 +000035#include "arm_compute/core/TensorInfo.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010036#include "arm_compute/core/Types.h"
37
Abe Mbise4bd2cb82017-09-27 18:39:19 +010038#include "tests/Types.h"
39
Anthony Barbier6ff3b192017-09-04 18:44:23 +010040#include <ostream>
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010041#include <sstream>
42#include <string>
Anthony Barbier6ff3b192017-09-04 18:44:23 +010043
44namespace arm_compute
45{
Anthony Barbierb940fd62018-06-04 14:14:32 +010046/** Formatted output if arg is not null
47 *
48 * @param[in] arg Object to print
49 *
50 * @return String representing arg.
51 */
52template <typename T>
53std::string to_string_if_not_null(T *arg)
54{
55 if(arg == nullptr)
56 {
57 return "nullptr";
58 }
59 else
60 {
61 return to_string(*arg);
62 }
63}
Alex Gildayc357c472018-03-21 13:54:09 +000064/** Formatted output of the Dimensions type.
65 *
66 * @param[out] os Output stream.
67 * @param[in] dimensions Type to output.
68 *
69 * @return Modified output stream.
70 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +010071template <typename T>
72inline ::std::ostream &operator<<(::std::ostream &os, const Dimensions<T> &dimensions)
73{
Anthony Barbier6ff3b192017-09-04 18:44:23 +010074 if(dimensions.num_dimensions() > 0)
75 {
76 os << dimensions[0];
77
78 for(unsigned int d = 1; d < dimensions.num_dimensions(); ++d)
79 {
Moritz Pflanzerc87fbf82017-07-18 14:02:10 +010080 os << "x" << dimensions[d];
Anthony Barbier6ff3b192017-09-04 18:44:23 +010081 }
82 }
83
Anthony Barbier6ff3b192017-09-04 18:44:23 +010084 return os;
85}
86
Alex Gildayc357c472018-03-21 13:54:09 +000087/** Formatted output of the NonLinearFilterFunction type.
88 *
89 * @param[out] os Output stream.
90 * @param[in] function Type to output.
91 *
92 * @return Modified output stream.
93 */
Isabella Gottardi3b77e9d2017-06-22 11:05:41 +010094inline ::std::ostream &operator<<(::std::ostream &os, const NonLinearFilterFunction &function)
95{
96 switch(function)
97 {
98 case NonLinearFilterFunction::MAX:
99 os << "MAX";
100 break;
101 case NonLinearFilterFunction::MEDIAN:
102 os << "MEDIAN";
103 break;
104 case NonLinearFilterFunction::MIN:
105 os << "MIN";
106 break;
107 default:
108 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
109 }
110
111 return os;
112}
113
Alex Gildayc357c472018-03-21 13:54:09 +0000114/** Formatted output of the NonLinearFilterFunction type.
115 *
116 * @param[in] function Type to output.
117 *
118 * @return Formatted string.
119 */
John Richardson6f4d49f2017-09-07 11:21:10 +0100120inline std::string to_string(const NonLinearFilterFunction &function)
121{
122 std::stringstream str;
123 str << function;
124 return str.str();
125}
126
Alex Gildayc357c472018-03-21 13:54:09 +0000127/** Formatted output of the MatrixPattern type.
128 *
129 * @param[out] os Output stream.
130 * @param[in] pattern Type to output.
131 *
132 * @return Modified output stream.
133 */
Isabella Gottardi3b77e9d2017-06-22 11:05:41 +0100134inline ::std::ostream &operator<<(::std::ostream &os, const MatrixPattern &pattern)
135{
136 switch(pattern)
137 {
138 case MatrixPattern::BOX:
139 os << "BOX";
140 break;
141 case MatrixPattern::CROSS:
142 os << "CROSS";
143 break;
144 case MatrixPattern::DISK:
145 os << "DISK";
146 break;
147 case MatrixPattern::OTHER:
148 os << "OTHER";
149 break;
150 default:
151 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
152 }
153
154 return os;
155}
156
Alex Gildayc357c472018-03-21 13:54:09 +0000157/** Formatted output of the MatrixPattern type.
158 *
159 * @param[in] pattern Type to output.
160 *
161 * @return Formatted string.
162 */
John Richardson6f4d49f2017-09-07 11:21:10 +0100163inline std::string to_string(const MatrixPattern &pattern)
164{
165 std::stringstream str;
166 str << pattern;
167 return str.str();
168}
169
Alex Gildayc357c472018-03-21 13:54:09 +0000170/** Formatted output of the RoundingPolicy type.
171 *
172 * @param[out] os Output stream.
173 * @param[in] rounding_policy Type to output.
174 *
175 * @return Modified output stream.
176 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100177inline ::std::ostream &operator<<(::std::ostream &os, const RoundingPolicy &rounding_policy)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100178{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100179 switch(rounding_policy)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100180 {
Anthony Barbier2a07e182017-08-04 18:20:27 +0100181 case RoundingPolicy::TO_ZERO:
182 os << "TO_ZERO";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100183 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100184 case RoundingPolicy::TO_NEAREST_UP:
185 os << "TO_NEAREST_UP";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100186 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100187 case RoundingPolicy::TO_NEAREST_EVEN:
188 os << "TO_NEAREST_EVEN";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100189 break;
190 default:
191 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
192 }
193
194 return os;
195}
196
Alex Gildayc357c472018-03-21 13:54:09 +0000197/** Formatted output of the WeightsInfo type.
198 *
199 * @param[out] os Output stream.
200 * @param[in] weights_info Type to output.
201 *
202 * @return Modified output stream.
203 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100204inline ::std::ostream &operator<<(::std::ostream &os, const WeightsInfo &weights_info)
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100205{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100206 os << weights_info.are_reshaped() << ";";
207 os << weights_info.num_kernels() << ";" << weights_info.kernel_size().first << "," << weights_info.kernel_size().second;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100208
209 return os;
210}
211
Alex Gildayc357c472018-03-21 13:54:09 +0000212/** Formatted output of the ROIPoolingInfo type.
213 *
214 * @param[out] os Output stream.
215 * @param[in] pool_info Type to output.
216 *
217 * @return Modified output stream.
218 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100219inline ::std::ostream &operator<<(::std::ostream &os, const ROIPoolingLayerInfo &pool_info)
Sanghoon Lee70f82912017-08-24 14:21:24 +0100220{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100221 os << pool_info.pooled_width() << "x" << pool_info.pooled_height() << "~" << pool_info.spatial_scale();
Georgios Pinitasd9769582017-08-03 10:19:40 +0100222 return os;
223}
224
Alex Gildayc357c472018-03-21 13:54:09 +0000225/** Formatted output of the QuantizationInfo type.
226 *
227 * @param[out] os Output stream.
228 * @param[in] quantization_info Type to output.
229 *
230 * @return Modified output stream.
231 */
Chunosovd621bca2017-11-03 17:33:15 +0700232inline ::std::ostream &operator<<(::std::ostream &os, const QuantizationInfo &quantization_info)
233{
234 os << "Scale:" << quantization_info.scale << "~"
235 << "Offset:" << quantization_info.offset;
236 return os;
237}
238
Alex Gildayc357c472018-03-21 13:54:09 +0000239/** Formatted output of the QuantizationInfo type.
240 *
241 * @param[in] quantization_info Type to output.
242 *
243 * @return Formatted string.
244 */
Chunosovd621bca2017-11-03 17:33:15 +0700245inline std::string to_string(const QuantizationInfo &quantization_info)
246{
247 std::stringstream str;
248 str << quantization_info;
249 return str.str();
250}
251
Alex Gildayc357c472018-03-21 13:54:09 +0000252/** Formatted output of the activation function type.
253 *
254 * @param[out] os Output stream.
255 * @param[in] act_function Type to output.
256 *
257 * @return Modified output stream.
258 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100259inline ::std::ostream &operator<<(::std::ostream &os, const ActivationLayerInfo::ActivationFunction &act_function)
260{
261 switch(act_function)
262 {
263 case ActivationLayerInfo::ActivationFunction::ABS:
264 os << "ABS";
265 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100266 case ActivationLayerInfo::ActivationFunction::LINEAR:
267 os << "LINEAR";
268 break;
269 case ActivationLayerInfo::ActivationFunction::LOGISTIC:
270 os << "LOGISTIC";
271 break;
272 case ActivationLayerInfo::ActivationFunction::RELU:
273 os << "RELU";
274 break;
Georgios Pinitas579c0492017-07-12 16:12:12 +0100275 case ActivationLayerInfo::ActivationFunction::BOUNDED_RELU:
276 os << "BOUNDED_RELU";
277 break;
278 case ActivationLayerInfo::ActivationFunction::LEAKY_RELU:
279 os << "LEAKY_RELU";
280 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100281 case ActivationLayerInfo::ActivationFunction::SOFT_RELU:
282 os << "SOFT_RELU";
283 break;
284 case ActivationLayerInfo::ActivationFunction::SQRT:
285 os << "SQRT";
286 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100287 case ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU:
288 os << "LU_BOUNDED_RELU";
Kevin Petitd9f80712017-12-06 12:18:48 +0000289 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100290 case ActivationLayerInfo::ActivationFunction::SQUARE:
291 os << "SQUARE";
292 break;
293 case ActivationLayerInfo::ActivationFunction::TANH:
294 os << "TANH";
295 break;
296 default:
297 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
298 }
299
300 return os;
301}
302
Alex Gildayc357c472018-03-21 13:54:09 +0000303/** Formatted output of the activation function info type.
304 *
305 * @param[in] info Type to output.
306 *
307 * @return Formatted string.
308 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100309inline std::string to_string(const arm_compute::ActivationLayerInfo &info)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100310{
311 std::stringstream str;
Isabella Gottardi3f217ec2018-02-12 14:59:19 +0000312 if(info.enabled())
313 {
314 str << info.activation();
315 }
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100316 return str.str();
317}
318
Alex Gildayc357c472018-03-21 13:54:09 +0000319/** Formatted output of the activation function type.
320 *
321 * @param[in] function Type to output.
322 *
323 * @return Formatted string.
324 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100325inline std::string to_string(const arm_compute::ActivationLayerInfo::ActivationFunction &function)
326{
327 std::stringstream str;
328 str << function;
329 return str.str();
330}
331
Alex Gildayc357c472018-03-21 13:54:09 +0000332/** Formatted output of the NormType type.
333 *
334 * @param[out] os Output stream.
335 * @param[in] norm_type Type to output.
336 *
337 * @return Modified output stream.
338 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100339inline ::std::ostream &operator<<(::std::ostream &os, const NormType &norm_type)
340{
341 switch(norm_type)
342 {
343 case NormType::CROSS_MAP:
344 os << "CROSS_MAP";
345 break;
346 case NormType::IN_MAP_1D:
347 os << "IN_MAP_1D";
348 break;
349 case NormType::IN_MAP_2D:
350 os << "IN_MAP_2D";
351 break;
352 default:
353 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
354 }
355
356 return os;
357}
358
Alex Gildayc357c472018-03-21 13:54:09 +0000359/** Formatted output of @ref NormalizationLayerInfo.
360 *
361 * @param[in] info Type to output.
362 *
363 * @return Formatted string.
364 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100365inline std::string to_string(const arm_compute::NormalizationLayerInfo &info)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100366{
367 std::stringstream str;
Michalis Spyroud466c2d2018-01-30 10:54:39 +0000368 str << info.type() << ":NormSize=" << info.norm_size();
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100369 return str.str();
370}
371
Alex Gildayc357c472018-03-21 13:54:09 +0000372/** Formatted output of @ref NormalizationLayerInfo.
373 *
374 * @param[out] os Output stream.
375 * @param[in] info Type to output.
376 *
377 * @return Modified output stream.
378 */
Georgios Pinitas6f669f02017-09-26 12:32:57 +0100379inline ::std::ostream &operator<<(::std::ostream &os, const NormalizationLayerInfo &info)
380{
Michalis Spyroud466c2d2018-01-30 10:54:39 +0000381 os << info.type() << ":NormSize=" << info.norm_size();
Georgios Pinitas6f669f02017-09-26 12:32:57 +0100382 return os;
383}
384
Alex Gildayc357c472018-03-21 13:54:09 +0000385/** Formatted output of the PoolingType type.
386 *
387 * @param[out] os Output stream.
388 * @param[in] pool_type Type to output.
389 *
390 * @return Modified output stream.
391 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100392inline ::std::ostream &operator<<(::std::ostream &os, const PoolingType &pool_type)
393{
394 switch(pool_type)
395 {
396 case PoolingType::AVG:
397 os << "AVG";
398 break;
399 case PoolingType::MAX:
400 os << "MAX";
401 break;
Georgios Pinitascdf51452017-08-31 14:21:36 +0100402 case PoolingType::L2:
403 os << "L2";
404 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100405 default:
406 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
407 }
408
409 return os;
410}
411
Alex Gildayc357c472018-03-21 13:54:09 +0000412/** Formatted output of @ref PoolingLayerInfo.
413 *
414 * @param[out] os Output stream.
415 * @param[in] info Type to output.
416 *
417 * @return Modified output stream.
418 */
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100419inline ::std::ostream &operator<<(::std::ostream &os, const PoolingLayerInfo &info)
420{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100421 os << info.pool_type();
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100422
423 return os;
424}
425
Alex Gildayc357c472018-03-21 13:54:09 +0000426/** Formatted output of @ref RoundingPolicy.
427 *
428 * @param[in] rounding_policy Type to output.
429 *
430 * @return Formatted string.
431 */
John Richardsondd715f22017-09-18 16:10:48 +0100432inline std::string to_string(const RoundingPolicy &rounding_policy)
433{
434 std::stringstream str;
435 str << rounding_policy;
436 return str.str();
437}
438
Alex Gildayc357c472018-03-21 13:54:09 +0000439/** Formatted output of the DataLayout type.
440 *
441 * @param[out] os Output stream.
442 * @param[in] data_layout Type to output.
443 *
444 * @return Modified output stream.
445 */
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000446inline ::std::ostream &operator<<(::std::ostream &os, const DataLayout &data_layout)
447{
448 switch(data_layout)
449 {
450 case DataLayout::UNKNOWN:
451 os << "UNKNOWN";
452 break;
453 case DataLayout::NHWC:
454 os << "NHWC";
455 break;
456 case DataLayout::NCHW:
457 os << "NCHW";
458 break;
459 default:
460 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
461 }
462
463 return os;
464}
465
Alex Gildayc357c472018-03-21 13:54:09 +0000466/** Formatted output of the DataLayout type.
467 *
468 * @param[in] data_layout Type to output.
469 *
470 * @return Formatted string.
471 */
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000472inline std::string to_string(const arm_compute::DataLayout &data_layout)
473{
474 std::stringstream str;
475 str << data_layout;
476 return str.str();
477}
478
Georgios Pinitase2220552018-07-20 13:23:44 +0100479/** Formatted output of the DataLayoutDimension type.
480 *
481 * @param[out] os Output stream.
482 * @param[in] data_layout_dim Data layout dimension to print.
483 *
484 * @return Modified output stream.
485 */
486inline ::std::ostream &operator<<(::std::ostream &os, const DataLayoutDimension &data_layout_dim)
487{
488 switch(data_layout_dim)
489 {
490 case DataLayoutDimension::WIDTH:
491 os << "WIDTH";
492 break;
493 case DataLayoutDimension::HEIGHT:
494 os << "HEIGHT";
495 break;
496 case DataLayoutDimension::CHANNEL:
497 os << "CHANNEL";
498 break;
499 case DataLayoutDimension::BATCHES:
500 os << "BATCHES";
501 break;
502 default:
503 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
504 }
505 return os;
506}
507
Alex Gildayc357c472018-03-21 13:54:09 +0000508/** Formatted output of the DataType type.
509 *
510 * @param[out] os Output stream.
511 * @param[in] data_type Type to output.
512 *
513 * @return Modified output stream.
514 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100515inline ::std::ostream &operator<<(::std::ostream &os, const DataType &data_type)
516{
517 switch(data_type)
518 {
519 case DataType::UNKNOWN:
520 os << "UNKNOWN";
521 break;
522 case DataType::U8:
523 os << "U8";
524 break;
Chunosovd621bca2017-11-03 17:33:15 +0700525 case DataType::QASYMM8:
526 os << "QASYMM8";
527 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100528 case DataType::S8:
529 os << "S8";
530 break;
531 case DataType::U16:
532 os << "U16";
533 break;
534 case DataType::S16:
535 os << "S16";
536 break;
537 case DataType::U32:
538 os << "U32";
539 break;
540 case DataType::S32:
541 os << "S32";
542 break;
543 case DataType::U64:
544 os << "U64";
545 break;
546 case DataType::S64:
547 os << "S64";
548 break;
549 case DataType::F16:
550 os << "F16";
551 break;
552 case DataType::F32:
553 os << "F32";
554 break;
555 case DataType::F64:
556 os << "F64";
557 break;
558 case DataType::SIZET:
559 os << "SIZET";
560 break;
561 default:
562 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
563 }
564
565 return os;
566}
567
Alex Gildayc357c472018-03-21 13:54:09 +0000568/** Formatted output of the DataType type.
569 *
570 * @param[in] data_type Type to output.
571 *
572 * @return Formatted string.
573 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100574inline std::string to_string(const arm_compute::DataType &data_type)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100575{
576 std::stringstream str;
577 str << data_type;
578 return str.str();
579}
580
Alex Gildayc357c472018-03-21 13:54:09 +0000581/** Formatted output of the Format type.
582 *
583 * @param[out] os Output stream.
584 * @param[in] format Type to output.
585 *
586 * @return Modified output stream.
587 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100588inline ::std::ostream &operator<<(::std::ostream &os, const Format &format)
589{
590 switch(format)
591 {
592 case Format::UNKNOWN:
593 os << "UNKNOWN";
594 break;
595 case Format::U8:
596 os << "U8";
597 break;
598 case Format::S16:
599 os << "S16";
600 break;
601 case Format::U16:
602 os << "U16";
603 break;
604 case Format::S32:
605 os << "S32";
606 break;
607 case Format::U32:
608 os << "U32";
609 break;
610 case Format::F16:
611 os << "F16";
612 break;
613 case Format::F32:
614 os << "F32";
615 break;
616 case Format::UV88:
617 os << "UV88";
618 break;
619 case Format::RGB888:
620 os << "RGB888";
621 break;
622 case Format::RGBA8888:
623 os << "RGBA8888";
624 break;
625 case Format::YUV444:
626 os << "YUV444";
627 break;
628 case Format::YUYV422:
629 os << "YUYV422";
630 break;
631 case Format::NV12:
632 os << "NV12";
633 break;
634 case Format::NV21:
635 os << "NV21";
636 break;
637 case Format::IYUV:
638 os << "IYUV";
639 break;
640 case Format::UYVY422:
641 os << "UYVY422";
642 break;
643 default:
644 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
645 }
646
647 return os;
648}
649
Alex Gildayc357c472018-03-21 13:54:09 +0000650/** Formatted output of the Format type.
651 *
652 * @param[in] format Type to output.
653 *
654 * @return Formatted string.
655 */
Moritz Pflanzer7655a672017-09-23 11:57:33 +0100656inline std::string to_string(const Format &format)
657{
658 std::stringstream str;
659 str << format;
660 return str.str();
661}
662
Alex Gildayc357c472018-03-21 13:54:09 +0000663/** Formatted output of the Channel type.
664 *
665 * @param[out] os Output stream.
666 * @param[in] channel Type to output.
667 *
668 * @return Modified output stream.
669 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100670inline ::std::ostream &operator<<(::std::ostream &os, const Channel &channel)
671{
672 switch(channel)
673 {
674 case Channel::UNKNOWN:
675 os << "UNKNOWN";
676 break;
677 case Channel::C0:
678 os << "C0";
679 break;
680 case Channel::C1:
681 os << "C1";
682 break;
683 case Channel::C2:
684 os << "C2";
685 break;
686 case Channel::C3:
687 os << "C3";
688 break;
689 case Channel::R:
690 os << "R";
691 break;
692 case Channel::G:
693 os << "G";
694 break;
695 case Channel::B:
696 os << "B";
697 break;
698 case Channel::A:
699 os << "A";
700 break;
701 case Channel::Y:
702 os << "Y";
703 break;
704 case Channel::U:
705 os << "U";
706 break;
707 case Channel::V:
708 os << "V";
709 break;
710 default:
711 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
712 }
713
714 return os;
715}
716
Alex Gildayc357c472018-03-21 13:54:09 +0000717/** Formatted output of the Channel type.
718 *
719 * @param[in] channel Type to output.
720 *
721 * @return Formatted string.
722 */
Ioan-Cristian Szabo9414f642017-10-27 17:35:40 +0100723inline std::string to_string(const Channel &channel)
724{
725 std::stringstream str;
726 str << channel;
727 return str.str();
728}
729
Alex Gildayc357c472018-03-21 13:54:09 +0000730/** Formatted output of the BorderMode type.
731 *
732 * @param[out] os Output stream.
733 * @param[in] mode Type to output.
734 *
735 * @return Modified output stream.
736 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100737inline ::std::ostream &operator<<(::std::ostream &os, const BorderMode &mode)
738{
739 switch(mode)
740 {
741 case BorderMode::UNDEFINED:
742 os << "UNDEFINED";
743 break;
744 case BorderMode::CONSTANT:
745 os << "CONSTANT";
746 break;
747 case BorderMode::REPLICATE:
748 os << "REPLICATE";
749 break;
750 default:
751 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
752 }
753
754 return os;
755}
756
Alex Gildayc357c472018-03-21 13:54:09 +0000757/** Formatted output of the BorderSize type.
758 *
759 * @param[out] os Output stream.
760 * @param[in] border Type to output.
761 *
762 * @return Modified output stream.
763 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100764inline ::std::ostream &operator<<(::std::ostream &os, const BorderSize &border)
765{
Moritz Pflanzerc87fbf82017-07-18 14:02:10 +0100766 os << border.top << ","
767 << border.right << ","
768 << border.bottom << ","
769 << border.left;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100770
771 return os;
772}
Anthony Barbier2a07e182017-08-04 18:20:27 +0100773
Alex Gildayc357c472018-03-21 13:54:09 +0000774/** Formatted output of the InterpolationPolicy type.
775 *
776 * @param[out] os Output stream.
777 * @param[in] policy Type to output.
778 *
779 * @return Modified output stream.
780 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100781inline ::std::ostream &operator<<(::std::ostream &os, const InterpolationPolicy &policy)
782{
783 switch(policy)
784 {
785 case InterpolationPolicy::NEAREST_NEIGHBOR:
786 os << "NEAREST_NEIGHBOR";
787 break;
788 case InterpolationPolicy::BILINEAR:
789 os << "BILINEAR";
790 break;
791 case InterpolationPolicy::AREA:
792 os << "AREA";
793 break;
794 default:
795 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
796 }
797
798 return os;
799}
800
Alex Gildayc357c472018-03-21 13:54:09 +0000801/** Formatted output of the SamplingPolicy type.
802 *
803 * @param[out] os Output stream.
804 * @param[in] policy Type to output.
805 *
806 * @return Modified output stream.
807 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700808inline ::std::ostream &operator<<(::std::ostream &os, const SamplingPolicy &policy)
809{
810 switch(policy)
811 {
812 case SamplingPolicy::CENTER:
813 os << "CENTER";
814 break;
815 case SamplingPolicy::TOP_LEFT:
816 os << "TOP_LEFT";
817 break;
818 default:
819 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
820 }
821
822 return os;
823}
824
Alex Gildayc357c472018-03-21 13:54:09 +0000825/** Formatted output of the TensorInfo type.
826 *
Anthony Barbier366628a2018-08-01 13:55:03 +0100827 * @param[out] os Output stream.
828 * @param[in] info Type to output.
829 *
830 * @return Modified output stream.
831 */
832inline ::std::ostream &operator<<(::std::ostream &os, const TensorInfo &info)
833{
834 os << "{Shape=" << info.tensor_shape() << ","
835 << "Type=" << info.data_type() << ","
836 << "Channels=" << info.num_channels() << "}";
837 return os;
838}
839/** Formatted output of the TensorInfo type.
840 *
Alex Gildayc357c472018-03-21 13:54:09 +0000841 * @param[in] info Type to output.
842 *
843 * @return Formatted string.
844 */
Georgios Pinitas3faea252017-10-30 14:13:50 +0000845inline std::string to_string(const TensorInfo &info)
846{
847 std::stringstream str;
Anthony Barbier366628a2018-08-01 13:55:03 +0100848 str << info;
Georgios Pinitas3faea252017-10-30 14:13:50 +0000849 return str.str();
850}
851
Abe Mbise925ca0f2017-10-02 19:16:33 +0100852//FIXME: Check why this doesn't work and the TensorShape and Coordinates overload are needed
Alex Gildayc357c472018-03-21 13:54:09 +0000853/** Formatted output of the Dimensions type.
854 *
855 * @param[in] dimensions Type to output.
856 *
857 * @return Formatted string.
858 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100859template <typename T>
860inline std::string to_string(const Dimensions<T> &dimensions)
861{
862 std::stringstream str;
863 str << dimensions;
864 return str.str();
865}
866
Alex Gildayc357c472018-03-21 13:54:09 +0000867/** Formatted output of the Strides type.
868 *
869 * @param[in] stride Type to output.
870 *
871 * @return Formatted string.
872 */
John Richardsona36eae12017-09-26 16:55:59 +0100873inline std::string to_string(const Strides &stride)
874{
875 std::stringstream str;
876 str << stride;
877 return str.str();
878}
879
Alex Gildayc357c472018-03-21 13:54:09 +0000880/** Formatted output of the TensorShape type.
881 *
882 * @param[in] shape Type to output.
883 *
884 * @return Formatted string.
885 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100886inline std::string to_string(const TensorShape &shape)
887{
888 std::stringstream str;
889 str << shape;
890 return str.str();
891}
892
Alex Gildayc357c472018-03-21 13:54:09 +0000893/** Formatted output of the Coordinates type.
894 *
895 * @param[in] coord Type to output.
896 *
897 * @return Formatted string.
898 */
Abe Mbise925ca0f2017-10-02 19:16:33 +0100899inline std::string to_string(const Coordinates &coord)
900{
901 std::stringstream str;
902 str << coord;
903 return str.str();
904}
905
Anthony Barbierb940fd62018-06-04 14:14:32 +0100906/** Formatted output of the GEMMReshapeInfo type.
907 *
908 * @param[out] os Output stream.
909 * @param[in] info Type to output.
910 *
911 * @return Modified output stream.
912 */
913inline ::std::ostream &operator<<(::std::ostream &os, const GEMMReshapeInfo &info)
914{
915 os << "{m=" << info.m() << ",";
916 os << "n=" << info.n() << ",";
917 os << "k=" << info.k() << ",";
918 os << "mult_transpose1xW_width=" << info.mult_transpose1xW_width() << ",";
919 os << "mult_interleave4x4_height=" << info.mult_interleave4x4_height();
920 os << "}";
921
922 return os;
923}
924
925/** Formatted output of the GEMMInfo type.
926 *
927 * @param[out] os Output stream.
928 * @param[in] info Type to output.
929 *
930 * @return Modified output stream.
931 */
932inline ::std::ostream &operator<<(::std::ostream &os, const GEMMInfo &info)
933{
934 os << "{is_a_reshaped=" << info.is_a_reshaped() << ",";
935 os << "is_b_reshaped=" << info.is_b_reshaped() << ",";
936 os << "reshape_b_only_on_first_run=" << info.reshape_b_only_on_first_run() << ",";
Anthony Barbierb940fd62018-06-04 14:14:32 +0100937 os << "}";
938
939 return os;
940}
941
942/** Formatted output of the Window::Dimension type.
943 *
944 * @param[out] os Output stream.
945 * @param[in] dim Type to output.
946 *
947 * @return Modified output stream.
948 */
949inline ::std::ostream &operator<<(::std::ostream &os, const Window::Dimension &dim)
950{
951 os << "{start=" << dim.start() << ", end=" << dim.end() << ", step=" << dim.step() << "}";
952
953 return os;
954}
955/** Formatted output of the Window type.
956 *
957 * @param[out] os Output stream.
958 * @param[in] win Type to output.
959 *
960 * @return Modified output stream.
961 */
962inline ::std::ostream &operator<<(::std::ostream &os, const Window &win)
963{
964 os << "{";
965 for(unsigned int i = 0; i < Coordinates::num_max_dimensions; i++)
966 {
967 if(i > 0)
968 {
969 os << ", ";
970 }
971 os << win[i];
972 }
973 os << "}";
974
975 return os;
976}
977
978/** Formatted output of the WeightsInfo type.
979 *
980 * @param[in] info Type to output.
981 *
982 * @return Formatted string.
983 */
984inline std::string to_string(const WeightsInfo &info)
985{
986 std::stringstream str;
987 str << info;
988 return str.str();
989}
990
991/** Formatted output of the GEMMReshapeInfo type.
992 *
993 * @param[in] info Type to output.
994 *
995 * @return Formatted string.
996 */
997inline std::string to_string(const GEMMReshapeInfo &info)
998{
999 std::stringstream str;
1000 str << info;
1001 return str.str();
1002}
1003
1004/** Formatted output of the GEMMInfo type.
1005 *
1006 * @param[in] info Type to output.
1007 *
1008 * @return Formatted string.
1009 */
1010inline std::string to_string(const GEMMInfo &info)
1011{
1012 std::stringstream str;
1013 str << info;
1014 return str.str();
1015}
1016
1017/** Formatted output of the Window::Dimension type.
1018 *
1019 * @param[in] dim Type to output.
1020 *
1021 * @return Formatted string.
1022 */
1023inline std::string to_string(const Window::Dimension &dim)
1024{
1025 std::stringstream str;
1026 str << dim;
1027 return str.str();
1028}
1029/** Formatted output of the Window type.
1030 *
1031 * @param[in] win Type to output.
1032 *
1033 * @return Formatted string.
1034 */
1035inline std::string to_string(const Window &win)
1036{
1037 std::stringstream str;
1038 str << win;
1039 return str.str();
1040}
1041
Alex Gildayc357c472018-03-21 13:54:09 +00001042/** Formatted output of the Rectangle type.
1043 *
1044 * @param[out] os Output stream.
1045 * @param[in] rect Type to output.
1046 *
1047 * @return Modified output stream.
1048 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001049inline ::std::ostream &operator<<(::std::ostream &os, const Rectangle &rect)
1050{
1051 os << rect.width << "x" << rect.height;
1052 os << "+" << rect.x << "+" << rect.y;
1053
1054 return os;
1055}
1056
Alex Gildayc357c472018-03-21 13:54:09 +00001057/** Formatted output of the PadStrideInfo type.
1058 *
1059 * @param[out] os Output stream.
1060 * @param[in] pad_stride_info Type to output.
1061 *
1062 * @return Modified output stream.
1063 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001064inline ::std::ostream &operator<<(::std::ostream &os, const PadStrideInfo &pad_stride_info)
1065{
1066 os << pad_stride_info.stride().first << "," << pad_stride_info.stride().second;
1067 os << ";";
Jaroslaw Rzepeckia1ed41f2017-10-13 11:13:58 +01001068 os << pad_stride_info.pad_left() << "," << pad_stride_info.pad_right() << ","
1069 << pad_stride_info.pad_top() << "," << pad_stride_info.pad_bottom();
Anthony Barbier2a07e182017-08-04 18:20:27 +01001070
1071 return os;
1072}
1073
Alex Gildayc357c472018-03-21 13:54:09 +00001074/** Formatted output of the PadStrideInfo type.
1075 *
1076 * @param[in] pad_stride_info Type to output.
1077 *
1078 * @return Formatted string.
1079 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001080inline std::string to_string(const PadStrideInfo &pad_stride_info)
1081{
1082 std::stringstream str;
1083 str << pad_stride_info;
1084 return str.str();
1085}
1086
Alex Gildayc357c472018-03-21 13:54:09 +00001087/** Formatted output of the BorderMode type.
1088 *
1089 * @param[in] mode Type to output.
1090 *
1091 * @return Formatted string.
1092 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001093inline std::string to_string(const BorderMode &mode)
1094{
1095 std::stringstream str;
1096 str << mode;
1097 return str.str();
1098}
1099
Alex Gildayc357c472018-03-21 13:54:09 +00001100/** Formatted output of the BorderSize type.
1101 *
1102 * @param[in] border Type to output.
1103 *
1104 * @return Formatted string.
1105 */
John Richardsonb482ce12017-09-18 12:44:01 +01001106inline std::string to_string(const BorderSize &border)
1107{
1108 std::stringstream str;
1109 str << border;
1110 return str.str();
1111}
1112
Alex Gildayc357c472018-03-21 13:54:09 +00001113/** Formatted output of the InterpolationPolicy type.
1114 *
1115 * @param[in] policy Type to output.
1116 *
1117 * @return Formatted string.
1118 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001119inline std::string to_string(const InterpolationPolicy &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 SamplingPolicy type.
1127 *
1128 * @param[in] policy Type to output.
1129 *
1130 * @return Formatted string.
1131 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +07001132inline std::string to_string(const SamplingPolicy &policy)
1133{
1134 std::stringstream str;
1135 str << policy;
1136 return str.str();
1137}
1138
Alex Gildayc357c472018-03-21 13:54:09 +00001139/** Formatted output of the ConvertPolicy type.
1140 *
1141 * @param[out] os Output stream.
1142 * @param[in] policy Type to output.
1143 *
1144 * @return Modified output stream.
1145 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001146inline ::std::ostream &operator<<(::std::ostream &os, const ConvertPolicy &policy)
1147{
1148 switch(policy)
1149 {
1150 case ConvertPolicy::WRAP:
1151 os << "WRAP";
1152 break;
1153 case ConvertPolicy::SATURATE:
1154 os << "SATURATE";
1155 break;
1156 default:
1157 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1158 }
1159
1160 return os;
1161}
1162
1163inline std::string to_string(const ConvertPolicy &policy)
1164{
1165 std::stringstream str;
1166 str << policy;
1167 return str.str();
1168}
1169
Alex Gildayc357c472018-03-21 13:54:09 +00001170/** Formatted output of the Reduction Operations.
1171 *
1172 * @param[out] os Output stream.
1173 * @param[in] op Type to output.
1174 *
1175 * @return Modified output stream.
1176 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001177inline ::std::ostream &operator<<(::std::ostream &os, const ReductionOperation &op)
1178{
1179 switch(op)
1180 {
1181 case ReductionOperation::SUM_SQUARE:
1182 os << "SUM_SQUARE";
1183 break;
1184 default:
1185 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1186 }
1187
1188 return os;
1189}
1190
Alex Gildayc357c472018-03-21 13:54:09 +00001191/** Formatted output of the Reduction Operations.
1192 *
1193 * @param[in] op Type to output.
1194 *
1195 * @return Formatted string.
1196 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001197inline std::string to_string(const ReductionOperation &op)
1198{
1199 std::stringstream str;
1200 str << op;
1201 return str.str();
1202}
1203
Alex Gildayc357c472018-03-21 13:54:09 +00001204/** Formatted output of the Norm 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 NormType &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 Type.
1218 *
1219 * @param[in] type Type to output.
1220 *
1221 * @return Formatted string.
1222 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001223inline std::string to_string(const PoolingType &type)
1224{
1225 std::stringstream str;
1226 str << type;
1227 return str.str();
1228}
1229
Alex Gildayc357c472018-03-21 13:54:09 +00001230/** Formatted output of the Pooling Layer Info.
1231 *
1232 * @param[in] info Type to output.
1233 *
1234 * @return Formatted string.
1235 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001236inline std::string to_string(const PoolingLayerInfo &info)
1237{
1238 std::stringstream str;
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001239 str << "{Type=" << info.pool_type() << ","
1240 << "IsGlobalPooling=" << info.is_global_pooling();
1241 if(!info.is_global_pooling())
1242 {
1243 str << ","
Isabella Gottardi6e464c32018-01-26 12:32:45 +00001244 << "PoolSize=" << info.pool_size().width << "," << info.pool_size().height << ","
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001245 << "PadStride=" << info.pad_stride_info();
1246 }
1247 str << "}";
Anthony Barbier2a07e182017-08-04 18:20:27 +01001248 return str.str();
1249}
1250
Alex Gildayc357c472018-03-21 13:54:09 +00001251/** Formatted output of the KeyPoint type.
1252 *
1253 * @param[out] os Output stream
1254 * @param[in] point Type to output.
1255 *
1256 * @return Modified output stream.
1257 */
Moritz Pflanzer6c6597c2017-09-24 12:09:41 +01001258inline ::std::ostream &operator<<(::std::ostream &os, const KeyPoint &point)
1259{
1260 os << "{x=" << point.x << ","
1261 << "y=" << point.y << ","
1262 << "strength=" << point.strength << ","
1263 << "scale=" << point.scale << ","
1264 << "orientation=" << point.orientation << ","
1265 << "tracking_status=" << point.tracking_status << ","
1266 << "error=" << point.error << "}";
1267
1268 return os;
1269}
John Richardson63e50412017-10-13 20:51:42 +01001270
Alex Gildayc357c472018-03-21 13:54:09 +00001271/** Formatted output of the PhaseType type.
1272 *
1273 * @param[out] os Output stream
1274 * @param[in] phase_type Type to output.
1275 *
1276 * @return Modified output stream.
1277 */
John Richardson63e50412017-10-13 20:51:42 +01001278inline ::std::ostream &operator<<(::std::ostream &os, const PhaseType &phase_type)
1279{
1280 switch(phase_type)
1281 {
1282 case PhaseType::SIGNED:
1283 os << "SIGNED";
1284 break;
1285 case PhaseType::UNSIGNED:
1286 os << "UNSIGNED";
1287 break;
1288 default:
1289 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1290 }
1291
1292 return os;
1293}
1294
Alex Gildayc357c472018-03-21 13:54:09 +00001295/** Formatted output of the PhaseType type.
1296 *
1297 * @param[in] type Type to output.
1298 *
1299 * @return Formatted string.
1300 */
John Richardson63e50412017-10-13 20:51:42 +01001301inline std::string to_string(const arm_compute::PhaseType &type)
1302{
1303 std::stringstream str;
1304 str << type;
1305 return str.str();
1306}
John Richardson3c5f9492017-10-04 15:27:37 +01001307
Alex Gildayc357c472018-03-21 13:54:09 +00001308/** Formatted output of the MagnitudeType type.
1309 *
1310 * @param[out] os Output stream
1311 * @param[in] magnitude_type Type to output.
1312 *
1313 * @return Modified output stream.
1314 */
John Richardson3c5f9492017-10-04 15:27:37 +01001315inline ::std::ostream &operator<<(::std::ostream &os, const MagnitudeType &magnitude_type)
1316{
1317 switch(magnitude_type)
1318 {
1319 case MagnitudeType::L1NORM:
1320 os << "L1NORM";
1321 break;
1322 case MagnitudeType::L2NORM:
1323 os << "L2NORM";
1324 break;
1325 default:
1326 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1327 }
1328
1329 return os;
1330}
1331
Alex Gildayc357c472018-03-21 13:54:09 +00001332/** Formatted output of the MagnitudeType type.
1333 *
1334 * @param[in] type Type to output.
1335 *
1336 * @return Formatted string.
1337 */
John Richardson3c5f9492017-10-04 15:27:37 +01001338inline std::string to_string(const arm_compute::MagnitudeType &type)
1339{
1340 std::stringstream str;
1341 str << type;
1342 return str.str();
1343}
John Richardson1c529922017-11-01 10:57:48 +00001344
Alex Gildayc357c472018-03-21 13:54:09 +00001345/** Formatted output of the GradientDimension type.
1346 *
1347 * @param[out] os Output stream
1348 * @param[in] dim Type to output
1349 *
1350 * @return Modified output stream.
1351 */
John Richardson1c529922017-11-01 10:57:48 +00001352inline ::std::ostream &operator<<(::std::ostream &os, const GradientDimension &dim)
1353{
1354 switch(dim)
1355 {
1356 case GradientDimension::GRAD_X:
1357 os << "GRAD_X";
1358 break;
1359 case GradientDimension::GRAD_Y:
1360 os << "GRAD_Y";
1361 break;
1362 case GradientDimension::GRAD_XY:
1363 os << "GRAD_XY";
1364 break;
1365 default:
1366 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1367 }
1368
1369 return os;
1370}
1371
Alex Gildayc357c472018-03-21 13:54:09 +00001372/** Formatted output of the GradientDimension type.
1373 *
1374 * @param[in] type Type to output
1375 *
1376 * @return Formatted string.
1377 */
John Richardson1c529922017-11-01 10:57:48 +00001378inline std::string to_string(const arm_compute::GradientDimension &type)
1379{
1380 std::stringstream str;
1381 str << type;
1382 return str.str();
1383}
John Richardson25f23682017-11-27 14:35:09 +00001384
Alex Gildayc357c472018-03-21 13:54:09 +00001385/** Formatted output of the HOGNormType type.
1386 *
1387 * @param[out] os Output stream
1388 * @param[in] norm_type Type to output
1389 *
1390 * @return Modified output stream.
1391 */
John Richardson25f23682017-11-27 14:35:09 +00001392inline ::std::ostream &operator<<(::std::ostream &os, const HOGNormType &norm_type)
1393{
1394 switch(norm_type)
1395 {
1396 case HOGNormType::L1_NORM:
1397 os << "L1_NORM";
1398 break;
1399 case HOGNormType::L2_NORM:
1400 os << "L2_NORM";
1401 break;
1402 case HOGNormType::L2HYS_NORM:
1403 os << "L2HYS_NORM";
1404 break;
1405 default:
1406 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1407 }
1408
1409 return os;
1410}
1411
Alex Gildayc357c472018-03-21 13:54:09 +00001412/** Formatted output of the HOGNormType type.
1413 *
1414 * @param[in] type Type to output
1415 *
1416 * @return Formatted string.
1417 */
John Richardson25f23682017-11-27 14:35:09 +00001418inline std::string to_string(const HOGNormType &type)
1419{
1420 std::stringstream str;
1421 str << type;
1422 return str.str();
1423}
1424
Alex Gildayc357c472018-03-21 13:54:09 +00001425/** Formatted output of the Size2D type.
1426 *
1427 * @param[out] os Output stream
1428 * @param[in] size Type to output
1429 *
1430 * @return Modified output stream.
1431 */
John Richardson25f23682017-11-27 14:35:09 +00001432inline ::std::ostream &operator<<(::std::ostream &os, const Size2D &size)
1433{
1434 os << size.width << "x" << size.height;
1435
1436 return os;
1437}
1438
Alex Gildayc357c472018-03-21 13:54:09 +00001439/** Formatted output of the Size2D type.
1440 *
1441 * @param[in] type Type to output
1442 *
1443 * @return Formatted string.
1444 */
John Richardson25f23682017-11-27 14:35:09 +00001445inline std::string to_string(const Size2D &type)
1446{
1447 std::stringstream str;
1448 str << type;
1449 return str.str();
1450}
1451
Alex Gildayc357c472018-03-21 13:54:09 +00001452/** Formatted output of the HOGInfo type.
1453 *
1454 * @param[out] os Output stream
1455 * @param[in] hog_info Type to output
1456 *
1457 * @return Modified output stream.
1458 */
John Richardson25f23682017-11-27 14:35:09 +00001459inline ::std::ostream &operator<<(::std::ostream &os, const HOGInfo &hog_info)
1460{
1461 os << "{CellSize=" << hog_info.cell_size() << ","
1462 << "BlockSize=" << hog_info.block_size() << ","
1463 << "DetectionWindowSize=" << hog_info.detection_window_size() << ","
1464 << "BlockStride=" << hog_info.block_stride() << ","
1465 << "NumBins=" << hog_info.num_bins() << ","
1466 << "NormType=" << hog_info.normalization_type() << ","
1467 << "L2HystThreshold=" << hog_info.l2_hyst_threshold() << ","
1468 << "PhaseType=" << hog_info.phase_type() << "}";
1469
1470 return os;
1471}
1472
Alex Gildayc357c472018-03-21 13:54:09 +00001473/** Formatted output of the HOGInfo type.
1474 *
1475 * @param[in] type Type to output
1476 *
1477 * @return Formatted string.
1478 */
John Richardson25f23682017-11-27 14:35:09 +00001479inline std::string to_string(const HOGInfo &type)
1480{
1481 std::stringstream str;
1482 str << type;
1483 return str.str();
1484}
1485
Alex Gildayc357c472018-03-21 13:54:09 +00001486/** Formatted output of the ConvolutionMethod type.
1487 *
1488 * @param[out] os Output stream
1489 * @param[in] conv_method Type to output
1490 *
1491 * @return Modified output stream.
1492 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001493inline ::std::ostream &operator<<(::std::ostream &os, const ConvolutionMethod &conv_method)
1494{
1495 switch(conv_method)
1496 {
1497 case ConvolutionMethod::GEMM:
1498 os << "GEMM";
1499 break;
1500 case ConvolutionMethod::DIRECT:
1501 os << "DIRECT";
1502 break;
1503 case ConvolutionMethod::WINOGRAD:
1504 os << "WINOGRAD";
1505 break;
1506 default:
1507 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1508 }
1509
1510 return os;
1511}
1512
Alex Gildayc357c472018-03-21 13:54:09 +00001513/** Formatted output of the ConvolutionMethod type.
1514 *
1515 * @param[in] conv_method Type to output
1516 *
1517 * @return Formatted string.
1518 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001519inline std::string to_string(const ConvolutionMethod &conv_method)
1520{
1521 std::stringstream str;
1522 str << conv_method;
1523 return str.str();
1524}
1525
Alex Gildayc357c472018-03-21 13:54:09 +00001526/** Formatted output of the GPUTarget type.
1527 *
1528 * @param[out] os Output stream
1529 * @param[in] gpu_target Type to output
1530 *
1531 * @return Modified output stream.
1532 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001533inline ::std::ostream &operator<<(::std::ostream &os, const GPUTarget &gpu_target)
1534{
1535 switch(gpu_target)
1536 {
1537 case GPUTarget::GPU_ARCH_MASK:
1538 os << "GPU_ARCH_MASK";
1539 break;
1540 case GPUTarget::MIDGARD:
1541 os << "MIDGARD";
1542 break;
1543 case GPUTarget::BIFROST:
1544 os << "BIFROST";
1545 break;
1546 case GPUTarget::T600:
1547 os << "T600";
1548 break;
1549 case GPUTarget::T700:
1550 os << "T700";
1551 break;
1552 case GPUTarget::T800:
1553 os << "T800";
1554 break;
Michalis Spyroua9676112018-02-22 18:07:43 +00001555 case GPUTarget::G71:
1556 os << "G71";
1557 break;
1558 case GPUTarget::G72:
1559 os << "G72";
1560 break;
1561 case GPUTarget::G51:
1562 os << "G51";
1563 break;
1564 case GPUTarget::G51BIG:
1565 os << "G51BIG";
1566 break;
1567 case GPUTarget::G51LIT:
1568 os << "G51LIT";
1569 break;
Georgios Pinitasb03f7c52018-07-12 10:49:53 +01001570 case GPUTarget::G76:
1571 os << "G76";
Michalis Spyroua9676112018-02-22 18:07:43 +00001572 break;
1573 case GPUTarget::TTRX:
1574 os << "TTRX";
1575 break;
1576 case GPUTarget::TBOX:
1577 os << "TBOX";
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001578 break;
1579 default:
1580 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1581 }
1582
1583 return os;
1584}
1585
Alex Gildayc357c472018-03-21 13:54:09 +00001586/** Formatted output of the GPUTarget type.
1587 *
1588 * @param[in] gpu_target Type to output
1589 *
1590 * @return Formatted string.
1591 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001592inline std::string to_string(const GPUTarget &gpu_target)
1593{
1594 std::stringstream str;
1595 str << gpu_target;
1596 return str.str();
1597}
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00001598
John Richardson8de92612018-02-22 14:09:31 +00001599/** Formatted output of the DetectionWindow type.
1600 *
1601 * @param[out] os Output stream
1602 * @param[in] detection_window Type to output
1603 *
1604 * @return Modified output stream.
1605 */
John Richardson684cb0f2018-01-09 11:17:00 +00001606inline ::std::ostream &operator<<(::std::ostream &os, const DetectionWindow &detection_window)
1607{
1608 os << "{x=" << detection_window.x << ","
1609 << "y=" << detection_window.y << ","
1610 << "width=" << detection_window.width << ","
1611 << "height=" << detection_window.height << ","
1612 << "idx_class=" << detection_window.idx_class << ","
1613 << "score=" << detection_window.score << "}";
1614
1615 return os;
1616}
1617
John Richardson8de92612018-02-22 14:09:31 +00001618/** Formatted output of the DetectionWindow type.
1619 *
1620 * @param[in] detection_window Type to output
1621 *
1622 * @return Formatted string.
1623 */
1624inline std::string to_string(const DetectionWindow &detection_window)
1625{
1626 std::stringstream str;
1627 str << detection_window;
1628 return str.str();
1629}
1630
1631/** Formatted output of the Termination type.
1632 *
1633 * @param[out] os Output stream
1634 * @param[in] termination Type to output
1635 *
1636 * @return Modified output stream.
1637 */
1638inline ::std::ostream &operator<<(::std::ostream &os, const Termination &termination)
1639{
1640 switch(termination)
1641 {
1642 case Termination::TERM_CRITERIA_EPSILON:
1643 os << "TERM_CRITERIA_EPSILON";
1644 break;
1645 case Termination::TERM_CRITERIA_ITERATIONS:
1646 os << "TERM_CRITERIA_ITERATIONS";
1647 break;
1648 case Termination::TERM_CRITERIA_BOTH:
1649 os << "TERM_CRITERIA_BOTH";
1650 break;
1651 default:
1652 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1653 }
1654
1655 return os;
1656}
1657
1658/** Formatted output of the Termination type.
1659 *
1660 * @param[in] termination Type to output
1661 *
1662 * @return Formatted string.
1663 */
1664inline std::string to_string(const Termination &termination)
1665{
1666 std::stringstream str;
1667 str << termination;
1668 return str.str();
1669}
1670
Anthony Barbier8914e322018-08-10 15:28:25 +01001671/** Formatted output of the CPUModel type.
1672 *
1673 * @param[out] os Output stream
1674 * @param[in] cpu_model Model to output
1675 *
1676 * @return Modified output stream.
1677 */
1678inline ::std::ostream &operator<<(::std::ostream &os, const CPUModel &cpu_model)
1679{
1680 switch(cpu_model)
1681 {
1682 case CPUModel::GENERIC:
1683 os << "GENERIC";
1684 break;
1685 case CPUModel::GENERIC_FP16:
1686 os << "GENERIC_FP16";
1687 break;
1688 case CPUModel::GENERIC_FP16_DOT:
1689 os << "GENERIC_FP16_DOT";
1690 break;
1691 case CPUModel::A53:
1692 os << "A53";
1693 break;
1694 case CPUModel::A55r0:
1695 os << "A55r0";
1696 break;
1697 case CPUModel::A55r1:
1698 os << "A55r1";
1699 break;
1700 default:
1701 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1702 }
1703
1704 return os;
1705}
1706
1707/** Formatted output of the CPUModel type.
1708 *
1709 * @param[in] cpu_model Model to output
1710 *
1711 * @return Formatted string.
1712 */
1713inline std::string to_string(const CPUModel &cpu_model)
1714{
1715 std::stringstream str;
1716 str << cpu_model;
1717 return str.str();
1718}
Anthony Barbier671a11e2018-07-06 15:11:36 +01001719/** Formatted output of a vector of objects.
1720 *
1721 * @param[out] os Output stream
1722 * @param[in] args Vector of objects to print
1723 *
1724 * @return Modified output stream.
1725 */
1726template <typename T>
1727inline ::std::ostream &operator<<(::std::ostream &os, const std::vector<T> &args)
1728{
1729 os << "[";
1730 bool first = true;
1731 for(auto &arg : args)
1732 {
1733 if(first)
1734 {
1735 first = false;
1736 }
1737 else
1738 {
1739 os << ", ";
1740 }
1741 os << arg;
1742 }
1743 os << "]";
1744 return os;
1745}
1746
1747/** Formatted output of a vector of objects.
1748 *
1749 * @param[in] args Vector of objects to print
1750 *
1751 * @return String representing args.
1752 */
1753template <typename T>
1754std::string to_string(const std::vector<T> &args)
1755{
1756 std::stringstream str;
1757 str << args;
1758 return str.str();
1759}
1760
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00001761/** Formatted output of the WinogradInfo type. */
1762inline ::std::ostream &operator<<(::std::ostream &os, const WinogradInfo &info)
1763{
1764 os << "{OutputTileSize=" << info.output_tile_size << ","
1765 << "KernelSize=" << info.kernel_size << ","
1766 << "PadStride=" << info.convolution_info << ","
1767 << "OutputDataLayout=" << info.output_data_layout << "}";
1768
1769 return os;
1770}
1771
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00001772inline std::string to_string(const WinogradInfo &type)
1773{
1774 std::stringstream str;
1775 str << type;
1776 return str.str();
1777}
Anthony Barbier671a11e2018-07-06 15:11:36 +01001778
1779/** Fallback method: try to use std::to_string:
1780 *
1781 * @param[in] val Value to convert to string
1782 *
1783 * @return String representing val.
1784 */
1785template <typename T>
1786inline std::string to_string(const T &val)
1787{
1788 return support::cpp11::to_string(val);
1789}
1790
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001791} // namespace arm_compute
John Richardson8de92612018-02-22 14:09:31 +00001792#endif /* __ARM_COMPUTE_TEST_TYPE_PRINTER_H__ */