blob: 63fba3505224be9af8e8e7480e2f5368df6ecba8 [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001/*
Michalis Spyroud466c2d2018-01-30 10:54:39 +00002 * Copyright (c) 2017-2018 ARM Limited.
Anthony Barbier6ff3b192017-09-04 18:44:23 +01003 *
4 * SPDX-License-Identifier: MIT
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
24#ifndef __ARM_COMPUTE_TEST_TYPE_PRINTER_H__
25#define __ARM_COMPUTE_TEST_TYPE_PRINTER_H__
26
Isabella Gottardif07d28d2018-02-06 14:52:43 +000027#include "arm_compute/core/CL/CLTypes.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010028#include "arm_compute/core/Dimensions.h"
29#include "arm_compute/core/Error.h"
John Richardson25f23682017-11-27 14:35:09 +000030#include "arm_compute/core/HOGInfo.h"
31#include "arm_compute/core/Size2D.h"
John Richardsona36eae12017-09-26 16:55:59 +010032#include "arm_compute/core/Strides.h"
Georgios Pinitas3faea252017-10-30 14:13:50 +000033#include "arm_compute/core/TensorInfo.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010034#include "arm_compute/core/Types.h"
35
Abe Mbise4bd2cb82017-09-27 18:39:19 +010036#include "tests/Types.h"
37
Anthony Barbier6ff3b192017-09-04 18:44:23 +010038#include <ostream>
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010039#include <sstream>
40#include <string>
Anthony Barbier6ff3b192017-09-04 18:44:23 +010041
42namespace arm_compute
43{
44/** Formatted output of the Dimensions type. */
45template <typename T>
46inline ::std::ostream &operator<<(::std::ostream &os, const Dimensions<T> &dimensions)
47{
Anthony Barbier6ff3b192017-09-04 18:44:23 +010048 if(dimensions.num_dimensions() > 0)
49 {
50 os << dimensions[0];
51
52 for(unsigned int d = 1; d < dimensions.num_dimensions(); ++d)
53 {
Moritz Pflanzerc87fbf82017-07-18 14:02:10 +010054 os << "x" << dimensions[d];
Anthony Barbier6ff3b192017-09-04 18:44:23 +010055 }
56 }
57
Anthony Barbier6ff3b192017-09-04 18:44:23 +010058 return os;
59}
60
Isabella Gottardi3b77e9d2017-06-22 11:05:41 +010061/** Formatted output of the NonLinearFilterFunction type. */
62inline ::std::ostream &operator<<(::std::ostream &os, const NonLinearFilterFunction &function)
63{
64 switch(function)
65 {
66 case NonLinearFilterFunction::MAX:
67 os << "MAX";
68 break;
69 case NonLinearFilterFunction::MEDIAN:
70 os << "MEDIAN";
71 break;
72 case NonLinearFilterFunction::MIN:
73 os << "MIN";
74 break;
75 default:
76 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
77 }
78
79 return os;
80}
81
John Richardson6f4d49f2017-09-07 11:21:10 +010082inline std::string to_string(const NonLinearFilterFunction &function)
83{
84 std::stringstream str;
85 str << function;
86 return str.str();
87}
88
Isabella Gottardi3b77e9d2017-06-22 11:05:41 +010089/** Formatted output of the MatrixPattern type. */
90inline ::std::ostream &operator<<(::std::ostream &os, const MatrixPattern &pattern)
91{
92 switch(pattern)
93 {
94 case MatrixPattern::BOX:
95 os << "BOX";
96 break;
97 case MatrixPattern::CROSS:
98 os << "CROSS";
99 break;
100 case MatrixPattern::DISK:
101 os << "DISK";
102 break;
103 case MatrixPattern::OTHER:
104 os << "OTHER";
105 break;
106 default:
107 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
108 }
109
110 return os;
111}
112
John Richardson6f4d49f2017-09-07 11:21:10 +0100113inline std::string to_string(const MatrixPattern &pattern)
114{
115 std::stringstream str;
116 str << pattern;
117 return str.str();
118}
119
Anthony Barbier2a07e182017-08-04 18:20:27 +0100120/** Formatted output of the RoundingPolicy type. */
121inline ::std::ostream &operator<<(::std::ostream &os, const RoundingPolicy &rounding_policy)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100122{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100123 switch(rounding_policy)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100124 {
Anthony Barbier2a07e182017-08-04 18:20:27 +0100125 case RoundingPolicy::TO_ZERO:
126 os << "TO_ZERO";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100127 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100128 case RoundingPolicy::TO_NEAREST_UP:
129 os << "TO_NEAREST_UP";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100130 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100131 case RoundingPolicy::TO_NEAREST_EVEN:
132 os << "TO_NEAREST_EVEN";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100133 break;
134 default:
135 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
136 }
137
138 return os;
139}
140
Anthony Barbier2a07e182017-08-04 18:20:27 +0100141/** Formatted output of the WeightsInfo type. */
142inline ::std::ostream &operator<<(::std::ostream &os, const WeightsInfo &weights_info)
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100143{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100144 os << weights_info.are_reshaped() << ";";
145 os << weights_info.num_kernels() << ";" << weights_info.kernel_size().first << "," << weights_info.kernel_size().second;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100146
147 return os;
148}
149
Anthony Barbier2a07e182017-08-04 18:20:27 +0100150/** Formatted output of the ROIPoolingInfo type. */
151inline ::std::ostream &operator<<(::std::ostream &os, const ROIPoolingLayerInfo &pool_info)
Sanghoon Lee70f82912017-08-24 14:21:24 +0100152{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100153 os << pool_info.pooled_width() << "x" << pool_info.pooled_height() << "~" << pool_info.spatial_scale();
Georgios Pinitasd9769582017-08-03 10:19:40 +0100154 return os;
155}
156
Chunosovd621bca2017-11-03 17:33:15 +0700157/** Formatted output of the QuantizationInfo type. */
158inline ::std::ostream &operator<<(::std::ostream &os, const QuantizationInfo &quantization_info)
159{
160 os << "Scale:" << quantization_info.scale << "~"
161 << "Offset:" << quantization_info.offset;
162 return os;
163}
164
165inline std::string to_string(const QuantizationInfo &quantization_info)
166{
167 std::stringstream str;
168 str << quantization_info;
169 return str.str();
170}
171
Abe Mbise4bd2cb82017-09-27 18:39:19 +0100172inline ::std::ostream &operator<<(::std::ostream &os, const FixedPointOp &op)
173{
174 switch(op)
175 {
John Richardson70f946b2017-10-02 16:52:16 +0100176 case FixedPointOp::ADD:
177 os << "ADD";
178 break;
179 case FixedPointOp::SUB:
180 os << "SUB";
181 break;
182 case FixedPointOp::MUL:
183 os << "MUL";
184 break;
Abe Mbise4bd2cb82017-09-27 18:39:19 +0100185 case FixedPointOp::EXP:
186 os << "EXP";
187 break;
188 case FixedPointOp::LOG:
189 os << "LOG";
190 break;
191 case FixedPointOp::INV_SQRT:
192 os << "INV_SQRT";
193 break;
194 case FixedPointOp::RECIPROCAL:
195 os << "RECIPROCAL";
196 break;
197 default:
198 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
199 }
200
201 return os;
202}
John Richardson70f946b2017-10-02 16:52:16 +0100203
Abe Mbise4bd2cb82017-09-27 18:39:19 +0100204inline std::string to_string(const FixedPointOp &op)
205{
206 std::stringstream str;
207 str << op;
208 return str.str();
209}
210
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100211/** Formatted output of the activation function type. */
212inline ::std::ostream &operator<<(::std::ostream &os, const ActivationLayerInfo::ActivationFunction &act_function)
213{
214 switch(act_function)
215 {
216 case ActivationLayerInfo::ActivationFunction::ABS:
217 os << "ABS";
218 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100219 case ActivationLayerInfo::ActivationFunction::LINEAR:
220 os << "LINEAR";
221 break;
222 case ActivationLayerInfo::ActivationFunction::LOGISTIC:
223 os << "LOGISTIC";
224 break;
225 case ActivationLayerInfo::ActivationFunction::RELU:
226 os << "RELU";
227 break;
Georgios Pinitas579c0492017-07-12 16:12:12 +0100228 case ActivationLayerInfo::ActivationFunction::BOUNDED_RELU:
229 os << "BOUNDED_RELU";
230 break;
231 case ActivationLayerInfo::ActivationFunction::LEAKY_RELU:
232 os << "LEAKY_RELU";
233 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100234 case ActivationLayerInfo::ActivationFunction::SOFT_RELU:
235 os << "SOFT_RELU";
236 break;
237 case ActivationLayerInfo::ActivationFunction::SQRT:
238 os << "SQRT";
239 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100240 case ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU:
241 os << "LU_BOUNDED_RELU";
Kevin Petitd9f80712017-12-06 12:18:48 +0000242 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100243 case ActivationLayerInfo::ActivationFunction::SQUARE:
244 os << "SQUARE";
245 break;
246 case ActivationLayerInfo::ActivationFunction::TANH:
247 os << "TANH";
248 break;
249 default:
250 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
251 }
252
253 return os;
254}
255
Anthony Barbier2a07e182017-08-04 18:20:27 +0100256inline std::string to_string(const arm_compute::ActivationLayerInfo &info)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100257{
258 std::stringstream str;
259 str << info.activation();
260 return str.str();
261}
262
Anthony Barbier2a07e182017-08-04 18:20:27 +0100263inline std::string to_string(const arm_compute::ActivationLayerInfo::ActivationFunction &function)
264{
265 std::stringstream str;
266 str << function;
267 return str.str();
268}
269
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100270/** Formatted output of the NormType type. */
271inline ::std::ostream &operator<<(::std::ostream &os, const NormType &norm_type)
272{
273 switch(norm_type)
274 {
275 case NormType::CROSS_MAP:
276 os << "CROSS_MAP";
277 break;
278 case NormType::IN_MAP_1D:
279 os << "IN_MAP_1D";
280 break;
281 case NormType::IN_MAP_2D:
282 os << "IN_MAP_2D";
283 break;
284 default:
285 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
286 }
287
288 return os;
289}
290
Anthony Barbier2a07e182017-08-04 18:20:27 +0100291inline std::string to_string(const arm_compute::NormalizationLayerInfo &info)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100292{
293 std::stringstream str;
Michalis Spyroud466c2d2018-01-30 10:54:39 +0000294 str << info.type() << ":NormSize=" << info.norm_size();
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100295 return str.str();
296}
297
Georgios Pinitas6f669f02017-09-26 12:32:57 +0100298/** Formatted output of @ref NormalizationLayerInfo. */
299inline ::std::ostream &operator<<(::std::ostream &os, const NormalizationLayerInfo &info)
300{
Michalis Spyroud466c2d2018-01-30 10:54:39 +0000301 os << info.type() << ":NormSize=" << info.norm_size();
Georgios Pinitas6f669f02017-09-26 12:32:57 +0100302 return os;
303}
304
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100305/** Formatted output of the PoolingType type. */
306inline ::std::ostream &operator<<(::std::ostream &os, const PoolingType &pool_type)
307{
308 switch(pool_type)
309 {
310 case PoolingType::AVG:
311 os << "AVG";
312 break;
313 case PoolingType::MAX:
314 os << "MAX";
315 break;
Georgios Pinitascdf51452017-08-31 14:21:36 +0100316 case PoolingType::L2:
317 os << "L2";
318 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100319 default:
320 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
321 }
322
323 return os;
324}
325
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100326/** Formatted output of @ref PoolingLayerInfo. */
327inline ::std::ostream &operator<<(::std::ostream &os, const PoolingLayerInfo &info)
328{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100329 os << info.pool_type();
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100330
331 return os;
332}
333
John Richardsondd715f22017-09-18 16:10:48 +0100334inline std::string to_string(const RoundingPolicy &rounding_policy)
335{
336 std::stringstream str;
337 str << rounding_policy;
338 return str.str();
339}
340
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100341/** Formatted output of the DataType type. */
342inline ::std::ostream &operator<<(::std::ostream &os, const DataType &data_type)
343{
344 switch(data_type)
345 {
346 case DataType::UNKNOWN:
347 os << "UNKNOWN";
348 break;
349 case DataType::U8:
350 os << "U8";
351 break;
352 case DataType::QS8:
353 os << "QS8";
354 break;
Chunosovd621bca2017-11-03 17:33:15 +0700355 case DataType::QASYMM8:
356 os << "QASYMM8";
357 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100358 case DataType::S8:
359 os << "S8";
360 break;
361 case DataType::U16:
362 os << "U16";
363 break;
364 case DataType::S16:
365 os << "S16";
366 break;
Gian Marco Iodicebdb6b0b2017-06-30 12:21:00 +0100367 case DataType::QS16:
368 os << "QS16";
369 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100370 case DataType::U32:
371 os << "U32";
372 break;
373 case DataType::S32:
374 os << "S32";
375 break;
376 case DataType::U64:
377 os << "U64";
378 break;
379 case DataType::S64:
380 os << "S64";
381 break;
382 case DataType::F16:
383 os << "F16";
384 break;
385 case DataType::F32:
386 os << "F32";
387 break;
388 case DataType::F64:
389 os << "F64";
390 break;
391 case DataType::SIZET:
392 os << "SIZET";
393 break;
394 default:
395 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
396 }
397
398 return os;
399}
400
Anthony Barbier2a07e182017-08-04 18:20:27 +0100401inline std::string to_string(const arm_compute::DataType &data_type)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100402{
403 std::stringstream str;
404 str << data_type;
405 return str.str();
406}
407
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100408/** Formatted output of the Format type. */
409inline ::std::ostream &operator<<(::std::ostream &os, const Format &format)
410{
411 switch(format)
412 {
413 case Format::UNKNOWN:
414 os << "UNKNOWN";
415 break;
416 case Format::U8:
417 os << "U8";
418 break;
419 case Format::S16:
420 os << "S16";
421 break;
422 case Format::U16:
423 os << "U16";
424 break;
425 case Format::S32:
426 os << "S32";
427 break;
428 case Format::U32:
429 os << "U32";
430 break;
431 case Format::F16:
432 os << "F16";
433 break;
434 case Format::F32:
435 os << "F32";
436 break;
437 case Format::UV88:
438 os << "UV88";
439 break;
440 case Format::RGB888:
441 os << "RGB888";
442 break;
443 case Format::RGBA8888:
444 os << "RGBA8888";
445 break;
446 case Format::YUV444:
447 os << "YUV444";
448 break;
449 case Format::YUYV422:
450 os << "YUYV422";
451 break;
452 case Format::NV12:
453 os << "NV12";
454 break;
455 case Format::NV21:
456 os << "NV21";
457 break;
458 case Format::IYUV:
459 os << "IYUV";
460 break;
461 case Format::UYVY422:
462 os << "UYVY422";
463 break;
464 default:
465 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
466 }
467
468 return os;
469}
470
Moritz Pflanzer7655a672017-09-23 11:57:33 +0100471inline std::string to_string(const Format &format)
472{
473 std::stringstream str;
474 str << format;
475 return str.str();
476}
477
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100478/** Formatted output of the Channel type. */
479inline ::std::ostream &operator<<(::std::ostream &os, const Channel &channel)
480{
481 switch(channel)
482 {
483 case Channel::UNKNOWN:
484 os << "UNKNOWN";
485 break;
486 case Channel::C0:
487 os << "C0";
488 break;
489 case Channel::C1:
490 os << "C1";
491 break;
492 case Channel::C2:
493 os << "C2";
494 break;
495 case Channel::C3:
496 os << "C3";
497 break;
498 case Channel::R:
499 os << "R";
500 break;
501 case Channel::G:
502 os << "G";
503 break;
504 case Channel::B:
505 os << "B";
506 break;
507 case Channel::A:
508 os << "A";
509 break;
510 case Channel::Y:
511 os << "Y";
512 break;
513 case Channel::U:
514 os << "U";
515 break;
516 case Channel::V:
517 os << "V";
518 break;
519 default:
520 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
521 }
522
523 return os;
524}
525
Ioan-Cristian Szabo9414f642017-10-27 17:35:40 +0100526inline std::string to_string(const Channel &channel)
527{
528 std::stringstream str;
529 str << channel;
530 return str.str();
531}
532
Anthony Barbier2a07e182017-08-04 18:20:27 +0100533/** Formatted output of the BorderMode type. */
534inline ::std::ostream &operator<<(::std::ostream &os, const BorderMode &mode)
535{
536 switch(mode)
537 {
538 case BorderMode::UNDEFINED:
539 os << "UNDEFINED";
540 break;
541 case BorderMode::CONSTANT:
542 os << "CONSTANT";
543 break;
544 case BorderMode::REPLICATE:
545 os << "REPLICATE";
546 break;
547 default:
548 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
549 }
550
551 return os;
552}
553
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100554/** Formatted output of the BorderSize type. */
555inline ::std::ostream &operator<<(::std::ostream &os, const BorderSize &border)
556{
Moritz Pflanzerc87fbf82017-07-18 14:02:10 +0100557 os << border.top << ","
558 << border.right << ","
559 << border.bottom << ","
560 << border.left;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100561
562 return os;
563}
Anthony Barbier2a07e182017-08-04 18:20:27 +0100564
565/** Formatted output of the InterpolationPolicy type. */
566inline ::std::ostream &operator<<(::std::ostream &os, const InterpolationPolicy &policy)
567{
568 switch(policy)
569 {
570 case InterpolationPolicy::NEAREST_NEIGHBOR:
571 os << "NEAREST_NEIGHBOR";
572 break;
573 case InterpolationPolicy::BILINEAR:
574 os << "BILINEAR";
575 break;
576 case InterpolationPolicy::AREA:
577 os << "AREA";
578 break;
579 default:
580 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
581 }
582
583 return os;
584}
585
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700586/** Formatted output of the SamplingPolicy type. */
587inline ::std::ostream &operator<<(::std::ostream &os, const SamplingPolicy &policy)
588{
589 switch(policy)
590 {
591 case SamplingPolicy::CENTER:
592 os << "CENTER";
593 break;
594 case SamplingPolicy::TOP_LEFT:
595 os << "TOP_LEFT";
596 break;
597 default:
598 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
599 }
600
601 return os;
602}
603
Georgios Pinitas3faea252017-10-30 14:13:50 +0000604/** Formatted output of the TensorInfo type. */
605inline std::string to_string(const TensorInfo &info)
606{
607 std::stringstream str;
608 str << "{Shape=" << info.tensor_shape() << ","
609 << "Type=" << info.data_type() << ","
610 << "Channels=" << info.num_channels() << ","
611 << "FixedPointPos=" << info.fixed_point_position() << "}";
612 return str.str();
613}
614
Abe Mbise925ca0f2017-10-02 19:16:33 +0100615//FIXME: Check why this doesn't work and the TensorShape and Coordinates overload are needed
Anthony Barbier2a07e182017-08-04 18:20:27 +0100616template <typename T>
617inline std::string to_string(const Dimensions<T> &dimensions)
618{
619 std::stringstream str;
620 str << dimensions;
621 return str.str();
622}
623
John Richardsona36eae12017-09-26 16:55:59 +0100624inline std::string to_string(const Strides &stride)
625{
626 std::stringstream str;
627 str << stride;
628 return str.str();
629}
630
Anthony Barbier2a07e182017-08-04 18:20:27 +0100631/** Formatted output of the TensorShape type. */
632inline std::string to_string(const TensorShape &shape)
633{
634 std::stringstream str;
635 str << shape;
636 return str.str();
637}
638
Abe Mbise925ca0f2017-10-02 19:16:33 +0100639/** Formatted output of the Coordinates type. */
640inline std::string to_string(const Coordinates &coord)
641{
642 std::stringstream str;
643 str << coord;
644 return str.str();
645}
646
Anthony Barbier2a07e182017-08-04 18:20:27 +0100647/** Formatted output of the Rectangle type. */
648inline ::std::ostream &operator<<(::std::ostream &os, const Rectangle &rect)
649{
650 os << rect.width << "x" << rect.height;
651 os << "+" << rect.x << "+" << rect.y;
652
653 return os;
654}
655
656/** Formatted output of the PadStridInfo type. */
657inline ::std::ostream &operator<<(::std::ostream &os, const PadStrideInfo &pad_stride_info)
658{
659 os << pad_stride_info.stride().first << "," << pad_stride_info.stride().second;
660 os << ";";
Jaroslaw Rzepeckia1ed41f2017-10-13 11:13:58 +0100661 os << pad_stride_info.pad_left() << "," << pad_stride_info.pad_right() << ","
662 << pad_stride_info.pad_top() << "," << pad_stride_info.pad_bottom();
Anthony Barbier2a07e182017-08-04 18:20:27 +0100663
664 return os;
665}
666
667inline std::string to_string(const PadStrideInfo &pad_stride_info)
668{
669 std::stringstream str;
670 str << pad_stride_info;
671 return str.str();
672}
673
674inline std::string to_string(const BorderMode &mode)
675{
676 std::stringstream str;
677 str << mode;
678 return str.str();
679}
680
John Richardsonb482ce12017-09-18 12:44:01 +0100681inline std::string to_string(const BorderSize &border)
682{
683 std::stringstream str;
684 str << border;
685 return str.str();
686}
687
Anthony Barbier2a07e182017-08-04 18:20:27 +0100688inline std::string to_string(const InterpolationPolicy &policy)
689{
690 std::stringstream str;
691 str << policy;
692 return str.str();
693}
694
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700695inline std::string to_string(const SamplingPolicy &policy)
696{
697 std::stringstream str;
698 str << policy;
699 return str.str();
700}
701
Anthony Barbier2a07e182017-08-04 18:20:27 +0100702/** Formatted output of the ConversionPolicy type. */
703inline ::std::ostream &operator<<(::std::ostream &os, const ConvertPolicy &policy)
704{
705 switch(policy)
706 {
707 case ConvertPolicy::WRAP:
708 os << "WRAP";
709 break;
710 case ConvertPolicy::SATURATE:
711 os << "SATURATE";
712 break;
713 default:
714 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
715 }
716
717 return os;
718}
719
720inline std::string to_string(const ConvertPolicy &policy)
721{
722 std::stringstream str;
723 str << policy;
724 return str.str();
725}
726
727/** Formatted output of the Reduction Operations. */
728inline ::std::ostream &operator<<(::std::ostream &os, const ReductionOperation &op)
729{
730 switch(op)
731 {
732 case ReductionOperation::SUM_SQUARE:
733 os << "SUM_SQUARE";
734 break;
735 default:
736 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
737 }
738
739 return os;
740}
741
742inline std::string to_string(const ReductionOperation &op)
743{
744 std::stringstream str;
745 str << op;
746 return str.str();
747}
748
749inline std::string to_string(const NormType &type)
750{
751 std::stringstream str;
752 str << type;
753 return str.str();
754}
755
756inline std::string to_string(const PoolingType &type)
757{
758 std::stringstream str;
759 str << type;
760 return str.str();
761}
762
763inline std::string to_string(const PoolingLayerInfo &info)
764{
765 std::stringstream str;
Georgios Pinitas4c2dd542017-11-13 12:58:41 +0000766 str << "{Type=" << info.pool_type() << ","
767 << "IsGlobalPooling=" << info.is_global_pooling();
768 if(!info.is_global_pooling())
769 {
770 str << ","
Isabella Gottardi6e464c32018-01-26 12:32:45 +0000771 << "PoolSize=" << info.pool_size().width << "," << info.pool_size().height << ","
Georgios Pinitas4c2dd542017-11-13 12:58:41 +0000772 << "PadStride=" << info.pad_stride_info();
773 }
774 str << "}";
Anthony Barbier2a07e182017-08-04 18:20:27 +0100775 return str.str();
776}
777
Moritz Pflanzer6c6597c2017-09-24 12:09:41 +0100778/** Formatted output of the KeyPoint type. */
779inline ::std::ostream &operator<<(::std::ostream &os, const KeyPoint &point)
780{
781 os << "{x=" << point.x << ","
782 << "y=" << point.y << ","
783 << "strength=" << point.strength << ","
784 << "scale=" << point.scale << ","
785 << "orientation=" << point.orientation << ","
786 << "tracking_status=" << point.tracking_status << ","
787 << "error=" << point.error << "}";
788
789 return os;
790}
John Richardson63e50412017-10-13 20:51:42 +0100791
792/** Formatted output of the PhaseType type. */
793inline ::std::ostream &operator<<(::std::ostream &os, const PhaseType &phase_type)
794{
795 switch(phase_type)
796 {
797 case PhaseType::SIGNED:
798 os << "SIGNED";
799 break;
800 case PhaseType::UNSIGNED:
801 os << "UNSIGNED";
802 break;
803 default:
804 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
805 }
806
807 return os;
808}
809
810inline std::string to_string(const arm_compute::PhaseType &type)
811{
812 std::stringstream str;
813 str << type;
814 return str.str();
815}
John Richardson3c5f9492017-10-04 15:27:37 +0100816
817/** Formatted output of the MagnitudeType type. */
818inline ::std::ostream &operator<<(::std::ostream &os, const MagnitudeType &magnitude_type)
819{
820 switch(magnitude_type)
821 {
822 case MagnitudeType::L1NORM:
823 os << "L1NORM";
824 break;
825 case MagnitudeType::L2NORM:
826 os << "L2NORM";
827 break;
828 default:
829 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
830 }
831
832 return os;
833}
834
835inline std::string to_string(const arm_compute::MagnitudeType &type)
836{
837 std::stringstream str;
838 str << type;
839 return str.str();
840}
John Richardson1c529922017-11-01 10:57:48 +0000841
842/** Formatted output of the GradientDimension type. */
843inline ::std::ostream &operator<<(::std::ostream &os, const GradientDimension &dim)
844{
845 switch(dim)
846 {
847 case GradientDimension::GRAD_X:
848 os << "GRAD_X";
849 break;
850 case GradientDimension::GRAD_Y:
851 os << "GRAD_Y";
852 break;
853 case GradientDimension::GRAD_XY:
854 os << "GRAD_XY";
855 break;
856 default:
857 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
858 }
859
860 return os;
861}
862
863inline std::string to_string(const arm_compute::GradientDimension &type)
864{
865 std::stringstream str;
866 str << type;
867 return str.str();
868}
John Richardson25f23682017-11-27 14:35:09 +0000869
870/** Formatted output of the HOGNormType type. */
871inline ::std::ostream &operator<<(::std::ostream &os, const HOGNormType &norm_type)
872{
873 switch(norm_type)
874 {
875 case HOGNormType::L1_NORM:
876 os << "L1_NORM";
877 break;
878 case HOGNormType::L2_NORM:
879 os << "L2_NORM";
880 break;
881 case HOGNormType::L2HYS_NORM:
882 os << "L2HYS_NORM";
883 break;
884 default:
885 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
886 }
887
888 return os;
889}
890
891inline std::string to_string(const HOGNormType &type)
892{
893 std::stringstream str;
894 str << type;
895 return str.str();
896}
897
898/** Formatted output of the Size2D type. */
899inline ::std::ostream &operator<<(::std::ostream &os, const Size2D &size)
900{
901 os << size.width << "x" << size.height;
902
903 return os;
904}
905
906inline std::string to_string(const Size2D &type)
907{
908 std::stringstream str;
909 str << type;
910 return str.str();
911}
912
913/** Formatted output of the Size2D type. */
914inline ::std::ostream &operator<<(::std::ostream &os, const HOGInfo &hog_info)
915{
916 os << "{CellSize=" << hog_info.cell_size() << ","
917 << "BlockSize=" << hog_info.block_size() << ","
918 << "DetectionWindowSize=" << hog_info.detection_window_size() << ","
919 << "BlockStride=" << hog_info.block_stride() << ","
920 << "NumBins=" << hog_info.num_bins() << ","
921 << "NormType=" << hog_info.normalization_type() << ","
922 << "L2HystThreshold=" << hog_info.l2_hyst_threshold() << ","
923 << "PhaseType=" << hog_info.phase_type() << "}";
924
925 return os;
926}
927
928/** Formatted output of the HOGInfo type. */
929inline std::string to_string(const HOGInfo &type)
930{
931 std::stringstream str;
932 str << type;
933 return str.str();
934}
935
Isabella Gottardif07d28d2018-02-06 14:52:43 +0000936inline ::std::ostream &operator<<(::std::ostream &os, const ConvolutionMethod &conv_method)
937{
938 switch(conv_method)
939 {
940 case ConvolutionMethod::GEMM:
941 os << "GEMM";
942 break;
943 case ConvolutionMethod::DIRECT:
944 os << "DIRECT";
945 break;
946 case ConvolutionMethod::WINOGRAD:
947 os << "WINOGRAD";
948 break;
949 default:
950 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
951 }
952
953 return os;
954}
955
956inline std::string to_string(const ConvolutionMethod &conv_method)
957{
958 std::stringstream str;
959 str << conv_method;
960 return str.str();
961}
962
963inline ::std::ostream &operator<<(::std::ostream &os, const GPUTarget &gpu_target)
964{
965 switch(gpu_target)
966 {
967 case GPUTarget::GPU_ARCH_MASK:
968 os << "GPU_ARCH_MASK";
969 break;
970 case GPUTarget::MIDGARD:
971 os << "MIDGARD";
972 break;
973 case GPUTarget::BIFROST:
974 os << "BIFROST";
975 break;
976 case GPUTarget::T600:
977 os << "T600";
978 break;
979 case GPUTarget::T700:
980 os << "T700";
981 break;
982 case GPUTarget::T800:
983 os << "T800";
984 break;
985 case GPUTarget::G70:
986 os << "G70";
987 break;
988 default:
989 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
990 }
991
992 return os;
993}
994
995inline std::string to_string(const GPUTarget &gpu_target)
996{
997 std::stringstream str;
998 str << gpu_target;
999 return str.str();
1000}
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001001} // namespace arm_compute
Anthony Barbierac69aa12017-07-03 17:39:37 +01001002#endif /* __ARM_COMPUTE_TEST_TYPE_PRINTER_H__ */