blob: d956d9ca0173379ca06228d5daa0e65394b79623 [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001/*
2 * Copyright (c) 2017 ARM Limited.
3 *
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 Richardsona36eae12017-09-26 16:55:59 +010029#include "arm_compute/core/Strides.h"
Georgios Pinitas3faea252017-10-30 14:13:50 +000030#include "arm_compute/core/TensorInfo.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010031#include "arm_compute/core/Types.h"
32
Abe Mbise4bd2cb82017-09-27 18:39:19 +010033#include "tests/Types.h"
34
Anthony Barbier6ff3b192017-09-04 18:44:23 +010035#include <ostream>
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010036#include <sstream>
37#include <string>
Anthony Barbier6ff3b192017-09-04 18:44:23 +010038
39namespace arm_compute
40{
41/** Formatted output of the Dimensions type. */
42template <typename T>
43inline ::std::ostream &operator<<(::std::ostream &os, const Dimensions<T> &dimensions)
44{
Anthony Barbier6ff3b192017-09-04 18:44:23 +010045 if(dimensions.num_dimensions() > 0)
46 {
47 os << dimensions[0];
48
49 for(unsigned int d = 1; d < dimensions.num_dimensions(); ++d)
50 {
Moritz Pflanzerc87fbf82017-07-18 14:02:10 +010051 os << "x" << dimensions[d];
Anthony Barbier6ff3b192017-09-04 18:44:23 +010052 }
53 }
54
Anthony Barbier6ff3b192017-09-04 18:44:23 +010055 return os;
56}
57
Isabella Gottardi3b77e9d2017-06-22 11:05:41 +010058/** Formatted output of the NonLinearFilterFunction type. */
59inline ::std::ostream &operator<<(::std::ostream &os, const NonLinearFilterFunction &function)
60{
61 switch(function)
62 {
63 case NonLinearFilterFunction::MAX:
64 os << "MAX";
65 break;
66 case NonLinearFilterFunction::MEDIAN:
67 os << "MEDIAN";
68 break;
69 case NonLinearFilterFunction::MIN:
70 os << "MIN";
71 break;
72 default:
73 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
74 }
75
76 return os;
77}
78
John Richardson6f4d49f2017-09-07 11:21:10 +010079inline std::string to_string(const NonLinearFilterFunction &function)
80{
81 std::stringstream str;
82 str << function;
83 return str.str();
84}
85
Isabella Gottardi3b77e9d2017-06-22 11:05:41 +010086/** Formatted output of the MatrixPattern type. */
87inline ::std::ostream &operator<<(::std::ostream &os, const MatrixPattern &pattern)
88{
89 switch(pattern)
90 {
91 case MatrixPattern::BOX:
92 os << "BOX";
93 break;
94 case MatrixPattern::CROSS:
95 os << "CROSS";
96 break;
97 case MatrixPattern::DISK:
98 os << "DISK";
99 break;
100 case MatrixPattern::OTHER:
101 os << "OTHER";
102 break;
103 default:
104 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
105 }
106
107 return os;
108}
109
John Richardson6f4d49f2017-09-07 11:21:10 +0100110inline std::string to_string(const MatrixPattern &pattern)
111{
112 std::stringstream str;
113 str << pattern;
114 return str.str();
115}
116
Anthony Barbier2a07e182017-08-04 18:20:27 +0100117/** Formatted output of the RoundingPolicy type. */
118inline ::std::ostream &operator<<(::std::ostream &os, const RoundingPolicy &rounding_policy)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100119{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100120 switch(rounding_policy)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100121 {
Anthony Barbier2a07e182017-08-04 18:20:27 +0100122 case RoundingPolicy::TO_ZERO:
123 os << "TO_ZERO";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100124 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100125 case RoundingPolicy::TO_NEAREST_UP:
126 os << "TO_NEAREST_UP";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100127 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100128 case RoundingPolicy::TO_NEAREST_EVEN:
129 os << "TO_NEAREST_EVEN";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100130 break;
131 default:
132 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
133 }
134
135 return os;
136}
137
Anthony Barbier2a07e182017-08-04 18:20:27 +0100138/** Formatted output of the WeightsInfo type. */
139inline ::std::ostream &operator<<(::std::ostream &os, const WeightsInfo &weights_info)
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100140{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100141 os << weights_info.are_reshaped() << ";";
142 os << weights_info.num_kernels() << ";" << weights_info.kernel_size().first << "," << weights_info.kernel_size().second;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100143
144 return os;
145}
146
Anthony Barbier2a07e182017-08-04 18:20:27 +0100147/** Formatted output of the ROIPoolingInfo type. */
148inline ::std::ostream &operator<<(::std::ostream &os, const ROIPoolingLayerInfo &pool_info)
Sanghoon Lee70f82912017-08-24 14:21:24 +0100149{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100150 os << pool_info.pooled_width() << "x" << pool_info.pooled_height() << "~" << pool_info.spatial_scale();
Georgios Pinitasd9769582017-08-03 10:19:40 +0100151 return os;
152}
153
Abe Mbise4bd2cb82017-09-27 18:39:19 +0100154inline ::std::ostream &operator<<(::std::ostream &os, const FixedPointOp &op)
155{
156 switch(op)
157 {
John Richardson70f946b2017-10-02 16:52:16 +0100158 case FixedPointOp::ADD:
159 os << "ADD";
160 break;
161 case FixedPointOp::SUB:
162 os << "SUB";
163 break;
164 case FixedPointOp::MUL:
165 os << "MUL";
166 break;
Abe Mbise4bd2cb82017-09-27 18:39:19 +0100167 case FixedPointOp::EXP:
168 os << "EXP";
169 break;
170 case FixedPointOp::LOG:
171 os << "LOG";
172 break;
173 case FixedPointOp::INV_SQRT:
174 os << "INV_SQRT";
175 break;
176 case FixedPointOp::RECIPROCAL:
177 os << "RECIPROCAL";
178 break;
179 default:
180 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
181 }
182
183 return os;
184}
John Richardson70f946b2017-10-02 16:52:16 +0100185
Abe Mbise4bd2cb82017-09-27 18:39:19 +0100186inline std::string to_string(const FixedPointOp &op)
187{
188 std::stringstream str;
189 str << op;
190 return str.str();
191}
192
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100193/** Formatted output of the activation function type. */
194inline ::std::ostream &operator<<(::std::ostream &os, const ActivationLayerInfo::ActivationFunction &act_function)
195{
196 switch(act_function)
197 {
198 case ActivationLayerInfo::ActivationFunction::ABS:
199 os << "ABS";
200 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100201 case ActivationLayerInfo::ActivationFunction::LINEAR:
202 os << "LINEAR";
203 break;
204 case ActivationLayerInfo::ActivationFunction::LOGISTIC:
205 os << "LOGISTIC";
206 break;
207 case ActivationLayerInfo::ActivationFunction::RELU:
208 os << "RELU";
209 break;
Georgios Pinitas579c0492017-07-12 16:12:12 +0100210 case ActivationLayerInfo::ActivationFunction::BOUNDED_RELU:
211 os << "BOUNDED_RELU";
212 break;
213 case ActivationLayerInfo::ActivationFunction::LEAKY_RELU:
214 os << "LEAKY_RELU";
215 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100216 case ActivationLayerInfo::ActivationFunction::SOFT_RELU:
217 os << "SOFT_RELU";
218 break;
219 case ActivationLayerInfo::ActivationFunction::SQRT:
220 os << "SQRT";
221 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100222 case ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU:
223 os << "LU_BOUNDED_RELU";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100224 case ActivationLayerInfo::ActivationFunction::SQUARE:
225 os << "SQUARE";
226 break;
227 case ActivationLayerInfo::ActivationFunction::TANH:
228 os << "TANH";
229 break;
230 default:
231 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
232 }
233
234 return os;
235}
236
Anthony Barbier2a07e182017-08-04 18:20:27 +0100237inline std::string to_string(const arm_compute::ActivationLayerInfo &info)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100238{
239 std::stringstream str;
240 str << info.activation();
241 return str.str();
242}
243
Anthony Barbier2a07e182017-08-04 18:20:27 +0100244inline std::string to_string(const arm_compute::ActivationLayerInfo::ActivationFunction &function)
245{
246 std::stringstream str;
247 str << function;
248 return str.str();
249}
250
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100251/** Formatted output of the NormType type. */
252inline ::std::ostream &operator<<(::std::ostream &os, const NormType &norm_type)
253{
254 switch(norm_type)
255 {
256 case NormType::CROSS_MAP:
257 os << "CROSS_MAP";
258 break;
259 case NormType::IN_MAP_1D:
260 os << "IN_MAP_1D";
261 break;
262 case NormType::IN_MAP_2D:
263 os << "IN_MAP_2D";
264 break;
265 default:
266 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
267 }
268
269 return os;
270}
271
Anthony Barbier2a07e182017-08-04 18:20:27 +0100272inline std::string to_string(const arm_compute::NormalizationLayerInfo &info)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100273{
274 std::stringstream str;
275 str << info.type();
276 return str.str();
277}
278
Georgios Pinitas6f669f02017-09-26 12:32:57 +0100279/** Formatted output of @ref NormalizationLayerInfo. */
280inline ::std::ostream &operator<<(::std::ostream &os, const NormalizationLayerInfo &info)
281{
282 os << info.type();
283 return os;
284}
285
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100286/** Formatted output of the PoolingType type. */
287inline ::std::ostream &operator<<(::std::ostream &os, const PoolingType &pool_type)
288{
289 switch(pool_type)
290 {
291 case PoolingType::AVG:
292 os << "AVG";
293 break;
294 case PoolingType::MAX:
295 os << "MAX";
296 break;
Georgios Pinitascdf51452017-08-31 14:21:36 +0100297 case PoolingType::L2:
298 os << "L2";
299 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100300 default:
301 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
302 }
303
304 return os;
305}
306
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100307/** Formatted output of @ref PoolingLayerInfo. */
308inline ::std::ostream &operator<<(::std::ostream &os, const PoolingLayerInfo &info)
309{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100310 os << info.pool_type();
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100311
312 return os;
313}
314
John Richardsondd715f22017-09-18 16:10:48 +0100315inline std::string to_string(const RoundingPolicy &rounding_policy)
316{
317 std::stringstream str;
318 str << rounding_policy;
319 return str.str();
320}
321
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100322/** Formatted output of the DataType type. */
323inline ::std::ostream &operator<<(::std::ostream &os, const DataType &data_type)
324{
325 switch(data_type)
326 {
327 case DataType::UNKNOWN:
328 os << "UNKNOWN";
329 break;
330 case DataType::U8:
331 os << "U8";
332 break;
333 case DataType::QS8:
334 os << "QS8";
335 break;
336 case DataType::S8:
337 os << "S8";
338 break;
339 case DataType::U16:
340 os << "U16";
341 break;
342 case DataType::S16:
343 os << "S16";
344 break;
Gian Marco Iodicebdb6b0b2017-06-30 12:21:00 +0100345 case DataType::QS16:
346 os << "QS16";
347 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100348 case DataType::U32:
349 os << "U32";
350 break;
351 case DataType::S32:
352 os << "S32";
353 break;
354 case DataType::U64:
355 os << "U64";
356 break;
357 case DataType::S64:
358 os << "S64";
359 break;
360 case DataType::F16:
361 os << "F16";
362 break;
363 case DataType::F32:
364 os << "F32";
365 break;
366 case DataType::F64:
367 os << "F64";
368 break;
369 case DataType::SIZET:
370 os << "SIZET";
371 break;
372 default:
373 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
374 }
375
376 return os;
377}
378
Anthony Barbier2a07e182017-08-04 18:20:27 +0100379inline std::string to_string(const arm_compute::DataType &data_type)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100380{
381 std::stringstream str;
382 str << data_type;
383 return str.str();
384}
385
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100386/** Formatted output of the Format type. */
387inline ::std::ostream &operator<<(::std::ostream &os, const Format &format)
388{
389 switch(format)
390 {
391 case Format::UNKNOWN:
392 os << "UNKNOWN";
393 break;
394 case Format::U8:
395 os << "U8";
396 break;
397 case Format::S16:
398 os << "S16";
399 break;
400 case Format::U16:
401 os << "U16";
402 break;
403 case Format::S32:
404 os << "S32";
405 break;
406 case Format::U32:
407 os << "U32";
408 break;
409 case Format::F16:
410 os << "F16";
411 break;
412 case Format::F32:
413 os << "F32";
414 break;
415 case Format::UV88:
416 os << "UV88";
417 break;
418 case Format::RGB888:
419 os << "RGB888";
420 break;
421 case Format::RGBA8888:
422 os << "RGBA8888";
423 break;
424 case Format::YUV444:
425 os << "YUV444";
426 break;
427 case Format::YUYV422:
428 os << "YUYV422";
429 break;
430 case Format::NV12:
431 os << "NV12";
432 break;
433 case Format::NV21:
434 os << "NV21";
435 break;
436 case Format::IYUV:
437 os << "IYUV";
438 break;
439 case Format::UYVY422:
440 os << "UYVY422";
441 break;
442 default:
443 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
444 }
445
446 return os;
447}
448
Moritz Pflanzer7655a672017-09-23 11:57:33 +0100449inline std::string to_string(const Format &format)
450{
451 std::stringstream str;
452 str << format;
453 return str.str();
454}
455
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100456/** Formatted output of the Channel type. */
457inline ::std::ostream &operator<<(::std::ostream &os, const Channel &channel)
458{
459 switch(channel)
460 {
461 case Channel::UNKNOWN:
462 os << "UNKNOWN";
463 break;
464 case Channel::C0:
465 os << "C0";
466 break;
467 case Channel::C1:
468 os << "C1";
469 break;
470 case Channel::C2:
471 os << "C2";
472 break;
473 case Channel::C3:
474 os << "C3";
475 break;
476 case Channel::R:
477 os << "R";
478 break;
479 case Channel::G:
480 os << "G";
481 break;
482 case Channel::B:
483 os << "B";
484 break;
485 case Channel::A:
486 os << "A";
487 break;
488 case Channel::Y:
489 os << "Y";
490 break;
491 case Channel::U:
492 os << "U";
493 break;
494 case Channel::V:
495 os << "V";
496 break;
497 default:
498 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
499 }
500
501 return os;
502}
503
Anthony Barbier2a07e182017-08-04 18:20:27 +0100504/** Formatted output of the BorderMode type. */
505inline ::std::ostream &operator<<(::std::ostream &os, const BorderMode &mode)
506{
507 switch(mode)
508 {
509 case BorderMode::UNDEFINED:
510 os << "UNDEFINED";
511 break;
512 case BorderMode::CONSTANT:
513 os << "CONSTANT";
514 break;
515 case BorderMode::REPLICATE:
516 os << "REPLICATE";
517 break;
518 default:
519 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
520 }
521
522 return os;
523}
524
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100525/** Formatted output of the BorderSize type. */
526inline ::std::ostream &operator<<(::std::ostream &os, const BorderSize &border)
527{
Moritz Pflanzerc87fbf82017-07-18 14:02:10 +0100528 os << border.top << ","
529 << border.right << ","
530 << border.bottom << ","
531 << border.left;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100532
533 return os;
534}
Anthony Barbier2a07e182017-08-04 18:20:27 +0100535
536/** Formatted output of the InterpolationPolicy type. */
537inline ::std::ostream &operator<<(::std::ostream &os, const InterpolationPolicy &policy)
538{
539 switch(policy)
540 {
541 case InterpolationPolicy::NEAREST_NEIGHBOR:
542 os << "NEAREST_NEIGHBOR";
543 break;
544 case InterpolationPolicy::BILINEAR:
545 os << "BILINEAR";
546 break;
547 case InterpolationPolicy::AREA:
548 os << "AREA";
549 break;
550 default:
551 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
552 }
553
554 return os;
555}
556
Georgios Pinitas3faea252017-10-30 14:13:50 +0000557/** Formatted output of the TensorInfo type. */
558inline std::string to_string(const TensorInfo &info)
559{
560 std::stringstream str;
561 str << "{Shape=" << info.tensor_shape() << ","
562 << "Type=" << info.data_type() << ","
563 << "Channels=" << info.num_channels() << ","
564 << "FixedPointPos=" << info.fixed_point_position() << "}";
565 return str.str();
566}
567
Abe Mbise925ca0f2017-10-02 19:16:33 +0100568//FIXME: Check why this doesn't work and the TensorShape and Coordinates overload are needed
Anthony Barbier2a07e182017-08-04 18:20:27 +0100569template <typename T>
570inline std::string to_string(const Dimensions<T> &dimensions)
571{
572 std::stringstream str;
573 str << dimensions;
574 return str.str();
575}
576
John Richardsona36eae12017-09-26 16:55:59 +0100577inline std::string to_string(const Strides &stride)
578{
579 std::stringstream str;
580 str << stride;
581 return str.str();
582}
583
Anthony Barbier2a07e182017-08-04 18:20:27 +0100584/** Formatted output of the TensorShape type. */
585inline std::string to_string(const TensorShape &shape)
586{
587 std::stringstream str;
588 str << shape;
589 return str.str();
590}
591
Abe Mbise925ca0f2017-10-02 19:16:33 +0100592/** Formatted output of the Coordinates type. */
593inline std::string to_string(const Coordinates &coord)
594{
595 std::stringstream str;
596 str << coord;
597 return str.str();
598}
599
Anthony Barbier2a07e182017-08-04 18:20:27 +0100600/** Formatted output of the Rectangle type. */
601inline ::std::ostream &operator<<(::std::ostream &os, const Rectangle &rect)
602{
603 os << rect.width << "x" << rect.height;
604 os << "+" << rect.x << "+" << rect.y;
605
606 return os;
607}
608
609/** Formatted output of the PadStridInfo type. */
610inline ::std::ostream &operator<<(::std::ostream &os, const PadStrideInfo &pad_stride_info)
611{
612 os << pad_stride_info.stride().first << "," << pad_stride_info.stride().second;
613 os << ";";
Jaroslaw Rzepeckia1ed41f2017-10-13 11:13:58 +0100614 os << pad_stride_info.pad_left() << "," << pad_stride_info.pad_right() << ","
615 << pad_stride_info.pad_top() << "," << pad_stride_info.pad_bottom();
Anthony Barbier2a07e182017-08-04 18:20:27 +0100616
617 return os;
618}
619
620inline std::string to_string(const PadStrideInfo &pad_stride_info)
621{
622 std::stringstream str;
623 str << pad_stride_info;
624 return str.str();
625}
626
627inline std::string to_string(const BorderMode &mode)
628{
629 std::stringstream str;
630 str << mode;
631 return str.str();
632}
633
John Richardsonb482ce12017-09-18 12:44:01 +0100634inline std::string to_string(const BorderSize &border)
635{
636 std::stringstream str;
637 str << border;
638 return str.str();
639}
640
Anthony Barbier2a07e182017-08-04 18:20:27 +0100641inline std::string to_string(const InterpolationPolicy &policy)
642{
643 std::stringstream str;
644 str << policy;
645 return str.str();
646}
647
648/** Formatted output of the ConversionPolicy type. */
649inline ::std::ostream &operator<<(::std::ostream &os, const ConvertPolicy &policy)
650{
651 switch(policy)
652 {
653 case ConvertPolicy::WRAP:
654 os << "WRAP";
655 break;
656 case ConvertPolicy::SATURATE:
657 os << "SATURATE";
658 break;
659 default:
660 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
661 }
662
663 return os;
664}
665
666inline std::string to_string(const ConvertPolicy &policy)
667{
668 std::stringstream str;
669 str << policy;
670 return str.str();
671}
672
673/** Formatted output of the Reduction Operations. */
674inline ::std::ostream &operator<<(::std::ostream &os, const ReductionOperation &op)
675{
676 switch(op)
677 {
678 case ReductionOperation::SUM_SQUARE:
679 os << "SUM_SQUARE";
680 break;
681 default:
682 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
683 }
684
685 return os;
686}
687
688inline std::string to_string(const ReductionOperation &op)
689{
690 std::stringstream str;
691 str << op;
692 return str.str();
693}
694
695inline std::string to_string(const NormType &type)
696{
697 std::stringstream str;
698 str << type;
699 return str.str();
700}
701
702inline std::string to_string(const PoolingType &type)
703{
704 std::stringstream str;
705 str << type;
706 return str.str();
707}
708
709inline std::string to_string(const PoolingLayerInfo &info)
710{
711 std::stringstream str;
712 str << info.pool_type();
713 return str.str();
714}
715
Moritz Pflanzer6c6597c2017-09-24 12:09:41 +0100716/** Formatted output of the KeyPoint type. */
717inline ::std::ostream &operator<<(::std::ostream &os, const KeyPoint &point)
718{
719 os << "{x=" << point.x << ","
720 << "y=" << point.y << ","
721 << "strength=" << point.strength << ","
722 << "scale=" << point.scale << ","
723 << "orientation=" << point.orientation << ","
724 << "tracking_status=" << point.tracking_status << ","
725 << "error=" << point.error << "}";
726
727 return os;
728}
John Richardson63e50412017-10-13 20:51:42 +0100729
730/** Formatted output of the PhaseType type. */
731inline ::std::ostream &operator<<(::std::ostream &os, const PhaseType &phase_type)
732{
733 switch(phase_type)
734 {
735 case PhaseType::SIGNED:
736 os << "SIGNED";
737 break;
738 case PhaseType::UNSIGNED:
739 os << "UNSIGNED";
740 break;
741 default:
742 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
743 }
744
745 return os;
746}
747
748inline std::string to_string(const arm_compute::PhaseType &type)
749{
750 std::stringstream str;
751 str << type;
752 return str.str();
753}
John Richardson3c5f9492017-10-04 15:27:37 +0100754
755/** Formatted output of the MagnitudeType type. */
756inline ::std::ostream &operator<<(::std::ostream &os, const MagnitudeType &magnitude_type)
757{
758 switch(magnitude_type)
759 {
760 case MagnitudeType::L1NORM:
761 os << "L1NORM";
762 break;
763 case MagnitudeType::L2NORM:
764 os << "L2NORM";
765 break;
766 default:
767 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
768 }
769
770 return os;
771}
772
773inline std::string to_string(const arm_compute::MagnitudeType &type)
774{
775 std::stringstream str;
776 str << type;
777 return str.str();
778}
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100779} // namespace arm_compute
Anthony Barbierac69aa12017-07-03 17:39:37 +0100780#endif /* __ARM_COMPUTE_TEST_TYPE_PRINTER_H__ */