blob: 863fcaf6d9d60d7ecaeff74428f93159eefaae3c [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
Chunosovd621bca2017-11-03 17:33:15 +0700154/** Formatted output of the QuantizationInfo type. */
155inline ::std::ostream &operator<<(::std::ostream &os, const QuantizationInfo &quantization_info)
156{
157 os << "Scale:" << quantization_info.scale << "~"
158 << "Offset:" << quantization_info.offset;
159 return os;
160}
161
162inline std::string to_string(const QuantizationInfo &quantization_info)
163{
164 std::stringstream str;
165 str << quantization_info;
166 return str.str();
167}
168
Abe Mbise4bd2cb82017-09-27 18:39:19 +0100169inline ::std::ostream &operator<<(::std::ostream &os, const FixedPointOp &op)
170{
171 switch(op)
172 {
John Richardson70f946b2017-10-02 16:52:16 +0100173 case FixedPointOp::ADD:
174 os << "ADD";
175 break;
176 case FixedPointOp::SUB:
177 os << "SUB";
178 break;
179 case FixedPointOp::MUL:
180 os << "MUL";
181 break;
Abe Mbise4bd2cb82017-09-27 18:39:19 +0100182 case FixedPointOp::EXP:
183 os << "EXP";
184 break;
185 case FixedPointOp::LOG:
186 os << "LOG";
187 break;
188 case FixedPointOp::INV_SQRT:
189 os << "INV_SQRT";
190 break;
191 case FixedPointOp::RECIPROCAL:
192 os << "RECIPROCAL";
193 break;
194 default:
195 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
196 }
197
198 return os;
199}
John Richardson70f946b2017-10-02 16:52:16 +0100200
Abe Mbise4bd2cb82017-09-27 18:39:19 +0100201inline std::string to_string(const FixedPointOp &op)
202{
203 std::stringstream str;
204 str << op;
205 return str.str();
206}
207
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100208/** Formatted output of the activation function type. */
209inline ::std::ostream &operator<<(::std::ostream &os, const ActivationLayerInfo::ActivationFunction &act_function)
210{
211 switch(act_function)
212 {
213 case ActivationLayerInfo::ActivationFunction::ABS:
214 os << "ABS";
215 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100216 case ActivationLayerInfo::ActivationFunction::LINEAR:
217 os << "LINEAR";
218 break;
219 case ActivationLayerInfo::ActivationFunction::LOGISTIC:
220 os << "LOGISTIC";
221 break;
222 case ActivationLayerInfo::ActivationFunction::RELU:
223 os << "RELU";
224 break;
Georgios Pinitas579c0492017-07-12 16:12:12 +0100225 case ActivationLayerInfo::ActivationFunction::BOUNDED_RELU:
226 os << "BOUNDED_RELU";
227 break;
228 case ActivationLayerInfo::ActivationFunction::LEAKY_RELU:
229 os << "LEAKY_RELU";
230 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100231 case ActivationLayerInfo::ActivationFunction::SOFT_RELU:
232 os << "SOFT_RELU";
233 break;
234 case ActivationLayerInfo::ActivationFunction::SQRT:
235 os << "SQRT";
236 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100237 case ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU:
238 os << "LU_BOUNDED_RELU";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100239 case ActivationLayerInfo::ActivationFunction::SQUARE:
240 os << "SQUARE";
241 break;
242 case ActivationLayerInfo::ActivationFunction::TANH:
243 os << "TANH";
244 break;
245 default:
246 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
247 }
248
249 return os;
250}
251
Anthony Barbier2a07e182017-08-04 18:20:27 +0100252inline std::string to_string(const arm_compute::ActivationLayerInfo &info)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100253{
254 std::stringstream str;
255 str << info.activation();
256 return str.str();
257}
258
Anthony Barbier2a07e182017-08-04 18:20:27 +0100259inline std::string to_string(const arm_compute::ActivationLayerInfo::ActivationFunction &function)
260{
261 std::stringstream str;
262 str << function;
263 return str.str();
264}
265
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100266/** Formatted output of the NormType type. */
267inline ::std::ostream &operator<<(::std::ostream &os, const NormType &norm_type)
268{
269 switch(norm_type)
270 {
271 case NormType::CROSS_MAP:
272 os << "CROSS_MAP";
273 break;
274 case NormType::IN_MAP_1D:
275 os << "IN_MAP_1D";
276 break;
277 case NormType::IN_MAP_2D:
278 os << "IN_MAP_2D";
279 break;
280 default:
281 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
282 }
283
284 return os;
285}
286
Anthony Barbier2a07e182017-08-04 18:20:27 +0100287inline std::string to_string(const arm_compute::NormalizationLayerInfo &info)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100288{
289 std::stringstream str;
290 str << info.type();
291 return str.str();
292}
293
Georgios Pinitas6f669f02017-09-26 12:32:57 +0100294/** Formatted output of @ref NormalizationLayerInfo. */
295inline ::std::ostream &operator<<(::std::ostream &os, const NormalizationLayerInfo &info)
296{
297 os << info.type();
298 return os;
299}
300
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100301/** Formatted output of the PoolingType type. */
302inline ::std::ostream &operator<<(::std::ostream &os, const PoolingType &pool_type)
303{
304 switch(pool_type)
305 {
306 case PoolingType::AVG:
307 os << "AVG";
308 break;
309 case PoolingType::MAX:
310 os << "MAX";
311 break;
Georgios Pinitascdf51452017-08-31 14:21:36 +0100312 case PoolingType::L2:
313 os << "L2";
314 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100315 default:
316 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
317 }
318
319 return os;
320}
321
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100322/** Formatted output of @ref PoolingLayerInfo. */
323inline ::std::ostream &operator<<(::std::ostream &os, const PoolingLayerInfo &info)
324{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100325 os << info.pool_type();
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100326
327 return os;
328}
329
John Richardsondd715f22017-09-18 16:10:48 +0100330inline std::string to_string(const RoundingPolicy &rounding_policy)
331{
332 std::stringstream str;
333 str << rounding_policy;
334 return str.str();
335}
336
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100337/** Formatted output of the DataType type. */
338inline ::std::ostream &operator<<(::std::ostream &os, const DataType &data_type)
339{
340 switch(data_type)
341 {
342 case DataType::UNKNOWN:
343 os << "UNKNOWN";
344 break;
345 case DataType::U8:
346 os << "U8";
347 break;
348 case DataType::QS8:
349 os << "QS8";
350 break;
Chunosovd621bca2017-11-03 17:33:15 +0700351 case DataType::QASYMM8:
352 os << "QASYMM8";
353 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100354 case DataType::S8:
355 os << "S8";
356 break;
357 case DataType::U16:
358 os << "U16";
359 break;
360 case DataType::S16:
361 os << "S16";
362 break;
Gian Marco Iodicebdb6b0b2017-06-30 12:21:00 +0100363 case DataType::QS16:
364 os << "QS16";
365 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100366 case DataType::U32:
367 os << "U32";
368 break;
369 case DataType::S32:
370 os << "S32";
371 break;
372 case DataType::U64:
373 os << "U64";
374 break;
375 case DataType::S64:
376 os << "S64";
377 break;
378 case DataType::F16:
379 os << "F16";
380 break;
381 case DataType::F32:
382 os << "F32";
383 break;
384 case DataType::F64:
385 os << "F64";
386 break;
387 case DataType::SIZET:
388 os << "SIZET";
389 break;
390 default:
391 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
392 }
393
394 return os;
395}
396
Anthony Barbier2a07e182017-08-04 18:20:27 +0100397inline std::string to_string(const arm_compute::DataType &data_type)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100398{
399 std::stringstream str;
400 str << data_type;
401 return str.str();
402}
403
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100404/** Formatted output of the Format type. */
405inline ::std::ostream &operator<<(::std::ostream &os, const Format &format)
406{
407 switch(format)
408 {
409 case Format::UNKNOWN:
410 os << "UNKNOWN";
411 break;
412 case Format::U8:
413 os << "U8";
414 break;
415 case Format::S16:
416 os << "S16";
417 break;
418 case Format::U16:
419 os << "U16";
420 break;
421 case Format::S32:
422 os << "S32";
423 break;
424 case Format::U32:
425 os << "U32";
426 break;
427 case Format::F16:
428 os << "F16";
429 break;
430 case Format::F32:
431 os << "F32";
432 break;
433 case Format::UV88:
434 os << "UV88";
435 break;
436 case Format::RGB888:
437 os << "RGB888";
438 break;
439 case Format::RGBA8888:
440 os << "RGBA8888";
441 break;
442 case Format::YUV444:
443 os << "YUV444";
444 break;
445 case Format::YUYV422:
446 os << "YUYV422";
447 break;
448 case Format::NV12:
449 os << "NV12";
450 break;
451 case Format::NV21:
452 os << "NV21";
453 break;
454 case Format::IYUV:
455 os << "IYUV";
456 break;
457 case Format::UYVY422:
458 os << "UYVY422";
459 break;
460 default:
461 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
462 }
463
464 return os;
465}
466
Moritz Pflanzer7655a672017-09-23 11:57:33 +0100467inline std::string to_string(const Format &format)
468{
469 std::stringstream str;
470 str << format;
471 return str.str();
472}
473
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100474/** Formatted output of the Channel type. */
475inline ::std::ostream &operator<<(::std::ostream &os, const Channel &channel)
476{
477 switch(channel)
478 {
479 case Channel::UNKNOWN:
480 os << "UNKNOWN";
481 break;
482 case Channel::C0:
483 os << "C0";
484 break;
485 case Channel::C1:
486 os << "C1";
487 break;
488 case Channel::C2:
489 os << "C2";
490 break;
491 case Channel::C3:
492 os << "C3";
493 break;
494 case Channel::R:
495 os << "R";
496 break;
497 case Channel::G:
498 os << "G";
499 break;
500 case Channel::B:
501 os << "B";
502 break;
503 case Channel::A:
504 os << "A";
505 break;
506 case Channel::Y:
507 os << "Y";
508 break;
509 case Channel::U:
510 os << "U";
511 break;
512 case Channel::V:
513 os << "V";
514 break;
515 default:
516 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
517 }
518
519 return os;
520}
521
Anthony Barbier2a07e182017-08-04 18:20:27 +0100522/** Formatted output of the BorderMode type. */
523inline ::std::ostream &operator<<(::std::ostream &os, const BorderMode &mode)
524{
525 switch(mode)
526 {
527 case BorderMode::UNDEFINED:
528 os << "UNDEFINED";
529 break;
530 case BorderMode::CONSTANT:
531 os << "CONSTANT";
532 break;
533 case BorderMode::REPLICATE:
534 os << "REPLICATE";
535 break;
536 default:
537 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
538 }
539
540 return os;
541}
542
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100543/** Formatted output of the BorderSize type. */
544inline ::std::ostream &operator<<(::std::ostream &os, const BorderSize &border)
545{
Moritz Pflanzerc87fbf82017-07-18 14:02:10 +0100546 os << border.top << ","
547 << border.right << ","
548 << border.bottom << ","
549 << border.left;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100550
551 return os;
552}
Anthony Barbier2a07e182017-08-04 18:20:27 +0100553
554/** Formatted output of the InterpolationPolicy type. */
555inline ::std::ostream &operator<<(::std::ostream &os, const InterpolationPolicy &policy)
556{
557 switch(policy)
558 {
559 case InterpolationPolicy::NEAREST_NEIGHBOR:
560 os << "NEAREST_NEIGHBOR";
561 break;
562 case InterpolationPolicy::BILINEAR:
563 os << "BILINEAR";
564 break;
565 case InterpolationPolicy::AREA:
566 os << "AREA";
567 break;
568 default:
569 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
570 }
571
572 return os;
573}
574
Georgios Pinitas3faea252017-10-30 14:13:50 +0000575/** Formatted output of the TensorInfo type. */
576inline std::string to_string(const TensorInfo &info)
577{
578 std::stringstream str;
579 str << "{Shape=" << info.tensor_shape() << ","
580 << "Type=" << info.data_type() << ","
581 << "Channels=" << info.num_channels() << ","
582 << "FixedPointPos=" << info.fixed_point_position() << "}";
583 return str.str();
584}
585
Abe Mbise925ca0f2017-10-02 19:16:33 +0100586//FIXME: Check why this doesn't work and the TensorShape and Coordinates overload are needed
Anthony Barbier2a07e182017-08-04 18:20:27 +0100587template <typename T>
588inline std::string to_string(const Dimensions<T> &dimensions)
589{
590 std::stringstream str;
591 str << dimensions;
592 return str.str();
593}
594
John Richardsona36eae12017-09-26 16:55:59 +0100595inline std::string to_string(const Strides &stride)
596{
597 std::stringstream str;
598 str << stride;
599 return str.str();
600}
601
Anthony Barbier2a07e182017-08-04 18:20:27 +0100602/** Formatted output of the TensorShape type. */
603inline std::string to_string(const TensorShape &shape)
604{
605 std::stringstream str;
606 str << shape;
607 return str.str();
608}
609
Abe Mbise925ca0f2017-10-02 19:16:33 +0100610/** Formatted output of the Coordinates type. */
611inline std::string to_string(const Coordinates &coord)
612{
613 std::stringstream str;
614 str << coord;
615 return str.str();
616}
617
Anthony Barbier2a07e182017-08-04 18:20:27 +0100618/** Formatted output of the Rectangle type. */
619inline ::std::ostream &operator<<(::std::ostream &os, const Rectangle &rect)
620{
621 os << rect.width << "x" << rect.height;
622 os << "+" << rect.x << "+" << rect.y;
623
624 return os;
625}
626
627/** Formatted output of the PadStridInfo type. */
628inline ::std::ostream &operator<<(::std::ostream &os, const PadStrideInfo &pad_stride_info)
629{
630 os << pad_stride_info.stride().first << "," << pad_stride_info.stride().second;
631 os << ";";
Jaroslaw Rzepeckia1ed41f2017-10-13 11:13:58 +0100632 os << pad_stride_info.pad_left() << "," << pad_stride_info.pad_right() << ","
633 << pad_stride_info.pad_top() << "," << pad_stride_info.pad_bottom();
Anthony Barbier2a07e182017-08-04 18:20:27 +0100634
635 return os;
636}
637
638inline std::string to_string(const PadStrideInfo &pad_stride_info)
639{
640 std::stringstream str;
641 str << pad_stride_info;
642 return str.str();
643}
644
645inline std::string to_string(const BorderMode &mode)
646{
647 std::stringstream str;
648 str << mode;
649 return str.str();
650}
651
John Richardsonb482ce12017-09-18 12:44:01 +0100652inline std::string to_string(const BorderSize &border)
653{
654 std::stringstream str;
655 str << border;
656 return str.str();
657}
658
Anthony Barbier2a07e182017-08-04 18:20:27 +0100659inline std::string to_string(const InterpolationPolicy &policy)
660{
661 std::stringstream str;
662 str << policy;
663 return str.str();
664}
665
666/** Formatted output of the ConversionPolicy type. */
667inline ::std::ostream &operator<<(::std::ostream &os, const ConvertPolicy &policy)
668{
669 switch(policy)
670 {
671 case ConvertPolicy::WRAP:
672 os << "WRAP";
673 break;
674 case ConvertPolicy::SATURATE:
675 os << "SATURATE";
676 break;
677 default:
678 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
679 }
680
681 return os;
682}
683
684inline std::string to_string(const ConvertPolicy &policy)
685{
686 std::stringstream str;
687 str << policy;
688 return str.str();
689}
690
691/** Formatted output of the Reduction Operations. */
692inline ::std::ostream &operator<<(::std::ostream &os, const ReductionOperation &op)
693{
694 switch(op)
695 {
696 case ReductionOperation::SUM_SQUARE:
697 os << "SUM_SQUARE";
698 break;
699 default:
700 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
701 }
702
703 return os;
704}
705
706inline std::string to_string(const ReductionOperation &op)
707{
708 std::stringstream str;
709 str << op;
710 return str.str();
711}
712
713inline std::string to_string(const NormType &type)
714{
715 std::stringstream str;
716 str << type;
717 return str.str();
718}
719
720inline std::string to_string(const PoolingType &type)
721{
722 std::stringstream str;
723 str << type;
724 return str.str();
725}
726
727inline std::string to_string(const PoolingLayerInfo &info)
728{
729 std::stringstream str;
Georgios Pinitas4c2dd542017-11-13 12:58:41 +0000730 str << "{Type=" << info.pool_type() << ","
731 << "IsGlobalPooling=" << info.is_global_pooling();
732 if(!info.is_global_pooling())
733 {
734 str << ","
735 << "PoolSize=" << info.pool_size() << ","
736 << "PadStride=" << info.pad_stride_info();
737 }
738 str << "}";
Anthony Barbier2a07e182017-08-04 18:20:27 +0100739 return str.str();
740}
741
Moritz Pflanzer6c6597c2017-09-24 12:09:41 +0100742/** Formatted output of the KeyPoint type. */
743inline ::std::ostream &operator<<(::std::ostream &os, const KeyPoint &point)
744{
745 os << "{x=" << point.x << ","
746 << "y=" << point.y << ","
747 << "strength=" << point.strength << ","
748 << "scale=" << point.scale << ","
749 << "orientation=" << point.orientation << ","
750 << "tracking_status=" << point.tracking_status << ","
751 << "error=" << point.error << "}";
752
753 return os;
754}
John Richardson63e50412017-10-13 20:51:42 +0100755
756/** Formatted output of the PhaseType type. */
757inline ::std::ostream &operator<<(::std::ostream &os, const PhaseType &phase_type)
758{
759 switch(phase_type)
760 {
761 case PhaseType::SIGNED:
762 os << "SIGNED";
763 break;
764 case PhaseType::UNSIGNED:
765 os << "UNSIGNED";
766 break;
767 default:
768 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
769 }
770
771 return os;
772}
773
774inline std::string to_string(const arm_compute::PhaseType &type)
775{
776 std::stringstream str;
777 str << type;
778 return str.str();
779}
John Richardson3c5f9492017-10-04 15:27:37 +0100780
781/** Formatted output of the MagnitudeType type. */
782inline ::std::ostream &operator<<(::std::ostream &os, const MagnitudeType &magnitude_type)
783{
784 switch(magnitude_type)
785 {
786 case MagnitudeType::L1NORM:
787 os << "L1NORM";
788 break;
789 case MagnitudeType::L2NORM:
790 os << "L2NORM";
791 break;
792 default:
793 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
794 }
795
796 return os;
797}
798
799inline std::string to_string(const arm_compute::MagnitudeType &type)
800{
801 std::stringstream str;
802 str << type;
803 return str.str();
804}
John Richardson1c529922017-11-01 10:57:48 +0000805
806/** Formatted output of the GradientDimension type. */
807inline ::std::ostream &operator<<(::std::ostream &os, const GradientDimension &dim)
808{
809 switch(dim)
810 {
811 case GradientDimension::GRAD_X:
812 os << "GRAD_X";
813 break;
814 case GradientDimension::GRAD_Y:
815 os << "GRAD_Y";
816 break;
817 case GradientDimension::GRAD_XY:
818 os << "GRAD_XY";
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::GradientDimension &type)
828{
829 std::stringstream str;
830 str << type;
831 return str.str();
832}
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100833} // namespace arm_compute
Anthony Barbierac69aa12017-07-03 17:39:37 +0100834#endif /* __ARM_COMPUTE_TEST_TYPE_PRINTER_H__ */