blob: f5915c474a143ee736d8301df22bb8d58beee99d [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;
200 case ActivationLayerInfo::ActivationFunction::BOUNDED_RELU:
201 os << "BOUNDED_RELU";
202 break;
203 case ActivationLayerInfo::ActivationFunction::LINEAR:
204 os << "LINEAR";
205 break;
206 case ActivationLayerInfo::ActivationFunction::LOGISTIC:
207 os << "LOGISTIC";
208 break;
209 case ActivationLayerInfo::ActivationFunction::RELU:
210 os << "RELU";
211 break;
212 case ActivationLayerInfo::ActivationFunction::SOFT_RELU:
213 os << "SOFT_RELU";
214 break;
215 case ActivationLayerInfo::ActivationFunction::SQRT:
216 os << "SQRT";
217 break;
218 case ActivationLayerInfo::ActivationFunction::SQUARE:
219 os << "SQUARE";
220 break;
221 case ActivationLayerInfo::ActivationFunction::TANH:
222 os << "TANH";
223 break;
224 default:
225 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
226 }
227
228 return os;
229}
230
231/** Formatted output of the NormType type. */
232inline ::std::ostream &operator<<(::std::ostream &os, const NormType &norm_type)
233{
234 switch(norm_type)
235 {
236 case NormType::CROSS_MAP:
237 os << "CROSS_MAP";
238 break;
239 case NormType::IN_MAP_1D:
240 os << "IN_MAP_1D";
241 break;
242 case NormType::IN_MAP_2D:
243 os << "IN_MAP_2D";
244 break;
245 default:
246 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
247 }
248
249 return os;
250}
251
252/** Formatted output of the PoolingType type. */
253inline ::std::ostream &operator<<(::std::ostream &os, const PoolingType &pool_type)
254{
255 switch(pool_type)
256 {
257 case PoolingType::AVG:
258 os << "AVG";
259 break;
260 case PoolingType::MAX:
261 os << "MAX";
262 break;
263 default:
264 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
265 }
266
267 return os;
268}
269
270/** Formatted output of the RoundingPolicy type. */
271inline ::std::ostream &operator<<(::std::ostream &os, const RoundingPolicy &rounding_policy)
272{
273 switch(rounding_policy)
274 {
275 case RoundingPolicy::TO_ZERO:
276 os << "TO_ZERO";
277 break;
278 case RoundingPolicy::TO_NEAREST_UP:
279 os << "TO_NEAREST_UP";
280 break;
281 case RoundingPolicy::TO_NEAREST_EVEN:
282 os << "TO_NEAREST_EVEN";
283 break;
284 default:
285 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
286 }
287
288 return os;
289}
290
291/** Formatted output of the DataType type. */
292inline ::std::ostream &operator<<(::std::ostream &os, const DataType &data_type)
293{
294 switch(data_type)
295 {
296 case DataType::UNKNOWN:
297 os << "UNKNOWN";
298 break;
299 case DataType::U8:
300 os << "U8";
301 break;
302 case DataType::QS8:
303 os << "QS8";
304 break;
305 case DataType::S8:
306 os << "S8";
307 break;
308 case DataType::U16:
309 os << "U16";
310 break;
311 case DataType::S16:
312 os << "S16";
313 break;
314 case DataType::U32:
315 os << "U32";
316 break;
317 case DataType::S32:
318 os << "S32";
319 break;
320 case DataType::U64:
321 os << "U64";
322 break;
323 case DataType::S64:
324 os << "S64";
325 break;
326 case DataType::F16:
327 os << "F16";
328 break;
329 case DataType::F32:
330 os << "F32";
331 break;
332 case DataType::F64:
333 os << "F64";
334 break;
335 case DataType::SIZET:
336 os << "SIZET";
337 break;
338 default:
339 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
340 }
341
342 return os;
343}
344
345/** Formatted output of the Format type. */
346inline ::std::ostream &operator<<(::std::ostream &os, const Format &format)
347{
348 switch(format)
349 {
350 case Format::UNKNOWN:
351 os << "UNKNOWN";
352 break;
353 case Format::U8:
354 os << "U8";
355 break;
356 case Format::S16:
357 os << "S16";
358 break;
359 case Format::U16:
360 os << "U16";
361 break;
362 case Format::S32:
363 os << "S32";
364 break;
365 case Format::U32:
366 os << "U32";
367 break;
368 case Format::F16:
369 os << "F16";
370 break;
371 case Format::F32:
372 os << "F32";
373 break;
374 case Format::UV88:
375 os << "UV88";
376 break;
377 case Format::RGB888:
378 os << "RGB888";
379 break;
380 case Format::RGBA8888:
381 os << "RGBA8888";
382 break;
383 case Format::YUV444:
384 os << "YUV444";
385 break;
386 case Format::YUYV422:
387 os << "YUYV422";
388 break;
389 case Format::NV12:
390 os << "NV12";
391 break;
392 case Format::NV21:
393 os << "NV21";
394 break;
395 case Format::IYUV:
396 os << "IYUV";
397 break;
398 case Format::UYVY422:
399 os << "UYVY422";
400 break;
401 default:
402 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
403 }
404
405 return os;
406}
407
408/** Formatted output of the Channel type. */
409inline ::std::ostream &operator<<(::std::ostream &os, const Channel &channel)
410{
411 switch(channel)
412 {
413 case Channel::UNKNOWN:
414 os << "UNKNOWN";
415 break;
416 case Channel::C0:
417 os << "C0";
418 break;
419 case Channel::C1:
420 os << "C1";
421 break;
422 case Channel::C2:
423 os << "C2";
424 break;
425 case Channel::C3:
426 os << "C3";
427 break;
428 case Channel::R:
429 os << "R";
430 break;
431 case Channel::G:
432 os << "G";
433 break;
434 case Channel::B:
435 os << "B";
436 break;
437 case Channel::A:
438 os << "A";
439 break;
440 case Channel::Y:
441 os << "Y";
442 break;
443 case Channel::U:
444 os << "U";
445 break;
446 case Channel::V:
447 os << "V";
448 break;
449 default:
450 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
451 }
452
453 return os;
454}
455
456/** Formatted output of the BorderSize type. */
457inline ::std::ostream &operator<<(::std::ostream &os, const BorderSize &border)
458{
459 os << "{" << border.top << ", "
460 << border.right << ", "
461 << border.bottom << ", "
462 << border.left << "}";
463
464 return os;
465}
466} // namespace arm_compute
467#endif