blob: c4f3495761289d3e6bc904a0847e185807d27572 [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"
29#include "arm_compute/core/Types.h"
30
31#include <ostream>
32
33namespace arm_compute
34{
35/** Formatted output of the Dimensions type. */
36template <typename T>
37inline ::std::ostream &operator<<(::std::ostream &os, const Dimensions<T> &dimensions)
38{
39 os << "(";
40
41 if(dimensions.num_dimensions() > 0)
42 {
43 os << dimensions[0];
44
45 for(unsigned int d = 1; d < dimensions.num_dimensions(); ++d)
46 {
47 os << ", " << dimensions[d];
48 }
49 }
50
51 os << ")";
52
53 return os;
54}
55
Georgios Pinitas7b7858d2017-06-21 16:44:24 +010056/** Formatted output of the Rectangle type. */
57inline ::std::ostream &operator<<(::std::ostream &os, const Rectangle &rect)
58{
59 os << "(";
60 os << rect.height << ", " << rect.width;
61 os << ", ";
62 os << rect.x << ", " << rect.y;
63 os << ")";
64
65 return os;
66}
67
Anthony Barbier6ff3b192017-09-04 18:44:23 +010068/** Formatted output of the PadStridInfo type. */
69inline ::std::ostream &operator<<(::std::ostream &os, const PadStrideInfo &pad_stride_info)
70{
71 os << "(";
72 os << pad_stride_info.stride().first << ", " << pad_stride_info.stride().second;
73 os << ", ";
74 os << pad_stride_info.pad().first << ", " << pad_stride_info.pad().second;
75 os << ")";
76
77 return os;
78}
79
Georgios Pinitas7b7858d2017-06-21 16:44:24 +010080/** Formatted output of the ROIPoolingInfo type. */
81inline ::std::ostream &operator<<(::std::ostream &os, const ROIPoolingLayerInfo &pool_info)
82{
83 os << pool_info.pooled_width() << ", " << pool_info.pooled_height() << ", " << pool_info.spatial_scale();
84 return os;
85}
86
Anthony Barbier6ff3b192017-09-04 18:44:23 +010087/** Formatted output of the BorderMode type. */
88inline ::std::ostream &operator<<(::std::ostream &os, const BorderMode &mode)
89{
90 switch(mode)
91 {
92 case BorderMode::UNDEFINED:
93 os << "UNDEFINED";
94 break;
95 case BorderMode::CONSTANT:
96 os << "CONSTANT";
97 break;
98 case BorderMode::REPLICATE:
99 os << "REPLICATE";
100 break;
101 default:
102 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
103 }
104
105 return os;
106}
107
Isabella Gottardi3b77e9d2017-06-22 11:05:41 +0100108/** Formatted output of the NonLinearFilterFunction type. */
109inline ::std::ostream &operator<<(::std::ostream &os, const NonLinearFilterFunction &function)
110{
111 switch(function)
112 {
113 case NonLinearFilterFunction::MAX:
114 os << "MAX";
115 break;
116 case NonLinearFilterFunction::MEDIAN:
117 os << "MEDIAN";
118 break;
119 case NonLinearFilterFunction::MIN:
120 os << "MIN";
121 break;
122 default:
123 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
124 }
125
126 return os;
127}
128
129/** Formatted output of the MatrixPattern type. */
130inline ::std::ostream &operator<<(::std::ostream &os, const MatrixPattern &pattern)
131{
132 switch(pattern)
133 {
134 case MatrixPattern::BOX:
135 os << "BOX";
136 break;
137 case MatrixPattern::CROSS:
138 os << "CROSS";
139 break;
140 case MatrixPattern::DISK:
141 os << "DISK";
142 break;
143 case MatrixPattern::OTHER:
144 os << "OTHER";
145 break;
146 default:
147 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
148 }
149
150 return os;
151}
152
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100153/** Formatted output of the InterpolationPolicy type. */
154inline ::std::ostream &operator<<(::std::ostream &os, const InterpolationPolicy &policy)
155{
156 switch(policy)
157 {
158 case InterpolationPolicy::NEAREST_NEIGHBOR:
159 os << "NEAREST_NEIGHBOR";
160 break;
161 case InterpolationPolicy::BILINEAR:
162 os << "BILINEAR";
163 break;
164 case InterpolationPolicy::AREA:
165 os << "AREA";
166 break;
167 default:
168 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
169 }
170
171 return os;
172}
173
174/** Formatted output of the ConversionPolicy type. */
175inline ::std::ostream &operator<<(::std::ostream &os, const ConvertPolicy &policy)
176{
177 switch(policy)
178 {
179 case ConvertPolicy::WRAP:
180 os << "WRAP";
181 break;
182 case ConvertPolicy::SATURATE:
183 os << "SATURATE";
184 break;
185 default:
186 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
187 }
188
189 return os;
190}
191
192/** Formatted output of the activation function type. */
193inline ::std::ostream &operator<<(::std::ostream &os, const ActivationLayerInfo::ActivationFunction &act_function)
194{
195 switch(act_function)
196 {
197 case ActivationLayerInfo::ActivationFunction::ABS:
198 os << "ABS";
199 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100200 case ActivationLayerInfo::ActivationFunction::LINEAR:
201 os << "LINEAR";
202 break;
203 case ActivationLayerInfo::ActivationFunction::LOGISTIC:
204 os << "LOGISTIC";
205 break;
206 case ActivationLayerInfo::ActivationFunction::RELU:
207 os << "RELU";
208 break;
Georgios Pinitas579c0492017-07-12 16:12:12 +0100209 case ActivationLayerInfo::ActivationFunction::BOUNDED_RELU:
210 os << "BOUNDED_RELU";
211 break;
212 case ActivationLayerInfo::ActivationFunction::LEAKY_RELU:
213 os << "LEAKY_RELU";
214 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100215 case ActivationLayerInfo::ActivationFunction::SOFT_RELU:
216 os << "SOFT_RELU";
217 break;
218 case ActivationLayerInfo::ActivationFunction::SQRT:
219 os << "SQRT";
220 break;
221 case ActivationLayerInfo::ActivationFunction::SQUARE:
222 os << "SQUARE";
223 break;
224 case ActivationLayerInfo::ActivationFunction::TANH:
225 os << "TANH";
226 break;
227 default:
228 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
229 }
230
231 return os;
232}
233
234/** Formatted output of the NormType type. */
235inline ::std::ostream &operator<<(::std::ostream &os, const NormType &norm_type)
236{
237 switch(norm_type)
238 {
239 case NormType::CROSS_MAP:
240 os << "CROSS_MAP";
241 break;
242 case NormType::IN_MAP_1D:
243 os << "IN_MAP_1D";
244 break;
245 case NormType::IN_MAP_2D:
246 os << "IN_MAP_2D";
247 break;
248 default:
249 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
250 }
251
252 return os;
253}
254
255/** Formatted output of the PoolingType type. */
256inline ::std::ostream &operator<<(::std::ostream &os, const PoolingType &pool_type)
257{
258 switch(pool_type)
259 {
260 case PoolingType::AVG:
261 os << "AVG";
262 break;
263 case PoolingType::MAX:
264 os << "MAX";
265 break;
266 default:
267 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
268 }
269
270 return os;
271}
272
273/** Formatted output of the RoundingPolicy type. */
274inline ::std::ostream &operator<<(::std::ostream &os, const RoundingPolicy &rounding_policy)
275{
276 switch(rounding_policy)
277 {
278 case RoundingPolicy::TO_ZERO:
279 os << "TO_ZERO";
280 break;
281 case RoundingPolicy::TO_NEAREST_UP:
282 os << "TO_NEAREST_UP";
283 break;
284 case RoundingPolicy::TO_NEAREST_EVEN:
285 os << "TO_NEAREST_EVEN";
286 break;
287 default:
288 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
289 }
290
291 return os;
292}
293
294/** Formatted output of the DataType type. */
295inline ::std::ostream &operator<<(::std::ostream &os, const DataType &data_type)
296{
297 switch(data_type)
298 {
299 case DataType::UNKNOWN:
300 os << "UNKNOWN";
301 break;
302 case DataType::U8:
303 os << "U8";
304 break;
305 case DataType::QS8:
306 os << "QS8";
307 break;
308 case DataType::S8:
309 os << "S8";
310 break;
311 case DataType::U16:
312 os << "U16";
313 break;
314 case DataType::S16:
315 os << "S16";
316 break;
Gian Marco Iodicebdb6b0b2017-06-30 12:21:00 +0100317 case DataType::QS16:
318 os << "QS16";
319 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100320 case DataType::U32:
321 os << "U32";
322 break;
323 case DataType::S32:
324 os << "S32";
325 break;
326 case DataType::U64:
327 os << "U64";
328 break;
329 case DataType::S64:
330 os << "S64";
331 break;
332 case DataType::F16:
333 os << "F16";
334 break;
335 case DataType::F32:
336 os << "F32";
337 break;
338 case DataType::F64:
339 os << "F64";
340 break;
341 case DataType::SIZET:
342 os << "SIZET";
343 break;
344 default:
345 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
346 }
347
348 return os;
349}
350
351/** Formatted output of the Format type. */
352inline ::std::ostream &operator<<(::std::ostream &os, const Format &format)
353{
354 switch(format)
355 {
356 case Format::UNKNOWN:
357 os << "UNKNOWN";
358 break;
359 case Format::U8:
360 os << "U8";
361 break;
362 case Format::S16:
363 os << "S16";
364 break;
365 case Format::U16:
366 os << "U16";
367 break;
368 case Format::S32:
369 os << "S32";
370 break;
371 case Format::U32:
372 os << "U32";
373 break;
374 case Format::F16:
375 os << "F16";
376 break;
377 case Format::F32:
378 os << "F32";
379 break;
380 case Format::UV88:
381 os << "UV88";
382 break;
383 case Format::RGB888:
384 os << "RGB888";
385 break;
386 case Format::RGBA8888:
387 os << "RGBA8888";
388 break;
389 case Format::YUV444:
390 os << "YUV444";
391 break;
392 case Format::YUYV422:
393 os << "YUYV422";
394 break;
395 case Format::NV12:
396 os << "NV12";
397 break;
398 case Format::NV21:
399 os << "NV21";
400 break;
401 case Format::IYUV:
402 os << "IYUV";
403 break;
404 case Format::UYVY422:
405 os << "UYVY422";
406 break;
407 default:
408 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
409 }
410
411 return os;
412}
413
414/** Formatted output of the Channel type. */
415inline ::std::ostream &operator<<(::std::ostream &os, const Channel &channel)
416{
417 switch(channel)
418 {
419 case Channel::UNKNOWN:
420 os << "UNKNOWN";
421 break;
422 case Channel::C0:
423 os << "C0";
424 break;
425 case Channel::C1:
426 os << "C1";
427 break;
428 case Channel::C2:
429 os << "C2";
430 break;
431 case Channel::C3:
432 os << "C3";
433 break;
434 case Channel::R:
435 os << "R";
436 break;
437 case Channel::G:
438 os << "G";
439 break;
440 case Channel::B:
441 os << "B";
442 break;
443 case Channel::A:
444 os << "A";
445 break;
446 case Channel::Y:
447 os << "Y";
448 break;
449 case Channel::U:
450 os << "U";
451 break;
452 case Channel::V:
453 os << "V";
454 break;
455 default:
456 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
457 }
458
459 return os;
460}
461
462/** Formatted output of the BorderSize type. */
463inline ::std::ostream &operator<<(::std::ostream &os, const BorderSize &border)
464{
465 os << "{" << border.top << ", "
466 << border.right << ", "
467 << border.bottom << ", "
468 << border.left << "}";
469
470 return os;
471}
472} // namespace arm_compute
Anthony Barbierac69aa12017-07-03 17:39:37 +0100473#endif /* __ARM_COMPUTE_TEST_TYPE_PRINTER_H__ */