blob: 3d5a19981fedefbbc033fb352bfcf4a6e667da8e [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
56/** Formatted output of the PadStridInfo type. */
57inline ::std::ostream &operator<<(::std::ostream &os, const PadStrideInfo &pad_stride_info)
58{
59 os << "(";
60 os << pad_stride_info.stride().first << ", " << pad_stride_info.stride().second;
61 os << ", ";
62 os << pad_stride_info.pad().first << ", " << pad_stride_info.pad().second;
63 os << ")";
64
65 return os;
66}
67
68/** Formatted output of the BorderMode type. */
69inline ::std::ostream &operator<<(::std::ostream &os, const BorderMode &mode)
70{
71 switch(mode)
72 {
73 case BorderMode::UNDEFINED:
74 os << "UNDEFINED";
75 break;
76 case BorderMode::CONSTANT:
77 os << "CONSTANT";
78 break;
79 case BorderMode::REPLICATE:
80 os << "REPLICATE";
81 break;
82 default:
83 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
84 }
85
86 return os;
87}
88
89/** Formatted output of the InterpolationPolicy type. */
90inline ::std::ostream &operator<<(::std::ostream &os, const InterpolationPolicy &policy)
91{
92 switch(policy)
93 {
94 case InterpolationPolicy::NEAREST_NEIGHBOR:
95 os << "NEAREST_NEIGHBOR";
96 break;
97 case InterpolationPolicy::BILINEAR:
98 os << "BILINEAR";
99 break;
100 case InterpolationPolicy::AREA:
101 os << "AREA";
102 break;
103 default:
104 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
105 }
106
107 return os;
108}
109
110/** Formatted output of the ConversionPolicy type. */
111inline ::std::ostream &operator<<(::std::ostream &os, const ConvertPolicy &policy)
112{
113 switch(policy)
114 {
115 case ConvertPolicy::WRAP:
116 os << "WRAP";
117 break;
118 case ConvertPolicy::SATURATE:
119 os << "SATURATE";
120 break;
121 default:
122 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
123 }
124
125 return os;
126}
127
128/** Formatted output of the activation function type. */
129inline ::std::ostream &operator<<(::std::ostream &os, const ActivationLayerInfo::ActivationFunction &act_function)
130{
131 switch(act_function)
132 {
133 case ActivationLayerInfo::ActivationFunction::ABS:
134 os << "ABS";
135 break;
136 case ActivationLayerInfo::ActivationFunction::BOUNDED_RELU:
137 os << "BOUNDED_RELU";
138 break;
139 case ActivationLayerInfo::ActivationFunction::LINEAR:
140 os << "LINEAR";
141 break;
142 case ActivationLayerInfo::ActivationFunction::LOGISTIC:
143 os << "LOGISTIC";
144 break;
145 case ActivationLayerInfo::ActivationFunction::RELU:
146 os << "RELU";
147 break;
148 case ActivationLayerInfo::ActivationFunction::SOFT_RELU:
149 os << "SOFT_RELU";
150 break;
151 case ActivationLayerInfo::ActivationFunction::SQRT:
152 os << "SQRT";
153 break;
154 case ActivationLayerInfo::ActivationFunction::SQUARE:
155 os << "SQUARE";
156 break;
157 case ActivationLayerInfo::ActivationFunction::TANH:
158 os << "TANH";
159 break;
160 default:
161 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
162 }
163
164 return os;
165}
166
167/** Formatted output of the NormType type. */
168inline ::std::ostream &operator<<(::std::ostream &os, const NormType &norm_type)
169{
170 switch(norm_type)
171 {
172 case NormType::CROSS_MAP:
173 os << "CROSS_MAP";
174 break;
175 case NormType::IN_MAP_1D:
176 os << "IN_MAP_1D";
177 break;
178 case NormType::IN_MAP_2D:
179 os << "IN_MAP_2D";
180 break;
181 default:
182 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
183 }
184
185 return os;
186}
187
188/** Formatted output of the PoolingType type. */
189inline ::std::ostream &operator<<(::std::ostream &os, const PoolingType &pool_type)
190{
191 switch(pool_type)
192 {
193 case PoolingType::AVG:
194 os << "AVG";
195 break;
196 case PoolingType::MAX:
197 os << "MAX";
198 break;
199 default:
200 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
201 }
202
203 return os;
204}
205
206/** Formatted output of the RoundingPolicy type. */
207inline ::std::ostream &operator<<(::std::ostream &os, const RoundingPolicy &rounding_policy)
208{
209 switch(rounding_policy)
210 {
211 case RoundingPolicy::TO_ZERO:
212 os << "TO_ZERO";
213 break;
214 case RoundingPolicy::TO_NEAREST_UP:
215 os << "TO_NEAREST_UP";
216 break;
217 case RoundingPolicy::TO_NEAREST_EVEN:
218 os << "TO_NEAREST_EVEN";
219 break;
220 default:
221 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
222 }
223
224 return os;
225}
226
227/** Formatted output of the DataType type. */
228inline ::std::ostream &operator<<(::std::ostream &os, const DataType &data_type)
229{
230 switch(data_type)
231 {
232 case DataType::UNKNOWN:
233 os << "UNKNOWN";
234 break;
235 case DataType::U8:
236 os << "U8";
237 break;
238 case DataType::QS8:
239 os << "QS8";
240 break;
241 case DataType::S8:
242 os << "S8";
243 break;
244 case DataType::U16:
245 os << "U16";
246 break;
247 case DataType::S16:
248 os << "S16";
249 break;
250 case DataType::U32:
251 os << "U32";
252 break;
253 case DataType::S32:
254 os << "S32";
255 break;
256 case DataType::U64:
257 os << "U64";
258 break;
259 case DataType::S64:
260 os << "S64";
261 break;
262 case DataType::F16:
263 os << "F16";
264 break;
265 case DataType::F32:
266 os << "F32";
267 break;
268 case DataType::F64:
269 os << "F64";
270 break;
271 case DataType::SIZET:
272 os << "SIZET";
273 break;
274 default:
275 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
276 }
277
278 return os;
279}
280
281/** Formatted output of the Format type. */
282inline ::std::ostream &operator<<(::std::ostream &os, const Format &format)
283{
284 switch(format)
285 {
286 case Format::UNKNOWN:
287 os << "UNKNOWN";
288 break;
289 case Format::U8:
290 os << "U8";
291 break;
292 case Format::S16:
293 os << "S16";
294 break;
295 case Format::U16:
296 os << "U16";
297 break;
298 case Format::S32:
299 os << "S32";
300 break;
301 case Format::U32:
302 os << "U32";
303 break;
304 case Format::F16:
305 os << "F16";
306 break;
307 case Format::F32:
308 os << "F32";
309 break;
310 case Format::UV88:
311 os << "UV88";
312 break;
313 case Format::RGB888:
314 os << "RGB888";
315 break;
316 case Format::RGBA8888:
317 os << "RGBA8888";
318 break;
319 case Format::YUV444:
320 os << "YUV444";
321 break;
322 case Format::YUYV422:
323 os << "YUYV422";
324 break;
325 case Format::NV12:
326 os << "NV12";
327 break;
328 case Format::NV21:
329 os << "NV21";
330 break;
331 case Format::IYUV:
332 os << "IYUV";
333 break;
334 case Format::UYVY422:
335 os << "UYVY422";
336 break;
337 default:
338 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
339 }
340
341 return os;
342}
343
344/** Formatted output of the Channel type. */
345inline ::std::ostream &operator<<(::std::ostream &os, const Channel &channel)
346{
347 switch(channel)
348 {
349 case Channel::UNKNOWN:
350 os << "UNKNOWN";
351 break;
352 case Channel::C0:
353 os << "C0";
354 break;
355 case Channel::C1:
356 os << "C1";
357 break;
358 case Channel::C2:
359 os << "C2";
360 break;
361 case Channel::C3:
362 os << "C3";
363 break;
364 case Channel::R:
365 os << "R";
366 break;
367 case Channel::G:
368 os << "G";
369 break;
370 case Channel::B:
371 os << "B";
372 break;
373 case Channel::A:
374 os << "A";
375 break;
376 case Channel::Y:
377 os << "Y";
378 break;
379 case Channel::U:
380 os << "U";
381 break;
382 case Channel::V:
383 os << "V";
384 break;
385 default:
386 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
387 }
388
389 return os;
390}
391
392/** Formatted output of the BorderSize type. */
393inline ::std::ostream &operator<<(::std::ostream &os, const BorderSize &border)
394{
395 os << "{" << border.top << ", "
396 << border.right << ", "
397 << border.bottom << ", "
398 << border.left << "}";
399
400 return os;
401}
402} // namespace arm_compute
403#endif