blob: 7638759b46ed65ba4cf7e28947f0f42b5cc0182b [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"
Michele Di Giorgiob8fc60f2018-04-25 11:58:07 +010030#include "arm_compute/core/GPUTarget.h"
John Richardson25f23682017-11-27 14:35:09 +000031#include "arm_compute/core/HOGInfo.h"
32#include "arm_compute/core/Size2D.h"
John Richardsona36eae12017-09-26 16:55:59 +010033#include "arm_compute/core/Strides.h"
Georgios Pinitas3faea252017-10-30 14:13:50 +000034#include "arm_compute/core/TensorInfo.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010035#include "arm_compute/core/Types.h"
36
Abe Mbise4bd2cb82017-09-27 18:39:19 +010037#include "tests/Types.h"
38
Anthony Barbier6ff3b192017-09-04 18:44:23 +010039#include <ostream>
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010040#include <sstream>
41#include <string>
Anthony Barbier6ff3b192017-09-04 18:44:23 +010042
43namespace arm_compute
44{
Anthony Barbierb940fd62018-06-04 14:14:32 +010045/** Formatted output if arg is not null
46 *
47 * @param[in] arg Object to print
48 *
49 * @return String representing arg.
50 */
51template <typename T>
52std::string to_string_if_not_null(T *arg)
53{
54 if(arg == nullptr)
55 {
56 return "nullptr";
57 }
58 else
59 {
60 return to_string(*arg);
61 }
62}
63
Alex Gildayc357c472018-03-21 13:54:09 +000064/** Formatted output of the Dimensions type.
65 *
66 * @param[out] os Output stream.
67 * @param[in] dimensions Type to output.
68 *
69 * @return Modified output stream.
70 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +010071template <typename T>
72inline ::std::ostream &operator<<(::std::ostream &os, const Dimensions<T> &dimensions)
73{
Anthony Barbier6ff3b192017-09-04 18:44:23 +010074 if(dimensions.num_dimensions() > 0)
75 {
76 os << dimensions[0];
77
78 for(unsigned int d = 1; d < dimensions.num_dimensions(); ++d)
79 {
Moritz Pflanzerc87fbf82017-07-18 14:02:10 +010080 os << "x" << dimensions[d];
Anthony Barbier6ff3b192017-09-04 18:44:23 +010081 }
82 }
83
Anthony Barbier6ff3b192017-09-04 18:44:23 +010084 return os;
85}
86
Alex Gildayc357c472018-03-21 13:54:09 +000087/** Formatted output of the NonLinearFilterFunction type.
88 *
89 * @param[out] os Output stream.
90 * @param[in] function Type to output.
91 *
92 * @return Modified output stream.
93 */
Isabella Gottardi3b77e9d2017-06-22 11:05:41 +010094inline ::std::ostream &operator<<(::std::ostream &os, const NonLinearFilterFunction &function)
95{
96 switch(function)
97 {
98 case NonLinearFilterFunction::MAX:
99 os << "MAX";
100 break;
101 case NonLinearFilterFunction::MEDIAN:
102 os << "MEDIAN";
103 break;
104 case NonLinearFilterFunction::MIN:
105 os << "MIN";
106 break;
107 default:
108 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
109 }
110
111 return os;
112}
113
Alex Gildayc357c472018-03-21 13:54:09 +0000114/** Formatted output of the NonLinearFilterFunction type.
115 *
116 * @param[in] function Type to output.
117 *
118 * @return Formatted string.
119 */
John Richardson6f4d49f2017-09-07 11:21:10 +0100120inline std::string to_string(const NonLinearFilterFunction &function)
121{
122 std::stringstream str;
123 str << function;
124 return str.str();
125}
126
Alex Gildayc357c472018-03-21 13:54:09 +0000127/** Formatted output of the MatrixPattern type.
128 *
129 * @param[out] os Output stream.
130 * @param[in] pattern Type to output.
131 *
132 * @return Modified output stream.
133 */
Isabella Gottardi3b77e9d2017-06-22 11:05:41 +0100134inline ::std::ostream &operator<<(::std::ostream &os, const MatrixPattern &pattern)
135{
136 switch(pattern)
137 {
138 case MatrixPattern::BOX:
139 os << "BOX";
140 break;
141 case MatrixPattern::CROSS:
142 os << "CROSS";
143 break;
144 case MatrixPattern::DISK:
145 os << "DISK";
146 break;
147 case MatrixPattern::OTHER:
148 os << "OTHER";
149 break;
150 default:
151 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
152 }
153
154 return os;
155}
156
Alex Gildayc357c472018-03-21 13:54:09 +0000157/** Formatted output of the MatrixPattern type.
158 *
159 * @param[in] pattern Type to output.
160 *
161 * @return Formatted string.
162 */
John Richardson6f4d49f2017-09-07 11:21:10 +0100163inline std::string to_string(const MatrixPattern &pattern)
164{
165 std::stringstream str;
166 str << pattern;
167 return str.str();
168}
169
Alex Gildayc357c472018-03-21 13:54:09 +0000170/** Formatted output of the RoundingPolicy type.
171 *
172 * @param[out] os Output stream.
173 * @param[in] rounding_policy Type to output.
174 *
175 * @return Modified output stream.
176 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100177inline ::std::ostream &operator<<(::std::ostream &os, const RoundingPolicy &rounding_policy)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100178{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100179 switch(rounding_policy)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100180 {
Anthony Barbier2a07e182017-08-04 18:20:27 +0100181 case RoundingPolicy::TO_ZERO:
182 os << "TO_ZERO";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100183 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100184 case RoundingPolicy::TO_NEAREST_UP:
185 os << "TO_NEAREST_UP";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100186 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100187 case RoundingPolicy::TO_NEAREST_EVEN:
188 os << "TO_NEAREST_EVEN";
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100189 break;
190 default:
191 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
192 }
193
194 return os;
195}
196
Alex Gildayc357c472018-03-21 13:54:09 +0000197/** Formatted output of the WeightsInfo type.
198 *
199 * @param[out] os Output stream.
200 * @param[in] weights_info Type to output.
201 *
202 * @return Modified output stream.
203 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100204inline ::std::ostream &operator<<(::std::ostream &os, const WeightsInfo &weights_info)
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100205{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100206 os << weights_info.are_reshaped() << ";";
207 os << weights_info.num_kernels() << ";" << weights_info.kernel_size().first << "," << weights_info.kernel_size().second;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100208
209 return os;
210}
211
Alex Gildayc357c472018-03-21 13:54:09 +0000212/** Formatted output of the ROIPoolingInfo type.
213 *
214 * @param[out] os Output stream.
215 * @param[in] pool_info Type to output.
216 *
217 * @return Modified output stream.
218 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100219inline ::std::ostream &operator<<(::std::ostream &os, const ROIPoolingLayerInfo &pool_info)
Sanghoon Lee70f82912017-08-24 14:21:24 +0100220{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100221 os << pool_info.pooled_width() << "x" << pool_info.pooled_height() << "~" << pool_info.spatial_scale();
Georgios Pinitasd9769582017-08-03 10:19:40 +0100222 return os;
223}
224
Alex Gildayc357c472018-03-21 13:54:09 +0000225/** Formatted output of the QuantizationInfo type.
226 *
227 * @param[out] os Output stream.
228 * @param[in] quantization_info Type to output.
229 *
230 * @return Modified output stream.
231 */
Chunosovd621bca2017-11-03 17:33:15 +0700232inline ::std::ostream &operator<<(::std::ostream &os, const QuantizationInfo &quantization_info)
233{
234 os << "Scale:" << quantization_info.scale << "~"
235 << "Offset:" << quantization_info.offset;
236 return os;
237}
238
Alex Gildayc357c472018-03-21 13:54:09 +0000239/** Formatted output of the QuantizationInfo type.
240 *
241 * @param[in] quantization_info Type to output.
242 *
243 * @return Formatted string.
244 */
Chunosovd621bca2017-11-03 17:33:15 +0700245inline std::string to_string(const QuantizationInfo &quantization_info)
246{
247 std::stringstream str;
248 str << quantization_info;
249 return str.str();
250}
251
Alex Gildayc357c472018-03-21 13:54:09 +0000252/** Formatted output of the FixedPointOp type.
253 *
254 * @param[out] os Output stream.
255 * @param[in] op Type to output.
256 *
257 * @return Modified output stream.
258 */
Abe Mbise4bd2cb82017-09-27 18:39:19 +0100259inline ::std::ostream &operator<<(::std::ostream &os, const FixedPointOp &op)
260{
261 switch(op)
262 {
John Richardson70f946b2017-10-02 16:52:16 +0100263 case FixedPointOp::ADD:
264 os << "ADD";
265 break;
266 case FixedPointOp::SUB:
267 os << "SUB";
268 break;
269 case FixedPointOp::MUL:
270 os << "MUL";
271 break;
Abe Mbise4bd2cb82017-09-27 18:39:19 +0100272 case FixedPointOp::EXP:
273 os << "EXP";
274 break;
275 case FixedPointOp::LOG:
276 os << "LOG";
277 break;
278 case FixedPointOp::INV_SQRT:
279 os << "INV_SQRT";
280 break;
281 case FixedPointOp::RECIPROCAL:
282 os << "RECIPROCAL";
283 break;
284 default:
285 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
286 }
287
288 return os;
289}
John Richardson70f946b2017-10-02 16:52:16 +0100290
Alex Gildayc357c472018-03-21 13:54:09 +0000291/** Formatted output of the FixedPointOp type.
292 *
293 * @param[in] op Type to output.
294 *
295 * @return Formatted string.
296 */
Abe Mbise4bd2cb82017-09-27 18:39:19 +0100297inline std::string to_string(const FixedPointOp &op)
298{
299 std::stringstream str;
300 str << op;
301 return str.str();
302}
303
Alex Gildayc357c472018-03-21 13:54:09 +0000304/** Formatted output of the activation function type.
305 *
306 * @param[out] os Output stream.
307 * @param[in] act_function Type to output.
308 *
309 * @return Modified output stream.
310 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100311inline ::std::ostream &operator<<(::std::ostream &os, const ActivationLayerInfo::ActivationFunction &act_function)
312{
313 switch(act_function)
314 {
315 case ActivationLayerInfo::ActivationFunction::ABS:
316 os << "ABS";
317 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100318 case ActivationLayerInfo::ActivationFunction::LINEAR:
319 os << "LINEAR";
320 break;
321 case ActivationLayerInfo::ActivationFunction::LOGISTIC:
322 os << "LOGISTIC";
323 break;
324 case ActivationLayerInfo::ActivationFunction::RELU:
325 os << "RELU";
326 break;
Georgios Pinitas579c0492017-07-12 16:12:12 +0100327 case ActivationLayerInfo::ActivationFunction::BOUNDED_RELU:
328 os << "BOUNDED_RELU";
329 break;
330 case ActivationLayerInfo::ActivationFunction::LEAKY_RELU:
331 os << "LEAKY_RELU";
332 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100333 case ActivationLayerInfo::ActivationFunction::SOFT_RELU:
334 os << "SOFT_RELU";
335 break;
336 case ActivationLayerInfo::ActivationFunction::SQRT:
337 os << "SQRT";
338 break;
Anthony Barbier2a07e182017-08-04 18:20:27 +0100339 case ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU:
340 os << "LU_BOUNDED_RELU";
Kevin Petitd9f80712017-12-06 12:18:48 +0000341 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100342 case ActivationLayerInfo::ActivationFunction::SQUARE:
343 os << "SQUARE";
344 break;
345 case ActivationLayerInfo::ActivationFunction::TANH:
346 os << "TANH";
347 break;
348 default:
349 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
350 }
351
352 return os;
353}
354
Alex Gildayc357c472018-03-21 13:54:09 +0000355/** Formatted output of the activation function info type.
356 *
357 * @param[in] info Type to output.
358 *
359 * @return Formatted string.
360 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100361inline std::string to_string(const arm_compute::ActivationLayerInfo &info)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100362{
363 std::stringstream str;
Isabella Gottardi3f217ec2018-02-12 14:59:19 +0000364 if(info.enabled())
365 {
366 str << info.activation();
367 }
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100368 return str.str();
369}
370
Alex Gildayc357c472018-03-21 13:54:09 +0000371/** Formatted output of the activation function type.
372 *
373 * @param[in] function Type to output.
374 *
375 * @return Formatted string.
376 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100377inline std::string to_string(const arm_compute::ActivationLayerInfo::ActivationFunction &function)
378{
379 std::stringstream str;
380 str << function;
381 return str.str();
382}
383
Alex Gildayc357c472018-03-21 13:54:09 +0000384/** Formatted output of the NormType type.
385 *
386 * @param[out] os Output stream.
387 * @param[in] norm_type Type to output.
388 *
389 * @return Modified output stream.
390 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100391inline ::std::ostream &operator<<(::std::ostream &os, const NormType &norm_type)
392{
393 switch(norm_type)
394 {
395 case NormType::CROSS_MAP:
396 os << "CROSS_MAP";
397 break;
398 case NormType::IN_MAP_1D:
399 os << "IN_MAP_1D";
400 break;
401 case NormType::IN_MAP_2D:
402 os << "IN_MAP_2D";
403 break;
404 default:
405 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
406 }
407
408 return os;
409}
410
Alex Gildayc357c472018-03-21 13:54:09 +0000411/** Formatted output of @ref NormalizationLayerInfo.
412 *
413 * @param[in] info Type to output.
414 *
415 * @return Formatted string.
416 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100417inline std::string to_string(const arm_compute::NormalizationLayerInfo &info)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100418{
419 std::stringstream str;
Michalis Spyroud466c2d2018-01-30 10:54:39 +0000420 str << info.type() << ":NormSize=" << info.norm_size();
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100421 return str.str();
422}
423
Alex Gildayc357c472018-03-21 13:54:09 +0000424/** Formatted output of @ref NormalizationLayerInfo.
425 *
426 * @param[out] os Output stream.
427 * @param[in] info Type to output.
428 *
429 * @return Modified output stream.
430 */
Georgios Pinitas6f669f02017-09-26 12:32:57 +0100431inline ::std::ostream &operator<<(::std::ostream &os, const NormalizationLayerInfo &info)
432{
Michalis Spyroud466c2d2018-01-30 10:54:39 +0000433 os << info.type() << ":NormSize=" << info.norm_size();
Georgios Pinitas6f669f02017-09-26 12:32:57 +0100434 return os;
435}
436
Alex Gildayc357c472018-03-21 13:54:09 +0000437/** Formatted output of the PoolingType type.
438 *
439 * @param[out] os Output stream.
440 * @param[in] pool_type Type to output.
441 *
442 * @return Modified output stream.
443 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100444inline ::std::ostream &operator<<(::std::ostream &os, const PoolingType &pool_type)
445{
446 switch(pool_type)
447 {
448 case PoolingType::AVG:
449 os << "AVG";
450 break;
451 case PoolingType::MAX:
452 os << "MAX";
453 break;
Georgios Pinitascdf51452017-08-31 14:21:36 +0100454 case PoolingType::L2:
455 os << "L2";
456 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100457 default:
458 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
459 }
460
461 return os;
462}
463
Alex Gildayc357c472018-03-21 13:54:09 +0000464/** Formatted output of @ref PoolingLayerInfo.
465 *
466 * @param[out] os Output stream.
467 * @param[in] info Type to output.
468 *
469 * @return Modified output stream.
470 */
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100471inline ::std::ostream &operator<<(::std::ostream &os, const PoolingLayerInfo &info)
472{
Anthony Barbier2a07e182017-08-04 18:20:27 +0100473 os << info.pool_type();
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100474
475 return os;
476}
477
Alex Gildayc357c472018-03-21 13:54:09 +0000478/** Formatted output of @ref RoundingPolicy.
479 *
480 * @param[in] rounding_policy Type to output.
481 *
482 * @return Formatted string.
483 */
John Richardsondd715f22017-09-18 16:10:48 +0100484inline std::string to_string(const RoundingPolicy &rounding_policy)
485{
486 std::stringstream str;
487 str << rounding_policy;
488 return str.str();
489}
490
Alex Gildayc357c472018-03-21 13:54:09 +0000491/** Formatted output of the DataLayout type.
492 *
493 * @param[out] os Output stream.
494 * @param[in] data_layout Type to output.
495 *
496 * @return Modified output stream.
497 */
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000498inline ::std::ostream &operator<<(::std::ostream &os, const DataLayout &data_layout)
499{
500 switch(data_layout)
501 {
502 case DataLayout::UNKNOWN:
503 os << "UNKNOWN";
504 break;
505 case DataLayout::NHWC:
506 os << "NHWC";
507 break;
508 case DataLayout::NCHW:
509 os << "NCHW";
510 break;
511 default:
512 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
513 }
514
515 return os;
516}
517
Alex Gildayc357c472018-03-21 13:54:09 +0000518/** Formatted output of the DataLayout type.
519 *
520 * @param[in] data_layout Type to output.
521 *
522 * @return Formatted string.
523 */
Michele Di Giorgio4a65b982018-03-02 11:21:38 +0000524inline std::string to_string(const arm_compute::DataLayout &data_layout)
525{
526 std::stringstream str;
527 str << data_layout;
528 return str.str();
529}
530
Alex Gildayc357c472018-03-21 13:54:09 +0000531/** Formatted output of the DataType type.
532 *
533 * @param[out] os Output stream.
534 * @param[in] data_type Type to output.
535 *
536 * @return Modified output stream.
537 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100538inline ::std::ostream &operator<<(::std::ostream &os, const DataType &data_type)
539{
540 switch(data_type)
541 {
542 case DataType::UNKNOWN:
543 os << "UNKNOWN";
544 break;
545 case DataType::U8:
546 os << "U8";
547 break;
548 case DataType::QS8:
549 os << "QS8";
550 break;
Chunosovd621bca2017-11-03 17:33:15 +0700551 case DataType::QASYMM8:
552 os << "QASYMM8";
553 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100554 case DataType::S8:
555 os << "S8";
556 break;
557 case DataType::U16:
558 os << "U16";
559 break;
560 case DataType::S16:
561 os << "S16";
562 break;
Gian Marco Iodicebdb6b0b2017-06-30 12:21:00 +0100563 case DataType::QS16:
564 os << "QS16";
565 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100566 case DataType::U32:
567 os << "U32";
568 break;
569 case DataType::S32:
570 os << "S32";
571 break;
572 case DataType::U64:
573 os << "U64";
574 break;
575 case DataType::S64:
576 os << "S64";
577 break;
578 case DataType::F16:
579 os << "F16";
580 break;
581 case DataType::F32:
582 os << "F32";
583 break;
584 case DataType::F64:
585 os << "F64";
586 break;
587 case DataType::SIZET:
588 os << "SIZET";
589 break;
590 default:
591 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
592 }
593
594 return os;
595}
596
Alex Gildayc357c472018-03-21 13:54:09 +0000597/** Formatted output of the DataType type.
598 *
599 * @param[in] data_type Type to output.
600 *
601 * @return Formatted string.
602 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100603inline std::string to_string(const arm_compute::DataType &data_type)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100604{
605 std::stringstream str;
606 str << data_type;
607 return str.str();
608}
609
Alex Gildayc357c472018-03-21 13:54:09 +0000610/** Formatted output of the Format type.
611 *
612 * @param[out] os Output stream.
613 * @param[in] format Type to output.
614 *
615 * @return Modified output stream.
616 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100617inline ::std::ostream &operator<<(::std::ostream &os, const Format &format)
618{
619 switch(format)
620 {
621 case Format::UNKNOWN:
622 os << "UNKNOWN";
623 break;
624 case Format::U8:
625 os << "U8";
626 break;
627 case Format::S16:
628 os << "S16";
629 break;
630 case Format::U16:
631 os << "U16";
632 break;
633 case Format::S32:
634 os << "S32";
635 break;
636 case Format::U32:
637 os << "U32";
638 break;
639 case Format::F16:
640 os << "F16";
641 break;
642 case Format::F32:
643 os << "F32";
644 break;
645 case Format::UV88:
646 os << "UV88";
647 break;
648 case Format::RGB888:
649 os << "RGB888";
650 break;
651 case Format::RGBA8888:
652 os << "RGBA8888";
653 break;
654 case Format::YUV444:
655 os << "YUV444";
656 break;
657 case Format::YUYV422:
658 os << "YUYV422";
659 break;
660 case Format::NV12:
661 os << "NV12";
662 break;
663 case Format::NV21:
664 os << "NV21";
665 break;
666 case Format::IYUV:
667 os << "IYUV";
668 break;
669 case Format::UYVY422:
670 os << "UYVY422";
671 break;
672 default:
673 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
674 }
675
676 return os;
677}
678
Alex Gildayc357c472018-03-21 13:54:09 +0000679/** Formatted output of the Format type.
680 *
681 * @param[in] format Type to output.
682 *
683 * @return Formatted string.
684 */
Moritz Pflanzer7655a672017-09-23 11:57:33 +0100685inline std::string to_string(const Format &format)
686{
687 std::stringstream str;
688 str << format;
689 return str.str();
690}
691
Alex Gildayc357c472018-03-21 13:54:09 +0000692/** Formatted output of the Channel type.
693 *
694 * @param[out] os Output stream.
695 * @param[in] channel Type to output.
696 *
697 * @return Modified output stream.
698 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100699inline ::std::ostream &operator<<(::std::ostream &os, const Channel &channel)
700{
701 switch(channel)
702 {
703 case Channel::UNKNOWN:
704 os << "UNKNOWN";
705 break;
706 case Channel::C0:
707 os << "C0";
708 break;
709 case Channel::C1:
710 os << "C1";
711 break;
712 case Channel::C2:
713 os << "C2";
714 break;
715 case Channel::C3:
716 os << "C3";
717 break;
718 case Channel::R:
719 os << "R";
720 break;
721 case Channel::G:
722 os << "G";
723 break;
724 case Channel::B:
725 os << "B";
726 break;
727 case Channel::A:
728 os << "A";
729 break;
730 case Channel::Y:
731 os << "Y";
732 break;
733 case Channel::U:
734 os << "U";
735 break;
736 case Channel::V:
737 os << "V";
738 break;
739 default:
740 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
741 }
742
743 return os;
744}
745
Alex Gildayc357c472018-03-21 13:54:09 +0000746/** Formatted output of the Channel type.
747 *
748 * @param[in] channel Type to output.
749 *
750 * @return Formatted string.
751 */
Ioan-Cristian Szabo9414f642017-10-27 17:35:40 +0100752inline std::string to_string(const Channel &channel)
753{
754 std::stringstream str;
755 str << channel;
756 return str.str();
757}
758
Alex Gildayc357c472018-03-21 13:54:09 +0000759/** Formatted output of the BorderMode type.
760 *
761 * @param[out] os Output stream.
762 * @param[in] mode Type to output.
763 *
764 * @return Modified output stream.
765 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100766inline ::std::ostream &operator<<(::std::ostream &os, const BorderMode &mode)
767{
768 switch(mode)
769 {
770 case BorderMode::UNDEFINED:
771 os << "UNDEFINED";
772 break;
773 case BorderMode::CONSTANT:
774 os << "CONSTANT";
775 break;
776 case BorderMode::REPLICATE:
777 os << "REPLICATE";
778 break;
779 default:
780 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
781 }
782
783 return os;
784}
785
Alex Gildayc357c472018-03-21 13:54:09 +0000786/** Formatted output of the BorderSize type.
787 *
788 * @param[out] os Output stream.
789 * @param[in] border Type to output.
790 *
791 * @return Modified output stream.
792 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100793inline ::std::ostream &operator<<(::std::ostream &os, const BorderSize &border)
794{
Moritz Pflanzerc87fbf82017-07-18 14:02:10 +0100795 os << border.top << ","
796 << border.right << ","
797 << border.bottom << ","
798 << border.left;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100799
800 return os;
801}
Anthony Barbier2a07e182017-08-04 18:20:27 +0100802
Alex Gildayc357c472018-03-21 13:54:09 +0000803/** Formatted output of the InterpolationPolicy type.
804 *
805 * @param[out] os Output stream.
806 * @param[in] policy Type to output.
807 *
808 * @return Modified output stream.
809 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100810inline ::std::ostream &operator<<(::std::ostream &os, const InterpolationPolicy &policy)
811{
812 switch(policy)
813 {
814 case InterpolationPolicy::NEAREST_NEIGHBOR:
815 os << "NEAREST_NEIGHBOR";
816 break;
817 case InterpolationPolicy::BILINEAR:
818 os << "BILINEAR";
819 break;
820 case InterpolationPolicy::AREA:
821 os << "AREA";
822 break;
823 default:
824 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
825 }
826
827 return os;
828}
829
Alex Gildayc357c472018-03-21 13:54:09 +0000830/** Formatted output of the SamplingPolicy type.
831 *
832 * @param[out] os Output stream.
833 * @param[in] policy Type to output.
834 *
835 * @return Modified output stream.
836 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700837inline ::std::ostream &operator<<(::std::ostream &os, const SamplingPolicy &policy)
838{
839 switch(policy)
840 {
841 case SamplingPolicy::CENTER:
842 os << "CENTER";
843 break;
844 case SamplingPolicy::TOP_LEFT:
845 os << "TOP_LEFT";
846 break;
847 default:
848 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
849 }
850
851 return os;
852}
853
Alex Gildayc357c472018-03-21 13:54:09 +0000854/** Formatted output of the TensorInfo type.
855 *
856 * @param[in] info Type to output.
857 *
858 * @return Formatted string.
859 */
Georgios Pinitas3faea252017-10-30 14:13:50 +0000860inline std::string to_string(const TensorInfo &info)
861{
862 std::stringstream str;
863 str << "{Shape=" << info.tensor_shape() << ","
864 << "Type=" << info.data_type() << ","
865 << "Channels=" << info.num_channels() << ","
866 << "FixedPointPos=" << info.fixed_point_position() << "}";
867 return str.str();
868}
869
Abe Mbise925ca0f2017-10-02 19:16:33 +0100870//FIXME: Check why this doesn't work and the TensorShape and Coordinates overload are needed
Alex Gildayc357c472018-03-21 13:54:09 +0000871/** Formatted output of the Dimensions type.
872 *
873 * @param[in] dimensions Type to output.
874 *
875 * @return Formatted string.
876 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100877template <typename T>
878inline std::string to_string(const Dimensions<T> &dimensions)
879{
880 std::stringstream str;
881 str << dimensions;
882 return str.str();
883}
884
Alex Gildayc357c472018-03-21 13:54:09 +0000885/** Formatted output of the Strides type.
886 *
887 * @param[in] stride Type to output.
888 *
889 * @return Formatted string.
890 */
John Richardsona36eae12017-09-26 16:55:59 +0100891inline std::string to_string(const Strides &stride)
892{
893 std::stringstream str;
894 str << stride;
895 return str.str();
896}
897
Alex Gildayc357c472018-03-21 13:54:09 +0000898/** Formatted output of the TensorShape type.
899 *
900 * @param[in] shape Type to output.
901 *
902 * @return Formatted string.
903 */
Anthony Barbier2a07e182017-08-04 18:20:27 +0100904inline std::string to_string(const TensorShape &shape)
905{
906 std::stringstream str;
907 str << shape;
908 return str.str();
909}
910
Alex Gildayc357c472018-03-21 13:54:09 +0000911/** Formatted output of the Coordinates type.
912 *
913 * @param[in] coord Type to output.
914 *
915 * @return Formatted string.
916 */
Abe Mbise925ca0f2017-10-02 19:16:33 +0100917inline std::string to_string(const Coordinates &coord)
918{
919 std::stringstream str;
920 str << coord;
921 return str.str();
922}
923
Anthony Barbierb940fd62018-06-04 14:14:32 +0100924/** Formatted output of the GEMMReshapeInfo type.
925 *
926 * @param[out] os Output stream.
927 * @param[in] info Type to output.
928 *
929 * @return Modified output stream.
930 */
931inline ::std::ostream &operator<<(::std::ostream &os, const GEMMReshapeInfo &info)
932{
933 os << "{m=" << info.m() << ",";
934 os << "n=" << info.n() << ",";
935 os << "k=" << info.k() << ",";
936 os << "mult_transpose1xW_width=" << info.mult_transpose1xW_width() << ",";
937 os << "mult_interleave4x4_height=" << info.mult_interleave4x4_height();
938 os << "}";
939
940 return os;
941}
942
943/** Formatted output of the GEMMInfo type.
944 *
945 * @param[out] os Output stream.
946 * @param[in] info Type to output.
947 *
948 * @return Modified output stream.
949 */
950inline ::std::ostream &operator<<(::std::ostream &os, const GEMMInfo &info)
951{
952 os << "{is_a_reshaped=" << info.is_a_reshaped() << ",";
953 os << "is_b_reshaped=" << info.is_b_reshaped() << ",";
954 os << "reshape_b_only_on_first_run=" << info.reshape_b_only_on_first_run() << ",";
955 os << "reshape_info=" << info.reshape_info();
956 os << "}";
957
958 return os;
959}
960
961/** Formatted output of the Window::Dimension type.
962 *
963 * @param[out] os Output stream.
964 * @param[in] dim Type to output.
965 *
966 * @return Modified output stream.
967 */
968inline ::std::ostream &operator<<(::std::ostream &os, const Window::Dimension &dim)
969{
970 os << "{start=" << dim.start() << ", end=" << dim.end() << ", step=" << dim.step() << "}";
971
972 return os;
973}
974/** Formatted output of the Window type.
975 *
976 * @param[out] os Output stream.
977 * @param[in] win Type to output.
978 *
979 * @return Modified output stream.
980 */
981inline ::std::ostream &operator<<(::std::ostream &os, const Window &win)
982{
983 os << "{";
984 for(unsigned int i = 0; i < Coordinates::num_max_dimensions; i++)
985 {
986 if(i > 0)
987 {
988 os << ", ";
989 }
990 os << win[i];
991 }
992 os << "}";
993
994 return os;
995}
996
997/** Formatted output of the WeightsInfo type.
998 *
999 * @param[in] info Type to output.
1000 *
1001 * @return Formatted string.
1002 */
1003inline std::string to_string(const WeightsInfo &info)
1004{
1005 std::stringstream str;
1006 str << info;
1007 return str.str();
1008}
1009
1010/** Formatted output of the GEMMReshapeInfo type.
1011 *
1012 * @param[in] info Type to output.
1013 *
1014 * @return Formatted string.
1015 */
1016inline std::string to_string(const GEMMReshapeInfo &info)
1017{
1018 std::stringstream str;
1019 str << info;
1020 return str.str();
1021}
1022
1023/** Formatted output of the GEMMInfo type.
1024 *
1025 * @param[in] info Type to output.
1026 *
1027 * @return Formatted string.
1028 */
1029inline std::string to_string(const GEMMInfo &info)
1030{
1031 std::stringstream str;
1032 str << info;
1033 return str.str();
1034}
1035
1036/** Formatted output of the Window::Dimension type.
1037 *
1038 * @param[in] dim Type to output.
1039 *
1040 * @return Formatted string.
1041 */
1042inline std::string to_string(const Window::Dimension &dim)
1043{
1044 std::stringstream str;
1045 str << dim;
1046 return str.str();
1047}
1048/** Formatted output of the Window type.
1049 *
1050 * @param[in] win Type to output.
1051 *
1052 * @return Formatted string.
1053 */
1054inline std::string to_string(const Window &win)
1055{
1056 std::stringstream str;
1057 str << win;
1058 return str.str();
1059}
1060
Alex Gildayc357c472018-03-21 13:54:09 +00001061/** Formatted output of the Rectangle type.
1062 *
1063 * @param[out] os Output stream.
1064 * @param[in] rect Type to output.
1065 *
1066 * @return Modified output stream.
1067 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001068inline ::std::ostream &operator<<(::std::ostream &os, const Rectangle &rect)
1069{
1070 os << rect.width << "x" << rect.height;
1071 os << "+" << rect.x << "+" << rect.y;
1072
1073 return os;
1074}
1075
Alex Gildayc357c472018-03-21 13:54:09 +00001076/** Formatted output of the PadStrideInfo type.
1077 *
1078 * @param[out] os Output stream.
1079 * @param[in] pad_stride_info Type to output.
1080 *
1081 * @return Modified output stream.
1082 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001083inline ::std::ostream &operator<<(::std::ostream &os, const PadStrideInfo &pad_stride_info)
1084{
1085 os << pad_stride_info.stride().first << "," << pad_stride_info.stride().second;
1086 os << ";";
Jaroslaw Rzepeckia1ed41f2017-10-13 11:13:58 +01001087 os << pad_stride_info.pad_left() << "," << pad_stride_info.pad_right() << ","
1088 << pad_stride_info.pad_top() << "," << pad_stride_info.pad_bottom();
Anthony Barbier2a07e182017-08-04 18:20:27 +01001089
1090 return os;
1091}
1092
Alex Gildayc357c472018-03-21 13:54:09 +00001093/** Formatted output of the PadStrideInfo type.
1094 *
1095 * @param[in] pad_stride_info Type to output.
1096 *
1097 * @return Formatted string.
1098 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001099inline std::string to_string(const PadStrideInfo &pad_stride_info)
1100{
1101 std::stringstream str;
1102 str << pad_stride_info;
1103 return str.str();
1104}
1105
Alex Gildayc357c472018-03-21 13:54:09 +00001106/** Formatted output of the BorderMode type.
1107 *
1108 * @param[in] mode Type to output.
1109 *
1110 * @return Formatted string.
1111 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001112inline std::string to_string(const BorderMode &mode)
1113{
1114 std::stringstream str;
1115 str << mode;
1116 return str.str();
1117}
1118
Alex Gildayc357c472018-03-21 13:54:09 +00001119/** Formatted output of the BorderSize type.
1120 *
1121 * @param[in] border Type to output.
1122 *
1123 * @return Formatted string.
1124 */
John Richardsonb482ce12017-09-18 12:44:01 +01001125inline std::string to_string(const BorderSize &border)
1126{
1127 std::stringstream str;
1128 str << border;
1129 return str.str();
1130}
1131
Alex Gildayc357c472018-03-21 13:54:09 +00001132/** Formatted output of the InterpolationPolicy type.
1133 *
1134 * @param[in] policy Type to output.
1135 *
1136 * @return Formatted string.
1137 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001138inline std::string to_string(const InterpolationPolicy &policy)
1139{
1140 std::stringstream str;
1141 str << policy;
1142 return str.str();
1143}
1144
Alex Gildayc357c472018-03-21 13:54:09 +00001145/** Formatted output of the SamplingPolicy type.
1146 *
1147 * @param[in] policy Type to output.
1148 *
1149 * @return Formatted string.
1150 */
Daniil Efremov02bf80d2017-11-22 00:26:51 +07001151inline std::string to_string(const SamplingPolicy &policy)
1152{
1153 std::stringstream str;
1154 str << policy;
1155 return str.str();
1156}
1157
Alex Gildayc357c472018-03-21 13:54:09 +00001158/** Formatted output of the ConvertPolicy type.
1159 *
1160 * @param[out] os Output stream.
1161 * @param[in] policy Type to output.
1162 *
1163 * @return Modified output stream.
1164 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001165inline ::std::ostream &operator<<(::std::ostream &os, const ConvertPolicy &policy)
1166{
1167 switch(policy)
1168 {
1169 case ConvertPolicy::WRAP:
1170 os << "WRAP";
1171 break;
1172 case ConvertPolicy::SATURATE:
1173 os << "SATURATE";
1174 break;
1175 default:
1176 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1177 }
1178
1179 return os;
1180}
1181
1182inline std::string to_string(const ConvertPolicy &policy)
1183{
1184 std::stringstream str;
1185 str << policy;
1186 return str.str();
1187}
1188
Alex Gildayc357c472018-03-21 13:54:09 +00001189/** Formatted output of the Reduction Operations.
1190 *
1191 * @param[out] os Output stream.
1192 * @param[in] op Type to output.
1193 *
1194 * @return Modified output stream.
1195 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001196inline ::std::ostream &operator<<(::std::ostream &os, const ReductionOperation &op)
1197{
1198 switch(op)
1199 {
1200 case ReductionOperation::SUM_SQUARE:
1201 os << "SUM_SQUARE";
1202 break;
1203 default:
1204 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1205 }
1206
1207 return os;
1208}
1209
Alex Gildayc357c472018-03-21 13:54:09 +00001210/** Formatted output of the Reduction Operations.
1211 *
1212 * @param[in] op Type to output.
1213 *
1214 * @return Formatted string.
1215 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001216inline std::string to_string(const ReductionOperation &op)
1217{
1218 std::stringstream str;
1219 str << op;
1220 return str.str();
1221}
1222
Alex Gildayc357c472018-03-21 13:54:09 +00001223/** Formatted output of the Norm Type.
1224 *
1225 * @param[in] type Type to output.
1226 *
1227 * @return Formatted string.
1228 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001229inline std::string to_string(const NormType &type)
1230{
1231 std::stringstream str;
1232 str << type;
1233 return str.str();
1234}
1235
Alex Gildayc357c472018-03-21 13:54:09 +00001236/** Formatted output of the Pooling Type.
1237 *
1238 * @param[in] type Type to output.
1239 *
1240 * @return Formatted string.
1241 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001242inline std::string to_string(const PoolingType &type)
1243{
1244 std::stringstream str;
1245 str << type;
1246 return str.str();
1247}
1248
Alex Gildayc357c472018-03-21 13:54:09 +00001249/** Formatted output of the Pooling Layer Info.
1250 *
1251 * @param[in] info Type to output.
1252 *
1253 * @return Formatted string.
1254 */
Anthony Barbier2a07e182017-08-04 18:20:27 +01001255inline std::string to_string(const PoolingLayerInfo &info)
1256{
1257 std::stringstream str;
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001258 str << "{Type=" << info.pool_type() << ","
1259 << "IsGlobalPooling=" << info.is_global_pooling();
1260 if(!info.is_global_pooling())
1261 {
1262 str << ","
Isabella Gottardi6e464c32018-01-26 12:32:45 +00001263 << "PoolSize=" << info.pool_size().width << "," << info.pool_size().height << ","
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001264 << "PadStride=" << info.pad_stride_info();
1265 }
1266 str << "}";
Anthony Barbier2a07e182017-08-04 18:20:27 +01001267 return str.str();
1268}
1269
Alex Gildayc357c472018-03-21 13:54:09 +00001270/** Formatted output of the KeyPoint type.
1271 *
1272 * @param[out] os Output stream
1273 * @param[in] point Type to output.
1274 *
1275 * @return Modified output stream.
1276 */
Moritz Pflanzer6c6597c2017-09-24 12:09:41 +01001277inline ::std::ostream &operator<<(::std::ostream &os, const KeyPoint &point)
1278{
1279 os << "{x=" << point.x << ","
1280 << "y=" << point.y << ","
1281 << "strength=" << point.strength << ","
1282 << "scale=" << point.scale << ","
1283 << "orientation=" << point.orientation << ","
1284 << "tracking_status=" << point.tracking_status << ","
1285 << "error=" << point.error << "}";
1286
1287 return os;
1288}
John Richardson63e50412017-10-13 20:51:42 +01001289
Alex Gildayc357c472018-03-21 13:54:09 +00001290/** Formatted output of the PhaseType type.
1291 *
1292 * @param[out] os Output stream
1293 * @param[in] phase_type Type to output.
1294 *
1295 * @return Modified output stream.
1296 */
John Richardson63e50412017-10-13 20:51:42 +01001297inline ::std::ostream &operator<<(::std::ostream &os, const PhaseType &phase_type)
1298{
1299 switch(phase_type)
1300 {
1301 case PhaseType::SIGNED:
1302 os << "SIGNED";
1303 break;
1304 case PhaseType::UNSIGNED:
1305 os << "UNSIGNED";
1306 break;
1307 default:
1308 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1309 }
1310
1311 return os;
1312}
1313
Alex Gildayc357c472018-03-21 13:54:09 +00001314/** Formatted output of the PhaseType type.
1315 *
1316 * @param[in] type Type to output.
1317 *
1318 * @return Formatted string.
1319 */
John Richardson63e50412017-10-13 20:51:42 +01001320inline std::string to_string(const arm_compute::PhaseType &type)
1321{
1322 std::stringstream str;
1323 str << type;
1324 return str.str();
1325}
John Richardson3c5f9492017-10-04 15:27:37 +01001326
Alex Gildayc357c472018-03-21 13:54:09 +00001327/** Formatted output of the MagnitudeType type.
1328 *
1329 * @param[out] os Output stream
1330 * @param[in] magnitude_type Type to output.
1331 *
1332 * @return Modified output stream.
1333 */
John Richardson3c5f9492017-10-04 15:27:37 +01001334inline ::std::ostream &operator<<(::std::ostream &os, const MagnitudeType &magnitude_type)
1335{
1336 switch(magnitude_type)
1337 {
1338 case MagnitudeType::L1NORM:
1339 os << "L1NORM";
1340 break;
1341 case MagnitudeType::L2NORM:
1342 os << "L2NORM";
1343 break;
1344 default:
1345 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1346 }
1347
1348 return os;
1349}
1350
Alex Gildayc357c472018-03-21 13:54:09 +00001351/** Formatted output of the MagnitudeType type.
1352 *
1353 * @param[in] type Type to output.
1354 *
1355 * @return Formatted string.
1356 */
John Richardson3c5f9492017-10-04 15:27:37 +01001357inline std::string to_string(const arm_compute::MagnitudeType &type)
1358{
1359 std::stringstream str;
1360 str << type;
1361 return str.str();
1362}
John Richardson1c529922017-11-01 10:57:48 +00001363
Alex Gildayc357c472018-03-21 13:54:09 +00001364/** Formatted output of the GradientDimension type.
1365 *
1366 * @param[out] os Output stream
1367 * @param[in] dim Type to output
1368 *
1369 * @return Modified output stream.
1370 */
John Richardson1c529922017-11-01 10:57:48 +00001371inline ::std::ostream &operator<<(::std::ostream &os, const GradientDimension &dim)
1372{
1373 switch(dim)
1374 {
1375 case GradientDimension::GRAD_X:
1376 os << "GRAD_X";
1377 break;
1378 case GradientDimension::GRAD_Y:
1379 os << "GRAD_Y";
1380 break;
1381 case GradientDimension::GRAD_XY:
1382 os << "GRAD_XY";
1383 break;
1384 default:
1385 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1386 }
1387
1388 return os;
1389}
1390
Alex Gildayc357c472018-03-21 13:54:09 +00001391/** Formatted output of the GradientDimension type.
1392 *
1393 * @param[in] type Type to output
1394 *
1395 * @return Formatted string.
1396 */
John Richardson1c529922017-11-01 10:57:48 +00001397inline std::string to_string(const arm_compute::GradientDimension &type)
1398{
1399 std::stringstream str;
1400 str << type;
1401 return str.str();
1402}
John Richardson25f23682017-11-27 14:35:09 +00001403
Alex Gildayc357c472018-03-21 13:54:09 +00001404/** Formatted output of the HOGNormType type.
1405 *
1406 * @param[out] os Output stream
1407 * @param[in] norm_type Type to output
1408 *
1409 * @return Modified output stream.
1410 */
John Richardson25f23682017-11-27 14:35:09 +00001411inline ::std::ostream &operator<<(::std::ostream &os, const HOGNormType &norm_type)
1412{
1413 switch(norm_type)
1414 {
1415 case HOGNormType::L1_NORM:
1416 os << "L1_NORM";
1417 break;
1418 case HOGNormType::L2_NORM:
1419 os << "L2_NORM";
1420 break;
1421 case HOGNormType::L2HYS_NORM:
1422 os << "L2HYS_NORM";
1423 break;
1424 default:
1425 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1426 }
1427
1428 return os;
1429}
1430
Alex Gildayc357c472018-03-21 13:54:09 +00001431/** Formatted output of the HOGNormType type.
1432 *
1433 * @param[in] type Type to output
1434 *
1435 * @return Formatted string.
1436 */
John Richardson25f23682017-11-27 14:35:09 +00001437inline std::string to_string(const HOGNormType &type)
1438{
1439 std::stringstream str;
1440 str << type;
1441 return str.str();
1442}
1443
Alex Gildayc357c472018-03-21 13:54:09 +00001444/** Formatted output of the Size2D type.
1445 *
1446 * @param[out] os Output stream
1447 * @param[in] size Type to output
1448 *
1449 * @return Modified output stream.
1450 */
John Richardson25f23682017-11-27 14:35:09 +00001451inline ::std::ostream &operator<<(::std::ostream &os, const Size2D &size)
1452{
1453 os << size.width << "x" << size.height;
1454
1455 return os;
1456}
1457
Alex Gildayc357c472018-03-21 13:54:09 +00001458/** Formatted output of the Size2D type.
1459 *
1460 * @param[in] type Type to output
1461 *
1462 * @return Formatted string.
1463 */
John Richardson25f23682017-11-27 14:35:09 +00001464inline std::string to_string(const Size2D &type)
1465{
1466 std::stringstream str;
1467 str << type;
1468 return str.str();
1469}
1470
Alex Gildayc357c472018-03-21 13:54:09 +00001471/** Formatted output of the HOGInfo type.
1472 *
1473 * @param[out] os Output stream
1474 * @param[in] hog_info Type to output
1475 *
1476 * @return Modified output stream.
1477 */
John Richardson25f23682017-11-27 14:35:09 +00001478inline ::std::ostream &operator<<(::std::ostream &os, const HOGInfo &hog_info)
1479{
1480 os << "{CellSize=" << hog_info.cell_size() << ","
1481 << "BlockSize=" << hog_info.block_size() << ","
1482 << "DetectionWindowSize=" << hog_info.detection_window_size() << ","
1483 << "BlockStride=" << hog_info.block_stride() << ","
1484 << "NumBins=" << hog_info.num_bins() << ","
1485 << "NormType=" << hog_info.normalization_type() << ","
1486 << "L2HystThreshold=" << hog_info.l2_hyst_threshold() << ","
1487 << "PhaseType=" << hog_info.phase_type() << "}";
1488
1489 return os;
1490}
1491
Alex Gildayc357c472018-03-21 13:54:09 +00001492/** Formatted output of the HOGInfo type.
1493 *
1494 * @param[in] type Type to output
1495 *
1496 * @return Formatted string.
1497 */
John Richardson25f23682017-11-27 14:35:09 +00001498inline std::string to_string(const HOGInfo &type)
1499{
1500 std::stringstream str;
1501 str << type;
1502 return str.str();
1503}
1504
Alex Gildayc357c472018-03-21 13:54:09 +00001505/** Formatted output of the ConvolutionMethod type.
1506 *
1507 * @param[out] os Output stream
1508 * @param[in] conv_method Type to output
1509 *
1510 * @return Modified output stream.
1511 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001512inline ::std::ostream &operator<<(::std::ostream &os, const ConvolutionMethod &conv_method)
1513{
1514 switch(conv_method)
1515 {
1516 case ConvolutionMethod::GEMM:
1517 os << "GEMM";
1518 break;
1519 case ConvolutionMethod::DIRECT:
1520 os << "DIRECT";
1521 break;
1522 case ConvolutionMethod::WINOGRAD:
1523 os << "WINOGRAD";
1524 break;
1525 default:
1526 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1527 }
1528
1529 return os;
1530}
1531
Alex Gildayc357c472018-03-21 13:54:09 +00001532/** Formatted output of the ConvolutionMethod type.
1533 *
1534 * @param[in] conv_method Type to output
1535 *
1536 * @return Formatted string.
1537 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001538inline std::string to_string(const ConvolutionMethod &conv_method)
1539{
1540 std::stringstream str;
1541 str << conv_method;
1542 return str.str();
1543}
1544
Alex Gildayc357c472018-03-21 13:54:09 +00001545/** Formatted output of the GPUTarget type.
1546 *
1547 * @param[out] os Output stream
1548 * @param[in] gpu_target Type to output
1549 *
1550 * @return Modified output stream.
1551 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001552inline ::std::ostream &operator<<(::std::ostream &os, const GPUTarget &gpu_target)
1553{
1554 switch(gpu_target)
1555 {
1556 case GPUTarget::GPU_ARCH_MASK:
1557 os << "GPU_ARCH_MASK";
1558 break;
1559 case GPUTarget::MIDGARD:
1560 os << "MIDGARD";
1561 break;
1562 case GPUTarget::BIFROST:
1563 os << "BIFROST";
1564 break;
1565 case GPUTarget::T600:
1566 os << "T600";
1567 break;
1568 case GPUTarget::T700:
1569 os << "T700";
1570 break;
1571 case GPUTarget::T800:
1572 os << "T800";
1573 break;
Michalis Spyroua9676112018-02-22 18:07:43 +00001574 case GPUTarget::G71:
1575 os << "G71";
1576 break;
1577 case GPUTarget::G72:
1578 os << "G72";
1579 break;
1580 case GPUTarget::G51:
1581 os << "G51";
1582 break;
1583 case GPUTarget::G51BIG:
1584 os << "G51BIG";
1585 break;
1586 case GPUTarget::G51LIT:
1587 os << "G51LIT";
1588 break;
1589 case GPUTarget::TNOX:
1590 os << "TNOX";
1591 break;
1592 case GPUTarget::TTRX:
1593 os << "TTRX";
1594 break;
1595 case GPUTarget::TBOX:
1596 os << "TBOX";
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001597 break;
1598 default:
1599 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1600 }
1601
1602 return os;
1603}
1604
Alex Gildayc357c472018-03-21 13:54:09 +00001605/** Formatted output of the GPUTarget type.
1606 *
1607 * @param[in] gpu_target Type to output
1608 *
1609 * @return Formatted string.
1610 */
Isabella Gottardif07d28d2018-02-06 14:52:43 +00001611inline std::string to_string(const GPUTarget &gpu_target)
1612{
1613 std::stringstream str;
1614 str << gpu_target;
1615 return str.str();
1616}
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00001617
John Richardson8de92612018-02-22 14:09:31 +00001618/** Formatted output of the DetectionWindow type.
1619 *
1620 * @param[out] os Output stream
1621 * @param[in] detection_window Type to output
1622 *
1623 * @return Modified output stream.
1624 */
John Richardson684cb0f2018-01-09 11:17:00 +00001625inline ::std::ostream &operator<<(::std::ostream &os, const DetectionWindow &detection_window)
1626{
1627 os << "{x=" << detection_window.x << ","
1628 << "y=" << detection_window.y << ","
1629 << "width=" << detection_window.width << ","
1630 << "height=" << detection_window.height << ","
1631 << "idx_class=" << detection_window.idx_class << ","
1632 << "score=" << detection_window.score << "}";
1633
1634 return os;
1635}
1636
John Richardson8de92612018-02-22 14:09:31 +00001637/** Formatted output of the DetectionWindow type.
1638 *
1639 * @param[in] detection_window Type to output
1640 *
1641 * @return Formatted string.
1642 */
1643inline std::string to_string(const DetectionWindow &detection_window)
1644{
1645 std::stringstream str;
1646 str << detection_window;
1647 return str.str();
1648}
1649
1650/** Formatted output of the Termination type.
1651 *
1652 * @param[out] os Output stream
1653 * @param[in] termination Type to output
1654 *
1655 * @return Modified output stream.
1656 */
1657inline ::std::ostream &operator<<(::std::ostream &os, const Termination &termination)
1658{
1659 switch(termination)
1660 {
1661 case Termination::TERM_CRITERIA_EPSILON:
1662 os << "TERM_CRITERIA_EPSILON";
1663 break;
1664 case Termination::TERM_CRITERIA_ITERATIONS:
1665 os << "TERM_CRITERIA_ITERATIONS";
1666 break;
1667 case Termination::TERM_CRITERIA_BOTH:
1668 os << "TERM_CRITERIA_BOTH";
1669 break;
1670 default:
1671 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
1672 }
1673
1674 return os;
1675}
1676
1677/** Formatted output of the Termination type.
1678 *
1679 * @param[in] termination Type to output
1680 *
1681 * @return Formatted string.
1682 */
1683inline std::string to_string(const Termination &termination)
1684{
1685 std::stringstream str;
1686 str << termination;
1687 return str.str();
1688}
1689
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00001690/** Formatted output of the WinogradInfo type. */
1691inline ::std::ostream &operator<<(::std::ostream &os, const WinogradInfo &info)
1692{
1693 os << "{OutputTileSize=" << info.output_tile_size << ","
1694 << "KernelSize=" << info.kernel_size << ","
1695 << "PadStride=" << info.convolution_info << ","
1696 << "OutputDataLayout=" << info.output_data_layout << "}";
1697
1698 return os;
1699}
1700
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00001701inline std::string to_string(const WinogradInfo &type)
1702{
1703 std::stringstream str;
1704 str << type;
1705 return str.str();
1706}
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001707} // namespace arm_compute
John Richardson8de92612018-02-22 14:09:31 +00001708#endif /* __ARM_COMPUTE_TEST_TYPE_PRINTER_H__ */