blob: 49c07938bd47c96b5eae5da80e377d1d3aea7600 [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}
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
Alex Gildayc357c472018-03-21 13:54:09 +0000479/** Formatted output of the DataType type.
480 *
481 * @param[out] os Output stream.
482 * @param[in] data_type Type to output.
483 *
484 * @return Modified output stream.
485 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100486inline ::std::ostream &operator<<(::std::ostream &os, const DataType &data_type)
487{
488 switch(data_type)
489 {
490 case DataType::UNKNOWN:
491 os << "UNKNOWN";
492 break;
493 case DataType::U8:
494 os << "U8";
495 break;
Chunosovd621bca2017-11-03 17:33:15 +0700496 case DataType::QASYMM8:
497 os << "QASYMM8";
498 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100499 case DataType::S8:
500 os << "S8";
501 break;
502 case DataType::U16:
503 os << "U16";
504 break;
505 case DataType::S16:
506 os << "S16";
507 break;
508 case DataType::U32:
509 os << "U32";
510 break;
511 case DataType::S32:
512 os << "S32";
513 break;
514 case DataType::U64:
515 os << "U64";
516 break;
517 case DataType::S64:
518 os << "S64";
519 break;
520 case DataType::F16:
521 os << "F16";
522 break;
523 case DataType::F32:
524 os << "F32";
525 break;
526 case DataType::F64:
527 os << "F64";
528 break;
529 case DataType::SIZET:
530 os << "SIZET";
531 break;
532 default:
533 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
534 }
535
536 return os;
537}
538
Alex Gildayc357c472018-03-21 13:54:09 +0000539/** Formatted output of the DataType type.
540 *
541 * @param[in] data_type Type to output.
542 *
543 * @return Formatted string.
544 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100545inline std::string to_string(const arm_compute::DataType &data_type)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100546{
547 std::stringstream str;
548 str << data_type;
549 return str.str();
550}
551
Alex Gildayc357c472018-03-21 13:54:09 +0000552/** Formatted output of the Format type.
553 *
554 * @param[out] os Output stream.
555 * @param[in] format Type to output.
556 *
557 * @return Modified output stream.
558 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100559inline ::std::ostream &operator<<(::std::ostream &os, const Format &format)
560{
561 switch(format)
562 {
563 case Format::UNKNOWN:
564 os << "UNKNOWN";
565 break;
566 case Format::U8:
567 os << "U8";
568 break;
569 case Format::S16:
570 os << "S16";
571 break;
572 case Format::U16:
573 os << "U16";
574 break;
575 case Format::S32:
576 os << "S32";
577 break;
578 case Format::U32:
579 os << "U32";
580 break;
581 case Format::F16:
582 os << "F16";
583 break;
584 case Format::F32:
585 os << "F32";
586 break;
587 case Format::UV88:
588 os << "UV88";
589 break;
590 case Format::RGB888:
591 os << "RGB888";
592 break;
593 case Format::RGBA8888:
594 os << "RGBA8888";
595 break;
596 case Format::YUV444:
597 os << "YUV444";
598 break;
599 case Format::YUYV422:
600 os << "YUYV422";
601 break;
602 case Format::NV12:
603 os << "NV12";
604 break;
605 case Format::NV21:
606 os << "NV21";
607 break;
608 case Format::IYUV:
609 os << "IYUV";
610 break;
611 case Format::UYVY422:
612 os << "UYVY422";
613 break;
614 default:
615 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
616 }
617
618 return os;
619}
620
Alex Gildayc357c472018-03-21 13:54:09 +0000621/** Formatted output of the Format type.
622 *
623 * @param[in] format Type to output.
624 *
625 * @return Formatted string.
626 */
Moritz Pflanzer7655a672017-09-23 11:57:33 +0100627inline std::string to_string(const Format &format)
628{
629 std::stringstream str;
630 str << format;
631 return str.str();
632}
633
Alex Gildayc357c472018-03-21 13:54:09 +0000634/** Formatted output of the Channel type.
635 *
636 * @param[out] os Output stream.
637 * @param[in] channel Type to output.
638 *
639 * @return Modified output stream.
640 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100641inline ::std::ostream &operator<<(::std::ostream &os, const Channel &channel)
642{
643 switch(channel)
644 {
645 case Channel::UNKNOWN:
646 os << "UNKNOWN";
647 break;
648 case Channel::C0:
649 os << "C0";
650 break;
651 case Channel::C1:
652 os << "C1";
653 break;
654 case Channel::C2:
655 os << "C2";
656 break;
657 case Channel::C3:
658 os << "C3";
659 break;
660 case Channel::R:
661 os << "R";
662 break;
663 case Channel::G:
664 os << "G";
665 break;
666 case Channel::B:
667 os << "B";
668 break;
669 case Channel::A:
670 os << "A";
671 break;
672 case Channel::Y:
673 os << "Y";
674 break;
675 case Channel::U:
676 os << "U";
677 break;
678 case Channel::V:
679 os << "V";
680 break;
681 default:
682 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
683 }
684
685 return os;
686}
687
Alex Gildayc357c472018-03-21 13:54:09 +0000688/** Formatted output of the Channel type.
689 *
690 * @param[in] channel Type to output.
691 *
692 * @return Formatted string.
693 */
Ioan-Cristian Szabo9414f642017-10-27 17:35:40 +0100694inline std::string to_string(const Channel &channel)
695{
696 std::stringstream str;
697 str << channel;
698 return str.str();
699}
700
Alex Gildayc357c472018-03-21 13:54:09 +0000701/** Formatted output of the BorderMode type.
702 *
703 * @param[out] os Output stream.
704 * @param[in] mode Type to output.
705 *
706 * @return Modified output stream.
707 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100708inline ::std::ostream &operator<<(::std::ostream &os, const BorderMode &mode)
709{
710 switch(mode)
711 {
712 case BorderMode::UNDEFINED:
713 os << "UNDEFINED";
714 break;
715 case BorderMode::CONSTANT:
716 os << "CONSTANT";
717 break;
718 case BorderMode::REPLICATE:
719 os << "REPLICATE";
720 break;
721 default:
722 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
723 }
724
725 return os;
726}
727
Alex Gildayc357c472018-03-21 13:54:09 +0000728/** Formatted output of the BorderSize type.
729 *
730 * @param[out] os Output stream.
731 * @param[in] border Type to output.
732 *
733 * @return Modified output stream.
734 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100735inline ::std::ostream &operator<<(::std::ostream &os, const BorderSize &border)
736{
Moritz Pflanzerc87fbf82017-07-18 14:02:10 +0100737 os << border.top << ","
738 << border.right << ","
739 << border.bottom << ","
740 << border.left;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100741
742 return os;
743}
Anthony Barbier2a07e182017-08-04 18:20:27 +0100744
Alex Gildayc357c472018-03-21 13:54:09 +0000745/** Formatted output of the InterpolationPolicy type.
746 *
747 * @param[out] os Output stream.
748 * @param[in] policy Type to output.
749 *
750 * @return Modified output stream.
751 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100752inline ::std::ostream &operator<<(::std::ostream &os, const InterpolationPolicy &policy)
753{
754 switch(policy)
755 {
756 case InterpolationPolicy::NEAREST_NEIGHBOR:
757 os << "NEAREST_NEIGHBOR";
758 break;
759 case InterpolationPolicy::BILINEAR:
760 os << "BILINEAR";
761 break;
762 case InterpolationPolicy::AREA:
763 os << "AREA";
764 break;
765 default:
766 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
767 }
768
769 return os;
770}
771
Alex Gildayc357c472018-03-21 13:54:09 +0000772/** Formatted output of the SamplingPolicy type.
773 *
774 * @param[out] os Output stream.
775 * @param[in] policy Type to output.
776 *
777 * @return Modified output stream.
778 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700779inline ::std::ostream &operator<<(::std::ostream &os, const SamplingPolicy &policy)
780{
781 switch(policy)
782 {
783 case SamplingPolicy::CENTER:
784 os << "CENTER";
785 break;
786 case SamplingPolicy::TOP_LEFT:
787 os << "TOP_LEFT";
788 break;
789 default:
790 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
791 }
792
793 return os;
794}
795
Alex Gildayc357c472018-03-21 13:54:09 +0000796/** Formatted output of the TensorInfo type.
797 *
798 * @param[in] info Type to output.
799 *
800 * @return Formatted string.
801 */
Georgios Pinitas3faea252017-10-30 14:13:50 +0000802inline std::string to_string(const TensorInfo &info)
803{
804 std::stringstream str;
805 str << "{Shape=" << info.tensor_shape() << ","
806 << "Type=" << info.data_type() << ","
Vidhya Sudhan Loganathan7485d5a2018-07-04 09:34:00 +0100807 << "Channels=" << info.num_channels() << "}";
Georgios Pinitas3faea252017-10-30 14:13:50 +0000808 return str.str();
809}
810
Abe Mbise925ca0f2017-10-02 19:16:33 +0100811//FIXME: Check why this doesn't work and the TensorShape and Coordinates overload are needed
Alex Gildayc357c472018-03-21 13:54:09 +0000812/** Formatted output of the Dimensions type.
813 *
814 * @param[in] dimensions Type to output.
815 *
816 * @return Formatted string.
817 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100818template <typename T>
819inline std::string to_string(const Dimensions<T> &dimensions)
820{
821 std::stringstream str;
822 str << dimensions;
823 return str.str();
824}
825
Alex Gildayc357c472018-03-21 13:54:09 +0000826/** Formatted output of the Strides type.
827 *
828 * @param[in] stride Type to output.
829 *
830 * @return Formatted string.
831 */
John Richardsona36eae12017-09-26 16:55:59 +0100832inline std::string to_string(const Strides &stride)
833{
834 std::stringstream str;
835 str << stride;
836 return str.str();
837}
838
Alex Gildayc357c472018-03-21 13:54:09 +0000839/** Formatted output of the TensorShape type.
840 *
841 * @param[in] shape Type to output.
842 *
843 * @return Formatted string.
844 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100845inline std::string to_string(const TensorShape &shape)
846{
847 std::stringstream str;
848 str << shape;
849 return str.str();
850}
851
Alex Gildayc357c472018-03-21 13:54:09 +0000852/** Formatted output of the Coordinates type.
853 *
854 * @param[in] coord Type to output.
855 *
856 * @return Formatted string.
857 */
Abe Mbise925ca0f2017-10-02 19:16:33 +0100858inline std::string to_string(const Coordinates &coord)
859{
860 std::stringstream str;
861 str << coord;
862 return str.str();
863}
864
Anthony Barbierb940fd62018-06-04 14:14:32 +0100865/** Formatted output of the GEMMReshapeInfo type.
866 *
867 * @param[out] os Output stream.
868 * @param[in] info Type to output.
869 *
870 * @return Modified output stream.
871 */
872inline ::std::ostream &operator<<(::std::ostream &os, const GEMMReshapeInfo &info)
873{
874 os << "{m=" << info.m() << ",";
875 os << "n=" << info.n() << ",";
876 os << "k=" << info.k() << ",";
877 os << "mult_transpose1xW_width=" << info.mult_transpose1xW_width() << ",";
878 os << "mult_interleave4x4_height=" << info.mult_interleave4x4_height();
879 os << "}";
880
881 return os;
882}
883
884/** Formatted output of the GEMMInfo type.
885 *
886 * @param[out] os Output stream.
887 * @param[in] info Type to output.
888 *
889 * @return Modified output stream.
890 */
891inline ::std::ostream &operator<<(::std::ostream &os, const GEMMInfo &info)
892{
893 os << "{is_a_reshaped=" << info.is_a_reshaped() << ",";
894 os << "is_b_reshaped=" << info.is_b_reshaped() << ",";
895 os << "reshape_b_only_on_first_run=" << info.reshape_b_only_on_first_run() << ",";
Anthony Barbierb940fd62018-06-04 14:14:32 +0100896 os << "}";
897
898 return os;
899}
900
901/** Formatted output of the Window::Dimension type.
902 *
903 * @param[out] os Output stream.
904 * @param[in] dim Type to output.
905 *
906 * @return Modified output stream.
907 */
908inline ::std::ostream &operator<<(::std::ostream &os, const Window::Dimension &dim)
909{
910 os << "{start=" << dim.start() << ", end=" << dim.end() << ", step=" << dim.step() << "}";
911
912 return os;
913}
914/** Formatted output of the Window type.
915 *
916 * @param[out] os Output stream.
917 * @param[in] win Type to output.
918 *
919 * @return Modified output stream.
920 */
921inline ::std::ostream &operator<<(::std::ostream &os, const Window &win)
922{
923 os << "{";
924 for(unsigned int i = 0; i < Coordinates::num_max_dimensions; i++)
925 {
926 if(i > 0)
927 {
928 os << ", ";
929 }
930 os << win[i];
931 }
932 os << "}";
933
934 return os;
935}
936
937/** Formatted output of the WeightsInfo type.
938 *
939 * @param[in] info Type to output.
940 *
941 * @return Formatted string.
942 */
943inline std::string to_string(const WeightsInfo &info)
944{
945 std::stringstream str;
946 str << info;
947 return str.str();
948}
949
950/** Formatted output of the GEMMReshapeInfo type.
951 *
952 * @param[in] info Type to output.
953 *
954 * @return Formatted string.
955 */
956inline std::string to_string(const GEMMReshapeInfo &info)
957{
958 std::stringstream str;
959 str << info;
960 return str.str();
961}
962
963/** Formatted output of the GEMMInfo type.
964 *
965 * @param[in] info Type to output.
966 *
967 * @return Formatted string.
968 */
969inline std::string to_string(const GEMMInfo &info)
970{
971 std::stringstream str;
972 str << info;
973 return str.str();
974}
975
976/** Formatted output of the Window::Dimension type.
977 *
978 * @param[in] dim Type to output.
979 *
980 * @return Formatted string.
981 */
982inline std::string to_string(const Window::Dimension &dim)
983{
984 std::stringstream str;
985 str << dim;
986 return str.str();
987}
988/** Formatted output of the Window type.
989 *
990 * @param[in] win Type to output.
991 *
992 * @return Formatted string.
993 */
994inline std::string to_string(const Window &win)
995{
996 std::stringstream str;
997 str << win;
998 return str.str();
999}
1000
Alex Gildayc357c472018-03-21 13:54:09 +00001001/** Formatted output of the Rectangle type.
1002 *
1003 * @param[out] os Output stream.
1004 * @param[in] rect Type to output.
1005 *
1006 * @return Modified output stream.
1007 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001008inline ::std::ostream &operator<<(::std::ostream &os, const Rectangle &rect)
1009{
1010 os << rect.width << "x" << rect.height;
1011 os << "+" << rect.x << "+" << rect.y;
1012
1013 return os;
1014}
1015
Alex Gildayc357c472018-03-21 13:54:09 +00001016/** Formatted output of the PadStrideInfo type.
1017 *
1018 * @param[out] os Output stream.
1019 * @param[in] pad_stride_info Type to output.
1020 *
1021 * @return Modified output stream.
1022 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001023inline ::std::ostream &operator<<(::std::ostream &os, const PadStrideInfo &pad_stride_info)
1024{
1025 os << pad_stride_info.stride().first << "," << pad_stride_info.stride().second;
1026 os << ";";
Jaroslaw Rzepeckia1ed41f2017-10-13 11:13:58 +01001027 os << pad_stride_info.pad_left() << "," << pad_stride_info.pad_right() << ","
1028 << pad_stride_info.pad_top() << "," << pad_stride_info.pad_bottom();
Anthony Barbier2a07e182017-08-04 18:20:27 +01001029
1030 return os;
1031}
1032
Alex Gildayc357c472018-03-21 13:54:09 +00001033/** Formatted output of the PadStrideInfo type.
1034 *
1035 * @param[in] pad_stride_info Type to output.
1036 *
1037 * @return Formatted string.
1038 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001039inline std::string to_string(const PadStrideInfo &pad_stride_info)
1040{
1041 std::stringstream str;
1042 str << pad_stride_info;
1043 return str.str();
1044}
1045
Alex Gildayc357c472018-03-21 13:54:09 +00001046/** Formatted output of the BorderMode type.
1047 *
1048 * @param[in] mode Type to output.
1049 *
1050 * @return Formatted string.
1051 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001052inline std::string to_string(const BorderMode &mode)
1053{
1054 std::stringstream str;
1055 str << mode;
1056 return str.str();
1057}
1058
Alex Gildayc357c472018-03-21 13:54:09 +00001059/** Formatted output of the BorderSize type.
1060 *
1061 * @param[in] border Type to output.
1062 *
1063 * @return Formatted string.
1064 */
John Richardsonb482ce12017-09-18 12:44:01 +01001065inline std::string to_string(const BorderSize &border)
1066{
1067 std::stringstream str;
1068 str << border;
1069 return str.str();
1070}
1071
Alex Gildayc357c472018-03-21 13:54:09 +00001072/** Formatted output of the InterpolationPolicy type.
1073 *
1074 * @param[in] policy Type to output.
1075 *
1076 * @return Formatted string.
1077 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001078inline std::string to_string(const InterpolationPolicy &policy)
1079{
1080 std::stringstream str;
1081 str << policy;
1082 return str.str();
1083}
1084
Alex Gildayc357c472018-03-21 13:54:09 +00001085/** Formatted output of the SamplingPolicy type.
1086 *
1087 * @param[in] policy Type to output.
1088 *
1089 * @return Formatted string.
1090 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +07001091inline std::string to_string(const SamplingPolicy &policy)
1092{
1093 std::stringstream str;
1094 str << policy;
1095 return str.str();
1096}
1097
Alex Gildayc357c472018-03-21 13:54:09 +00001098/** Formatted output of the ConvertPolicy type.
1099 *
1100 * @param[out] os Output stream.
1101 * @param[in] policy Type to output.
1102 *
1103 * @return Modified output stream.
1104 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001105inline ::std::ostream &operator<<(::std::ostream &os, const ConvertPolicy &policy)
1106{
1107 switch(policy)
1108 {
1109 case ConvertPolicy::WRAP:
1110 os << "WRAP";
1111 break;
1112 case ConvertPolicy::SATURATE:
1113 os << "SATURATE";
1114 break;
1115 default:
1116 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1117 }
1118
1119 return os;
1120}
1121
1122inline std::string to_string(const ConvertPolicy &policy)
1123{
1124 std::stringstream str;
1125 str << policy;
1126 return str.str();
1127}
1128
Alex Gildayc357c472018-03-21 13:54:09 +00001129/** Formatted output of the Reduction Operations.
1130 *
1131 * @param[out] os Output stream.
1132 * @param[in] op Type to output.
1133 *
1134 * @return Modified output stream.
1135 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001136inline ::std::ostream &operator<<(::std::ostream &os, const ReductionOperation &op)
1137{
1138 switch(op)
1139 {
1140 case ReductionOperation::SUM_SQUARE:
1141 os << "SUM_SQUARE";
1142 break;
1143 default:
1144 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1145 }
1146
1147 return os;
1148}
1149
Alex Gildayc357c472018-03-21 13:54:09 +00001150/** Formatted output of the Reduction Operations.
1151 *
1152 * @param[in] op Type to output.
1153 *
1154 * @return Formatted string.
1155 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001156inline std::string to_string(const ReductionOperation &op)
1157{
1158 std::stringstream str;
1159 str << op;
1160 return str.str();
1161}
1162
Alex Gildayc357c472018-03-21 13:54:09 +00001163/** Formatted output of the Norm Type.
1164 *
1165 * @param[in] type Type to output.
1166 *
1167 * @return Formatted string.
1168 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001169inline std::string to_string(const NormType &type)
1170{
1171 std::stringstream str;
1172 str << type;
1173 return str.str();
1174}
1175
Alex Gildayc357c472018-03-21 13:54:09 +00001176/** Formatted output of the Pooling Type.
1177 *
1178 * @param[in] type Type to output.
1179 *
1180 * @return Formatted string.
1181 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001182inline std::string to_string(const PoolingType &type)
1183{
1184 std::stringstream str;
1185 str << type;
1186 return str.str();
1187}
1188
Alex Gildayc357c472018-03-21 13:54:09 +00001189/** Formatted output of the Pooling Layer Info.
1190 *
1191 * @param[in] info Type to output.
1192 *
1193 * @return Formatted string.
1194 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001195inline std::string to_string(const PoolingLayerInfo &info)
1196{
1197 std::stringstream str;
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001198 str << "{Type=" << info.pool_type() << ","
1199 << "IsGlobalPooling=" << info.is_global_pooling();
1200 if(!info.is_global_pooling())
1201 {
1202 str << ","
Isabella Gottardi6e464c32018-01-26 12:32:45 +00001203 << "PoolSize=" << info.pool_size().width << "," << info.pool_size().height << ","
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001204 << "PadStride=" << info.pad_stride_info();
1205 }
1206 str << "}";
Anthony Barbier2a07e182017-08-04 18:20:27 +01001207 return str.str();
1208}
1209
Alex Gildayc357c472018-03-21 13:54:09 +00001210/** Formatted output of the KeyPoint type.
1211 *
1212 * @param[out] os Output stream
1213 * @param[in] point Type to output.
1214 *
1215 * @return Modified output stream.
1216 */
Moritz Pflanzer6c6597c2017-09-24 12:09:41 +01001217inline ::std::ostream &operator<<(::std::ostream &os, const KeyPoint &point)
1218{
1219 os << "{x=" << point.x << ","
1220 << "y=" << point.y << ","
1221 << "strength=" << point.strength << ","
1222 << "scale=" << point.scale << ","
1223 << "orientation=" << point.orientation << ","
1224 << "tracking_status=" << point.tracking_status << ","
1225 << "error=" << point.error << "}";
1226
1227 return os;
1228}
John Richardson63e50412017-10-13 20:51:42 +01001229
Alex Gildayc357c472018-03-21 13:54:09 +00001230/** Formatted output of the PhaseType type.
1231 *
1232 * @param[out] os Output stream
1233 * @param[in] phase_type Type to output.
1234 *
1235 * @return Modified output stream.
1236 */
John Richardson63e50412017-10-13 20:51:42 +01001237inline ::std::ostream &operator<<(::std::ostream &os, const PhaseType &phase_type)
1238{
1239 switch(phase_type)
1240 {
1241 case PhaseType::SIGNED:
1242 os << "SIGNED";
1243 break;
1244 case PhaseType::UNSIGNED:
1245 os << "UNSIGNED";
1246 break;
1247 default:
1248 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1249 }
1250
1251 return os;
1252}
1253
Alex Gildayc357c472018-03-21 13:54:09 +00001254/** Formatted output of the PhaseType type.
1255 *
1256 * @param[in] type Type to output.
1257 *
1258 * @return Formatted string.
1259 */
John Richardson63e50412017-10-13 20:51:42 +01001260inline std::string to_string(const arm_compute::PhaseType &type)
1261{
1262 std::stringstream str;
1263 str << type;
1264 return str.str();
1265}
John Richardson3c5f9492017-10-04 15:27:37 +01001266
Alex Gildayc357c472018-03-21 13:54:09 +00001267/** Formatted output of the MagnitudeType type.
1268 *
1269 * @param[out] os Output stream
1270 * @param[in] magnitude_type Type to output.
1271 *
1272 * @return Modified output stream.
1273 */
John Richardson3c5f9492017-10-04 15:27:37 +01001274inline ::std::ostream &operator<<(::std::ostream &os, const MagnitudeType &magnitude_type)
1275{
1276 switch(magnitude_type)
1277 {
1278 case MagnitudeType::L1NORM:
1279 os << "L1NORM";
1280 break;
1281 case MagnitudeType::L2NORM:
1282 os << "L2NORM";
1283 break;
1284 default:
1285 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1286 }
1287
1288 return os;
1289}
1290
Alex Gildayc357c472018-03-21 13:54:09 +00001291/** Formatted output of the MagnitudeType type.
1292 *
1293 * @param[in] type Type to output.
1294 *
1295 * @return Formatted string.
1296 */
John Richardson3c5f9492017-10-04 15:27:37 +01001297inline std::string to_string(const arm_compute::MagnitudeType &type)
1298{
1299 std::stringstream str;
1300 str << type;
1301 return str.str();
1302}
John Richardson1c529922017-11-01 10:57:48 +00001303
Alex Gildayc357c472018-03-21 13:54:09 +00001304/** Formatted output of the GradientDimension type.
1305 *
1306 * @param[out] os Output stream
1307 * @param[in] dim Type to output
1308 *
1309 * @return Modified output stream.
1310 */
John Richardson1c529922017-11-01 10:57:48 +00001311inline ::std::ostream &operator<<(::std::ostream &os, const GradientDimension &dim)
1312{
1313 switch(dim)
1314 {
1315 case GradientDimension::GRAD_X:
1316 os << "GRAD_X";
1317 break;
1318 case GradientDimension::GRAD_Y:
1319 os << "GRAD_Y";
1320 break;
1321 case GradientDimension::GRAD_XY:
1322 os << "GRAD_XY";
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 GradientDimension type.
1332 *
1333 * @param[in] type Type to output
1334 *
1335 * @return Formatted string.
1336 */
John Richardson1c529922017-11-01 10:57:48 +00001337inline std::string to_string(const arm_compute::GradientDimension &type)
1338{
1339 std::stringstream str;
1340 str << type;
1341 return str.str();
1342}
John Richardson25f23682017-11-27 14:35:09 +00001343
Alex Gildayc357c472018-03-21 13:54:09 +00001344/** Formatted output of the HOGNormType type.
1345 *
1346 * @param[out] os Output stream
1347 * @param[in] norm_type Type to output
1348 *
1349 * @return Modified output stream.
1350 */
John Richardson25f23682017-11-27 14:35:09 +00001351inline ::std::ostream &operator<<(::std::ostream &os, const HOGNormType &norm_type)
1352{
1353 switch(norm_type)
1354 {
1355 case HOGNormType::L1_NORM:
1356 os << "L1_NORM";
1357 break;
1358 case HOGNormType::L2_NORM:
1359 os << "L2_NORM";
1360 break;
1361 case HOGNormType::L2HYS_NORM:
1362 os << "L2HYS_NORM";
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 HOGNormType type.
1372 *
1373 * @param[in] type Type to output
1374 *
1375 * @return Formatted string.
1376 */
John Richardson25f23682017-11-27 14:35:09 +00001377inline std::string to_string(const HOGNormType &type)
1378{
1379 std::stringstream str;
1380 str << type;
1381 return str.str();
1382}
1383
Alex Gildayc357c472018-03-21 13:54:09 +00001384/** Formatted output of the Size2D type.
1385 *
1386 * @param[out] os Output stream
1387 * @param[in] size 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 Size2D &size)
1392{
1393 os << size.width << "x" << size.height;
1394
1395 return os;
1396}
1397
Alex Gildayc357c472018-03-21 13:54:09 +00001398/** Formatted output of the Size2D type.
1399 *
1400 * @param[in] type Type to output
1401 *
1402 * @return Formatted string.
1403 */
John Richardson25f23682017-11-27 14:35:09 +00001404inline std::string to_string(const Size2D &type)
1405{
1406 std::stringstream str;
1407 str << type;
1408 return str.str();
1409}
1410
Alex Gildayc357c472018-03-21 13:54:09 +00001411/** Formatted output of the HOGInfo type.
1412 *
1413 * @param[out] os Output stream
1414 * @param[in] hog_info Type to output
1415 *
1416 * @return Modified output stream.
1417 */
John Richardson25f23682017-11-27 14:35:09 +00001418inline ::std::ostream &operator<<(::std::ostream &os, const HOGInfo &hog_info)
1419{
1420 os << "{CellSize=" << hog_info.cell_size() << ","
1421 << "BlockSize=" << hog_info.block_size() << ","
1422 << "DetectionWindowSize=" << hog_info.detection_window_size() << ","
1423 << "BlockStride=" << hog_info.block_stride() << ","
1424 << "NumBins=" << hog_info.num_bins() << ","
1425 << "NormType=" << hog_info.normalization_type() << ","
1426 << "L2HystThreshold=" << hog_info.l2_hyst_threshold() << ","
1427 << "PhaseType=" << hog_info.phase_type() << "}";
1428
1429 return os;
1430}
1431
Alex Gildayc357c472018-03-21 13:54:09 +00001432/** Formatted output of the HOGInfo type.
1433 *
1434 * @param[in] type Type to output
1435 *
1436 * @return Formatted string.
1437 */
John Richardson25f23682017-11-27 14:35:09 +00001438inline std::string to_string(const HOGInfo &type)
1439{
1440 std::stringstream str;
1441 str << type;
1442 return str.str();
1443}
1444
Alex Gildayc357c472018-03-21 13:54:09 +00001445/** Formatted output of the ConvolutionMethod type.
1446 *
1447 * @param[out] os Output stream
1448 * @param[in] conv_method Type to output
1449 *
1450 * @return Modified output stream.
1451 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001452inline ::std::ostream &operator<<(::std::ostream &os, const ConvolutionMethod &conv_method)
1453{
1454 switch(conv_method)
1455 {
1456 case ConvolutionMethod::GEMM:
1457 os << "GEMM";
1458 break;
1459 case ConvolutionMethod::DIRECT:
1460 os << "DIRECT";
1461 break;
1462 case ConvolutionMethod::WINOGRAD:
1463 os << "WINOGRAD";
1464 break;
1465 default:
1466 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1467 }
1468
1469 return os;
1470}
1471
Alex Gildayc357c472018-03-21 13:54:09 +00001472/** Formatted output of the ConvolutionMethod type.
1473 *
1474 * @param[in] conv_method Type to output
1475 *
1476 * @return Formatted string.
1477 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001478inline std::string to_string(const ConvolutionMethod &conv_method)
1479{
1480 std::stringstream str;
1481 str << conv_method;
1482 return str.str();
1483}
1484
Alex Gildayc357c472018-03-21 13:54:09 +00001485/** Formatted output of the GPUTarget type.
1486 *
1487 * @param[out] os Output stream
1488 * @param[in] gpu_target 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 GPUTarget &gpu_target)
1493{
1494 switch(gpu_target)
1495 {
1496 case GPUTarget::GPU_ARCH_MASK:
1497 os << "GPU_ARCH_MASK";
1498 break;
1499 case GPUTarget::MIDGARD:
1500 os << "MIDGARD";
1501 break;
1502 case GPUTarget::BIFROST:
1503 os << "BIFROST";
1504 break;
1505 case GPUTarget::T600:
1506 os << "T600";
1507 break;
1508 case GPUTarget::T700:
1509 os << "T700";
1510 break;
1511 case GPUTarget::T800:
1512 os << "T800";
1513 break;
Michalis Spyroua9676112018-02-22 18:07:43 +00001514 case GPUTarget::G71:
1515 os << "G71";
1516 break;
1517 case GPUTarget::G72:
1518 os << "G72";
1519 break;
1520 case GPUTarget::G51:
1521 os << "G51";
1522 break;
1523 case GPUTarget::G51BIG:
1524 os << "G51BIG";
1525 break;
1526 case GPUTarget::G51LIT:
1527 os << "G51LIT";
1528 break;
1529 case GPUTarget::TNOX:
1530 os << "TNOX";
1531 break;
1532 case GPUTarget::TTRX:
1533 os << "TTRX";
1534 break;
1535 case GPUTarget::TBOX:
1536 os << "TBOX";
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001537 break;
1538 default:
1539 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1540 }
1541
1542 return os;
1543}
1544
Alex Gildayc357c472018-03-21 13:54:09 +00001545/** Formatted output of the GPUTarget type.
1546 *
1547 * @param[in] gpu_target Type to output
1548 *
1549 * @return Formatted string.
1550 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001551inline std::string to_string(const GPUTarget &gpu_target)
1552{
1553 std::stringstream str;
1554 str << gpu_target;
1555 return str.str();
1556}
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00001557
John Richardson8de92612018-02-22 14:09:31 +00001558/** Formatted output of the DetectionWindow type.
1559 *
1560 * @param[out] os Output stream
1561 * @param[in] detection_window Type to output
1562 *
1563 * @return Modified output stream.
1564 */
John Richardson684cb0f2018-01-09 11:17:00 +00001565inline ::std::ostream &operator<<(::std::ostream &os, const DetectionWindow &detection_window)
1566{
1567 os << "{x=" << detection_window.x << ","
1568 << "y=" << detection_window.y << ","
1569 << "width=" << detection_window.width << ","
1570 << "height=" << detection_window.height << ","
1571 << "idx_class=" << detection_window.idx_class << ","
1572 << "score=" << detection_window.score << "}";
1573
1574 return os;
1575}
1576
John Richardson8de92612018-02-22 14:09:31 +00001577/** Formatted output of the DetectionWindow type.
1578 *
1579 * @param[in] detection_window Type to output
1580 *
1581 * @return Formatted string.
1582 */
1583inline std::string to_string(const DetectionWindow &detection_window)
1584{
1585 std::stringstream str;
1586 str << detection_window;
1587 return str.str();
1588}
1589
1590/** Formatted output of the Termination type.
1591 *
1592 * @param[out] os Output stream
1593 * @param[in] termination Type to output
1594 *
1595 * @return Modified output stream.
1596 */
1597inline ::std::ostream &operator<<(::std::ostream &os, const Termination &termination)
1598{
1599 switch(termination)
1600 {
1601 case Termination::TERM_CRITERIA_EPSILON:
1602 os << "TERM_CRITERIA_EPSILON";
1603 break;
1604 case Termination::TERM_CRITERIA_ITERATIONS:
1605 os << "TERM_CRITERIA_ITERATIONS";
1606 break;
1607 case Termination::TERM_CRITERIA_BOTH:
1608 os << "TERM_CRITERIA_BOTH";
1609 break;
1610 default:
1611 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1612 }
1613
1614 return os;
1615}
1616
1617/** Formatted output of the Termination type.
1618 *
1619 * @param[in] termination Type to output
1620 *
1621 * @return Formatted string.
1622 */
1623inline std::string to_string(const Termination &termination)
1624{
1625 std::stringstream str;
1626 str << termination;
1627 return str.str();
1628}
1629
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00001630/** Formatted output of the WinogradInfo type. */
1631inline ::std::ostream &operator<<(::std::ostream &os, const WinogradInfo &info)
1632{
1633 os << "{OutputTileSize=" << info.output_tile_size << ","
1634 << "KernelSize=" << info.kernel_size << ","
1635 << "PadStride=" << info.convolution_info << ","
1636 << "OutputDataLayout=" << info.output_data_layout << "}";
1637
1638 return os;
1639}
1640
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00001641inline std::string to_string(const WinogradInfo &type)
1642{
1643 std::stringstream str;
1644 str << type;
1645 return str.str();
1646}
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001647} // namespace arm_compute
John Richardson8de92612018-02-22 14:09:31 +00001648#endif /* __ARM_COMPUTE_TEST_TYPE_PRINTER_H__ */