blob: 24e91bd3c5bf0f242183acbf151fe30270de6ee4 [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001/*
Manuel Bottinicc5171b2019-01-09 17:04:39 +00002 * Copyright (c) 2016-2019 ARM Limited.
Anthony Barbier6ff3b192017-09-04 18:44:23 +01003 *
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"
Michel Iwaniec5dfeae62017-11-29 10:48:23 +000028#include "arm_compute/core/QAsymm8.h"
29#include "arm_compute/core/Rounding.h"
Isabella Gottardi6e464c32018-01-26 12:32:45 +000030#include "arm_compute/core/Size2D.h"
Georgios Pinitas8795ffb2017-12-01 16:13:40 +000031#include "arm_compute/core/Strides.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010032#include "arm_compute/core/TensorShape.h"
Georgios Pinitas583137c2017-08-31 18:12:42 +010033#include "support/Half.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010034
Michel Iwaniec5dfeae62017-11-29 10:48:23 +000035#include <cmath>
Anthony Barbier6ff3b192017-09-04 18:44:23 +010036#include <cstddef>
37#include <cstdint>
38#include <string>
39#include <utility>
40
41namespace arm_compute
42{
Georgios Pinitas583137c2017-08-31 18:12:42 +010043/** 16-bit floating point type */
44using half = half_float::half;
45
Georgios Pinitas8795ffb2017-12-01 16:13:40 +000046/** Permutation vector */
47using PermutationVector = Strides;
Georgios Pinitas77589b52018-08-21 14:41:35 +010048/** Bidirectional strides */
49using BiStrides = Coordinates;
Georgios Pinitas8795ffb2017-12-01 16:13:40 +000050
Anthony Barbier6ff3b192017-09-04 18:44:23 +010051/** Image colour formats */
52enum class Format
53{
Daniil Efremov02bf80d2017-11-22 00:26:51 +070054 UNKNOWN, /**< Unknown image format */
55 U8, /**< 1 channel, 1 U8 per channel */
56 S16, /**< 1 channel, 1 S16 per channel */
57 U16, /**< 1 channel, 1 U16 per channel */
58 S32, /**< 1 channel, 1 S32 per channel */
59 U32, /**< 1 channel, 1 U32 per channel */
60 F16, /**< 1 channel, 1 F16 per channel */
61 F32, /**< 1 channel, 1 F32 per channel */
62 UV88, /**< 2 channel, 1 U8 per channel */
63 RGB888, /**< 3 channels, 1 U8 per channel */
64 RGBA8888, /**< 4 channels, 1 U8 per channel */
65 YUV444, /**< A 3 plane of 8 bit 4:4:4 sampled Y, U, V planes */
66 YUYV422, /**< A single plane of 32-bit macro pixel of Y0, U0, Y1, V0 bytes */
67 NV12, /**< A 2 plane YUV format of Luma (Y) and interleaved UV data at 4:2:0 sampling */
68 NV21, /**< A 2 plane YUV format of Luma (Y) and interleaved VU data at 4:2:0 sampling */
69 IYUV, /**< A 3 plane of 8-bit 4:2:0 sampled Y, U, V planes */
70 UYVY422 /**< A single plane of 32-bit macro pixel of U0, Y0, V0, Y1 byte */
Anthony Barbier6ff3b192017-09-04 18:44:23 +010071};
72
73/** Available data types */
74enum class DataType
75{
Alex Gildayc357c472018-03-21 13:54:09 +000076 UNKNOWN, /**< Unknown data type */
77 U8, /**< unsigned 8-bit number */
78 S8, /**< signed 8-bit number */
Alex Gildayc357c472018-03-21 13:54:09 +000079 QASYMM8, /**< quantized, asymmetric fixed-point 8-bit number */
80 U16, /**< unsigned 16-bit number */
81 S16, /**< signed 16-bit number */
Alex Gildayc357c472018-03-21 13:54:09 +000082 U32, /**< unsigned 32-bit number */
83 S32, /**< signed 32-bit number */
Alex Gildayc357c472018-03-21 13:54:09 +000084 U64, /**< unsigned 64-bit number */
85 S64, /**< signed 64-bit number */
86 F16, /**< 16-bit floating-point number */
87 F32, /**< 32-bit floating-point number */
88 F64, /**< 64-bit floating-point number */
89 SIZET /**< size_t */
Anthony Barbier6ff3b192017-09-04 18:44:23 +010090};
91
Daniil Efremov02bf80d2017-11-22 00:26:51 +070092/** Available Sampling Policies */
93enum class SamplingPolicy
94{
95 CENTER, /**< Samples are taken at pixel center */
96 TOP_LEFT /**< Samples are taken at pixel top left corner */
97};
98
Anthony Barbier6ff3b192017-09-04 18:44:23 +010099/** Constant value of the border pixels when using BorderMode::CONSTANT */
100constexpr uint8_t CONSTANT_BORDER_VALUE = 199;
101
Alex Gildayc357c472018-03-21 13:54:09 +0000102/** Constant value used to indicate a half-scale pyramid */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100103constexpr float SCALE_PYRAMID_HALF = 0.5f;
104
Alex Gildayc357c472018-03-21 13:54:09 +0000105/** Constant value used to indicate a ORB scaled pyramid */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100106constexpr float SCALE_PYRAMID_ORB = 8.408964152537146130583778358414e-01;
107
Vidhya Sudhan Loganathand646ae12018-11-19 15:18:20 +0000108/** [DataLayout enum definition] **/
109
Georgios Pinitas4074c992018-01-30 18:13:46 +0000110/** Supported tensor data layouts */
111enum class DataLayout
112{
Alex Gildayc357c472018-03-21 13:54:09 +0000113 UNKNOWN, /**< Unknown data layout */
114 NCHW, /**< Num samples, channels, height, width */
115 NHWC /**< Num samples, height, width, channels */
Georgios Pinitas4074c992018-01-30 18:13:46 +0000116};
Vidhya Sudhan Loganathand646ae12018-11-19 15:18:20 +0000117/** [DataLayout enum definition] **/
Georgios Pinitas4074c992018-01-30 18:13:46 +0000118
Isabella Gottardid17a6772018-02-27 17:41:55 +0000119/** Supported tensor data layout dimensions */
120enum class DataLayoutDimension
121{
Alex Gildayc357c472018-03-21 13:54:09 +0000122 CHANNEL, /**< channel */
123 HEIGHT, /**< height */
124 WIDTH, /**< width */
125 BATCHES /**< batches */
Isabella Gottardid17a6772018-02-27 17:41:55 +0000126};
127
Georgios Pinitas7900a9e2018-11-23 11:44:58 +0000128/** Available ConvolutionMethod*/
129enum class ConvolutionMethod
130{
Vidhya Sudhan Loganathan8ec0bb62019-04-23 10:40:44 +0100131 GEMM, /**< Convolution using GEMM */
132 DIRECT, /**< Direct convolution */
133 WINOGRAD, /**< Convolution using Winograd */
134 FFT /**< Convolution using FFT */
Georgios Pinitas7900a9e2018-11-23 11:44:58 +0000135};
136
Usama Arif89890c62019-03-19 10:57:05 +0000137/** Padding mode to use for PadLayer */
138enum class PaddingMode
139{
140 CONSTANT,
141 REFLECT,
142 SYMMETRIC
143};
144
Georgios Pinitas7900a9e2018-11-23 11:44:58 +0000145/** Supported comparison operations */
146enum class ComparisonOperation
147{
148 Equal, /**< Equal comparison ( \f$ x == y \f$ ) */
149 NotEqual, /**< NotEqual comparison ( \f$ x != y \f$ ) */
150 Greater, /**< Greater comparison ( \f$ x > y \f$ ) */
151 GreaterEqual, /**< Greater equal comparison ( \f$ x >= y \f$ ) */
152 Less, /**< Less comparison ( \f$ x < y \f$ ) */
153 LessEqual /**< Less equal comparison ( \f$ x <= y \f$ ) */
154};
155
Michel Iwaniec00633802017-10-12 14:14:15 +0100156/** Quantization settings (used for QASYMM8 data type) */
157struct QuantizationInfo
158{
Alex Gildayc357c472018-03-21 13:54:09 +0000159 /** Default constructor */
Georgios Pinitasf8d8f3a2018-06-06 17:57:04 +0100160 QuantizationInfo() noexcept
161 : scale(0.0f),
162 offset(0)
Michel Iwaniec00633802017-10-12 14:14:15 +0100163 {
164 }
165
Alex Gildayc357c472018-03-21 13:54:09 +0000166 /** Construct quantization info.
167 *
168 * @param[in] scale Scale.
169 * @param[in] offset Offset.
170 */
Michel Iwaniec00633802017-10-12 14:14:15 +0100171 QuantizationInfo(float scale, int offset)
172 : scale(scale), offset(offset)
173 {
174 }
175
Alex Gildayc357c472018-03-21 13:54:09 +0000176 /** Check whether equal to a given quantization info.
177 *
178 * @param[in] other Other quantization info.
179 *
180 * @return True if the given quantization info is the same.
181 */
Georgios Pinitas08346e92018-10-16 19:10:46 +0100182 bool operator==(const QuantizationInfo &other) const
Daniil Efremoveed841c2017-11-09 19:05:25 +0700183 {
184 return scale == other.scale && offset == other.offset;
185 }
186
Alex Gildayc357c472018-03-21 13:54:09 +0000187 /** Check whether not equal to a given quantization info.
188 *
189 * @param[in] other Other quantization info.
190 *
191 * @return True if the given quantization info is not the same.
192 */
Georgios Pinitas08346e92018-10-16 19:10:46 +0100193 bool operator!=(const QuantizationInfo &other) const
Daniil Efremoveed841c2017-11-09 19:05:25 +0700194 {
195 return !(*this == other);
196 }
197
Michel Iwaniec00633802017-10-12 14:14:15 +0100198 float scale; /**< scale */
199 int offset; /**< offset */
200
Alex Gildayc357c472018-03-21 13:54:09 +0000201 /** Quantizes a value using the scale/offset in this QuantizationInfo
202 *
203 * @param[in] value Value to quantize.
204 * @param[in] rounding_policy Policy to use when rounding.
205 *
206 * @return the quantized value.
207 */
Michel Iwaniec5dfeae62017-11-29 10:48:23 +0000208 qasymm8_t quantize(float value, RoundingPolicy rounding_policy) const
Michel Iwaniec00633802017-10-12 14:14:15 +0100209 {
210 ARM_COMPUTE_ERROR_ON_MSG(scale == 0, "QuantizationInfo::quantize: scale == 0");
Michel Iwaniec5dfeae62017-11-29 10:48:23 +0000211 return sqcvt_qasymm8_f32(value, scale, offset, rounding_policy);
Michel Iwaniec00633802017-10-12 14:14:15 +0100212 }
213
Alex Gildayc357c472018-03-21 13:54:09 +0000214 /** Dequantizes a value using the scale/offset in this QuantizationInfo
215 *
216 * @param[in] value Value to dequantize.
217 *
218 * @return the original value before quantization.
219 */
Michel Iwaniec5dfeae62017-11-29 10:48:23 +0000220 float dequantize(qasymm8_t value) const
Michel Iwaniec00633802017-10-12 14:14:15 +0100221 {
222 ARM_COMPUTE_ERROR_ON_MSG(scale == 0, "QuantizationInfo::dequantize: scale == 0");
Michel Iwaniec5dfeae62017-11-29 10:48:23 +0000223 return scvt_f32_qasymm8(value, scale, offset);
Michel Iwaniec00633802017-10-12 14:14:15 +0100224 }
225
Alex Gildayc357c472018-03-21 13:54:09 +0000226 /** Indicates whether this QuantizationInfo has valid settings or not
227 *
228 * @return True if the this has invalid settings.
229 */
Michel Iwaniec00633802017-10-12 14:14:15 +0100230 bool empty() const
231 {
232 return scale == 0;
233 }
234};
235
Alex Gildayc357c472018-03-21 13:54:09 +0000236/** Container for valid region of a window */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100237struct ValidRegion
238{
Alex Gildayc357c472018-03-21 13:54:09 +0000239 /** Default constructor */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100240 ValidRegion()
241 : anchor{}, shape{}
242 {
243 }
244
Alex Gildayc357c472018-03-21 13:54:09 +0000245 /** Allow instances of this class to be copy constructed */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100246 ValidRegion(const ValidRegion &) = default;
Alex Gildayc357c472018-03-21 13:54:09 +0000247 /** Allow instances of this class to be move constructed */
248 ValidRegion(ValidRegion &&) = default;
249 /** Allow instances of this class to be copied */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100250 ValidRegion &operator=(const ValidRegion &) = default;
Alex Gildayc357c472018-03-21 13:54:09 +0000251 /** Allow instances of this class to be moved */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100252 ValidRegion &operator=(ValidRegion &&) = default;
Alex Gildayc357c472018-03-21 13:54:09 +0000253 /** Default destructor */
254 ~ValidRegion() = default;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100255
Alex Gildayc357c472018-03-21 13:54:09 +0000256 /** Constructor for a valid region with default number of dimensions
257 *
258 * @param[in] an_anchor Anchor for the start of the valid region.
259 * @param[in] a_shape Shape of the valid region.
260 *
261 */
Diego Lopez Recasbcbc9702017-12-18 11:28:27 +0000262 ValidRegion(const Coordinates &an_anchor, const TensorShape &a_shape)
263 : anchor{ an_anchor }, shape{ a_shape }
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100264 {
Diego Lopez Recasbcbc9702017-12-18 11:28:27 +0000265 anchor.set_num_dimensions(std::max(anchor.num_dimensions(), shape.num_dimensions()));
266 }
267
Alex Gildayc357c472018-03-21 13:54:09 +0000268 /** Constructor for a valid region with specified number of dimensions
269 *
270 * @param[in] an_anchor Anchor for the start of the valid region.
271 * @param[in] a_shape Shape of the valid region.
272 * @param[in] num_dimensions Number of dimensions (must be >= number of dimensions of anchor and shape).
273 *
274 */
Diego Lopez Recasbcbc9702017-12-18 11:28:27 +0000275 ValidRegion(const Coordinates &an_anchor, const TensorShape &a_shape, size_t num_dimensions)
276 : anchor{ an_anchor }, shape{ a_shape }
277 {
278 ARM_COMPUTE_ERROR_ON(num_dimensions < std::max(anchor.num_dimensions(), shape.num_dimensions()));
279 anchor.set_num_dimensions(num_dimensions);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100280 }
281
282 /** Return the start of the valid region for the given dimension @p d */
283 int start(unsigned int d) const
284 {
285 return anchor[d];
286 }
287
288 /** Return the end of the valid region for the given dimension @p d */
289 int end(unsigned int d) const
290 {
291 return anchor[d] + shape[d];
292 }
293
Diego Lopez Recas35ceeb22017-12-04 18:56:10 +0000294 /** Accessor to set the value of anchor and shape for one of the dimensions.
295 *
296 * @param[in] dimension Dimension for which the value is set.
297 * @param[in] start Value to be set in anchor for the dimension.
298 * @param[in] size Value to be set in shape for the dimension.
299 *
300 * @return *this.
301 */
302 ValidRegion &set(size_t dimension, int start, size_t size)
303 {
304 anchor.set(dimension, start);
305 shape.set(dimension, size);
306 return *this;
307 }
308
Alex Gildayc357c472018-03-21 13:54:09 +0000309 Coordinates anchor; /**< Anchor for the start of the valid region. */
310 TensorShape shape; /**< Shape of the valid region. */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100311};
312
313/** Methods available to handle borders */
314enum class BorderMode
315{
316 UNDEFINED, /**< Borders are left undefined */
317 CONSTANT, /**< Pixels outside the image are assumed to have a constant value */
318 REPLICATE /**< Pixels outside the image are assumed to have the same value as the closest image pixel */
319};
320
321/** Container for 2D border size */
322struct BorderSize
323{
324 /** Empty border, i.e. no border */
325 constexpr BorderSize()
326 : top{ 0 }, right{ 0 }, bottom{ 0 }, left{ 0 }
327 {
328 }
329
330 /** Border with equal size around the 2D plane */
Moritz Pflanzer7655a672017-09-23 11:57:33 +0100331 explicit constexpr BorderSize(unsigned int size)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100332 : top{ size }, right{ size }, bottom{ size }, left{ size }
333 {
334 }
335
336 /** Border with same size for top/bottom and left/right */
337 constexpr BorderSize(unsigned int top_bottom, unsigned int left_right)
338 : top{ top_bottom }, right{ left_right }, bottom{ top_bottom }, left{ left_right }
339 {
340 }
341
342 /** Border with different sizes */
343 constexpr BorderSize(unsigned int top, unsigned int right, unsigned int bottom, unsigned int left)
344 : top{ top }, right{ right }, bottom{ bottom }, left{ left }
345 {
346 }
347
348 /** Check if the entire border is zero */
349 constexpr bool empty() const
350 {
351 return top == 0 && right == 0 && bottom == 0 && left == 0;
352 }
353
354 /** Check if the border is the same size on all sides */
355 constexpr bool uniform() const
356 {
357 return top == right && top == bottom && top == left;
358 }
359
Alex Gildayc357c472018-03-21 13:54:09 +0000360 /** Scale this border size.
361 *
362 * @param[in] scale Scale to multiply border size by.
363 *
364 * @return *this.
365 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100366 BorderSize &operator*=(float scale)
367 {
368 top *= scale;
369 right *= scale;
370 bottom *= scale;
371 left *= scale;
372
373 return *this;
374 }
375
Alex Gildayc357c472018-03-21 13:54:09 +0000376 /** Scale a copy of this border size.
377 *
378 * @param[in] scale Scale to multiply border size by.
379 *
380 * @return a scaled copy of this.
381 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100382 BorderSize operator*(float scale)
383 {
384 BorderSize size = *this;
385 size *= scale;
386
387 return size;
388 }
389
Alex Gildayc357c472018-03-21 13:54:09 +0000390 /** Limit this border size.
391 *
392 * @param[in] limit Border size to limit this border size to.
393 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100394 void limit(const BorderSize &limit)
395 {
396 top = std::min(top, limit.top);
397 right = std::min(right, limit.right);
398 bottom = std::min(bottom, limit.bottom);
399 left = std::min(left, limit.left);
400 }
401
Alex Gildayc357c472018-03-21 13:54:09 +0000402 unsigned int top; /**< top of the border */
403 unsigned int right; /**< right of the border */
404 unsigned int bottom; /**< bottom of the border */
405 unsigned int left; /**< left of the border */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100406};
407
Alex Gildayc357c472018-03-21 13:54:09 +0000408/** Container for 2D padding size */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100409using PaddingSize = BorderSize;
410
411/** Policy to handle overflow */
412enum class ConvertPolicy
413{
414 WRAP, /**< Wrap around */
415 SATURATE /**< Saturate */
416};
417
418/** Interpolation method */
419enum class InterpolationPolicy
420{
421 NEAREST_NEIGHBOR, /**< Output values are defined to match the source pixel whose center is nearest to the sample position */
422 BILINEAR, /**< Output values are defined by bilinear interpolation between the pixels */
423 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 */
424};
425
426/** Bilinear Interpolation method used by LKTracker */
427enum class BilinearInterpolation
428{
Alex Gildayc357c472018-03-21 13:54:09 +0000429 BILINEAR_OLD_NEW, /**< Old-new method */
430 BILINEAR_SCHARR /**< Scharr method */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100431};
432
433/** Threshold mode */
434enum class ThresholdType
435{
436 BINARY, /**< Threshold with one value */
437 RANGE /**< Threshold with two values*/
438};
439
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100440/** Termination criteria */
441enum class Termination
442{
Alex Gildayc357c472018-03-21 13:54:09 +0000443 TERM_CRITERIA_EPSILON, /**< Terminate when within epsilon of a threshold */
444 TERM_CRITERIA_ITERATIONS, /**< Terminate after a maximum number of iterations */
445 TERM_CRITERIA_BOTH /**< Terminate on whichever of the other conditions occurs first */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100446};
447
448/** Magnitude calculation type. */
449enum class MagnitudeType
450{
451 L1NORM, /**< L1 normalization type */
452 L2NORM /**< L2 normalization type */
453};
454
455/** Phase calculation type.
456 *
457 * @note When PhaseType == SIGNED, each angle is mapped to the range 0 to 255 inclusive otherwise angles between 0 and 180
458 */
459enum class PhaseType
460{
461 SIGNED, /**< Angle range: [0, 360] */
462 UNSIGNED /**< Angle range: [0, 180] */
463};
464
465/** Keypoint type */
466struct KeyPoint
467{
468 int32_t x{ 0 }; /**< X coordinates */
469 int32_t y{ 0 }; /**< Y coordinates */
470 float strength{ 0.f }; /**< Strength of the point */
471 float scale{ 0.f }; /**< Scale initialized to 0 by the corner detector */
472 float orientation{ 0.f }; /**< Orientation initialized to 0 by the corner detector */
473 int32_t tracking_status{ 0 }; /**< Status initialized to 1 by the corner detector, set to 0 when the point is lost */
474 float error{ 0.f }; /**< Tracking error initialized to 0 by the corner detector */
475};
476
Alex Gildayc357c472018-03-21 13:54:09 +0000477/** Internal key point */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100478using InternalKeypoint = std::tuple<float, float, float>; /* x,y,strength */
479
480/** Rectangle type */
481struct Rectangle
482{
483 uint16_t x; /**< Top-left x coordinate */
484 uint16_t y; /**< Top-left y coordinate */
485 uint16_t width; /**< Width of the rectangle */
486 uint16_t height; /**< Height of the rectangle */
487};
488
489/** Coordinate type */
490struct Coordinates2D
491{
492 int32_t x; /**< X coordinates */
493 int32_t y; /**< Y coordinates */
494};
495
496/** Coordinate type */
497struct Coordinates3D
498{
499 uint32_t x; /**< X coordinates */
500 uint32_t y; /**< Y coordinates */
501 uint32_t z; /**< Z coordinates */
502};
503
Giuseppe Rossinid7647d42018-07-17 18:13:13 +0100504/** Padding information as a pair of unsigned int start/end */
505using PaddingInfo = std::pair<uint32_t, uint32_t>;
506
507/** List of padding information */
508using PaddingList = std::vector<PaddingInfo>;
509
giuros013175fcf2018-11-21 09:59:17 +0000510/** Information to produce a tiled version of a Tensor */
511using Multiples = std::vector<uint32_t>;
512
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100513/** Available channels */
514enum class Channel
515{
516 UNKNOWN, /** Unknown channel format */
517 C0, /**< First channel (used by formats with unknown channel types). */
518 C1, /**< Second channel (used by formats with unknown channel types). */
519 C2, /**< Third channel (used by formats with unknown channel types). */
520 C3, /**< Fourth channel (used by formats with unknown channel types). */
521 R, /**< Red channel. */
522 G, /**< Green channel. */
523 B, /**< Blue channel. */
524 A, /**< Alpha channel. */
525 Y, /**< Luma channel. */
526 U, /**< Cb/U channel. */
527 V /**< Cr/V/Value channel. */
528};
529
530/** Available matrix patterns */
531enum class MatrixPattern
532{
533 BOX, /**< Box pattern matrix. */
534 CROSS, /**< Cross pattern matrix. */
535 DISK, /**< Disk pattern matrix. */
536 OTHER /**< Any other matrix pattern. */
537};
538
539/** Available non linear functions. */
540enum class NonLinearFilterFunction : unsigned
541{
542 MEDIAN = 0, /**< Non linear median filter. */
543 MIN = 1, /**< Non linear erode. */
544 MAX = 2, /**< Non linear dilate. */
545};
546
Georgios Pinitasd9769582017-08-03 10:19:40 +0100547/** Available reduction operations */
548enum class ReductionOperation
549{
Michalis Spyrou7930db42018-11-22 17:36:28 +0000550 ARG_IDX_MAX, /**< Index of the max value */
Manuel Bottinib412fab2018-12-10 17:40:23 +0000551 ARG_IDX_MIN, /**< Index of the min value */
552 MEAN_SUM, /**< Mean of sum */
553 PROD, /**< Product */
554 SUM_SQUARE, /**< Sum of squares */
555 SUM /**< Sum */
Georgios Pinitasd9769582017-08-03 10:19:40 +0100556};
557
giuros01164a2722018-11-20 18:34:46 +0000558/** Available element-wise operations */
559enum class ArithmeticOperation
560{
561 ADD, /**< (x + y) */
562 SUB, /**< (x - y) */
563 DIV, /**< (x / y) */
564 MIN, /**< Min(x, y) */
565 MAX, /**< Max(x, y) */
566 SQUARED_DIFF, /**< (x - y)^2 */
567};
568
Michalis Spyroue9362622018-11-23 17:41:37 +0000569/** Available element wise unary operations */
570enum class ElementWiseUnary
571{
572 RSQRT, /**< Reverse square root */
573 EXP, /**< Exponential */
574};
575
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100576/** The normalization type used for the normalization layer */
577enum class NormType
578{
579 IN_MAP_1D, /**< Normalization applied within the same map in 1D region */
580 IN_MAP_2D, /**< Normalization applied within the same map in 2D region */
581 CROSS_MAP /**< Normalization applied cross maps */
582};
583
584/** Normalization type for Histogram of Oriented Gradients (HOG) */
585enum class HOGNormType
586{
587 L2_NORM = 1, /**< L2-norm */
588 L2HYS_NORM = 2, /**< L2-norm followed by clipping */
589 L1_NORM = 3 /**< L1 norm */
590};
591
592/** Detection window used for the object detection. The detection window keeps the following information:
593 *
594 * -# Geometry of the rectangular window (x/y of top-left corner and width/height)
595 * -# Index of the class used for evaluating which class the detection window belongs to
596 * -# Confidence value (score) obtained with the classifier
597 */
598struct DetectionWindow
599{
600 uint16_t x{ 0 }; /**< Top-left x coordinate */
601 uint16_t y{ 0 }; /**< Top-left y coordinate */
602 uint16_t width{ 0 }; /**< Width of the detection window */
603 uint16_t height{ 0 }; /**< Height of the detection window */
604 uint16_t idx_class{ 0 }; /**< Index of the class */
605 float score{ 0.f }; /**< Confidence value for the detection window */
606};
607
608/** Dimension rounding type when down-scaling on CNNs
609 * @note Used in pooling and convolution layer
610 */
611enum class DimensionRoundingType
612{
613 FLOOR, /**< Floor rounding */
614 CEIL /**< Ceil rounding */
615};
616
617/** Available pooling types */
618enum class PoolingType
619{
620 MAX, /**< Max Pooling */
Georgios Pinitascdf51452017-08-31 14:21:36 +0100621 AVG, /**< Average Pooling */
622 L2 /**< L2 Pooling */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100623};
624
Michalis Spyrou2709d612018-09-19 09:46:47 +0100625/** Available non maxima suppression types */
626enum class NMSType
627{
628 LINEAR, /**< Linear NMS */
629 GAUSSIAN, /**< Gaussian NMS */
630 ORIGINAL /**< Original NMS */
631};
632
633/** BoxWithNonMaximaSuppressionLimit Information class */
634class BoxNMSLimitInfo final
635{
636public:
637 /** Constructor
638 *
639 * @param[in] score_thresh (Optional) Score threshold.
640 * @param[in] nms (Optional) NMS value
641 * @param[in] detections (Optional) Number of detections
642 * @param[in] soft_nms_enabled (Optional) Enable SoftNMS
643 * @param[in] soft_nms_method (Optional) Soft NMS method
644 * @param[in] soft_nms_sigma (Optional) Soft NMS sigma value
645 * @param[in] soft_nms_min_score_thres (Optional) Soft NMS minimum score threshold
Manuel Bottini5209be52019-02-13 16:34:56 +0000646 * @param[in] suppress_size (Optional) Filter out boxes based on their size. Defaults to false
647 * @param[in] min_size (Optional) Smaller boxes than min_size will be filtered out. Defaults to 1
648 * @param[in] im_width (Optional) Boxes whose centers (on the x axis) is beyond im_width will be filtered. Defaults to 1
649 * @param[in] im_height (Optional) Boxes whose centers (on the y axis) is beyond im_height will be filtered. Defaults to 1
Michalis Spyrou2709d612018-09-19 09:46:47 +0100650 */
651 BoxNMSLimitInfo(float score_thresh = 0.05f, float nms = 0.3f,
652 int detections = 100, bool soft_nms_enabled = false,
653 NMSType soft_nms_method = NMSType::LINEAR,
Manuel Bottini5209be52019-02-13 16:34:56 +0000654 float soft_nms_sigma = 0.5f, float soft_nms_min_score_thres = 0.001f, bool suppress_size = false, float min_size = 1.0f, float im_width = 1.0f, float im_height = 1.0f)
Michalis Spyrou2709d612018-09-19 09:46:47 +0100655 : _score_thresh(score_thresh), _nms(nms), _detections_per_im(detections), _soft_nms_enabled(soft_nms_enabled), _soft_nms_method(soft_nms_method), _soft_nms_sigma(soft_nms_sigma),
Manuel Bottini5209be52019-02-13 16:34:56 +0000656 _soft_nms_min_score_thres(soft_nms_min_score_thres), _suppress_size(suppress_size), _min_size(min_size), _im_width(im_width), _im_height(im_height)
Michalis Spyrou2709d612018-09-19 09:46:47 +0100657 {
658 }
659 /** Get the score threshold */
660 float score_thresh() const
661 {
662 return _score_thresh;
663 }
664 /** Get the NMS */
665 float nms() const
666 {
667 return _nms;
668 }
669 /** Get the number of detections */
670 int detections_per_im() const
671 {
672 return _detections_per_im;
673 }
674 /** Check if soft NMS is enabled */
675 bool soft_nms_enabled() const
676 {
677 return _soft_nms_enabled;
678 }
679 /** Get soft NMS method */
680 NMSType soft_nms_method() const
681 {
682 return _soft_nms_method;
683 }
684 /** Get soft NMS sigma */
685 float soft_nms_sigma() const
686 {
687 return _soft_nms_sigma;
688 }
689 /** Get soft nms min score threshold */
690 float soft_nms_min_score_thres() const
691 {
692 return _soft_nms_min_score_thres;
693 }
Manuel Bottini5209be52019-02-13 16:34:56 +0000694 /** Get if NMS will suppress boxes based on their size/position */
695 bool suppress_size() const
696 {
697 return _suppress_size;
698 }
699 /** Get size suppression threshold */
700 float min_size() const
701 {
702 return _min_size;
703 }
704 /** Get image width (NMS may suppress boxes whose center sits beyond the image width) */
705 float im_width() const
706 {
707 return _im_width;
708 }
709 /** Get image height (NMS may suppress boxes whose center sits beyond the image height) */
710 float im_height() const
711 {
712 return _im_height;
713 }
Michalis Spyrou2709d612018-09-19 09:46:47 +0100714
715private:
716 float _score_thresh;
717 float _nms;
718 int _detections_per_im;
719 bool _soft_nms_enabled;
720 NMSType _soft_nms_method;
721 float _soft_nms_sigma;
722 float _soft_nms_min_score_thres;
Manuel Bottini5209be52019-02-13 16:34:56 +0000723 bool _suppress_size;
724 float _min_size;
725 float _im_width;
726 float _im_height;
Michalis Spyrou2709d612018-09-19 09:46:47 +0100727};
728
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100729/** Padding and stride information class */
730class PadStrideInfo
731{
732public:
733 /** Constructor
734 *
735 * @param[in] stride_x (Optional) Stride, in elements, across x. Defaults to 1.
736 * @param[in] stride_y (Optional) Stride, in elements, across y. Defaults to 1.
737 * @param[in] pad_x (Optional) Padding, in elements, across x. Defaults to 0.
738 * @param[in] pad_y (Optional) Padding, in elements, across y. Defaults to 0.
739 * @param[in] round (Optional) Dimensions rounding. Defaults to @ref FLOOR.
740 */
741 PadStrideInfo(unsigned int stride_x = 1, unsigned int stride_y = 1,
742 unsigned int pad_x = 0, unsigned int pad_y = 0,
743 DimensionRoundingType round = DimensionRoundingType::FLOOR)
744 : _stride(std::make_pair(stride_x, stride_y)),
Jaroslaw Rzepeckia1ed41f2017-10-13 11:13:58 +0100745 _pad_left(pad_x),
746 _pad_top(pad_y),
747 _pad_right(pad_x),
748 _pad_bottom(pad_y),
749 _round_type(round)
750 {
751 }
752 /** Constructor
753 *
754 * @param[in] stride_x Stride, in elements, across x.
755 * @param[in] stride_y Stride, in elements, across y.
756 * @param[in] pad_left Padding across x on the left, in elements.
757 * @param[in] pad_top Padding across y on the top, in elements.
758 * @param[in] pad_right Padding across x on the right, in elements.
759 * @param[in] pad_bottom Padding across y on the bottom, in elements.
760 * @param[in] round Dimensions rounding.
761 */
762 PadStrideInfo(unsigned int stride_x, unsigned int stride_y,
763 unsigned int pad_left, unsigned int pad_right,
764 unsigned int pad_top, unsigned int pad_bottom,
765 DimensionRoundingType round)
766 : _stride(std::make_pair(stride_x, stride_y)),
767 _pad_left(pad_left),
768 _pad_top(pad_top),
769 _pad_right(pad_right),
770 _pad_bottom(pad_bottom),
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100771 _round_type(round)
772 {
773 }
Alex Gildayc357c472018-03-21 13:54:09 +0000774 /** Get the stride.
775 *
776 * @return a pair: stride x, stride y.
777 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100778 std::pair<unsigned int, unsigned int> stride() const
779 {
780 return _stride;
781 }
Alex Gildayc357c472018-03-21 13:54:09 +0000782 /** Check whether the padding is symmetric.
783 *
784 * @return True if the padding is symmetric.
785 */
Anthony Barbier21f67d62018-02-16 15:17:48 +0000786 bool padding_is_symmetric() const
787 {
788 return (_pad_left == _pad_right) && (_pad_top == _pad_bottom);
789 }
Alex Gildayc357c472018-03-21 13:54:09 +0000790 /** Get the padding.
791 *
792 * @note This should only be used when the padding is symmetric.
793 *
794 * @return a pair: padding left/right, padding top/bottom
795 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100796 std::pair<unsigned int, unsigned int> pad() const
797 {
Jaroslaw Rzepeckia1ed41f2017-10-13 11:13:58 +0100798 //this accessor should be used only when padding is symmetric
Anthony Barbier21f67d62018-02-16 15:17:48 +0000799 ARM_COMPUTE_ERROR_ON(!padding_is_symmetric());
Jaroslaw Rzepeckia1ed41f2017-10-13 11:13:58 +0100800 return std::make_pair(_pad_left, _pad_top);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100801 }
Jaroslaw Rzepeckia1ed41f2017-10-13 11:13:58 +0100802
Alex Gildayc357c472018-03-21 13:54:09 +0000803 /** Get the left padding */
Jaroslaw Rzepeckia1ed41f2017-10-13 11:13:58 +0100804 unsigned int pad_left() const
805 {
806 return _pad_left;
807 }
Alex Gildayc357c472018-03-21 13:54:09 +0000808 /** Get the right padding */
Jaroslaw Rzepeckia1ed41f2017-10-13 11:13:58 +0100809 unsigned int pad_right() const
810 {
811 return _pad_right;
812 }
Alex Gildayc357c472018-03-21 13:54:09 +0000813 /** Get the top padding */
Jaroslaw Rzepeckia1ed41f2017-10-13 11:13:58 +0100814 unsigned int pad_top() const
815 {
816 return _pad_top;
817 }
Alex Gildayc357c472018-03-21 13:54:09 +0000818 /** Get the bottom padding */
Jaroslaw Rzepeckia1ed41f2017-10-13 11:13:58 +0100819 unsigned int pad_bottom() const
820 {
821 return _pad_bottom;
822 }
823
Alex Gildayc357c472018-03-21 13:54:09 +0000824 /** Get the rounding type */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100825 DimensionRoundingType round() const
826 {
827 return _round_type;
828 }
829
Alex Gildayc357c472018-03-21 13:54:09 +0000830 /** Check whether this has any padding */
Jaroslaw Rzepeckia1ed41f2017-10-13 11:13:58 +0100831 bool has_padding() const
832 {
833 return (_pad_left != 0 || _pad_top != 0 || _pad_right != 0 || _pad_bottom != 0);
834 }
835
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100836private:
837 std::pair<unsigned int, unsigned int> _stride;
Jaroslaw Rzepeckia1ed41f2017-10-13 11:13:58 +0100838 unsigned int _pad_left;
839 unsigned int _pad_top;
840 unsigned int _pad_right;
841 unsigned int _pad_bottom;
842
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100843 DimensionRoundingType _round_type;
844};
845
Georgios Pinitas7d66a8e2018-07-17 12:28:42 +0100846/** Fully connected layer info */
847struct FullyConnectedLayerInfo
848{
849 DataLayout weights_trained_layout{ DataLayout::NCHW }; /**< Layout that the weights have been trained with. */
850 bool transpose_weights{ true }; /**< Transpose weights if true. */
851 bool are_weights_reshaped{ false }; /**< Reshape the weights tensor if false. */
852 bool retain_internal_weights{ false }; /**< Retain internal reshaped weights. */
Georgios Pinitasc55cef12018-08-01 15:24:18 +0100853
854 /** Sets the weights trained data layout
855 *
856 * @param[in] layout Data layout that the weights were trained with
857 *
858 * @return Updated object
859 */
860 FullyConnectedLayerInfo &set_weights_trained_layout(DataLayout layout)
861 {
862 weights_trained_layout = layout;
863 return *this;
864 }
Georgios Pinitas195b0ba2018-08-02 17:18:51 +0100865 /** Sets the transpose weights flag
866 *
867 * @param[in] should_transpose_weights Boolean flag indicating if weights should be transposed
868 *
869 * @return Updated object
870 */
871 FullyConnectedLayerInfo &set_transpose_weights(bool should_transpose_weights)
872 {
873 transpose_weights = should_transpose_weights;
874 return *this;
875 }
Georgios Pinitas7d66a8e2018-07-17 12:28:42 +0100876};
877
Michalis Spyrou6c7c38e2018-08-29 16:28:11 +0100878/** PriorBox layer info */
879class PriorBoxLayerInfo final
880{
881public:
882 /** Default Constructor */
883 PriorBoxLayerInfo()
884 : _min_sizes(),
885 _variances(),
886 _offset(),
887 _flip(true),
888 _clip(false),
889 _max_sizes(),
890 _aspect_ratios(),
891 _img_size(),
892 _steps()
893 {
894 }
895 /** Constructor
896 *
897 * @param[in] min_sizes Min sizes vector.
Michalis Spyrou721c4cb2018-09-04 15:27:25 +0100898 * @param[in] variances Variances vector.
Michalis Spyrou6c7c38e2018-08-29 16:28:11 +0100899 * @param[in] offset Offset value.
900 * @param[in] flip (Optional) Flip the aspect ratios.
901 * @param[in] clip (Optional) Clip coordinates so that they're within [0,1].
902 * @param[in] max_sizes (Optional) Max sizes vector.
903 * @param[in] aspect_ratios (Optional) Aspect ratios of the boxes.
904 * @param[in] img_size (Optional) Image size.
905 * @param[in] steps (Optional) Step values.
906 */
907 PriorBoxLayerInfo(const std::vector<float> &min_sizes, const std::vector<float> &variances, float offset, bool flip = true, bool clip = false,
Pablo Tello32521432018-11-15 14:43:10 +0000908 const std::vector<float> &max_sizes = {}, const std::vector<float> &aspect_ratios = {},
909 const Coordinates2D &img_size = Coordinates2D{ 0, 0 }, const std::array<float, 2> &steps = { { 0.f, 0.f } })
Michalis Spyrou6c7c38e2018-08-29 16:28:11 +0100910 : _min_sizes(min_sizes),
911 _variances(variances),
912 _offset(offset),
913 _flip(flip),
914 _clip(clip),
915 _max_sizes(max_sizes),
Michalis Spyrou721c4cb2018-09-04 15:27:25 +0100916 _aspect_ratios(),
Michalis Spyrou6c7c38e2018-08-29 16:28:11 +0100917 _img_size(img_size),
918 _steps(steps)
919 {
920 _aspect_ratios.push_back(1.);
921 for(unsigned int i = 0; i < aspect_ratios.size(); ++i)
922 {
923 float ar = aspect_ratios[i];
924 bool already_exist = false;
925 for(auto ar_new : _aspect_ratios)
926 {
927 if(fabs(ar - ar_new) < 1e-6)
928 {
929 already_exist = true;
930 break;
931 }
932 }
933 if(!already_exist)
934 {
935 _aspect_ratios.push_back(ar);
936 if(flip)
937 {
938 _aspect_ratios.push_back(1.f / ar);
939 }
940 }
941 }
942 }
943 /** Get min sizes. */
944 std::vector<float> min_sizes() const
945 {
946 return _min_sizes;
947 }
948 /** Get min variances. */
949 std::vector<float> variances() const
950 {
951 return _variances;
952 }
953 /** Get the step coordinates */
954 std::array<float, 2> steps() const
955 {
956 return _steps;
957 }
958 /** Get the image size coordinates */
959 Coordinates2D img_size() const
960 {
961 return _img_size;
962 }
963 /** Get the offset */
964 float offset() const
965 {
966 return _offset;
967 }
968 /** Get the flip value */
969 bool flip() const
970 {
971 return _flip;
972 }
973 /** Get the clip value */
974 bool clip() const
975 {
976 return _clip;
977 }
978 /** Get max sizes. */
979 std::vector<float> max_sizes() const
980 {
981 return _max_sizes;
982 }
983 /** Get aspect ratios. */
984 std::vector<float> aspect_ratios() const
985 {
986 return _aspect_ratios;
987 }
988
989private:
990 std::vector<float> _min_sizes;
991 std::vector<float> _variances;
992 float _offset;
993 bool _flip;
994 bool _clip;
995 std::vector<float> _max_sizes;
996 std::vector<float> _aspect_ratios;
997 Coordinates2D _img_size;
998 std::array<float, 2> _steps;
999};
1000
Isabella Gottardi05e56442018-11-16 11:26:52 +00001001/** Available Detection Output code types */
1002enum class DetectionOutputLayerCodeType
1003{
1004 CORNER, /**< Use box corners */
1005 CENTER_SIZE, /**< Use box centers and size */
1006 CORNER_SIZE, /**< Use box centers and size */
1007 TF_CENTER /**< Use box centers and size but flip x and y co-ordinates */
1008};
1009
1010/** Detection Output layer info */
1011class DetectionOutputLayerInfo final
1012{
1013public:
1014 /** Default Constructor */
1015 DetectionOutputLayerInfo()
1016 : _num_classes(),
1017 _share_location(),
1018 _code_type(DetectionOutputLayerCodeType::CORNER),
1019 _keep_top_k(),
1020 _nms_threshold(),
1021 _top_k(),
1022 _background_label_id(),
1023 _confidence_threshold(),
1024 _variance_encoded_in_target(false),
1025 _eta(),
1026 _num_loc_classes()
1027 {
1028 _num_loc_classes = _share_location ? 1 : _num_classes;
1029 }
1030 /** Constructor
1031 *
1032 * @param[in] num_classes Number of classes to be predicted.
1033 * @param[in] share_location If true, bounding box are shared among different classes.
1034 * @param[in] code_type Type of coding method for bbox.
1035 * @param[in] keep_top_k Number of total bounding boxes to be kept per image after NMS step.
1036 * @param[in] nms_threshold Threshold to be used in NMS.
1037 * @param[in] top_k (Optional) Number of boxes per image with top confidence scores that are fed into the NMS algorithm. Default set to -1.
1038 * @param[in] background_label_id (Optional) Background label ID. If there is no background class, set it as -1.
1039 * @param[in] confidence_threshold (Optional) Only consider detections whose confidences are larger than a threshold. Default set to -FLT_MAX.
1040 * @param[in] variance_encoded_in_target (Optional) If true, variance is encoded in target. Otherwise we need to adjust the predicted offset accordingly.Default set to false.
1041 * @param[in] eta (Optional) Eta.
1042 */
1043 DetectionOutputLayerInfo(int num_classes, bool share_location, DetectionOutputLayerCodeType code_type, int keep_top_k, float nms_threshold, int top_k = -1, int background_label_id = -1,
1044 float confidence_threshold = std::numeric_limits<float>::lowest(), bool variance_encoded_in_target = false, float eta = 1)
1045 : _num_classes(num_classes),
1046 _share_location(share_location),
1047 _code_type(code_type),
1048 _keep_top_k(keep_top_k),
1049 _nms_threshold(nms_threshold),
1050 _top_k(top_k),
1051 _background_label_id(background_label_id),
1052 _confidence_threshold(confidence_threshold),
1053 _variance_encoded_in_target(variance_encoded_in_target),
1054 _eta(eta),
1055 _num_loc_classes()
1056 {
1057 _num_loc_classes = _share_location ? 1 : _num_classes;
1058 }
1059 /** Get num classes. */
1060 int num_classes() const
1061 {
1062 return _num_classes;
1063 }
1064 /** Get share location. */
1065 bool share_location() const
1066 {
1067 return _share_location;
1068 }
1069 /** Get detection output code type. */
1070 DetectionOutputLayerCodeType code_type() const
1071 {
1072 return _code_type;
1073 }
1074 /** Get if variance encoded in target. */
1075 bool variance_encoded_in_target() const
1076 {
1077 return _variance_encoded_in_target;
1078 }
1079 /** Get the number of total bounding boxes to be kept per image. */
1080 int keep_top_k() const
1081 {
1082 return _keep_top_k;
1083 }
1084 /** Get nms threshold. */
1085 float nms_threshold() const
1086 {
1087 return _nms_threshold;
1088 }
1089 /** Get eta. */
1090 float eta() const
1091 {
1092 return _eta;
1093 }
1094 /** Get background label ID. */
1095 int background_label_id() const
1096 {
1097 return _background_label_id;
1098 }
1099 /** Get confidence threshold. */
1100 float confidence_threshold() const
1101 {
1102 return _confidence_threshold;
1103 }
1104 /** Get top K. */
1105 int top_k() const
1106 {
1107 return _top_k;
1108 }
1109 /** Get number of location classes. */
1110 int num_loc_classes() const
1111 {
1112 return _num_loc_classes;
1113 }
1114
1115private:
1116 int _num_classes;
1117 bool _share_location;
1118 DetectionOutputLayerCodeType _code_type;
1119 int _keep_top_k;
1120 float _nms_threshold;
1121 int _top_k;
1122 int _background_label_id;
1123 float _confidence_threshold;
1124 bool _variance_encoded_in_target;
1125 float _eta;
1126 int _num_loc_classes;
1127};
1128
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001129/** Pooling Layer Information class */
1130class PoolingLayerInfo
1131{
1132public:
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001133 /** Default Constructor */
1134 PoolingLayerInfo()
Isabella Gottardi6e464c32018-01-26 12:32:45 +00001135 : _pool_type(PoolingType::MAX), _pool_size(Size2D()), _pad_stride_info(PadStrideInfo()), _exclude_padding(false), _is_global_pooling(false)
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001136 {
1137 }
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001138 /** Default Constructor
1139 *
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001140 * @param[in] pool_type Pooling type @ref PoolingType.
1141 * @param[in] pool_size Pooling size, in elements, across x and y.
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001142 * @param[in] pad_stride_info (Optional) Padding and stride information @ref PadStrideInfo
Georgios Pinitasadaae7e2017-10-30 15:56:32 +00001143 * @param[in] exclude_padding (Optional) Strategy when accounting padding in calculations.
1144 * True will exclude padding while false will not (Used in AVG/L2 pooling to determine the pooling area).
1145 * Defaults to false;
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001146 */
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001147 explicit PoolingLayerInfo(PoolingType pool_type,
1148 unsigned int pool_size,
1149 PadStrideInfo pad_stride_info = PadStrideInfo(),
1150 bool exclude_padding = false)
Isabella Gottardi6e464c32018-01-26 12:32:45 +00001151 : _pool_type(pool_type), _pool_size(Size2D(pool_size, pool_size)), _pad_stride_info(pad_stride_info), _exclude_padding(exclude_padding), _is_global_pooling(false)
1152 {
1153 }
1154 /** Default Constructor
1155 *
1156 * @param[in] pool_type Pooling type @ref PoolingType.
1157 * @param[in] pool_size Pooling size, in elements, across x and y.
1158 * @param[in] pad_stride_info (Optional) Padding and stride information @ref PadStrideInfo
1159 * @param[in] exclude_padding (Optional) Strategy when accounting padding in calculations.
1160 * True will exclude padding while false will not (Used in AVG/L2 pooling to determine the pooling area).
1161 * Defaults to false;
1162 */
1163 explicit PoolingLayerInfo(PoolingType pool_type,
1164 Size2D pool_size,
1165 PadStrideInfo pad_stride_info = PadStrideInfo(),
1166 bool exclude_padding = false)
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001167 : _pool_type(pool_type), _pool_size(pool_size), _pad_stride_info(pad_stride_info), _exclude_padding(exclude_padding), _is_global_pooling(false)
1168 {
1169 }
1170 /** Default Constructor
1171 *
1172 * @note This constructor is used for global pooling
1173 *
1174 * @param[in] pool_type Pooling type @ref PoolingType.
1175 */
1176 explicit PoolingLayerInfo(PoolingType pool_type)
Isabella Gottardi6e464c32018-01-26 12:32:45 +00001177 : _pool_type(pool_type), _pool_size(Size2D()), _pad_stride_info(PadStrideInfo(1, 1, 0, 0)), _exclude_padding(false), _is_global_pooling(true)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001178 {
1179 }
Alex Gildayc357c472018-03-21 13:54:09 +00001180 /** Get the pooling type */
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001181 PoolingType pool_type() const
1182 {
1183 return _pool_type;
1184 }
Alex Gildayc357c472018-03-21 13:54:09 +00001185 /** Get the pooling size */
Isabella Gottardi6e464c32018-01-26 12:32:45 +00001186 const Size2D &pool_size() const
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001187 {
1188 return _pool_size;
1189 }
Alex Gildayc357c472018-03-21 13:54:09 +00001190 /** Get the padding and stride */
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001191 PadStrideInfo pad_stride_info() const
1192 {
1193 return _pad_stride_info;
1194 }
Alex Gildayc357c472018-03-21 13:54:09 +00001195 /** Check if padding is excluded in calculations */
Georgios Pinitasadaae7e2017-10-30 15:56:32 +00001196 bool exclude_padding() const
1197 {
1198 return _exclude_padding;
1199 }
Alex Gildayc357c472018-03-21 13:54:09 +00001200 /** Check if is global pooling */
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001201 bool is_global_pooling() const
1202 {
1203 return _is_global_pooling;
1204 }
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001205
1206private:
1207 PoolingType _pool_type;
Isabella Gottardi6e464c32018-01-26 12:32:45 +00001208 Size2D _pool_size;
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001209 PadStrideInfo _pad_stride_info;
Georgios Pinitasadaae7e2017-10-30 15:56:32 +00001210 bool _exclude_padding;
Georgios Pinitas4c2dd542017-11-13 12:58:41 +00001211 bool _is_global_pooling;
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001212};
1213
Georgios Pinitas7b7858d2017-06-21 16:44:24 +01001214/** ROI Pooling Layer Information class */
giuros0118870812018-09-13 09:31:40 +01001215class ROIPoolingLayerInfo final
Georgios Pinitas7b7858d2017-06-21 16:44:24 +01001216{
1217public:
giuros0118870812018-09-13 09:31:40 +01001218 /** Constructor
Georgios Pinitas7b7858d2017-06-21 16:44:24 +01001219 *
giuros0118870812018-09-13 09:31:40 +01001220 * @param[in] pooled_width Pooled width of the layer.
1221 * @param[in] pooled_height Pooled height of the layer.
1222 * @param[in] spatial_scale Spatial scale to be applied to the ROI coordinates and dimensions.
1223 * @param[in] sampling_ratio Number of samples to include in each pooling region (if set to zero, a ceil(roi_dims/pooling_dims))
Georgios Pinitas7b7858d2017-06-21 16:44:24 +01001224 */
giuros0118870812018-09-13 09:31:40 +01001225 ROIPoolingLayerInfo(unsigned int pooled_width, unsigned int pooled_height, float spatial_scale, unsigned int sampling_ratio = 0)
1226 : _pooled_width(pooled_width), _pooled_height(pooled_height), _spatial_scale(spatial_scale), _sampling_ratio(sampling_ratio)
Georgios Pinitas7b7858d2017-06-21 16:44:24 +01001227 {
1228 }
Alex Gildayc357c472018-03-21 13:54:09 +00001229 /** Get the pooled width of the layer */
Georgios Pinitas7b7858d2017-06-21 16:44:24 +01001230 unsigned int pooled_width() const
1231 {
1232 return _pooled_width;
1233 }
Alex Gildayc357c472018-03-21 13:54:09 +00001234 /** Get the pooled height of the layer */
Georgios Pinitas7b7858d2017-06-21 16:44:24 +01001235 unsigned int pooled_height() const
1236 {
1237 return _pooled_height;
1238 }
Alex Gildayc357c472018-03-21 13:54:09 +00001239 /** Get the spatial scale */
Georgios Pinitas7b7858d2017-06-21 16:44:24 +01001240 float spatial_scale() const
1241 {
1242 return _spatial_scale;
1243 }
giuros0118870812018-09-13 09:31:40 +01001244 /** Get sampling ratio */
1245 unsigned int sampling_ratio() const
1246 {
1247 return _sampling_ratio;
1248 }
Georgios Pinitas7b7858d2017-06-21 16:44:24 +01001249
1250private:
1251 unsigned int _pooled_width;
1252 unsigned int _pooled_height;
1253 float _spatial_scale;
giuros0118870812018-09-13 09:31:40 +01001254 unsigned int _sampling_ratio;
Georgios Pinitas7b7858d2017-06-21 16:44:24 +01001255};
1256
Manuel Bottini5209be52019-02-13 16:34:56 +00001257/** Generate Proposals Information class */
1258class GenerateProposalsInfo
1259{
1260public:
1261 /** Constructor
1262 *
1263 * @param[in] im_width Width of the original image
1264 * @param[in] im_height Height of the original image
1265 * @param[in] im_scale Scale applied to the original image
1266 * @param[in] spatial_scale (Optional)Scale applied to the feature map. Defaults to 1.0
1267 * @param[in] pre_nms_topN (Optional)Number of the best scores to be selected from the transformations. Defaults to 6000.
1268 * @param[in] post_nms_topN (Optional)Number of the best scores to be selected from the NMS operation. Defaults to 300.
1269 * @param[in] nms_thres (Optional)NMS overlap threshold. Defaults to 0.7.
1270 * @param[in] min_size (Optional)Size used to validate the anchors produced. Defaults to 16.
1271 * @param[in] values_per_roi (Optional)Values used to represent a ROI(Region of interest). Defaults to 4.
1272 */
1273 GenerateProposalsInfo(float im_width, float im_height, float im_scale, float spatial_scale = 1.0, int pre_nms_topN = 6000, int post_nms_topN = 300, float nms_thres = 0.7, float min_size = 16.0,
1274 size_t values_per_roi = 4)
1275 : _im_height(im_height), _im_width(im_width), _im_scale(im_scale), _spatial_scale(spatial_scale), _pre_nms_topN(pre_nms_topN), _post_nms_topN(post_nms_topN), _nms_thres(nms_thres),
1276 _min_size(min_size), _values_per_roi(values_per_roi)
1277 {
1278 }
1279
1280 /* Get the original height */
1281 float im_height() const
1282 {
1283 return _im_height;
1284 }
1285 /* Get the original width */
1286 float im_width() const
1287 {
1288 return _im_width;
1289 }
1290 /* Get the image scale */
1291 float im_scale() const
1292 {
1293 return _im_scale;
1294 }
1295 /* Get the value of how many best scores to select (before NMS) */
1296 int pre_nms_topN() const
1297 {
1298 return _pre_nms_topN;
1299 }
1300 /* Get the value of how many best scores to select (after NMS) */
1301 int post_nms_topN() const
1302 {
1303 return _post_nms_topN;
1304 }
1305 /* Get the NMS overlap threshold */
1306 float nms_thres() const
1307 {
1308 return _nms_thres;
1309 }
1310 /* Get the minimal size */
1311 float min_size() const
1312 {
1313 return _min_size;
1314 }
1315 /* Get the spatial scale to be applied to the feature maps */
1316 float spatial_scale() const
1317 {
1318 return _spatial_scale;
1319 }
1320 /* Get the values used to represent a ROI(Region of interest)*/
1321 size_t values_per_roi() const
1322 {
1323 return _values_per_roi;
1324 }
1325
1326private:
1327 float _im_height;
1328 float _im_width;
1329 float _im_scale;
1330 float _spatial_scale;
1331 int _pre_nms_topN;
1332 int _post_nms_topN;
1333 float _nms_thres;
1334 float _min_size;
1335 size_t _values_per_roi;
1336};
1337
1338/** ComputeAnchors information class */
1339class ComputeAnchorsInfo
1340{
1341public:
1342 /** Constructor
1343 *
1344 * @param[in] feat_width Feature map width
1345 * @param[in] feat_height Feature map height
1346 * @param[in] spatial_scale Feature map scale
1347 * @param[in] values_per_roi (Optional)Values used to represent a ROI(Region Of Interest). Defaults to 4
1348 */
1349 ComputeAnchorsInfo(float feat_width, float feat_height, float spatial_scale, size_t values_per_roi = 4)
1350 : _feat_height(feat_height),
1351 _feat_width(feat_width),
1352 _spatial_scale(spatial_scale),
1353 _values_per_roi(values_per_roi)
1354 {
1355 }
1356
1357 /* Get the height of the feature map */
1358 float feat_height() const
1359 {
1360 return _feat_height;
1361 }
1362
1363 /* Get the width of the feature map */
1364 float feat_width() const
1365 {
1366 return _feat_width;
1367 }
1368
1369 /* Get the scale of the feature map */
1370 float spatial_scale() const
1371 {
1372 return _spatial_scale;
1373 }
1374
1375 /* Get the values used to represent a ROI(Region Of Interest)*/
1376 size_t values_per_roi() const
1377 {
1378 return _values_per_roi;
1379 }
1380
1381private:
1382 float _feat_height;
1383 float _feat_width;
1384 float _spatial_scale;
1385 size_t _values_per_roi;
1386};
1387
giuros01c04a0e82018-10-03 12:44:35 +01001388/** Bounding Box Transform information class */
giuros01d696cb62018-11-16 10:39:59 +00001389class BoundingBoxTransformInfo final
giuros01c04a0e82018-10-03 12:44:35 +01001390{
1391public:
1392 /** Constructor
1393 *
giuros01d696cb62018-11-16 10:39:59 +00001394 * @param[in] img_width Width of the original image
1395 * @param[in] img_height Height, of the original image
1396 * @param[in] scale Scale of the original image
1397 * @param[in] apply_scale (Optional)Re-apply scaling after transforming the boxes. Defaults to false
1398 * @param[in] weights (Optional)Weights [wx, wy, ww, wh] for the deltas. Defaults to all ones
1399 * @param[in] correct_transform_coords (Optional)Correct bounding box transform coordinates. Defaults to false
1400 * @param[in] bbox_xform_clip (Optional)Minimum bounding box width and height after bounding box transformation in log-space. Defaults to log(1000/16)
giuros01c04a0e82018-10-03 12:44:35 +01001401 */
giuros01d696cb62018-11-16 10:39:59 +00001402 BoundingBoxTransformInfo(float img_width, float img_height, float scale, bool apply_scale = false, const std::array<float, 4> weights = { { 1.f, 1.f, 1.f, 1.f } }, bool correct_transform_coords =
1403 false,
1404 float bbox_xform_clip =
1405 4.135166556742356f)
1406 : _img_width(img_width), _img_height(img_height), _scale(scale), _apply_scale(apply_scale), _correct_transform_coords(correct_transform_coords), _weights(weights), _bbox_xform_clip(bbox_xform_clip)
giuros01c04a0e82018-10-03 12:44:35 +01001407 {
1408 }
1409
1410 std::array<float, 4> weights() const
1411 {
1412 return _weights;
1413 }
1414
1415 float bbox_xform_clip() const
1416 {
1417 return _bbox_xform_clip;
1418 }
1419
1420 float img_height() const
1421 {
1422 return _img_height;
1423 }
1424
1425 float img_width() const
1426 {
1427 return _img_width;
1428 }
1429
1430 float scale() const
1431 {
1432 return _scale;
1433 }
1434
1435 bool apply_scale() const
1436 {
1437 return _apply_scale;
1438 }
1439
giuros01d696cb62018-11-16 10:39:59 +00001440 bool correct_transform_coords() const
1441 {
1442 return _correct_transform_coords;
1443 }
1444
giuros01c04a0e82018-10-03 12:44:35 +01001445private:
1446 float _img_width;
1447 float _img_height;
1448 float _scale;
1449 bool _apply_scale;
giuros01d696cb62018-11-16 10:39:59 +00001450 bool _correct_transform_coords;
giuros01c04a0e82018-10-03 12:44:35 +01001451 std::array<float, 4> _weights;
1452 float _bbox_xform_clip;
1453};
1454
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001455/** Activation Layer Information class */
1456class ActivationLayerInfo
1457{
1458public:
1459 /** Available activation functions */
1460 enum class ActivationFunction
1461 {
Georgios Pinitas64ebe5b2017-09-01 17:44:24 +01001462 LOGISTIC, /**< Logistic ( \f$ f(x) = \frac{1}{1 + e^{-x}} \f$ ) */
1463 TANH, /**< Hyperbolic tangent ( \f$ f(x) = a \cdot tanh(b \cdot x) \f$ ) */
1464 RELU, /**< Rectifier ( \f$ f(x) = max(0,x) \f$ ) */
1465 BOUNDED_RELU, /**< Upper Bounded Rectifier ( \f$ f(x) = min(a, max(0,x)) \f$ ) */
1466 LU_BOUNDED_RELU, /**< Lower and Upper Bounded Rectifier ( \f$ f(x) = min(a, max(b,x)) \f$ ) */
Manuel Bottini581c8982019-02-07 10:31:57 +00001467 LEAKY_RELU, /**< Leaky Rectifier ( \f$ f(x) = \begin{cases} \alpha x & \quad \text{if } x \text{ < 0}\\ x & \quad \text{if } x \geq \text{ 0 } \end{cases} \f$ ) */
Georgios Pinitas64ebe5b2017-09-01 17:44:24 +01001468 SOFT_RELU, /**< Soft Rectifier ( \f$ f(x)= log(1+e^x) \f$ ) */
1469 ABS, /**< Absolute ( \f$ f(x)= |x| \f$ ) */
1470 SQUARE, /**< Square ( \f$ f(x)= x^2 \f$ )*/
1471 SQRT, /**< Square root ( \f$ f(x) = \sqrt{x} \f$ )*/
1472 LINEAR /**< Linear ( \f$ f(x)= ax + b \f$ ) */
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001473 };
1474
Giorgio Arena11674872018-02-07 15:38:12 +00001475 ActivationLayerInfo() = default;
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001476 /** Default Constructor
1477 *
1478 * @param[in] f The activation function to use.
1479 * @param[in] a (Optional) The alpha parameter used by some activation functions
Georgios Pinitas64ebe5b2017-09-01 17:44:24 +01001480 * (@ref ActivationFunction::BOUNDED_RELU, @ref ActivationFunction::LU_BOUNDED_RELU, @ref ActivationFunction::LINEAR, @ref ActivationFunction::TANH).
1481 * @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 +01001482 */
1483 ActivationLayerInfo(ActivationFunction f, float a = 0.0f, float b = 0.0f)
Giorgio Arena11674872018-02-07 15:38:12 +00001484 : _act(f), _a(a), _b(b), _enabled(true)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001485 {
1486 }
Alex Gildayc357c472018-03-21 13:54:09 +00001487 /** Get the type of activation function */
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001488 ActivationFunction activation() const
1489 {
1490 return _act;
1491 }
Alex Gildayc357c472018-03-21 13:54:09 +00001492 /** Get the alpha value */
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001493 float a() const
1494 {
1495 return _a;
1496 }
Alex Gildayc357c472018-03-21 13:54:09 +00001497 /** Get the beta value */
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001498 float b() const
1499 {
1500 return _b;
1501 }
Alex Gildayc357c472018-03-21 13:54:09 +00001502 /** Check if initialised */
Giorgio Arena11674872018-02-07 15:38:12 +00001503 bool enabled() const
1504 {
1505 return _enabled;
1506 }
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001507
1508private:
Giorgio Arena11674872018-02-07 15:38:12 +00001509 ActivationFunction _act = { ActivationLayerInfo::ActivationFunction::LOGISTIC };
1510 float _a = {};
1511 float _b = {};
1512 bool _enabled = { false };
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001513};
1514
1515/** Normalization Layer Information class */
1516class NormalizationLayerInfo
1517{
1518public:
1519 /** Default Constructor
1520 *
Michele Di Giorgio9d3a8312018-11-20 12:31:24 +00001521 * @param[in] type The normalization type. Can be @ref NormType::IN_MAP_1D, @ref NormType::IN_MAP_2D or @ref NormType::CROSS_MAP
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001522 * @param[in] norm_size The normalization size is the number of elements to normalize across. Defaults to 5.
Georgios Pinitas41caa622017-11-16 14:37:08 +00001523 * @param[in] alpha (Optional) Alpha parameter used by normalization equation. Defaults to 0.0001.
1524 * @param[in] beta (Optional) Beta parameter used by normalization equation. Defaults to 0.5.
1525 * @param[in] kappa (Optional) Kappa parameter used by [Krichevksy 2012] Across Channel Local Brightness Normalization equation.
1526 * @param[in] is_scaled (Optional) Boolean that specifies if alpha will be scaled by the normalization size or not.
1527 * Should be false to follow [Krichevksy 2012].
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001528 */
Georgios Pinitas41caa622017-11-16 14:37:08 +00001529 NormalizationLayerInfo(NormType type, uint32_t norm_size = 5, float alpha = 0.0001f, float beta = 0.5f, float kappa = 1.f, bool is_scaled = true)
1530 : _type(type), _norm_size(norm_size), _alpha(alpha), _beta(beta), _kappa(kappa), _is_scaled(is_scaled)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001531 {
1532 }
Alex Gildayc357c472018-03-21 13:54:09 +00001533 /** Get the normalization type */
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001534 NormType type() const
1535 {
1536 return _type;
1537 }
Alex Gildayc357c472018-03-21 13:54:09 +00001538 /** Get the normalization size */
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001539 uint32_t norm_size() const
1540 {
1541 return _norm_size;
1542 }
Alex Gildayc357c472018-03-21 13:54:09 +00001543 /** Get the alpha value */
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001544 float alpha() const
1545 {
1546 return _alpha;
1547 }
Alex Gildayc357c472018-03-21 13:54:09 +00001548 /** Get the beta value */
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001549 float beta() const
1550 {
1551 return _beta;
1552 }
Alex Gildayc357c472018-03-21 13:54:09 +00001553 /** Get the kappa value */
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001554 float kappa() const
1555 {
1556 return _kappa;
1557 }
Michele Di Giorgio9d3a8312018-11-20 12:31:24 +00001558 /** Get the is_scaled value */
1559 bool is_scaled() const
1560 {
1561 return _is_scaled;
1562 }
Alex Gildayc357c472018-03-21 13:54:09 +00001563 /** Check if normalization is cross map */
Georgios Pinitas41caa622017-11-16 14:37:08 +00001564 bool is_cross_map() const
1565 {
1566 return _type == NormType::CROSS_MAP;
1567 }
Alex Gildayc357c472018-03-21 13:54:09 +00001568 /** Check if normalization is not cross map */
Georgios Pinitas41caa622017-11-16 14:37:08 +00001569 bool is_in_map() const
1570 {
1571 return !is_cross_map();
1572 }
1573 /** Return the scaling factor of the normalization function.
1574 *
1575 * If is_scaled is set to false then [Krichevksy 2012] normalization scaling is performed,
1576 * where alpha is returned plainly, else alpha is scaled by the total number of elements used for the normalization.
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001577 *
1578 * @return The normalization scaling factor.
1579 */
1580 float scale_coeff() const
1581 {
1582 const uint32_t size = (_type == NormType::IN_MAP_2D) ? _norm_size * _norm_size : _norm_size;
Georgios Pinitas41caa622017-11-16 14:37:08 +00001583 return (_is_scaled) ? (_alpha / size) : _alpha;
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001584 }
1585
1586private:
1587 NormType _type;
1588 uint32_t _norm_size;
1589 float _alpha;
1590 float _beta;
1591 float _kappa;
Georgios Pinitas41caa622017-11-16 14:37:08 +00001592 bool _is_scaled;
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001593};
1594
Gian Marco Iodice559d7712017-08-08 08:38:09 +01001595/** 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 +01001596class WeightsInfo
1597{
1598public:
Gian Marco Iodice4e288692017-06-27 11:41:59 +01001599 /** Default constructor */
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001600 WeightsInfo()
Michele Di Giorgiob62280a2018-05-31 17:31:05 +01001601 : _are_reshaped(false), _kernel_width(0), _kernel_height(0), _num_kernels(0), _retain_internal_weights(false)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001602 {
1603 }
1604 /** Constructor
1605 *
Michele Di Giorgiob62280a2018-05-31 17:31:05 +01001606 * @param[in] are_reshaped True if the weights have been reshaped
1607 * @param[in] kernel_width Kernel width.
1608 * @param[in] kernel_height Kernel height.
1609 * @param[in] num_kernels Number of convolution kernels.
1610 * @param[in] retain_internal_weights (Optional) True if internal reshaped weights must be retained. Used for reconfiguration purposes. Default is false.
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001611 */
Michele Di Giorgiob62280a2018-05-31 17:31:05 +01001612 WeightsInfo(bool are_reshaped, unsigned int kernel_width, unsigned int kernel_height, unsigned int num_kernels, bool retain_internal_weights = false)
1613 : _are_reshaped(are_reshaped), _kernel_width(kernel_width), _kernel_height(kernel_height), _num_kernels(num_kernels), _retain_internal_weights(retain_internal_weights)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001614 {
1615 }
Gian Marco Iodice4e288692017-06-27 11:41:59 +01001616 /** Flag which specifies if the weights tensor has been reshaped.
1617 *
1618 * @return True if the weights tensors has been reshaped
1619 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001620 bool are_reshaped() const
1621 {
1622 return _are_reshaped;
1623 };
Gian Marco Iodice559d7712017-08-08 08:38:09 +01001624 /** Return the number of convolution kernels
1625 *
1626 * @return The number of convolution kernels
1627 */
1628 unsigned int num_kernels() const
1629 {
1630 return _num_kernels;
1631 };
Gian Marco Iodice4e288692017-06-27 11:41:59 +01001632 /** Return the width and height of the kernel
1633 *
1634 * @return The width and height of the kernel
1635 */
1636 std::pair<unsigned int, unsigned int> kernel_size() const
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001637 {
Gian Marco Iodice4e288692017-06-27 11:41:59 +01001638 return std::make_pair(_kernel_width, _kernel_height);
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001639 }
Michele Di Giorgiob62280a2018-05-31 17:31:05 +01001640 bool retain_internal_weights() const
1641 {
1642 return _retain_internal_weights;
1643 }
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001644
1645private:
1646 const bool _are_reshaped;
Gian Marco Iodice4e288692017-06-27 11:41:59 +01001647 const unsigned int _kernel_width;
1648 const unsigned int _kernel_height;
Gian Marco Iodice559d7712017-08-08 08:38:09 +01001649 const unsigned int _num_kernels;
Michele Di Giorgiob62280a2018-05-31 17:31:05 +01001650 const bool _retain_internal_weights;
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001651};
1652
Gian Marco36a0a462018-01-12 10:21:40 +00001653/** GEMM reshape information class. This class stores the necessary information about matrix A and matrix B reshape.
1654 *
1655 * The matrix A can only be reshaped through @ref CLGEMMInterleave4x4Kernel or @ref NEGEMMInterleave4x4Kernel or @ref GCGEMMInterleave4x4Kernel
1656 * Note: Optionally just for @ref CLGEMMInterleave4x4Kernel is it possible to set mult_interleave4x4_height, the multiplication factor for the height of the 4x4 interleaved block
1657 *
giuros018b6b4a92018-12-18 19:01:33 +00001658 * The matrix B can only be reshaped through @ref CLGEMMReshapeRHSMatrixKernel or @ref NEGEMMTranspose1xWKernel or @ref GCGEMMTranspose1xWKernel
1659 * Note: Optionally just for @ref CLGEMMReshapeRHSMatrixKernel is it possible to set mult_transpose1xW_width, the multiplication factor for the width of the 1xW transposed block
Gian Marco36a0a462018-01-12 10:21:40 +00001660 *
1661 */
1662class GEMMReshapeInfo final
1663{
1664public:
1665 /** Default constructor */
1666 GEMMReshapeInfo()
Gian Marco Iodice3139f032018-11-05 14:26:32 +00001667 : _m(1), _n(1), _k(1), _mult_transpose1xW_width(1), _mult_interleave4x4_height(1), _depth_output_gemm3d(0), _reinterpret_input_as_3d(false)
Gian Marco36a0a462018-01-12 10:21:40 +00001668 {
1669 }
1670 /** Constructor
1671 *
1672 * @param[in] m Number of matrix A rows
1673 * @param[in] n Number of matrix B columns
1674 * @param[in] k Number of matrix A columns or matrix B rows
1675 * @param[in] mult_transpose1xW_width (Optional) Multiplication factor for the width of the 1xW transposed block
1676 * @param[in] mult_interleave4x4_height (Optional) Multiplication factor for the height of the 4x4 interleaved block
Gian Marco Iodice3139f032018-11-05 14:26:32 +00001677 * @param[in] depth_output_gemm3d (Optional) Depth (third dimension) of the output tensor to be used with the GEMM3D kernel.
1678 * If 0 the output will not be reinterpreted as 3D. Default 0
Gian Marco Iodice68a3f562018-07-26 11:44:03 +01001679 * @param[in] reinterpret_input_as_3d (Optional) Reinterpret the input as 3D tensor. (i.e. this flag should be set to true when GEMM is used
1680 * to perform 1x1 convolutions with the NHWC data layout)
Gian Marco36a0a462018-01-12 10:21:40 +00001681 */
Gian Marco Iodice3139f032018-11-05 14:26:32 +00001682 GEMMReshapeInfo(int m, int n, int k, int mult_transpose1xW_width = 1, int mult_interleave4x4_height = 1, int depth_output_gemm3d = 0, bool reinterpret_input_as_3d = false)
Gian Marco Iodice68a3f562018-07-26 11:44:03 +01001683 : _m(m), _n(n), _k(k), _mult_transpose1xW_width(mult_transpose1xW_width), _mult_interleave4x4_height(mult_interleave4x4_height), _depth_output_gemm3d(depth_output_gemm3d),
1684 _reinterpret_input_as_3d(reinterpret_input_as_3d)
Gian Marco36a0a462018-01-12 10:21:40 +00001685 {
1686 }
1687 /** Number of matrix A rows
1688 *
1689 * @return the number of matrix A rows
1690 */
1691 int m() const
1692 {
1693 return _m;
1694 }
1695 /** Number of matrix B columns
1696 *
1697 * @return the number of matrix B columns
1698 */
1699 int n() const
1700 {
1701 return _n;
1702 }
1703 /** Number of matrix A columns or matrix B rows
1704 *
1705 * @return the number of matrix A columns or matrix B rows
1706 */
1707 int k() const
1708 {
1709 return _k;
1710 }
1711 /** Multiplication factor for the width of the 1xW transposed block
1712 *
1713 * @return the multiplication factor for the width of the 1xW transposed block
1714 */
1715 int mult_transpose1xW_width() const
1716 {
1717 return _mult_transpose1xW_width;
1718 }
1719 /** Multiplication factor for the height of the 4x4 interleaved block
1720 *
1721 * @return the multiplication factor for the height of the 4x4 interleaved block
1722 */
1723 int mult_interleave4x4_height() const
1724 {
1725 return _mult_interleave4x4_height;
1726 }
Isabella Gottardi8e74f442018-03-01 16:42:00 +00001727 /** Depth (third dimension) of the output tensor to be used with the GEMM3D kernel
1728 *
1729 * @note GEMM3D kernel is used when the output has to be reinterpret as 3D tensor. In that case:
1730 * m = depth_output_gemm3d * output_height
1731 *
1732 * @return the depth of the output tensor to be used with the GEMM3D kernel
1733 */
1734 int depth_output_gemm3d() const
1735 {
1736 return _depth_output_gemm3d;
1737 }
Gian Marco Iodice68a3f562018-07-26 11:44:03 +01001738 /** Flag which specifies if the input tensor has to be reinterpreted as 3D
1739 *
1740 * @return True if the input tensor has to be reinterpreted as 3D tensor
1741 */
1742 bool reinterpret_input_as_3d() const
1743 {
1744 return _reinterpret_input_as_3d;
1745 };
Gian Marco36a0a462018-01-12 10:21:40 +00001746
1747private:
Gian Marco Iodice68a3f562018-07-26 11:44:03 +01001748 const int _m;
1749 const int _n;
1750 const int _k;
1751 const int _mult_transpose1xW_width;
1752 const int _mult_interleave4x4_height;
1753 const int _depth_output_gemm3d;
1754 const bool _reinterpret_input_as_3d;
Gian Marco36a0a462018-01-12 10:21:40 +00001755};
1756
giuros016d109962019-01-07 17:47:19 +00001757struct DepthwiseConvolutionReshapeInfo
1758{
1759 unsigned int c0{ 1 }; /**< Number of channels processed by the depth-wise convolution */
1760 bool transpose{ false }; /**< True if the block MxC0 (where M is the area of the filter i.e. KwxKh) has to be transposed */
1761};
1762
Gian Marco Iodice4b908652018-10-18 10:21:02 +01001763/** GEMMLowp output stage type */
1764enum class GEMMLowpOutputStageType
1765{
1766 NONE, /**< No quantization to uint8 */
1767 QUANTIZE_DOWN, /**< Quantize to uint8 using an integer multiplication */
1768 QUANTIZE_DOWN_FIXEDPOINT, /**< Quantize to uint8 using a fixed point multiplication */
1769 QUANTIZE_DOWN_FLOAT /**< Quantize to uint8 using a floating point multiplication */
1770};
1771
1772/** GEMMLowp output stage info */
1773struct GEMMLowpOutputStageInfo
1774{
1775 GEMMLowpOutputStageType type{ GEMMLowpOutputStageType::NONE }; /**< GEMMLowp output stage type */
1776 int gemmlowp_offset{ 0 }; /**< GEMMLowp output stage offset used for quantizing to QASYMM8 */
1777 int gemmlowp_multiplier{ 0 }; /**< GEMMLowp output stage multiplier used for quantizing to QASYMM8 */
1778 int gemmlowp_shift{ 0 }; /**< GEMMLowp output stage shift used for quantizing to uint8 */
1779 int gemmlowp_min_bound{ 0 }; /**< GEMMLowp min value used to saturate down the output result before converting back to QASYMM8 */
1780 int gemmlowp_max_bound{ 0 }; /**< GEMMLowp max value used to saturate down the output result before converting back to QASYMM8 */
1781};
1782
Gian Marco Iodice5ba5e092018-12-06 17:13:09 +00001783/** GEMM LHS (Left Hand Side) matrix information */
1784struct GEMMLHSMatrixInfo
1785{
1786 unsigned int m0{ 1 }; /**< Number of rows processed by the matrix multiplication */
1787 unsigned int k0{ 1 }; /**< Number of partial accumulations performed by the matrix multiplication */
1788 unsigned int v0{ 1 }; /**< Number of vertical blocks of size (m0xk0) stored on the same output row */
1789 bool transpose{ true }; /**< True if the (m0xk0) block has to be transposed before been stored */
1790 bool interleave{ true }; /**< True if the v0 (m0xk0) blocks have to be interleaved in the output row */
1791};
1792
Gian Marco Iodice3b0a2652018-12-07 11:18:09 +00001793/** GEMM RHS (Right Hand Side) matrix information */
1794struct GEMMRHSMatrixInfo
1795{
1796 unsigned int n0{ 1 }; /**< Number of columns processed by the matrix multiplication */
1797 unsigned int k0{ 1 }; /**< Number of partial accumulations performed by the matrix multiplication */
1798 unsigned int h0{ 1 }; /**< Number of horizontal blocks of size (k0xn0) stored on the same output row */
1799 bool transpose{ true }; /**< True if the (k0xn0) block has to be transposed before been stored */
1800 bool interleave{ true }; /**< True if the h0 (k0xn0) blocks have to be interleaved in the output row */
1801};
1802
Gian Marco36a0a462018-01-12 10:21:40 +00001803/** GEMM information class. This class stores the necessary information to compute GEMM functions
1804 *
1805 * This object also contains the information about how matrix A and matrix B have been reshaped
1806 *
1807 */
Chunosov5124be52017-11-22 20:42:13 +07001808class GEMMInfo
1809{
1810public:
1811 /** Default constructor */
1812 GEMMInfo()
Anthony Barbier08a45172018-11-30 17:20:26 +00001813 : _is_a_reshaped(false), _is_b_reshaped(false), _reshape_b_only_on_first_run(true), _depth_output_gemm3d(0), _reinterpret_input_as_3d(false), _retain_internal_weights(false), _gemmlowp_output_stage(),
1814 _fp_mixed_precision(false)
Chunosov5124be52017-11-22 20:42:13 +07001815 {
1816 }
1817 /** Constructor
1818 *
1819 * @param[in] is_a_reshaped True if the matrix A has been reshaped
1820 * @param[in] is_b_reshaped True if the matrix B has been reshaped
1821 * @param[in] reshape_b_only_on_first_run Reshape matrix B only for the first run
Isabella Gottardi8e74f442018-03-01 16:42:00 +00001822 * @param[in] depth_output_gemm3d (Optional) Depth (third dimension) of the output tensor to be used with the GEMM3D kernel
Gian Marco Iodice3139f032018-11-05 14:26:32 +00001823 * If 0 the output will not be reinterpreted as 3D. Default 0
Gian Marco Iodice68a3f562018-07-26 11:44:03 +01001824 * @param[in] reinterpret_input_as_3d (Optional) Reinterpret the input as 3D tensor. (i.e. this flag should be set to true when GEMM is used
1825 * to perform 1x1 convolutions with the NHWC data layout)
Michele Di Giorgioba1ffe92018-08-22 14:28:30 +01001826 * @param[in] retain_internal_weights (Optional) Retain the weights tensor from previous run
Gian Marco Iodice4b908652018-10-18 10:21:02 +01001827 * @param[in] gemmlowp_output_stage (Optional) GEMMLowp Output stage info
Vidhya Sudhan Loganathana25d16c2018-11-16 11:33:12 +00001828 * @param[in] fp_mixed_precision (Optional) Use wider accumulators (32 bit instead of 16 for FP16) to improve accuracy.
Isabella Gottardi8e74f442018-03-01 16:42:00 +00001829 *
Chunosov5124be52017-11-22 20:42:13 +07001830 */
Gian Marco Iodice3139f032018-11-05 14:26:32 +00001831 GEMMInfo(bool is_a_reshaped, bool is_b_reshaped, bool reshape_b_only_on_first_run, int depth_output_gemm3d = 0, bool reinterpret_input_as_3d = false, bool retain_internal_weights = false,
Vidhya Sudhan Loganathana25d16c2018-11-16 11:33:12 +00001832 GEMMLowpOutputStageInfo gemmlowp_output_stage = GEMMLowpOutputStageInfo(), bool fp_mixed_precision = false)
Gian Marco Iodice68a3f562018-07-26 11:44:03 +01001833 : _is_a_reshaped(is_a_reshaped), _is_b_reshaped(is_b_reshaped), _reshape_b_only_on_first_run(reshape_b_only_on_first_run), _depth_output_gemm3d(depth_output_gemm3d),
Vidhya Sudhan Loganathana25d16c2018-11-16 11:33:12 +00001834 _reinterpret_input_as_3d(reinterpret_input_as_3d), _retain_internal_weights(retain_internal_weights), _gemmlowp_output_stage(gemmlowp_output_stage), _fp_mixed_precision(fp_mixed_precision)
Chunosov5124be52017-11-22 20:42:13 +07001835 {
1836 }
1837 /** Flag which specifies if the matrix A has been reshaped
1838 *
1839 * @return True if the matrix A has been reshaped
1840 */
1841 bool is_a_reshaped() const
1842 {
1843 return _is_a_reshaped;
1844 };
1845 /** Flag which specifies if the matrix B has been reshaped
1846 *
1847 * @return True if the matrix B has been reshaped
1848 */
1849 bool is_b_reshaped() const
1850 {
1851 return _is_b_reshaped;
1852 };
1853 /** Flag which specifies if the reshape of matrix B should executed only for the first
1854 *
1855 * @note This flag could be set to TRUE when GEMM is used to accelerate convolution layer
1856 *
1857 * @return True if the reshaped of matrix B happens only for the first run
1858 */
1859 bool reshape_b_only_on_first_run() const
1860 {
1861 return _reshape_b_only_on_first_run;
1862 };
Isabella Gottardi8e74f442018-03-01 16:42:00 +00001863 /** Depth of the output when GEMM output is reinterpreted as 3D tensor
Gian Marco36a0a462018-01-12 10:21:40 +00001864 *
Isabella Gottardi8e74f442018-03-01 16:42:00 +00001865 * @return the depth of the output tensor
Gian Marco36a0a462018-01-12 10:21:40 +00001866 */
Isabella Gottardi8e74f442018-03-01 16:42:00 +00001867 int depth_output_gemm3d() const
Gian Marco36a0a462018-01-12 10:21:40 +00001868 {
Isabella Gottardi8e74f442018-03-01 16:42:00 +00001869 return _depth_output_gemm3d;
1870 };
Gian Marco Iodice68a3f562018-07-26 11:44:03 +01001871 /** Flag which specifies if the input tensor has to be reinterpreted as 3D
1872 *
1873 * @return True if the input tensor has to be reinterpreted as 3D tensor
1874 */
1875 bool reinterpret_input_as_3d() const
1876 {
1877 return _reinterpret_input_as_3d;
1878 };
Michele Di Giorgioba1ffe92018-08-22 14:28:30 +01001879 /** Flag which specifies if the weights tensor has to be retained from previous run
1880 *
1881 * @return True if the weights tensor has to be retained
1882 */
1883 bool retain_internal_weights() const
1884 {
1885 return _retain_internal_weights;
1886 };
Gian Marco Iodice4b908652018-10-18 10:21:02 +01001887 /** GEMMLowp output stage
1888 *
1889 * @return the GEMMLowp output stage info
1890 */
1891 GEMMLowpOutputStageInfo gemmlowp_output_stage() const
1892 {
1893 return _gemmlowp_output_stage;
1894 };
Vidhya Sudhan Loganathana25d16c2018-11-16 11:33:12 +00001895 /** Flag which specifies if a wider accumulator should be used.
1896 *
1897 * @return True if a wider accumulator has to be used
1898 */
1899 bool fp_mixed_precision() const
1900 {
1901 return _fp_mixed_precision;
1902 };
Chunosov5124be52017-11-22 20:42:13 +07001903
1904private:
Gian Marco Iodice4b908652018-10-18 10:21:02 +01001905 const bool _is_a_reshaped;
1906 const bool _is_b_reshaped;
1907 const bool _reshape_b_only_on_first_run;
1908 const int _depth_output_gemm3d;
1909 const bool _reinterpret_input_as_3d;
1910 const bool _retain_internal_weights;
1911 const GEMMLowpOutputStageInfo _gemmlowp_output_stage;
Vidhya Sudhan Loganathana25d16c2018-11-16 11:33:12 +00001912 const bool _fp_mixed_precision;
Chunosov5124be52017-11-22 20:42:13 +07001913};
1914
Gian Marco Iodice247f52c2018-03-22 11:24:56 +00001915/** Winograd information */
1916struct WinogradInfo
1917{
1918 /** Default constructor
1919 *
1920 * @param[in] output_tile_sz Width and height of the output tile
1921 * @param[in] kernel_sz Width and height of the kernel
1922 * @param[in] input_dims Width and height of the input tensor before the convolution is applied
1923 * @param[in] conv_info Convolution info (Pads, strides)
1924 * @param[in] data_layout Data layout to use for the output tensor once the convolution has been applied
1925 */
1926 WinogradInfo(Size2D output_tile_sz, Size2D kernel_sz, Size2D input_dims, PadStrideInfo conv_info, DataLayout data_layout)
1927 : output_tile_size(output_tile_sz), kernel_size(kernel_sz), input_dimensions(input_dims), convolution_info(conv_info), output_data_layout(data_layout)
1928 {
1929 }
1930
1931 Size2D output_tile_size{}; /**< Width and height of the output tile */
1932 Size2D kernel_size{}; /**< Width and height of the kernel*/
1933 Size2D input_dimensions{}; /**< Width and height of the input tensor before the convolution is applied */
1934 PadStrideInfo convolution_info{}; /**< Convolution info (Pads, strides,...) */
1935 DataLayout output_data_layout{ DataLayout::NCHW }; /**< Data layout to use for the output tensor once the convolution has been applied (NCHW or NHWC) */
1936};
1937
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001938/** IO formatting information class*/
1939struct IOFormatInfo
1940{
1941 /** Precision type used when printing floating point numbers */
1942 enum class PrecisionType
1943 {
1944 Default, /**< Default precision to the one that the current stream has */
1945 Custom, /**< Custom precision specified by the user using the precision parameter */
1946 Full /**< The maximum precision of the floating point representation */
1947 };
1948
1949 /** Specifies the area to be printed, used by Tensor objects */
1950 enum class PrintRegion
1951 {
1952 ValidRegion, /**< Prints the valid region of the Tensor object */
1953 NoPadding, /**< Prints the Tensor object without the padding */
1954 Full /**< Print the tensor object including padding */
1955 };
1956
Alex Gildayc357c472018-03-21 13:54:09 +00001957 /** Construct a set of IO formatting information.
1958 *
1959 * @param[in] print_region Area to be printed. Used by Tensor objects. Default: ValidRegion.
1960 * @param[in] precision_type Precision type for floating point numbers. Default: stream default.
1961 * @param[in] precision Precision value for float point numbers. Default: 10.
1962 * @param[in] align_columns Whether to align columns when printed. Default: true.
1963 * @param[in] element_delim Delimeter between elements. Default: " ".
1964 * @param[in] row_delim Delimenter between rows. Default: "\n".
1965 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001966 IOFormatInfo(PrintRegion print_region = PrintRegion::ValidRegion,
1967 PrecisionType precision_type = PrecisionType::Default,
1968 unsigned int precision = 10,
1969 bool align_columns = true,
1970 std::string element_delim = " ",
1971 std::string row_delim = "\n")
1972 : print_region(print_region),
1973 precision_type(precision_type),
1974 precision(precision),
1975 element_delim(element_delim),
1976 row_delim(row_delim),
1977 align_columns(align_columns)
1978 {
1979 }
1980
Alex Gildayc357c472018-03-21 13:54:09 +00001981 /** Area to be printed by Tensor objects */
1982 PrintRegion print_region;
1983 /** Floating point precision type */
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001984 PrecisionType precision_type;
Alex Gildayc357c472018-03-21 13:54:09 +00001985 /** Floating point precision */
1986 unsigned int precision;
1987 /** Element delimeter */
1988 std::string element_delim;
1989 /** Row delimeter */
1990 std::string row_delim;
1991 /** Align columns */
1992 bool align_columns;
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001993};
Georgios Pinitasd8734b52017-12-22 15:27:52 +00001994} // namespace arm_compute
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001995#endif /* __ARM_COMPUTE_TYPES_H__ */