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