blob: 876f3fc36fe4300ec2304f4f89ab497c9332b9b1 [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
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700575/** Formatted output of the SamplingPolicy type. */
576inline ::std::ostream &operator<<(::std::ostream &os, const SamplingPolicy &policy)
577{
578 switch(policy)
579 {
580 case SamplingPolicy::CENTER:
581 os << "CENTER";
582 break;
583 case SamplingPolicy::TOP_LEFT:
584 os << "TOP_LEFT";
585 break;
586 default:
587 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
588 }
589
590 return os;
591}
592
Georgios Pinitas3faea252017-10-30 14:13:50 +0000593/** Formatted output of the TensorInfo type. */
594inline std::string to_string(const TensorInfo &info)
595{
596 std::stringstream str;
597 str << "{Shape=" << info.tensor_shape() << ","
598 << "Type=" << info.data_type() << ","
599 << "Channels=" << info.num_channels() << ","
600 << "FixedPointPos=" << info.fixed_point_position() << "}";
601 return str.str();
602}
603
Abe Mbise925ca0f2017-10-02 19:16:33 +0100604//FIXME: Check why this doesn't work and the TensorShape and Coordinates overload are needed
Anthony Barbier2a07e182017-08-04 18:20:27 +0100605template <typename T>
606inline std::string to_string(const Dimensions<T> &dimensions)
607{
608 std::stringstream str;
609 str << dimensions;
610 return str.str();
611}
612
John Richardsona36eae12017-09-26 16:55:59 +0100613inline std::string to_string(const Strides &stride)
614{
615 std::stringstream str;
616 str << stride;
617 return str.str();
618}
619
Anthony Barbier2a07e182017-08-04 18:20:27 +0100620/** Formatted output of the TensorShape type. */
621inline std::string to_string(const TensorShape &shape)
622{
623 std::stringstream str;
624 str << shape;
625 return str.str();
626}
627
Abe Mbise925ca0f2017-10-02 19:16:33 +0100628/** Formatted output of the Coordinates type. */
629inline std::string to_string(const Coordinates &coord)
630{
631 std::stringstream str;
632 str << coord;
633 return str.str();
634}
635
Anthony Barbier2a07e182017-08-04 18:20:27 +0100636/** Formatted output of the Rectangle type. */
637inline ::std::ostream &operator<<(::std::ostream &os, const Rectangle &rect)
638{
639 os << rect.width << "x" << rect.height;
640 os << "+" << rect.x << "+" << rect.y;
641
642 return os;
643}
644
645/** Formatted output of the PadStridInfo type. */
646inline ::std::ostream &operator<<(::std::ostream &os, const PadStrideInfo &pad_stride_info)
647{
648 os << pad_stride_info.stride().first << "," << pad_stride_info.stride().second;
649 os << ";";
Jaroslaw Rzepeckia1ed41f2017-10-13 11:13:58 +0100650 os << pad_stride_info.pad_left() << "," << pad_stride_info.pad_right() << ","
651 << pad_stride_info.pad_top() << "," << pad_stride_info.pad_bottom();
Anthony Barbier2a07e182017-08-04 18:20:27 +0100652
653 return os;
654}
655
656inline std::string to_string(const PadStrideInfo &pad_stride_info)
657{
658 std::stringstream str;
659 str << pad_stride_info;
660 return str.str();
661}
662
663inline std::string to_string(const BorderMode &mode)
664{
665 std::stringstream str;
666 str << mode;
667 return str.str();
668}
669
John Richardsonb482ce12017-09-18 12:44:01 +0100670inline std::string to_string(const BorderSize &border)
671{
672 std::stringstream str;
673 str << border;
674 return str.str();
675}
676
Anthony Barbier2a07e182017-08-04 18:20:27 +0100677inline std::string to_string(const InterpolationPolicy &policy)
678{
679 std::stringstream str;
680 str << policy;
681 return str.str();
682}
683
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700684inline std::string to_string(const SamplingPolicy &policy)
685{
686 std::stringstream str;
687 str << policy;
688 return str.str();
689}
690
Anthony Barbier2a07e182017-08-04 18:20:27 +0100691/** Formatted output of the ConversionPolicy type. */
692inline ::std::ostream &operator<<(::std::ostream &os, const ConvertPolicy &policy)
693{
694 switch(policy)
695 {
696 case ConvertPolicy::WRAP:
697 os << "WRAP";
698 break;
699 case ConvertPolicy::SATURATE:
700 os << "SATURATE";
701 break;
702 default:
703 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
704 }
705
706 return os;
707}
708
709inline std::string to_string(const ConvertPolicy &policy)
710{
711 std::stringstream str;
712 str << policy;
713 return str.str();
714}
715
716/** Formatted output of the Reduction Operations. */
717inline ::std::ostream &operator<<(::std::ostream &os, const ReductionOperation &op)
718{
719 switch(op)
720 {
721 case ReductionOperation::SUM_SQUARE:
722 os << "SUM_SQUARE";
723 break;
724 default:
725 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
726 }
727
728 return os;
729}
730
731inline std::string to_string(const ReductionOperation &op)
732{
733 std::stringstream str;
734 str << op;
735 return str.str();
736}
737
738inline std::string to_string(const NormType &type)
739{
740 std::stringstream str;
741 str << type;
742 return str.str();
743}
744
745inline std::string to_string(const PoolingType &type)
746{
747 std::stringstream str;
748 str << type;
749 return str.str();
750}
751
752inline std::string to_string(const PoolingLayerInfo &info)
753{
754 std::stringstream str;
Georgios Pinitas4c2dd542017-11-13 12:58:41 +0000755 str << "{Type=" << info.pool_type() << ","
756 << "IsGlobalPooling=" << info.is_global_pooling();
757 if(!info.is_global_pooling())
758 {
759 str << ","
760 << "PoolSize=" << info.pool_size() << ","
761 << "PadStride=" << info.pad_stride_info();
762 }
763 str << "}";
Anthony Barbier2a07e182017-08-04 18:20:27 +0100764 return str.str();
765}
766
Moritz Pflanzer6c6597c2017-09-24 12:09:41 +0100767/** Formatted output of the KeyPoint type. */
768inline ::std::ostream &operator<<(::std::ostream &os, const KeyPoint &point)
769{
770 os << "{x=" << point.x << ","
771 << "y=" << point.y << ","
772 << "strength=" << point.strength << ","
773 << "scale=" << point.scale << ","
774 << "orientation=" << point.orientation << ","
775 << "tracking_status=" << point.tracking_status << ","
776 << "error=" << point.error << "}";
777
778 return os;
779}
John Richardson63e50412017-10-13 20:51:42 +0100780
781/** Formatted output of the PhaseType type. */
782inline ::std::ostream &operator<<(::std::ostream &os, const PhaseType &phase_type)
783{
784 switch(phase_type)
785 {
786 case PhaseType::SIGNED:
787 os << "SIGNED";
788 break;
789 case PhaseType::UNSIGNED:
790 os << "UNSIGNED";
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::PhaseType &type)
800{
801 std::stringstream str;
802 str << type;
803 return str.str();
804}
John Richardson3c5f9492017-10-04 15:27:37 +0100805
806/** Formatted output of the MagnitudeType type. */
807inline ::std::ostream &operator<<(::std::ostream &os, const MagnitudeType &magnitude_type)
808{
809 switch(magnitude_type)
810 {
811 case MagnitudeType::L1NORM:
812 os << "L1NORM";
813 break;
814 case MagnitudeType::L2NORM:
815 os << "L2NORM";
816 break;
817 default:
818 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
819 }
820
821 return os;
822}
823
824inline std::string to_string(const arm_compute::MagnitudeType &type)
825{
826 std::stringstream str;
827 str << type;
828 return str.str();
829}
John Richardson1c529922017-11-01 10:57:48 +0000830
831/** Formatted output of the GradientDimension type. */
832inline ::std::ostream &operator<<(::std::ostream &os, const GradientDimension &dim)
833{
834 switch(dim)
835 {
836 case GradientDimension::GRAD_X:
837 os << "GRAD_X";
838 break;
839 case GradientDimension::GRAD_Y:
840 os << "GRAD_Y";
841 break;
842 case GradientDimension::GRAD_XY:
843 os << "GRAD_XY";
844 break;
845 default:
846 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
847 }
848
849 return os;
850}
851
852inline std::string to_string(const arm_compute::GradientDimension &type)
853{
854 std::stringstream str;
855 str << type;
856 return str.str();
857}
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100858} // namespace arm_compute
Anthony Barbierac69aa12017-07-03 17:39:37 +0100859#endif /* __ARM_COMPUTE_TEST_TYPE_PRINTER_H__ */