blob: b90798e5ffc5b558852b082d49c94bfe9d56e794 [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001/*
2 * Copyright (c) 2016, 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_TYPES_H__
25#define __ARM_COMPUTE_TYPES_H__
26
27#include "arm_compute/core/Coordinates.h"
28#include "arm_compute/core/TensorShape.h"
29
30#include <cstddef>
31#include <cstdint>
32#include <string>
33#include <utility>
34
35namespace arm_compute
36{
37/** Image colour formats */
38enum class Format
39{
40 UNKNOWN, /** Unknown image format */
41 U8, /** 1 channel, 1 U8 per channel */
42 S16, /** 1 channel, 1 S16 per channel */
43 U16, /** 1 channel, 1 U16 per channel */
44 S32, /** 1 channel, 1 S32 per channel */
45 U32, /** 1 channel, 1 U32 per channel */
46 F16, /** 1 channel, 1 F16 per channel */
47 F32, /** 1 channel, 1 F32 per channel */
48 UV88, /** 2 channel, 1 U8 per channel */
49 RGB888, /** 3 channels, 1 U8 per channel */
50 RGBA8888, /** 4 channels, 1 U8 per channel */
51 YUV444, /** A 3 plane of 8 bit 4:4:4 sampled Y, U, V planes */
52 YUYV422, /** A single plane of 32-bit macro pixel of Y0, U0, Y1, V0 bytes */
53 NV12, /** A 2 plane YUV format of Luma (Y) and interleaved UV data at 4:2:0 sampling */
54 NV21, /** A 2 plane YUV format of Luma (Y) and interleaved VU data at 4:2:0 sampling */
55 IYUV, /** A 3 plane of 8-bit 4:2:0 sampled Y, U, V planes */
56 UYVY422 /** A single plane of 32-bit macro pixel of U0, Y0, V0, Y1 byte */
57};
58
59/** Available data types */
60enum class DataType
61{
62 UNKNOWN,
63 U8,
64 S8,
65 QS8,
66 U16,
67 S16,
68 QS16,
69 U32,
70 S32,
Pablo Tellof87cc7f2017-07-26 10:28:40 +010071 QS32,
Anthony Barbier6ff3b192017-09-04 18:44:23 +010072 U64,
73 S64,
74 F16,
75 F32,
76 F64,
77 SIZET
78};
79
80/** Constant value of the border pixels when using BorderMode::CONSTANT */
81constexpr uint8_t CONSTANT_BORDER_VALUE = 199;
82
83/* Constant value used to indicate a half-scale pyramid */
84constexpr float SCALE_PYRAMID_HALF = 0.5f;
85
86/* Constant value used to indicate a ORB scaled pyramid */
87constexpr float SCALE_PYRAMID_ORB = 8.408964152537146130583778358414e-01;
88
89struct ValidRegion
90{
91 ValidRegion()
92 : anchor{}, shape{}
93 {
94 }
95
96 ValidRegion(const ValidRegion &) = default;
97 ValidRegion(ValidRegion &&) = default;
98 ValidRegion &operator=(const ValidRegion &) = default;
99 ValidRegion &operator=(ValidRegion &&) = default;
100 ~ValidRegion() = default;
101
102 ValidRegion(Coordinates anchor, TensorShape shape)
103 : anchor{ anchor }, shape{ shape }
104 {
105 }
106
107 /** Return the start of the valid region for the given dimension @p d */
108 int start(unsigned int d) const
109 {
110 return anchor[d];
111 }
112
113 /** Return the end of the valid region for the given dimension @p d */
114 int end(unsigned int d) const
115 {
116 return anchor[d] + shape[d];
117 }
118
119 Coordinates anchor;
120 TensorShape shape;
121};
122
123/** Methods available to handle borders */
124enum class BorderMode
125{
126 UNDEFINED, /**< Borders are left undefined */
127 CONSTANT, /**< Pixels outside the image are assumed to have a constant value */
128 REPLICATE /**< Pixels outside the image are assumed to have the same value as the closest image pixel */
129};
130
131/** Container for 2D border size */
132struct BorderSize
133{
134 /** Empty border, i.e. no border */
135 constexpr BorderSize()
136 : top{ 0 }, right{ 0 }, bottom{ 0 }, left{ 0 }
137 {
138 }
139
140 /** Border with equal size around the 2D plane */
141 constexpr BorderSize(unsigned int size)
142 : top{ size }, right{ size }, bottom{ size }, left{ size }
143 {
144 }
145
146 /** Border with same size for top/bottom and left/right */
147 constexpr BorderSize(unsigned int top_bottom, unsigned int left_right)
148 : top{ top_bottom }, right{ left_right }, bottom{ top_bottom }, left{ left_right }
149 {
150 }
151
152 /** Border with different sizes */
153 constexpr BorderSize(unsigned int top, unsigned int right, unsigned int bottom, unsigned int left)
154 : top{ top }, right{ right }, bottom{ bottom }, left{ left }
155 {
156 }
157
158 /** Check if the entire border is zero */
159 constexpr bool empty() const
160 {
161 return top == 0 && right == 0 && bottom == 0 && left == 0;
162 }
163
164 /** Check if the border is the same size on all sides */
165 constexpr bool uniform() const
166 {
167 return top == right && top == bottom && top == left;
168 }
169
170 BorderSize &operator*=(float scale)
171 {
172 top *= scale;
173 right *= scale;
174 bottom *= scale;
175 left *= scale;
176
177 return *this;
178 }
179
180 BorderSize operator*(float scale)
181 {
182 BorderSize size = *this;
183 size *= scale;
184
185 return size;
186 }
187
188 void limit(const BorderSize &limit)
189 {
190 top = std::min(top, limit.top);
191 right = std::min(right, limit.right);
192 bottom = std::min(bottom, limit.bottom);
193 left = std::min(left, limit.left);
194 }
195
196 unsigned int top;
197 unsigned int right;
198 unsigned int bottom;
199 unsigned int left;
200};
201
202using PaddingSize = BorderSize;
203
204/** Policy to handle overflow */
205enum class ConvertPolicy
206{
207 WRAP, /**< Wrap around */
208 SATURATE /**< Saturate */
209};
210
211/** Interpolation method */
212enum class InterpolationPolicy
213{
214 NEAREST_NEIGHBOR, /**< Output values are defined to match the source pixel whose center is nearest to the sample position */
215 BILINEAR, /**< Output values are defined by bilinear interpolation between the pixels */
216 AREA, /**< Output values are determined by averaging the source pixels whose areas fall under the area of the destination pixel, projected onto the source image */
217};
218
219/** Bilinear Interpolation method used by LKTracker */
220enum class BilinearInterpolation
221{
222 BILINEAR_OLD_NEW,
223 BILINEAR_SCHARR
224};
225
226/** Threshold mode */
227enum class ThresholdType
228{
229 BINARY, /**< Threshold with one value */
230 RANGE /**< Threshold with two values*/
231};
232
233/** Rounding method */
234enum class RoundingPolicy
235{
236 TO_ZERO, /**< Truncates the least significand values that are lost in operations. */
237 TO_NEAREST_UP, /**< Rounds to nearest value; half rounds up */
238 TO_NEAREST_EVEN /**< Rounds to nearest value; half rounds to nearest even */
239};
240
241/** Termination criteria */
242enum class Termination
243{
244 TERM_CRITERIA_EPSILON,
245 TERM_CRITERIA_ITERATIONS,
246 TERM_CRITERIA_BOTH
247};
248
249/** Magnitude calculation type. */
250enum class MagnitudeType
251{
252 L1NORM, /**< L1 normalization type */
253 L2NORM /**< L2 normalization type */
254};
255
256/** Phase calculation type.
257 *
258 * @note When PhaseType == SIGNED, each angle is mapped to the range 0 to 255 inclusive otherwise angles between 0 and 180
259 */
260enum class PhaseType
261{
262 SIGNED, /**< Angle range: [0, 360] */
263 UNSIGNED /**< Angle range: [0, 180] */
264};
265
266/** Keypoint type */
267struct KeyPoint
268{
269 int32_t x{ 0 }; /**< X coordinates */
270 int32_t y{ 0 }; /**< Y coordinates */
271 float strength{ 0.f }; /**< Strength of the point */
272 float scale{ 0.f }; /**< Scale initialized to 0 by the corner detector */
273 float orientation{ 0.f }; /**< Orientation initialized to 0 by the corner detector */
274 int32_t tracking_status{ 0 }; /**< Status initialized to 1 by the corner detector, set to 0 when the point is lost */
275 float error{ 0.f }; /**< Tracking error initialized to 0 by the corner detector */
276};
277
278using InternalKeypoint = std::tuple<float, float, float>; /* x,y,strength */
279
280/** Rectangle type */
281struct Rectangle
282{
283 uint16_t x; /**< Top-left x coordinate */
284 uint16_t y; /**< Top-left y coordinate */
285 uint16_t width; /**< Width of the rectangle */
286 uint16_t height; /**< Height of the rectangle */
287};
288
289/** Coordinate type */
290struct Coordinates2D
291{
292 int32_t x; /**< X coordinates */
293 int32_t y; /**< Y coordinates */
294};
295
296/** Coordinate type */
297struct Coordinates3D
298{
299 uint32_t x; /**< X coordinates */
300 uint32_t y; /**< Y coordinates */
301 uint32_t z; /**< Z coordinates */
302};
303
Georgios Pinitas7b7858d2017-06-21 16:44:24 +0100304/** Region of interest */
305struct ROI
306{
307 Rectangle rect; /**< Rectangle specifying the region of interest */
308 uint16_t batch_idx; /**< The batch index of the region of interest */
309};
310
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100311/** Available channels */
312enum class Channel
313{
314 UNKNOWN, /** Unknown channel format */
315 C0, /**< First channel (used by formats with unknown channel types). */
316 C1, /**< Second channel (used by formats with unknown channel types). */
317 C2, /**< Third channel (used by formats with unknown channel types). */
318 C3, /**< Fourth channel (used by formats with unknown channel types). */
319 R, /**< Red channel. */
320 G, /**< Green channel. */
321 B, /**< Blue channel. */
322 A, /**< Alpha channel. */
323 Y, /**< Luma channel. */
324 U, /**< Cb/U channel. */
325 V /**< Cr/V/Value channel. */
326};
327
328/** Available matrix patterns */
329enum class MatrixPattern
330{
331 BOX, /**< Box pattern matrix. */
332 CROSS, /**< Cross pattern matrix. */
333 DISK, /**< Disk pattern matrix. */
334 OTHER /**< Any other matrix pattern. */
335};
336
337/** Available non linear functions. */
338enum class NonLinearFilterFunction : unsigned
339{
340 MEDIAN = 0, /**< Non linear median filter. */
341 MIN = 1, /**< Non linear erode. */
342 MAX = 2, /**< Non linear dilate. */
343};
344
Georgios Pinitasd9769582017-08-03 10:19:40 +0100345/** Available reduction operations */
346enum class ReductionOperation
347{
348 SUM_SQUARE, /**< Sum of squares */
Michalis Spyrou04f089c2017-08-08 17:42:38 +0100349 SUM, /**< Sum */
Georgios Pinitasd9769582017-08-03 10:19:40 +0100350};
351
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100352/** The normalization type used for the normalization layer */
353enum class NormType
354{
355 IN_MAP_1D, /**< Normalization applied within the same map in 1D region */
356 IN_MAP_2D, /**< Normalization applied within the same map in 2D region */
357 CROSS_MAP /**< Normalization applied cross maps */
358};
359
360/** Normalization type for Histogram of Oriented Gradients (HOG) */
361enum class HOGNormType
362{
363 L2_NORM = 1, /**< L2-norm */
364 L2HYS_NORM = 2, /**< L2-norm followed by clipping */
365 L1_NORM = 3 /**< L1 norm */
366};
367
368/** Detection window used for the object detection. The detection window keeps the following information:
369 *
370 * -# Geometry of the rectangular window (x/y of top-left corner and width/height)
371 * -# Index of the class used for evaluating which class the detection window belongs to
372 * -# Confidence value (score) obtained with the classifier
373 */
374struct DetectionWindow
375{
376 uint16_t x{ 0 }; /**< Top-left x coordinate */
377 uint16_t y{ 0 }; /**< Top-left y coordinate */
378 uint16_t width{ 0 }; /**< Width of the detection window */
379 uint16_t height{ 0 }; /**< Height of the detection window */
380 uint16_t idx_class{ 0 }; /**< Index of the class */
381 float score{ 0.f }; /**< Confidence value for the detection window */
382};
383
384/** Dimension rounding type when down-scaling on CNNs
385 * @note Used in pooling and convolution layer
386 */
387enum class DimensionRoundingType
388{
389 FLOOR, /**< Floor rounding */
390 CEIL /**< Ceil rounding */
391};
392
393/** Available pooling types */
394enum class PoolingType
395{
396 MAX, /**< Max Pooling */
397 AVG /**< Average Pooling */
398};
399
400/** Padding and stride information class */
401class PadStrideInfo
402{
403public:
404 /** Constructor
405 *
406 * @param[in] stride_x (Optional) Stride, in elements, across x. Defaults to 1.
407 * @param[in] stride_y (Optional) Stride, in elements, across y. Defaults to 1.
408 * @param[in] pad_x (Optional) Padding, in elements, across x. Defaults to 0.
409 * @param[in] pad_y (Optional) Padding, in elements, across y. Defaults to 0.
410 * @param[in] round (Optional) Dimensions rounding. Defaults to @ref FLOOR.
411 */
412 PadStrideInfo(unsigned int stride_x = 1, unsigned int stride_y = 1,
413 unsigned int pad_x = 0, unsigned int pad_y = 0,
414 DimensionRoundingType round = DimensionRoundingType::FLOOR)
415 : _stride(std::make_pair(stride_x, stride_y)),
416 _pad(std::make_pair(pad_x, pad_y)),
417 _round_type(round)
418 {
419 }
420 std::pair<unsigned int, unsigned int> stride() const
421 {
422 return _stride;
423 }
424 std::pair<unsigned int, unsigned int> pad() const
425 {
426 return _pad;
427 }
428 DimensionRoundingType round() const
429 {
430 return _round_type;
431 }
432
433private:
434 std::pair<unsigned int, unsigned int> _stride;
435 std::pair<unsigned int, unsigned int> _pad;
436 DimensionRoundingType _round_type;
437};
438
439/** Pooling Layer Information class */
440class PoolingLayerInfo
441{
442public:
443 /** Default Constructor
444 *
445 * @param[in] pool_type Pooling type @ref PoolingType. Defaults to @ref PoolingType::MAX
446 * @param[in] pool_size (Optional) Pooling size, in elements, across x and y. Defaults to 2.
447 * @param[in] pad_stride_info (Optional) Padding and stride information @ref PadStrideInfo
448 */
449 PoolingLayerInfo(PoolingType pool_type = PoolingType::MAX, unsigned int pool_size = 2, PadStrideInfo pad_stride_info = PadStrideInfo())
450 : _pool_type(pool_type), _pool_size(pool_size), _pad_stride_info(pad_stride_info)
451 {
452 }
453 PoolingType pool_type() const
454 {
455 return _pool_type;
456 }
457 unsigned int pool_size() const
458 {
459 return _pool_size;
460 }
461 PadStrideInfo pad_stride_info() const
462 {
463 return _pad_stride_info;
464 }
465
466private:
467 PoolingType _pool_type;
468 unsigned int _pool_size;
469 PadStrideInfo _pad_stride_info;
470};
471
Georgios Pinitas7b7858d2017-06-21 16:44:24 +0100472/** ROI Pooling Layer Information class */
473class ROIPoolingLayerInfo
474{
475public:
476 /** Default Constructor
477 *
478 * @param[in] pooled_width Pooled width of the layer.
479 * @param[in] pooled_height Pooled height of the layer.
480 * @param[in] spatial_scale Spatial scale to be applied to the ROI coordinates and dimensions.
481 */
482 ROIPoolingLayerInfo(unsigned int pooled_width, unsigned int pooled_height, float spatial_scale)
483 : _pooled_width(pooled_width), _pooled_height(pooled_height), _spatial_scale(spatial_scale)
484 {
485 }
486 unsigned int pooled_width() const
487 {
488 return _pooled_width;
489 }
490 unsigned int pooled_height() const
491 {
492 return _pooled_height;
493 }
494 float spatial_scale() const
495 {
496 return _spatial_scale;
497 }
498
499private:
500 unsigned int _pooled_width;
501 unsigned int _pooled_height;
502 float _spatial_scale;
503};
504
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100505/** Activation Layer Information class */
506class ActivationLayerInfo
507{
508public:
509 /** Available activation functions */
510 enum class ActivationFunction
511 {
Georgios Pinitas64ebe5b2017-09-01 17:44:24 +0100512 LOGISTIC, /**< Logistic ( \f$ f(x) = \frac{1}{1 + e^{-x}} \f$ ) */
513 TANH, /**< Hyperbolic tangent ( \f$ f(x) = a \cdot tanh(b \cdot x) \f$ ) */
514 RELU, /**< Rectifier ( \f$ f(x) = max(0,x) \f$ ) */
515 BOUNDED_RELU, /**< Upper Bounded Rectifier ( \f$ f(x) = min(a, max(0,x)) \f$ ) */
516 LU_BOUNDED_RELU, /**< Lower and Upper Bounded Rectifier ( \f$ f(x) = min(a, max(b,x)) \f$ ) */
517 LEAKY_RELU, /**< Leaky Rectifier ( \f$ f(x)= log(1+e^x) \f$ ) */
518 SOFT_RELU, /**< Soft Rectifier ( \f$ f(x)= log(1+e^x) \f$ ) */
519 ABS, /**< Absolute ( \f$ f(x)= |x| \f$ ) */
520 SQUARE, /**< Square ( \f$ f(x)= x^2 \f$ )*/
521 SQRT, /**< Square root ( \f$ f(x) = \sqrt{x} \f$ )*/
522 LINEAR /**< Linear ( \f$ f(x)= ax + b \f$ ) */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100523 };
524
525 /** Default Constructor
526 *
527 * @param[in] f The activation function to use.
528 * @param[in] a (Optional) The alpha parameter used by some activation functions
Georgios Pinitas64ebe5b2017-09-01 17:44:24 +0100529 * (@ref ActivationFunction::BOUNDED_RELU, @ref ActivationFunction::LU_BOUNDED_RELU, @ref ActivationFunction::LINEAR, @ref ActivationFunction::TANH).
530 * @param[in] b (Optional) The beta parameter used by some activation functions (@ref ActivationFunction::LINEAR, @ref ActivationFunction::LU_BOUNDED_RELU, @ref ActivationFunction::TANH).
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100531 */
532 ActivationLayerInfo(ActivationFunction f, float a = 0.0f, float b = 0.0f)
533 : _act(f), _a(a), _b(b)
534 {
535 }
536 ActivationFunction activation() const
537 {
538 return _act;
539 }
540 float a() const
541 {
542 return _a;
543 }
544 float b() const
545 {
546 return _b;
547 }
548
549private:
550 ActivationFunction _act;
551 float _a;
552 float _b;
553};
554
555/** Normalization Layer Information class */
556class NormalizationLayerInfo
557{
558public:
559 /** Default Constructor
560 *
561 * @param[in] type The normalization type. Can be @ref NormType::IN_MAP_1D, @ref NormType::IN_MAP_2D or @ref NORM_TYPE::CROSS_MAP
562 * @param[in] norm_size The normalization size is the number of elements to normalize across. Defaults to 5.
563 * @param[in] alpha Alpha parameter used by normalization equation. Defaults to 0.0001.
564 * @param[in] beta Beta parameter used by normalization equation. Defaults to 0.5.
565 * @param[in] kappa Kappa parameter used by [Krichevksy 2012] Across Channel Local Brightness Normalization equation.
566 */
567 NormalizationLayerInfo(NormType type, uint32_t norm_size = 5, float alpha = 0.0001f, float beta = 0.5f, float kappa = 1.f)
568 : _type(type), _norm_size(norm_size), _alpha(alpha), _beta(beta), _kappa(kappa)
569 {
570 }
571 NormType type() const
572 {
573 return _type;
574 }
575 uint32_t norm_size() const
576 {
577 return _norm_size;
578 }
579 float alpha() const
580 {
581 return _alpha;
582 }
583 float beta() const
584 {
585 return _beta;
586 }
587 float kappa() const
588 {
589 return _kappa;
590 }
591 /** Return the scaling factor of the normalization function. If kappa is not
592 * 1 then [Krichevksy 2012] normalization scaling is specified. Scaling
593 * factor takes into account the total number of elements used for the
594 * normalization, so in case of 2 dimensions this is _norm_size^2.
595 *
596 * @return The normalization scaling factor.
597 */
598 float scale_coeff() const
599 {
600 const uint32_t size = (_type == NormType::IN_MAP_2D) ? _norm_size * _norm_size : _norm_size;
601 return (_kappa == 1.f) ? (_alpha / size) : _alpha;
602 }
603
604private:
605 NormType _type;
606 uint32_t _norm_size;
607 float _alpha;
608 float _beta;
609 float _kappa;
610};
611
Gian Marco Iodice559d7712017-08-08 08:38:09 +0100612/** Convolution Layer Weights Information class. This class stores the necessary information to compute convolution layer when the weights are already reshaped */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100613class WeightsInfo
614{
615public:
Gian Marco Iodice4e288692017-06-27 11:41:59 +0100616 /** Default constructor */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100617 WeightsInfo()
Gian Marco Iodice559d7712017-08-08 08:38:09 +0100618 : _are_reshaped(false), _kernel_width(0), _kernel_height(0), _num_kernels(0)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100619 {
620 }
621 /** Constructor
622 *
Gian Marco Iodice4e288692017-06-27 11:41:59 +0100623 * @param[in] are_reshaped True if the weights have been reshaped
624 * @param[in] kernel_width Kernel width.
625 * @param[in] kernel_height Kernel height.
Gian Marco Iodice559d7712017-08-08 08:38:09 +0100626 * @param[in] num_kernels Number of convolution kernels.
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100627 */
Gian Marco Iodice559d7712017-08-08 08:38:09 +0100628 WeightsInfo(bool are_reshaped, unsigned int kernel_width, unsigned int kernel_height, unsigned int num_kernels)
629 : _are_reshaped(are_reshaped), _kernel_width(kernel_width), _kernel_height(kernel_height), _num_kernels(num_kernels)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100630 {
631 }
Gian Marco Iodice4e288692017-06-27 11:41:59 +0100632 /** Flag which specifies if the weights tensor has been reshaped.
633 *
634 * @return True if the weights tensors has been reshaped
635 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100636 bool are_reshaped() const
637 {
638 return _are_reshaped;
639 };
Gian Marco Iodice559d7712017-08-08 08:38:09 +0100640 /** Return the number of convolution kernels
641 *
642 * @return The number of convolution kernels
643 */
644 unsigned int num_kernels() const
645 {
646 return _num_kernels;
647 };
Gian Marco Iodice4e288692017-06-27 11:41:59 +0100648 /** Return the width and height of the kernel
649 *
650 * @return The width and height of the kernel
651 */
652 std::pair<unsigned int, unsigned int> kernel_size() const
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100653 {
Gian Marco Iodice4e288692017-06-27 11:41:59 +0100654 return std::make_pair(_kernel_width, _kernel_height);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100655 }
656
657private:
658 const bool _are_reshaped;
Gian Marco Iodice4e288692017-06-27 11:41:59 +0100659 const unsigned int _kernel_width;
660 const unsigned int _kernel_height;
Gian Marco Iodice559d7712017-08-08 08:38:09 +0100661 const unsigned int _num_kernels;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100662};
663
664/** IO formatting information class*/
665struct IOFormatInfo
666{
667 /** Precision type used when printing floating point numbers */
668 enum class PrecisionType
669 {
670 Default, /**< Default precision to the one that the current stream has */
671 Custom, /**< Custom precision specified by the user using the precision parameter */
672 Full /**< The maximum precision of the floating point representation */
673 };
674
675 /** Specifies the area to be printed, used by Tensor objects */
676 enum class PrintRegion
677 {
678 ValidRegion, /**< Prints the valid region of the Tensor object */
679 NoPadding, /**< Prints the Tensor object without the padding */
680 Full /**< Print the tensor object including padding */
681 };
682
683 IOFormatInfo(PrintRegion print_region = PrintRegion::ValidRegion,
684 PrecisionType precision_type = PrecisionType::Default,
685 unsigned int precision = 10,
686 bool align_columns = true,
687 std::string element_delim = " ",
688 std::string row_delim = "\n")
689 : print_region(print_region),
690 precision_type(precision_type),
691 precision(precision),
692 element_delim(element_delim),
693 row_delim(row_delim),
694 align_columns(align_columns)
695 {
696 }
697
698 PrintRegion print_region;
699 PrecisionType precision_type;
700 unsigned int precision;
701 std::string element_delim;
702 std::string row_delim;
703 bool align_columns;
704};
705}
706#endif /* __ARM_COMPUTE_TYPES_H__ */