blob: 6babd3961d7639fa027dda9ae1b2720b72e86385 [file] [log] [blame]
Georgios Pinitasd8734b52017-12-22 15:27:52 +00001/*
2 * Copyright (c) 2018 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 */
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010024#ifndef __ARM_COMPUTE_GRAPH_TYPE_PRINTER_H__
25#define __ARM_COMPUTE_GRAPH_TYPE_PRINTER_H__
Georgios Pinitasd8734b52017-12-22 15:27:52 +000026
27#include "arm_compute/core/Error.h"
28#include "arm_compute/core/Types.h"
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010029#include "arm_compute/graph/Types.h"
Georgios Pinitasd8734b52017-12-22 15:27:52 +000030
31namespace arm_compute
32{
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010033namespace graph
Georgios Pinitasd8734b52017-12-22 15:27:52 +000034{
35/** Formatted output of the Dimensions type. */
36template <typename T>
37inline ::std::ostream &operator<<(::std::ostream &os, const arm_compute::Dimensions<T> &dimensions)
38{
39 if(dimensions.num_dimensions() > 0)
40 {
41 os << dimensions[0];
42
43 for(unsigned int d = 1; d < dimensions.num_dimensions(); ++d)
44 {
45 os << "x" << dimensions[d];
46 }
47 }
48
49 return os;
50}
51
52/** Formatted output of the Size2D type. */
53inline ::std::ostream &operator<<(::std::ostream &os, const Size2D &size)
54{
55 os << size.width << "x" << size.height;
56
57 return os;
58}
59
60/** Formatted output of the DataType type. */
61inline ::std::ostream &operator<<(::std::ostream &os, const DataType &data_type)
62{
63 switch(data_type)
64 {
65 case DataType::UNKNOWN:
66 os << "UNKNOWN";
67 break;
68 case DataType::U8:
69 os << "U8";
70 break;
71 case DataType::QS8:
72 os << "QS8";
73 break;
74 case DataType::QASYMM8:
75 os << "QASYMM8";
76 break;
77 case DataType::S8:
78 os << "S8";
79 break;
80 case DataType::U16:
81 os << "U16";
82 break;
83 case DataType::S16:
84 os << "S16";
85 break;
86 case DataType::QS16:
87 os << "QS16";
88 break;
89 case DataType::U32:
90 os << "U32";
91 break;
92 case DataType::S32:
93 os << "S32";
94 break;
95 case DataType::U64:
96 os << "U64";
97 break;
98 case DataType::S64:
99 os << "S64";
100 break;
101 case DataType::F16:
102 os << "F16";
103 break;
104 case DataType::F32:
105 os << "F32";
106 break;
107 case DataType::F64:
108 os << "F64";
109 break;
110 case DataType::SIZET:
111 os << "SIZET";
112 break;
113 default:
114 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
115 }
116
117 return os;
118}
119
120/** Formatted output of the Target. */
121inline ::std::ostream &operator<<(::std::ostream &os, const Target &target)
122{
123 switch(target)
124 {
125 case Target::UNSPECIFIED:
126 os << "UNSPECIFIED";
127 break;
128 case Target::NEON:
129 os << "NEON";
130 break;
131 case Target::CL:
132 os << "CL";
133 break;
134 default:
135 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
136 }
137
138 return os;
139}
140
Georgios Pinitascac13b12018-04-27 19:07:19 +0100141/** Formatted output of the DataLayout */
142inline ::std::ostream &operator<<(::std::ostream &os, const DataLayout &data_layout)
143{
144 switch(data_layout)
145 {
146 case DataLayout::NCHW:
147 os << "NCHW";
148 break;
149 case DataLayout::NHWC:
150 os << "NHWC";
151 break;
152 default:
153 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
154 }
155
156 return os;
157}
158
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000159/** Formatted output of the activation function type. */
160inline ::std::ostream &operator<<(::std::ostream &os, const ActivationLayerInfo::ActivationFunction &act_function)
161{
162 switch(act_function)
163 {
164 case ActivationLayerInfo::ActivationFunction::ABS:
165 os << "ABS";
166 break;
167 case ActivationLayerInfo::ActivationFunction::LINEAR:
168 os << "LINEAR";
169 break;
170 case ActivationLayerInfo::ActivationFunction::LOGISTIC:
171 os << "LOGISTIC";
172 break;
173 case ActivationLayerInfo::ActivationFunction::RELU:
174 os << "RELU";
175 break;
176 case ActivationLayerInfo::ActivationFunction::BOUNDED_RELU:
177 os << "BOUNDED_RELU";
178 break;
179 case ActivationLayerInfo::ActivationFunction::LEAKY_RELU:
180 os << "LEAKY_RELU";
181 break;
182 case ActivationLayerInfo::ActivationFunction::SOFT_RELU:
183 os << "SOFT_RELU";
184 break;
185 case ActivationLayerInfo::ActivationFunction::SQRT:
186 os << "SQRT";
187 break;
188 case ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU:
189 os << "LU_BOUNDED_RELU";
190 break;
191 case ActivationLayerInfo::ActivationFunction::SQUARE:
192 os << "SQUARE";
193 break;
194 case ActivationLayerInfo::ActivationFunction::TANH:
195 os << "TANH";
196 break;
197 default:
198 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
199 }
200
201 return os;
202}
203
204inline std::string to_string(const ActivationLayerInfo::ActivationFunction &act_function)
205{
206 std::stringstream str;
207 str << act_function;
208 return str.str();
209}
210
211/** Formatted output of the PoolingType type. */
212inline ::std::ostream &operator<<(::std::ostream &os, const PoolingType &pool_type)
213{
214 switch(pool_type)
215 {
216 case PoolingType::AVG:
217 os << "AVG";
218 break;
219 case PoolingType::MAX:
220 os << "MAX";
221 break;
222 case PoolingType::L2:
223 os << "L2";
224 break;
225 default:
226 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
227 }
228
229 return os;
230}
231
232/** Formatted output of the NormType type. */
233inline ::std::ostream &operator<<(::std::ostream &os, const NormType &norm_type)
234{
235 switch(norm_type)
236 {
237 case NormType::CROSS_MAP:
238 os << "CROSS_MAP";
239 break;
240 case NormType::IN_MAP_1D:
241 os << "IN_MAP_1D";
242 break;
243 case NormType::IN_MAP_2D:
244 os << "IN_MAP_2D";
245 break;
246 default:
247 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
248 }
249
250 return os;
251}
252
253/** Formatted output of the EltwiseOperation type. */
254inline ::std::ostream &operator<<(::std::ostream &os, const EltwiseOperation &eltwise_op)
255{
256 switch(eltwise_op)
257 {
258 case EltwiseOperation::ADD:
259 os << "ADD";
260 break;
261 case EltwiseOperation::MUL:
262 os << "MUL";
263 break;
264 case EltwiseOperation::SUB:
265 os << "SUB";
266 break;
267 default:
268 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
269 }
270
271 return os;
272}
273
274/** Formatted output of the ConvolutionMethod type. */
275inline ::std::ostream &operator<<(::std::ostream &os, const ConvolutionMethod &method)
276{
277 switch(method)
278 {
279 case ConvolutionMethod::DEFAULT:
280 os << "DEFAULT";
281 break;
282 case ConvolutionMethod::DIRECT:
283 os << "DIRECT";
284 break;
285 case ConvolutionMethod::GEMM:
286 os << "GEMM";
287 break;
288 case ConvolutionMethod::WINOGRAD:
289 os << "WINOGRAD";
290 break;
291 default:
292 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
293 }
294
295 return os;
296}
297
Giorgio Arena59631a12018-05-02 13:59:04 +0100298/** Formatted output of the FastMathHint type. */
299inline ::std::ostream &operator<<(::std::ostream &os, const FastMathHint &hint)
300{
301 switch(hint)
302 {
303 case FastMathHint::ENABLED:
304 os << "ENABLED";
305 break;
306 case FastMathHint::DISABLED:
307 os << "DISABLED";
308 break;
309 default:
310 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
311 }
312
313 return os;
314}
315
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000316/** Formatted output of the DepthwiseConvolutionMethod type. */
317inline ::std::ostream &operator<<(::std::ostream &os, const DepthwiseConvolutionMethod &method)
318{
319 switch(method)
320 {
321 case DepthwiseConvolutionMethod::DEFAULT:
322 os << "DEFAULT";
323 break;
324 case DepthwiseConvolutionMethod::GEMV:
325 os << "GEMV";
326 break;
327 case DepthwiseConvolutionMethod::OPTIMIZED_3x3:
328 os << "OPTIMIZED_3x3";
329 break;
330 default:
331 ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
332 }
333
334 return os;
335}
336
337/** Formatted output of the PadStrideInfo type. */
338inline ::std::ostream &operator<<(::std::ostream &os, const PadStrideInfo &pad_stride_info)
339{
340 os << pad_stride_info.stride().first << "," << pad_stride_info.stride().second;
341 os << ";";
342 os << pad_stride_info.pad_left() << "," << pad_stride_info.pad_right() << ","
343 << pad_stride_info.pad_top() << "," << pad_stride_info.pad_bottom();
344
345 return os;
346}
Giorgio Arenabb54e4e2018-04-05 17:20:34 +0100347
348/** Formatted output of the QuantizationInfo type. */
349inline ::std::ostream &operator<<(::std::ostream &os, const QuantizationInfo &quantization_info)
350{
351 os << "Scale:" << quantization_info.scale << "~"
352 << "Offset:" << quantization_info.offset;
353 return os;
354}
Georgios Pinitasd9eb2752018-04-03 13:44:29 +0100355} // namespace graph
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000356} // namespace arm_compute
Georgios Pinitasd9eb2752018-04-03 13:44:29 +0100357#endif /* __ARM_COMPUTE_GRAPH_TYPE_PRINTER_H__ */