blob: 5805ee6ed095bcc10b708e30c8b63bc07de52838 [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001/*
John Richardson25f23682017-11-27 14:35:09 +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
27#include "arm_compute/core/Dimensions.h"
28#include "arm_compute/core/Error.h"
John Richardson25f23682017-11-27 14:35:09 +000029#include "arm_compute/core/HOGInfo.h"
30#include "arm_compute/core/Size2D.h"
John Richardsona36eae12017-09-26 16:55:59 +010031#include "arm_compute/core/Strides.h"
Georgios Pinitas3faea252017-10-30 14:13:50 +000032#include "arm_compute/core/TensorInfo.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010033#include "arm_compute/core/Types.h"
34
Abe Mbise4bd2cb82017-09-27 18:39:19 +010035#include "tests/Types.h"
36
Anthony Barbier6ff3b192017-09-04 18:44:23 +010037#include <ostream>
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010038#include <sstream>
39#include <string>
Anthony Barbier6ff3b192017-09-04 18:44:23 +010040
41namespace arm_compute
42{
43/** Formatted output of the Dimensions type. */
44template <typename T>
45inline ::std::ostream &operator<<(::std::ostream &os, const Dimensions<T> &dimensions)
46{
Anthony Barbier6ff3b192017-09-04 18:44:23 +010047 if(dimensions.num_dimensions() > 0)
48 {
49 os << dimensions[0];
50
51 for(unsigned int d = 1; d < dimensions.num_dimensions(); ++d)
52 {
Moritz Pflanzerc87fbf82017-07-18 14:02:10 +010053 os << "x" << dimensions[d];
Anthony Barbier6ff3b192017-09-04 18:44:23 +010054 }
55 }
56
Anthony Barbier6ff3b192017-09-04 18:44:23 +010057 return os;
58}
59
Isabella Gottardi3b77e9d2017-06-22 11:05:41 +010060/** Formatted output of the NonLinearFilterFunction type. */
61inline ::std::ostream &operator<<(::std::ostream &os, const NonLinearFilterFunction &function)
62{
63 switch(function)
64 {
65 case NonLinearFilterFunction::MAX:
66 os << "MAX";
67 break;
68 case NonLinearFilterFunction::MEDIAN:
69 os << "MEDIAN";
70 break;
71 case NonLinearFilterFunction::MIN:
72 os << "MIN";
73 break;
74 default:
75 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
76 }
77
78 return os;
79}
80
John Richardson6f4d49f2017-09-07 11:21:10 +010081inline std::string to_string(const NonLinearFilterFunction &function)
82{
83 std::stringstream str;
84 str << function;
85 return str.str();
86}
87
Isabella Gottardi3b77e9d2017-06-22 11:05:41 +010088/** Formatted output of the MatrixPattern type. */
89inline ::std::ostream &operator<<(::std::ostream &os, const MatrixPattern &pattern)
90{
91 switch(pattern)
92 {
93 case MatrixPattern::BOX:
94 os << "BOX";
95 break;
96 case MatrixPattern::CROSS:
97 os << "CROSS";
98 break;
99 case MatrixPattern::DISK:
100 os << "DISK";
101 break;
102 case MatrixPattern::OTHER:
103 os << "OTHER";
104 break;
105 default:
106 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
107 }
108
109 return os;
110}
111
John Richardson6f4d49f2017-09-07 11:21:10 +0100112inline std::string to_string(const MatrixPattern &pattern)
113{
114 std::stringstream str;
115 str << pattern;
116 return str.str();
117}
118
Anthony Barbier2a07e182017-08-04 18:20:27 +0100119/** Formatted output of the RoundingPolicy type. */
120inline ::std::ostream &operator<<(::std::ostream &os, const RoundingPolicy &rounding_policy)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100121{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100122 switch(rounding_policy)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100123 {
Anthony Barbier2a07e182017-08-04 18:20:27 +0100124 case RoundingPolicy::TO_ZERO:
125 os << "TO_ZERO";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100126 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100127 case RoundingPolicy::TO_NEAREST_UP:
128 os << "TO_NEAREST_UP";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100129 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100130 case RoundingPolicy::TO_NEAREST_EVEN:
131 os << "TO_NEAREST_EVEN";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100132 break;
133 default:
134 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
135 }
136
137 return os;
138}
139
Anthony Barbier2a07e182017-08-04 18:20:27 +0100140/** Formatted output of the WeightsInfo type. */
141inline ::std::ostream &operator<<(::std::ostream &os, const WeightsInfo &weights_info)
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100142{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100143 os << weights_info.are_reshaped() << ";";
144 os << weights_info.num_kernels() << ";" << weights_info.kernel_size().first << "," << weights_info.kernel_size().second;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100145
146 return os;
147}
148
Anthony Barbier2a07e182017-08-04 18:20:27 +0100149/** Formatted output of the ROIPoolingInfo type. */
150inline ::std::ostream &operator<<(::std::ostream &os, const ROIPoolingLayerInfo &pool_info)
Sanghoon Lee70f82912017-08-24 14:21:24 +0100151{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100152 os << pool_info.pooled_width() << "x" << pool_info.pooled_height() << "~" << pool_info.spatial_scale();
Georgios Pinitasd9769582017-08-03 10:19:40 +0100153 return os;
154}
155
Chunosovd621bca2017-11-03 17:33:15 +0700156/** Formatted output of the QuantizationInfo type. */
157inline ::std::ostream &operator<<(::std::ostream &os, const QuantizationInfo &quantization_info)
158{
159 os << "Scale:" << quantization_info.scale << "~"
160 << "Offset:" << quantization_info.offset;
161 return os;
162}
163
164inline std::string to_string(const QuantizationInfo &quantization_info)
165{
166 std::stringstream str;
167 str << quantization_info;
168 return str.str();
169}
170
Abe Mbise4bd2cb82017-09-27 18:39:19 +0100171inline ::std::ostream &operator<<(::std::ostream &os, const FixedPointOp &op)
172{
173 switch(op)
174 {
John Richardson70f946b2017-10-02 16:52:16 +0100175 case FixedPointOp::ADD:
176 os << "ADD";
177 break;
178 case FixedPointOp::SUB:
179 os << "SUB";
180 break;
181 case FixedPointOp::MUL:
182 os << "MUL";
183 break;
Abe Mbise4bd2cb82017-09-27 18:39:19 +0100184 case FixedPointOp::EXP:
185 os << "EXP";
186 break;
187 case FixedPointOp::LOG:
188 os << "LOG";
189 break;
190 case FixedPointOp::INV_SQRT:
191 os << "INV_SQRT";
192 break;
193 case FixedPointOp::RECIPROCAL:
194 os << "RECIPROCAL";
195 break;
196 default:
197 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
198 }
199
200 return os;
201}
John Richardson70f946b2017-10-02 16:52:16 +0100202
Abe Mbise4bd2cb82017-09-27 18:39:19 +0100203inline std::string to_string(const FixedPointOp &op)
204{
205 std::stringstream str;
206 str << op;
207 return str.str();
208}
209
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100210/** Formatted output of the activation function type. */
211inline ::std::ostream &operator<<(::std::ostream &os, const ActivationLayerInfo::ActivationFunction &act_function)
212{
213 switch(act_function)
214 {
215 case ActivationLayerInfo::ActivationFunction::ABS:
216 os << "ABS";
217 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100218 case ActivationLayerInfo::ActivationFunction::LINEAR:
219 os << "LINEAR";
220 break;
221 case ActivationLayerInfo::ActivationFunction::LOGISTIC:
222 os << "LOGISTIC";
223 break;
224 case ActivationLayerInfo::ActivationFunction::RELU:
225 os << "RELU";
226 break;
Georgios Pinitas579c0492017-07-12 16:12:12 +0100227 case ActivationLayerInfo::ActivationFunction::BOUNDED_RELU:
228 os << "BOUNDED_RELU";
229 break;
230 case ActivationLayerInfo::ActivationFunction::LEAKY_RELU:
231 os << "LEAKY_RELU";
232 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100233 case ActivationLayerInfo::ActivationFunction::SOFT_RELU:
234 os << "SOFT_RELU";
235 break;
236 case ActivationLayerInfo::ActivationFunction::SQRT:
237 os << "SQRT";
238 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100239 case ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU:
240 os << "LU_BOUNDED_RELU";
Kevin Petitd9f80712017-12-06 12:18:48 +0000241 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100242 case ActivationLayerInfo::ActivationFunction::SQUARE:
243 os << "SQUARE";
244 break;
245 case ActivationLayerInfo::ActivationFunction::TANH:
246 os << "TANH";
247 break;
248 default:
249 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
250 }
251
252 return os;
253}
254
Anthony Barbier2a07e182017-08-04 18:20:27 +0100255inline std::string to_string(const arm_compute::ActivationLayerInfo &info)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100256{
257 std::stringstream str;
258 str << info.activation();
259 return str.str();
260}
261
Anthony Barbier2a07e182017-08-04 18:20:27 +0100262inline std::string to_string(const arm_compute::ActivationLayerInfo::ActivationFunction &function)
263{
264 std::stringstream str;
265 str << function;
266 return str.str();
267}
268
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100269/** Formatted output of the NormType type. */
270inline ::std::ostream &operator<<(::std::ostream &os, const NormType &norm_type)
271{
272 switch(norm_type)
273 {
274 case NormType::CROSS_MAP:
275 os << "CROSS_MAP";
276 break;
277 case NormType::IN_MAP_1D:
278 os << "IN_MAP_1D";
279 break;
280 case NormType::IN_MAP_2D:
281 os << "IN_MAP_2D";
282 break;
283 default:
284 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
285 }
286
287 return os;
288}
289
Anthony Barbier2a07e182017-08-04 18:20:27 +0100290inline std::string to_string(const arm_compute::NormalizationLayerInfo &info)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100291{
292 std::stringstream str;
293 str << info.type();
294 return str.str();
295}
296
Georgios Pinitas6f669f02017-09-26 12:32:57 +0100297/** Formatted output of @ref NormalizationLayerInfo. */
298inline ::std::ostream &operator<<(::std::ostream &os, const NormalizationLayerInfo &info)
299{
300 os << info.type();
301 return os;
302}
303
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100304/** Formatted output of the PoolingType type. */
305inline ::std::ostream &operator<<(::std::ostream &os, const PoolingType &pool_type)
306{
307 switch(pool_type)
308 {
309 case PoolingType::AVG:
310 os << "AVG";
311 break;
312 case PoolingType::MAX:
313 os << "MAX";
314 break;
Georgios Pinitascdf51452017-08-31 14:21:36 +0100315 case PoolingType::L2:
316 os << "L2";
317 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100318 default:
319 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
320 }
321
322 return os;
323}
324
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100325/** Formatted output of @ref PoolingLayerInfo. */
326inline ::std::ostream &operator<<(::std::ostream &os, const PoolingLayerInfo &info)
327{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100328 os << info.pool_type();
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100329
330 return os;
331}
332
John Richardsondd715f22017-09-18 16:10:48 +0100333inline std::string to_string(const RoundingPolicy &rounding_policy)
334{
335 std::stringstream str;
336 str << rounding_policy;
337 return str.str();
338}
339
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100340/** Formatted output of the DataType type. */
341inline ::std::ostream &operator<<(::std::ostream &os, const DataType &data_type)
342{
343 switch(data_type)
344 {
345 case DataType::UNKNOWN:
346 os << "UNKNOWN";
347 break;
348 case DataType::U8:
349 os << "U8";
350 break;
351 case DataType::QS8:
352 os << "QS8";
353 break;
Chunosovd621bca2017-11-03 17:33:15 +0700354 case DataType::QASYMM8:
355 os << "QASYMM8";
356 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100357 case DataType::S8:
358 os << "S8";
359 break;
360 case DataType::U16:
361 os << "U16";
362 break;
363 case DataType::S16:
364 os << "S16";
365 break;
Gian Marco Iodicebdb6b0b2017-06-30 12:21:00 +0100366 case DataType::QS16:
367 os << "QS16";
368 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100369 case DataType::U32:
370 os << "U32";
371 break;
372 case DataType::S32:
373 os << "S32";
374 break;
375 case DataType::U64:
376 os << "U64";
377 break;
378 case DataType::S64:
379 os << "S64";
380 break;
381 case DataType::F16:
382 os << "F16";
383 break;
384 case DataType::F32:
385 os << "F32";
386 break;
387 case DataType::F64:
388 os << "F64";
389 break;
390 case DataType::SIZET:
391 os << "SIZET";
392 break;
393 default:
394 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
395 }
396
397 return os;
398}
399
Anthony Barbier2a07e182017-08-04 18:20:27 +0100400inline std::string to_string(const arm_compute::DataType &data_type)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100401{
402 std::stringstream str;
403 str << data_type;
404 return str.str();
405}
406
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100407/** Formatted output of the Format type. */
408inline ::std::ostream &operator<<(::std::ostream &os, const Format &format)
409{
410 switch(format)
411 {
412 case Format::UNKNOWN:
413 os << "UNKNOWN";
414 break;
415 case Format::U8:
416 os << "U8";
417 break;
418 case Format::S16:
419 os << "S16";
420 break;
421 case Format::U16:
422 os << "U16";
423 break;
424 case Format::S32:
425 os << "S32";
426 break;
427 case Format::U32:
428 os << "U32";
429 break;
430 case Format::F16:
431 os << "F16";
432 break;
433 case Format::F32:
434 os << "F32";
435 break;
436 case Format::UV88:
437 os << "UV88";
438 break;
439 case Format::RGB888:
440 os << "RGB888";
441 break;
442 case Format::RGBA8888:
443 os << "RGBA8888";
444 break;
445 case Format::YUV444:
446 os << "YUV444";
447 break;
448 case Format::YUYV422:
449 os << "YUYV422";
450 break;
451 case Format::NV12:
452 os << "NV12";
453 break;
454 case Format::NV21:
455 os << "NV21";
456 break;
457 case Format::IYUV:
458 os << "IYUV";
459 break;
460 case Format::UYVY422:
461 os << "UYVY422";
462 break;
463 default:
464 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
465 }
466
467 return os;
468}
469
Moritz Pflanzer7655a672017-09-23 11:57:33 +0100470inline std::string to_string(const Format &format)
471{
472 std::stringstream str;
473 str << format;
474 return str.str();
475}
476
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100477/** Formatted output of the Channel type. */
478inline ::std::ostream &operator<<(::std::ostream &os, const Channel &channel)
479{
480 switch(channel)
481 {
482 case Channel::UNKNOWN:
483 os << "UNKNOWN";
484 break;
485 case Channel::C0:
486 os << "C0";
487 break;
488 case Channel::C1:
489 os << "C1";
490 break;
491 case Channel::C2:
492 os << "C2";
493 break;
494 case Channel::C3:
495 os << "C3";
496 break;
497 case Channel::R:
498 os << "R";
499 break;
500 case Channel::G:
501 os << "G";
502 break;
503 case Channel::B:
504 os << "B";
505 break;
506 case Channel::A:
507 os << "A";
508 break;
509 case Channel::Y:
510 os << "Y";
511 break;
512 case Channel::U:
513 os << "U";
514 break;
515 case Channel::V:
516 os << "V";
517 break;
518 default:
519 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
520 }
521
522 return os;
523}
524
Anthony Barbier2a07e182017-08-04 18:20:27 +0100525/** Formatted output of the BorderMode type. */
526inline ::std::ostream &operator<<(::std::ostream &os, const BorderMode &mode)
527{
528 switch(mode)
529 {
530 case BorderMode::UNDEFINED:
531 os << "UNDEFINED";
532 break;
533 case BorderMode::CONSTANT:
534 os << "CONSTANT";
535 break;
536 case BorderMode::REPLICATE:
537 os << "REPLICATE";
538 break;
539 default:
540 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
541 }
542
543 return os;
544}
545
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100546/** Formatted output of the BorderSize type. */
547inline ::std::ostream &operator<<(::std::ostream &os, const BorderSize &border)
548{
Moritz Pflanzerc87fbf82017-07-18 14:02:10 +0100549 os << border.top << ","
550 << border.right << ","
551 << border.bottom << ","
552 << border.left;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100553
554 return os;
555}
Anthony Barbier2a07e182017-08-04 18:20:27 +0100556
557/** Formatted output of the InterpolationPolicy type. */
558inline ::std::ostream &operator<<(::std::ostream &os, const InterpolationPolicy &policy)
559{
560 switch(policy)
561 {
562 case InterpolationPolicy::NEAREST_NEIGHBOR:
563 os << "NEAREST_NEIGHBOR";
564 break;
565 case InterpolationPolicy::BILINEAR:
566 os << "BILINEAR";
567 break;
568 case InterpolationPolicy::AREA:
569 os << "AREA";
570 break;
571 default:
572 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
573 }
574
575 return os;
576}
577
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700578/** Formatted output of the SamplingPolicy type. */
579inline ::std::ostream &operator<<(::std::ostream &os, const SamplingPolicy &policy)
580{
581 switch(policy)
582 {
583 case SamplingPolicy::CENTER:
584 os << "CENTER";
585 break;
586 case SamplingPolicy::TOP_LEFT:
587 os << "TOP_LEFT";
588 break;
589 default:
590 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
591 }
592
593 return os;
594}
595
Georgios Pinitas3faea252017-10-30 14:13:50 +0000596/** Formatted output of the TensorInfo type. */
597inline std::string to_string(const TensorInfo &info)
598{
599 std::stringstream str;
600 str << "{Shape=" << info.tensor_shape() << ","
601 << "Type=" << info.data_type() << ","
602 << "Channels=" << info.num_channels() << ","
603 << "FixedPointPos=" << info.fixed_point_position() << "}";
604 return str.str();
605}
606
Abe Mbise925ca0f2017-10-02 19:16:33 +0100607//FIXME: Check why this doesn't work and the TensorShape and Coordinates overload are needed
Anthony Barbier2a07e182017-08-04 18:20:27 +0100608template <typename T>
609inline std::string to_string(const Dimensions<T> &dimensions)
610{
611 std::stringstream str;
612 str << dimensions;
613 return str.str();
614}
615
John Richardsona36eae12017-09-26 16:55:59 +0100616inline std::string to_string(const Strides &stride)
617{
618 std::stringstream str;
619 str << stride;
620 return str.str();
621}
622
Anthony Barbier2a07e182017-08-04 18:20:27 +0100623/** Formatted output of the TensorShape type. */
624inline std::string to_string(const TensorShape &shape)
625{
626 std::stringstream str;
627 str << shape;
628 return str.str();
629}
630
Abe Mbise925ca0f2017-10-02 19:16:33 +0100631/** Formatted output of the Coordinates type. */
632inline std::string to_string(const Coordinates &coord)
633{
634 std::stringstream str;
635 str << coord;
636 return str.str();
637}
638
Anthony Barbier2a07e182017-08-04 18:20:27 +0100639/** Formatted output of the Rectangle type. */
640inline ::std::ostream &operator<<(::std::ostream &os, const Rectangle &rect)
641{
642 os << rect.width << "x" << rect.height;
643 os << "+" << rect.x << "+" << rect.y;
644
645 return os;
646}
647
648/** Formatted output of the PadStridInfo type. */
649inline ::std::ostream &operator<<(::std::ostream &os, const PadStrideInfo &pad_stride_info)
650{
651 os << pad_stride_info.stride().first << "," << pad_stride_info.stride().second;
652 os << ";";
Jaroslaw Rzepeckia1ed41f2017-10-13 11:13:58 +0100653 os << pad_stride_info.pad_left() << "," << pad_stride_info.pad_right() << ","
654 << pad_stride_info.pad_top() << "," << pad_stride_info.pad_bottom();
Anthony Barbier2a07e182017-08-04 18:20:27 +0100655
656 return os;
657}
658
659inline std::string to_string(const PadStrideInfo &pad_stride_info)
660{
661 std::stringstream str;
662 str << pad_stride_info;
663 return str.str();
664}
665
666inline std::string to_string(const BorderMode &mode)
667{
668 std::stringstream str;
669 str << mode;
670 return str.str();
671}
672
John Richardsonb482ce12017-09-18 12:44:01 +0100673inline std::string to_string(const BorderSize &border)
674{
675 std::stringstream str;
676 str << border;
677 return str.str();
678}
679
Anthony Barbier2a07e182017-08-04 18:20:27 +0100680inline std::string to_string(const InterpolationPolicy &policy)
681{
682 std::stringstream str;
683 str << policy;
684 return str.str();
685}
686
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700687inline std::string to_string(const SamplingPolicy &policy)
688{
689 std::stringstream str;
690 str << policy;
691 return str.str();
692}
693
Anthony Barbier2a07e182017-08-04 18:20:27 +0100694/** Formatted output of the ConversionPolicy type. */
695inline ::std::ostream &operator<<(::std::ostream &os, const ConvertPolicy &policy)
696{
697 switch(policy)
698 {
699 case ConvertPolicy::WRAP:
700 os << "WRAP";
701 break;
702 case ConvertPolicy::SATURATE:
703 os << "SATURATE";
704 break;
705 default:
706 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
707 }
708
709 return os;
710}
711
712inline std::string to_string(const ConvertPolicy &policy)
713{
714 std::stringstream str;
715 str << policy;
716 return str.str();
717}
718
719/** Formatted output of the Reduction Operations. */
720inline ::std::ostream &operator<<(::std::ostream &os, const ReductionOperation &op)
721{
722 switch(op)
723 {
724 case ReductionOperation::SUM_SQUARE:
725 os << "SUM_SQUARE";
726 break;
727 default:
728 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
729 }
730
731 return os;
732}
733
734inline std::string to_string(const ReductionOperation &op)
735{
736 std::stringstream str;
737 str << op;
738 return str.str();
739}
740
741inline std::string to_string(const NormType &type)
742{
743 std::stringstream str;
744 str << type;
745 return str.str();
746}
747
748inline std::string to_string(const PoolingType &type)
749{
750 std::stringstream str;
751 str << type;
752 return str.str();
753}
754
755inline std::string to_string(const PoolingLayerInfo &info)
756{
757 std::stringstream str;
Georgios Pinitas4c2dd542017-11-13 12:58:41 +0000758 str << "{Type=" << info.pool_type() << ","
759 << "IsGlobalPooling=" << info.is_global_pooling();
760 if(!info.is_global_pooling())
761 {
762 str << ","
763 << "PoolSize=" << info.pool_size() << ","
764 << "PadStride=" << info.pad_stride_info();
765 }
766 str << "}";
Anthony Barbier2a07e182017-08-04 18:20:27 +0100767 return str.str();
768}
769
Moritz Pflanzer6c6597c2017-09-24 12:09:41 +0100770/** Formatted output of the KeyPoint type. */
771inline ::std::ostream &operator<<(::std::ostream &os, const KeyPoint &point)
772{
773 os << "{x=" << point.x << ","
774 << "y=" << point.y << ","
775 << "strength=" << point.strength << ","
776 << "scale=" << point.scale << ","
777 << "orientation=" << point.orientation << ","
778 << "tracking_status=" << point.tracking_status << ","
779 << "error=" << point.error << "}";
780
781 return os;
782}
John Richardson63e50412017-10-13 20:51:42 +0100783
784/** Formatted output of the PhaseType type. */
785inline ::std::ostream &operator<<(::std::ostream &os, const PhaseType &phase_type)
786{
787 switch(phase_type)
788 {
789 case PhaseType::SIGNED:
790 os << "SIGNED";
791 break;
792 case PhaseType::UNSIGNED:
793 os << "UNSIGNED";
794 break;
795 default:
796 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
797 }
798
799 return os;
800}
801
802inline std::string to_string(const arm_compute::PhaseType &type)
803{
804 std::stringstream str;
805 str << type;
806 return str.str();
807}
John Richardson3c5f9492017-10-04 15:27:37 +0100808
809/** Formatted output of the MagnitudeType type. */
810inline ::std::ostream &operator<<(::std::ostream &os, const MagnitudeType &magnitude_type)
811{
812 switch(magnitude_type)
813 {
814 case MagnitudeType::L1NORM:
815 os << "L1NORM";
816 break;
817 case MagnitudeType::L2NORM:
818 os << "L2NORM";
819 break;
820 default:
821 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
822 }
823
824 return os;
825}
826
827inline std::string to_string(const arm_compute::MagnitudeType &type)
828{
829 std::stringstream str;
830 str << type;
831 return str.str();
832}
John Richardson1c529922017-11-01 10:57:48 +0000833
834/** Formatted output of the GradientDimension type. */
835inline ::std::ostream &operator<<(::std::ostream &os, const GradientDimension &dim)
836{
837 switch(dim)
838 {
839 case GradientDimension::GRAD_X:
840 os << "GRAD_X";
841 break;
842 case GradientDimension::GRAD_Y:
843 os << "GRAD_Y";
844 break;
845 case GradientDimension::GRAD_XY:
846 os << "GRAD_XY";
847 break;
848 default:
849 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
850 }
851
852 return os;
853}
854
855inline std::string to_string(const arm_compute::GradientDimension &type)
856{
857 std::stringstream str;
858 str << type;
859 return str.str();
860}
John Richardson25f23682017-11-27 14:35:09 +0000861
862/** Formatted output of the HOGNormType type. */
863inline ::std::ostream &operator<<(::std::ostream &os, const HOGNormType &norm_type)
864{
865 switch(norm_type)
866 {
867 case HOGNormType::L1_NORM:
868 os << "L1_NORM";
869 break;
870 case HOGNormType::L2_NORM:
871 os << "L2_NORM";
872 break;
873 case HOGNormType::L2HYS_NORM:
874 os << "L2HYS_NORM";
875 break;
876 default:
877 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
878 }
879
880 return os;
881}
882
883inline std::string to_string(const HOGNormType &type)
884{
885 std::stringstream str;
886 str << type;
887 return str.str();
888}
889
890/** Formatted output of the Size2D type. */
891inline ::std::ostream &operator<<(::std::ostream &os, const Size2D &size)
892{
893 os << size.width << "x" << size.height;
894
895 return os;
896}
897
898inline std::string to_string(const Size2D &type)
899{
900 std::stringstream str;
901 str << type;
902 return str.str();
903}
904
905/** Formatted output of the Size2D type. */
906inline ::std::ostream &operator<<(::std::ostream &os, const HOGInfo &hog_info)
907{
908 os << "{CellSize=" << hog_info.cell_size() << ","
909 << "BlockSize=" << hog_info.block_size() << ","
910 << "DetectionWindowSize=" << hog_info.detection_window_size() << ","
911 << "BlockStride=" << hog_info.block_stride() << ","
912 << "NumBins=" << hog_info.num_bins() << ","
913 << "NormType=" << hog_info.normalization_type() << ","
914 << "L2HystThreshold=" << hog_info.l2_hyst_threshold() << ","
915 << "PhaseType=" << hog_info.phase_type() << "}";
916
917 return os;
918}
919
920/** Formatted output of the HOGInfo type. */
921inline std::string to_string(const HOGInfo &type)
922{
923 std::stringstream str;
924 str << type;
925 return str.str();
926}
927
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100928} // namespace arm_compute
Anthony Barbierac69aa12017-07-03 17:39:37 +0100929#endif /* __ARM_COMPUTE_TEST_TYPE_PRINTER_H__ */