Compute Library
 20.05
Types.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016-2020 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 
33 #include "support/Bfloat16.h"
34 #include "support/Half.h"
35 
36 #include <cmath>
37 #include <cstddef>
38 #include <cstdint>
39 #include <map>
40 #include <string>
41 #include <utility>
42 
43 namespace arm_compute
44 {
45 /** 16-bit floating point type */
47 
48 /** Permutation vector */
50 /** Bidirectional strides */
52 
53 /** Image colour formats */
54 enum class Format
55 {
56  UNKNOWN, /**< Unknown image format */
57  U8, /**< 1 channel, 1 U8 per channel */
58  S16, /**< 1 channel, 1 S16 per channel */
59  U16, /**< 1 channel, 1 U16 per channel */
60  S32, /**< 1 channel, 1 S32 per channel */
61  U32, /**< 1 channel, 1 U32 per channel */
62  BFLOAT16, /**< 16-bit brain floating-point number */
63  F16, /**< 1 channel, 1 F16 per channel */
64  F32, /**< 1 channel, 1 F32 per channel */
65  UV88, /**< 2 channel, 1 U8 per channel */
66  RGB888, /**< 3 channels, 1 U8 per channel */
67  RGBA8888, /**< 4 channels, 1 U8 per channel */
68  YUV444, /**< A 3 plane of 8 bit 4:4:4 sampled Y, U, V planes */
69  YUYV422, /**< A single plane of 32-bit macro pixel of Y0, U0, Y1, V0 bytes */
70  NV12, /**< A 2 plane YUV format of Luma (Y) and interleaved UV data at 4:2:0 sampling */
71  NV21, /**< A 2 plane YUV format of Luma (Y) and interleaved VU data at 4:2:0 sampling */
72  IYUV, /**< A 3 plane of 8-bit 4:2:0 sampled Y, U, V planes */
73  UYVY422 /**< A single plane of 32-bit macro pixel of U0, Y0, V0, Y1 byte */
74 };
75 
76 /** Available data types */
77 enum class DataType
78 {
79  UNKNOWN, /**< Unknown data type */
80  U8, /**< unsigned 8-bit number */
81  S8, /**< signed 8-bit number */
82  QSYMM8, /**< quantized, symmetric fixed-point 8-bit number */
83  QASYMM8, /**< quantized, asymmetric fixed-point 8-bit number unsigned */
84  QASYMM8_SIGNED, /**< quantized, asymmetric fixed-point 8-bit number signed */
85  QSYMM8_PER_CHANNEL, /**< quantized, symmetric per channel fixed-point 8-bit number */
86  U16, /**< unsigned 16-bit number */
87  S16, /**< signed 16-bit number */
88  QSYMM16, /**< quantized, symmetric fixed-point 16-bit number */
89  QASYMM16, /**< quantized, asymmetric fixed-point 16-bit number */
90  U32, /**< unsigned 32-bit number */
91  S32, /**< signed 32-bit number */
92  U64, /**< unsigned 64-bit number */
93  S64, /**< signed 64-bit number */
94  BFLOAT16, /**< 16-bit brain floating-point number */
95  F16, /**< 16-bit floating-point number */
96  F32, /**< 32-bit floating-point number */
97  F64, /**< 64-bit floating-point number */
98  SIZET /**< size_t */
99 };
100 
101 /** Available Sampling Policies */
102 enum class SamplingPolicy
103 {
104  CENTER, /**< Samples are taken at pixel center */
105  TOP_LEFT /**< Samples are taken at pixel top left corner */
106 };
107 
108 /** Constant value of the border pixels when using BorderMode::CONSTANT */
109 constexpr uint8_t CONSTANT_BORDER_VALUE = 199;
110 
111 /** Constant value used to indicate a half-scale pyramid */
112 constexpr float SCALE_PYRAMID_HALF = 0.5f;
113 
114 /** Constant value used to indicate a ORB scaled pyramid */
115 constexpr float SCALE_PYRAMID_ORB = 8.408964152537146130583778358414e-01;
116 
117 /** [DataLayout enum definition] **/
118 
119 /** Supported tensor data layouts */
120 enum class DataLayout
121 {
122  UNKNOWN, /**< Unknown data layout */
123  NCHW, /**< Num samples, channels, height, width */
124  NHWC /**< Num samples, height, width, channels */
125 };
126 /** [DataLayout enum definition] **/
127 
128 /** Supported tensor data layout dimensions */
130 {
131  CHANNEL, /**< channel */
132  HEIGHT, /**< height */
133  WIDTH, /**< width */
134  BATCHES /**< batches */
135 };
136 
137 /** Available ConvolutionMethod*/
139 {
140  GEMM, /**< Convolution using GEMM */
141  DIRECT, /**< Direct convolution */
142  WINOGRAD, /**< Convolution using Winograd */
143  FFT /**< Convolution using FFT */
144 };
145 
146 /** Available DepthwiseConvolutionFunction*/
148 {
149  OPTIMIZED, /**< Optimized Depthwise Convolution */
150  GENERIC, /**< Generic Depthwise Convolution */
151 };
152 
153 /** Available DeconvolutionMethod*/
155 {
156  GEMM, /**< Deconvolution using GEMM */
157  DIRECT, /**< Direct deconvolution */
158 };
159 
160 /** Available FuseBatchNormalizationType*/
162 {
163  CONVOLUTION, /**< For Convolution weights */
164  DEPTHWISECONVOLUTION /**< For Depthwise Convolution weights*/
165 };
166 
167 /** Padding mode to use for PadLayer */
168 enum class PaddingMode
169 {
170  CONSTANT,
171  REFLECT,
172  SYMMETRIC
173 };
174 
175 /** Supported comparison operations */
177 {
178  Equal, /**< Equal comparison ( \f$ x == y \f$ ) */
179  NotEqual, /**< NotEqual comparison ( \f$ x != y \f$ ) */
180  Greater, /**< Greater comparison ( \f$ x > y \f$ ) */
181  GreaterEqual, /**< Greater equal comparison ( \f$ x >= y \f$ ) */
182  Less, /**< Less comparison ( \f$ x < y \f$ ) */
183  LessEqual /**< Less equal comparison ( \f$ x <= y \f$ ) */
184 };
185 
186 /** Container for valid region of a window */
188 {
189  /** Default constructor */
191  : anchor{}, shape{}
192  {
193  }
194 
195  /** Allow instances of this class to be copy constructed */
196  ValidRegion(const ValidRegion &) = default;
197  /** Allow instances of this class to be move constructed */
198  ValidRegion(ValidRegion &&) = default;
199  /** Allow instances of this class to be copied */
200  ValidRegion &operator=(const ValidRegion &) = default;
201  /** Allow instances of this class to be moved */
202  ValidRegion &operator=(ValidRegion &&) = default;
203  /** Default destructor */
204  ~ValidRegion() = default;
205 
206  /** Constructor for a valid region with default number of dimensions
207  *
208  * @param[in] an_anchor Anchor for the start of the valid region.
209  * @param[in] a_shape Shape of the valid region.
210  *
211  */
212  ValidRegion(const Coordinates &an_anchor, const TensorShape &a_shape)
213  : anchor{ an_anchor }, shape{ a_shape }
214  {
216  }
217 
218  /** Constructor for a valid region with specified number of dimensions
219  *
220  * @param[in] an_anchor Anchor for the start of the valid region.
221  * @param[in] a_shape Shape of the valid region.
222  * @param[in] num_dimensions Number of dimensions (must be >= number of dimensions of anchor and shape).
223  *
224  */
225  ValidRegion(const Coordinates &an_anchor, const TensorShape &a_shape, size_t num_dimensions)
226  : anchor{ an_anchor }, shape{ a_shape }
227  {
228  ARM_COMPUTE_ERROR_ON(num_dimensions < std::max(anchor.num_dimensions(), shape.num_dimensions()));
229  anchor.set_num_dimensions(num_dimensions);
230  }
231 
232  /** Return the start of the valid region for the given dimension @p d */
233  int start(unsigned int d) const
234  {
235  return anchor[d];
236  }
237 
238  /** Return the end of the valid region for the given dimension @p d */
239  int end(unsigned int d) const
240  {
241  return anchor[d] + shape[d];
242  }
243 
244  /** Accessor to set the value of anchor and shape for one of the dimensions.
245  *
246  * @param[in] dimension Dimension for which the value is set.
247  * @param[in] start Value to be set in anchor for the dimension.
248  * @param[in] size Value to be set in shape for the dimension.
249  *
250  * @return *this.
251  */
252  ValidRegion &set(size_t dimension, int start, size_t size)
253  {
254  anchor.set(dimension, start);
255  shape.set(dimension, size);
256  return *this;
257  }
258 
259  Coordinates anchor; /**< Anchor for the start of the valid region. */
260  TensorShape shape; /**< Shape of the valid region. */
261 };
262 
263 /** Methods available to handle borders */
264 enum class BorderMode
265 {
266  UNDEFINED, /**< Borders are left undefined */
267  CONSTANT, /**< Pixels outside the image are assumed to have a constant value */
268  REPLICATE /**< Pixels outside the image are assumed to have the same value as the closest image pixel */
269 };
270 
271 /** Container for 2D border size */
273 {
274  /** Empty border, i.e. no border */
275  constexpr BorderSize()
276  : top{ 0 }, right{ 0 }, bottom{ 0 }, left{ 0 }
277  {
278  }
279 
280  /** Border with equal size around the 2D plane */
281  explicit constexpr BorderSize(unsigned int size)
282  : top{ size }, right{ size }, bottom{ size }, left{ size }
283  {
284  }
285 
286  /** Border with same size for top/bottom and left/right */
287  constexpr BorderSize(unsigned int top_bottom, unsigned int left_right)
288  : top{ top_bottom }, right{ left_right }, bottom{ top_bottom }, left{ left_right }
289  {
290  }
291 
292  /** Border with different sizes */
293  constexpr BorderSize(unsigned int top, unsigned int right, unsigned int bottom, unsigned int left)
294  : top{ top }, right{ right }, bottom{ bottom }, left{ left }
295  {
296  }
297 
298  /** Check if the entire border is zero */
299  constexpr bool empty() const
300  {
301  return top == 0 && right == 0 && bottom == 0 && left == 0;
302  }
303 
304  /** Check if the border is the same size on all sides */
305  constexpr bool uniform() const
306  {
307  return top == right && top == bottom && top == left;
308  }
309 
310  /** Scale this border size.
311  *
312  * @param[in] scale Scale to multiply border size by.
313  *
314  * @return *this.
315  */
317  {
318  top *= scale;
319  right *= scale;
320  bottom *= scale;
321  left *= scale;
322 
323  return *this;
324  }
325 
326  /** Scale a copy of this border size.
327  *
328  * @param[in] scale Scale to multiply border size by.
329  *
330  * @return a scaled copy of this.
331  */
333  {
334  BorderSize size = *this;
335  size *= scale;
336 
337  return size;
338  }
339 
340  /** Limit this border size.
341  *
342  * @param[in] limit Border size to limit this border size to.
343  */
344  void limit(const BorderSize &limit)
345  {
346  top = std::min(top, limit.top);
347  right = std::min(right, limit.right);
348  bottom = std::min(bottom, limit.bottom);
349  left = std::min(left, limit.left);
350  }
351 
352  unsigned int top; /**< top of the border */
353  unsigned int right; /**< right of the border */
354  unsigned int bottom; /**< bottom of the border */
355  unsigned int left; /**< left of the border */
356 };
357 
358 /** Container for 2D padding size */
360 
361 /** Policy to handle overflow */
362 enum class ConvertPolicy
363 {
364  WRAP, /**< Wrap around */
365  SATURATE /**< Saturate */
366 };
367 
368 /** Interpolation method */
370 {
371  NEAREST_NEIGHBOR, /**< Output values are defined to match the source pixel whose center is nearest to the sample position */
372  BILINEAR, /**< Output values are defined by bilinear interpolation between the pixels */
373  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 */
374 };
375 
376 /** Bilinear Interpolation method used by LKTracker */
378 {
379  BILINEAR_OLD_NEW, /**< Old-new method */
380  BILINEAR_SCHARR /**< Scharr method */
381 };
382 
383 /** Threshold mode */
384 enum class ThresholdType
385 {
386  BINARY, /**< Threshold with one value */
387  RANGE /**< Threshold with two values*/
388 };
389 
390 /** Termination criteria */
391 enum class Termination
392 {
393  TERM_CRITERIA_EPSILON, /**< Terminate when within epsilon of a threshold */
394  TERM_CRITERIA_ITERATIONS, /**< Terminate after a maximum number of iterations */
395  TERM_CRITERIA_BOTH /**< Terminate on whichever of the other conditions occurs first */
396 };
397 
398 /** Magnitude calculation type. */
399 enum class MagnitudeType
400 {
401  L1NORM, /**< L1 normalization type */
402  L2NORM /**< L2 normalization type */
403 };
404 
405 /** Phase calculation type.
406  *
407  * @note When PhaseType == SIGNED, each angle is mapped to the range 0 to 255 inclusive otherwise angles between 0 and 180
408  */
409 enum class PhaseType
410 {
411  SIGNED, /**< Angle range: [0, 360] */
412  UNSIGNED /**< Angle range: [0, 180] */
413 };
414 
415 /** Keypoint type */
416 struct KeyPoint
417 {
418  int32_t x{ 0 }; /**< X coordinates */
419  int32_t y{ 0 }; /**< Y coordinates */
420  float strength{ 0.f }; /**< Strength of the point */
421  float scale{ 0.f }; /**< Scale initialized to 0 by the corner detector */
422  float orientation{ 0.f }; /**< Orientation initialized to 0 by the corner detector */
423  int32_t tracking_status{ 0 }; /**< Status initialized to 1 by the corner detector, set to 0 when the point is lost */
424  float error{ 0.f }; /**< Tracking error initialized to 0 by the corner detector */
425 };
426 
427 /** Internal key point */
428 using InternalKeypoint = std::tuple<float, float, float>; /* x,y,strength */
429 
430 /** Rectangle type */
431 struct Rectangle
432 {
433  uint16_t x; /**< Top-left x coordinate */
434  uint16_t y; /**< Top-left y coordinate */
435  uint16_t width; /**< Width of the rectangle */
436  uint16_t height; /**< Height of the rectangle */
437 };
438 
439 /** Coordinate type */
441 {
442  int32_t x; /**< X coordinates */
443  int32_t y; /**< Y coordinates */
444 };
445 
446 /** Coordinate type */
448 {
449  uint32_t x; /**< X coordinates */
450  uint32_t y; /**< Y coordinates */
451  uint32_t z; /**< Z coordinates */
452 };
453 
454 /** Padding information as a pair of unsigned int start/end */
455 using PaddingInfo = std::pair<uint32_t, uint32_t>;
456 
457 /** List of padding information */
458 using PaddingList = std::vector<PaddingInfo>;
459 
460 /** Information to produce a tiled version of a Tensor */
461 using Multiples = std::vector<uint32_t>;
462 
463 /** Available channels */
464 enum class Channel
465 {
466  UNKNOWN, /** Unknown channel format */
467  C0, /**< First channel (used by formats with unknown channel types). */
468  C1, /**< Second channel (used by formats with unknown channel types). */
469  C2, /**< Third channel (used by formats with unknown channel types). */
470  C3, /**< Fourth channel (used by formats with unknown channel types). */
471  R, /**< Red channel. */
472  G, /**< Green channel. */
473  B, /**< Blue channel. */
474  A, /**< Alpha channel. */
475  Y, /**< Luma channel. */
476  U, /**< Cb/U channel. */
477  V /**< Cr/V/Value channel. */
478 };
479 
480 /** Available matrix patterns */
481 enum class MatrixPattern
482 {
483  BOX, /**< Box pattern matrix. */
484  CROSS, /**< Cross pattern matrix. */
485  DISK, /**< Disk pattern matrix. */
486  OTHER /**< Any other matrix pattern. */
487 };
488 
489 /** Available non linear functions. */
490 enum class NonLinearFilterFunction : unsigned
491 {
492  MEDIAN = 0, /**< Non linear median filter. */
493  MIN = 1, /**< Non linear erode. */
494  MAX = 2, /**< Non linear dilate. */
495 };
496 
497 /** Available reduction operations */
499 {
500  ARG_IDX_MAX, /**< Index of the max value */
501  ARG_IDX_MIN, /**< Index of the min value */
502  MEAN_SUM, /**< Mean of sum */
503  PROD, /**< Product */
504  SUM_SQUARE, /**< Sum of squares */
505  SUM, /**< Sum */
506  MIN, /**< Min */
507  MAX, /**< Max */
508 };
509 
510 /** Available element-wise operations */
512 {
513  ADD, /**< (x + y) */
514  SUB, /**< (x - y) */
515  DIV, /**< (x / y) */
516  MIN, /**< Min(x, y) */
517  MAX, /**< Max(x, y) */
518  SQUARED_DIFF, /**< (x - y)^2 */
519  POWER, /**< x ^ y */
520  PRELU, /**< y*x if x < 0, x otherwise */
521 };
522 
523 /** Available element wise unary operations */
525 {
526  RSQRT, /**< Reverse square root */
527  EXP, /**< Exponential */
528  NEG, /**< Negate */
529  LOG, /**< Natural Logarithm */
530  ABS, /**< Absolute value */
531  SIN, /**< Sine */
532  ROUND, /**< Round */
533 };
534 
535 /** The normalization type used for the normalization layer */
536 enum class NormType
537 {
538  IN_MAP_1D, /**< Normalization applied within the same map in 1D region */
539  IN_MAP_2D, /**< Normalization applied within the same map in 2D region */
540  CROSS_MAP /**< Normalization applied cross maps */
541 };
542 
543 /** Normalization type for Histogram of Oriented Gradients (HOG) */
544 enum class HOGNormType
545 {
546  L2_NORM = 1, /**< L2-norm */
547  L2HYS_NORM = 2, /**< L2-norm followed by clipping */
548  L1_NORM = 3 /**< L1 norm */
549 };
550 
551 /** Detection window used for the object detection. The detection window keeps the following information:
552  *
553  * -# Geometry of the rectangular window (x/y of top-left corner and width/height)
554  * -# Index of the class used for evaluating which class the detection window belongs to
555  * -# Confidence value (score) obtained with the classifier
556  */
558 {
559  uint16_t x{ 0 }; /**< Top-left x coordinate */
560  uint16_t y{ 0 }; /**< Top-left y coordinate */
561  uint16_t width{ 0 }; /**< Width of the detection window */
562  uint16_t height{ 0 }; /**< Height of the detection window */
563  uint16_t idx_class{ 0 }; /**< Index of the class */
564  float score{ 0.f }; /**< Confidence value for the detection window */
565 };
566 
567 /** Dimension rounding type when down-scaling on CNNs
568  * @note Used in pooling and convolution layer
569  */
571 {
572  FLOOR, /**< Floor rounding */
573  CEIL /**< Ceil rounding */
574 };
575 
576 /** Available pooling types */
577 enum class PoolingType
578 {
579  MAX, /**< Max Pooling */
580  AVG, /**< Average Pooling */
581  L2 /**< L2 Pooling */
582 };
583 
584 /** Available non maxima suppression types */
585 enum class NMSType
586 {
587  LINEAR, /**< Linear NMS */
588  GAUSSIAN, /**< Gaussian NMS */
589  ORIGINAL /**< Original NMS */
590 };
591 
592 /** BoxWithNonMaximaSuppressionLimit Information class */
593 class BoxNMSLimitInfo final
594 {
595 public:
596  /** Constructor
597  *
598  * @param[in] score_thresh (Optional) Score threshold.
599  * @param[in] nms (Optional) NMS value
600  * @param[in] detections (Optional) Number of detections
601  * @param[in] soft_nms_enabled (Optional) Enable SoftNMS
602  * @param[in] soft_nms_method (Optional) Soft NMS method
603  * @param[in] soft_nms_sigma (Optional) Soft NMS sigma value
604  * @param[in] soft_nms_min_score_thres (Optional) Soft NMS minimum score threshold
605  * @param[in] suppress_size (Optional) Filter out boxes based on their size. Defaults to false
606  * @param[in] min_size (Optional) Smaller boxes than min_size will be filtered out. Defaults to 1
607  * @param[in] im_width (Optional) Boxes whose centers (on the x axis) is beyond im_width will be filtered. Defaults to 1
608  * @param[in] im_height (Optional) Boxes whose centers (on the y axis) is beyond im_height will be filtered. Defaults to 1
609  */
610  BoxNMSLimitInfo(float score_thresh = 0.05f, float nms = 0.3f,
611  int detections = 100, bool soft_nms_enabled = false,
613  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)
614  : _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),
615  _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)
616  {
617  }
618  /** Get the score threshold */
619  float score_thresh() const
620  {
621  return _score_thresh;
622  }
623  /** Get the NMS */
624  float nms() const
625  {
626  return _nms;
627  }
628  /** Get the number of detections */
629  int detections_per_im() const
630  {
631  return _detections_per_im;
632  }
633  /** Check if soft NMS is enabled */
634  bool soft_nms_enabled() const
635  {
636  return _soft_nms_enabled;
637  }
638  /** Get soft NMS method */
640  {
641  return _soft_nms_method;
642  }
643  /** Get soft NMS sigma */
644  float soft_nms_sigma() const
645  {
646  return _soft_nms_sigma;
647  }
648  /** Get soft nms min score threshold */
650  {
651  return _soft_nms_min_score_thres;
652  }
653  /** Get if NMS will suppress boxes based on their size/position */
654  bool suppress_size() const
655  {
656  return _suppress_size;
657  }
658  /** Get size suppression threshold */
659  float min_size() const
660  {
661  return _min_size;
662  }
663  /** Get image width (NMS may suppress boxes whose center sits beyond the image width) */
664  float im_width() const
665  {
666  return _im_width;
667  }
668  /** Get image height (NMS may suppress boxes whose center sits beyond the image height) */
669  float im_height() const
670  {
671  return _im_height;
672  }
673 
674 private:
675  float _score_thresh;
676  float _nms;
677  int _detections_per_im;
678  bool _soft_nms_enabled;
679  NMSType _soft_nms_method;
680  float _soft_nms_sigma;
681  float _soft_nms_min_score_thres;
682  bool _suppress_size;
683  float _min_size;
684  float _im_width;
685  float _im_height;
686 };
687 
688 /** Padding and stride information class */
690 {
691 public:
692  /** Constructor
693  *
694  * @param[in] stride_x (Optional) Stride, in elements, across x. Defaults to 1.
695  * @param[in] stride_y (Optional) Stride, in elements, across y. Defaults to 1.
696  * @param[in] pad_x (Optional) Padding, in elements, across x. Defaults to 0.
697  * @param[in] pad_y (Optional) Padding, in elements, across y. Defaults to 0.
698  * @param[in] round (Optional) Dimensions rounding. Defaults to @ref FLOOR.
699  */
700  PadStrideInfo(unsigned int stride_x = 1, unsigned int stride_y = 1,
701  unsigned int pad_x = 0, unsigned int pad_y = 0,
703  : _stride(std::make_pair(stride_x, stride_y)),
704  _pad_left(pad_x),
705  _pad_top(pad_y),
706  _pad_right(pad_x),
707  _pad_bottom(pad_y),
708  _round_type(round)
709  {
710  }
711  /** Constructor
712  *
713  * @param[in] stride_x Stride, in elements, across x.
714  * @param[in] stride_y Stride, in elements, across y.
715  * @param[in] pad_left Padding across x on the left, in elements.
716  * @param[in] pad_top Padding across y on the top, in elements.
717  * @param[in] pad_right Padding across x on the right, in elements.
718  * @param[in] pad_bottom Padding across y on the bottom, in elements.
719  * @param[in] round Dimensions rounding.
720  */
721  PadStrideInfo(unsigned int stride_x, unsigned int stride_y,
722  unsigned int pad_left, unsigned int pad_right,
723  unsigned int pad_top, unsigned int pad_bottom,
725  : _stride(std::make_pair(stride_x, stride_y)),
726  _pad_left(pad_left),
727  _pad_top(pad_top),
728  _pad_right(pad_right),
729  _pad_bottom(pad_bottom),
730  _round_type(round)
731  {
732  }
733  /** Get the stride.
734  *
735  * @return a pair: stride x, stride y.
736  */
737  std::pair<unsigned int, unsigned int> stride() const
738  {
739  return _stride;
740  }
741  /** Check whether the padding is symmetric.
742  *
743  * @return True if the padding is symmetric.
744  */
745  bool padding_is_symmetric() const
746  {
747  return (_pad_left == _pad_right) && (_pad_top == _pad_bottom);
748  }
749  /** Get the padding.
750  *
751  * @note This should only be used when the padding is symmetric.
752  *
753  * @return a pair: padding left/right, padding top/bottom
754  */
755  std::pair<unsigned int, unsigned int> pad() const
756  {
757  //this accessor should be used only when padding is symmetric
759  return std::make_pair(_pad_left, _pad_top);
760  }
761 
762  /** Get the left padding */
763  unsigned int pad_left() const
764  {
765  return _pad_left;
766  }
767  /** Get the right padding */
768  unsigned int pad_right() const
769  {
770  return _pad_right;
771  }
772  /** Get the top padding */
773  unsigned int pad_top() const
774  {
775  return _pad_top;
776  }
777  /** Get the bottom padding */
778  unsigned int pad_bottom() const
779  {
780  return _pad_bottom;
781  }
782 
783  /** Get the rounding type */
785  {
786  return _round_type;
787  }
788 
789  /** Check whether this has any padding */
790  bool has_padding() const
791  {
792  return (_pad_left != 0 || _pad_top != 0 || _pad_right != 0 || _pad_bottom != 0);
793  }
794 
795 private:
796  std::pair<unsigned int, unsigned int> _stride;
797  unsigned int _pad_left;
798  unsigned int _pad_top;
799  unsigned int _pad_right;
800  unsigned int _pad_bottom;
801 
802  DimensionRoundingType _round_type;
803 };
804 
805 /** PriorBox layer info */
806 class PriorBoxLayerInfo final
807 {
808 public:
809  /** Default Constructor */
811  : _min_sizes(),
812  _variances(),
813  _offset(),
814  _flip(true),
815  _clip(false),
816  _max_sizes(),
817  _aspect_ratios(),
818  _img_size(),
819  _steps()
820  {
821  }
822  /** Constructor
823  *
824  * @param[in] min_sizes Min sizes vector.
825  * @param[in] variances Variances vector.
826  * @param[in] offset Offset value.
827  * @param[in] flip (Optional) Flip the aspect ratios.
828  * @param[in] clip (Optional) Clip coordinates so that they're within [0,1].
829  * @param[in] max_sizes (Optional) Max sizes vector.
830  * @param[in] aspect_ratios (Optional) Aspect ratios of the boxes.
831  * @param[in] img_size (Optional) Image size.
832  * @param[in] steps (Optional) Step values.
833  */
834  PriorBoxLayerInfo(const std::vector<float> &min_sizes, const std::vector<float> &variances, float offset, bool flip = true, bool clip = false,
835  const std::vector<float> &max_sizes = {}, const std::vector<float> &aspect_ratios = {},
836  const Coordinates2D &img_size = Coordinates2D{ 0, 0 }, const std::array<float, 2> &steps = { { 0.f, 0.f } })
837  : _min_sizes(min_sizes),
838  _variances(variances),
839  _offset(offset),
840  _flip(flip),
841  _clip(clip),
842  _max_sizes(max_sizes),
843  _aspect_ratios(),
844  _img_size(img_size),
845  _steps(steps)
846  {
847  _aspect_ratios.push_back(1.);
848  for(unsigned int i = 0; i < aspect_ratios.size(); ++i)
849  {
850  float ar = aspect_ratios[i];
851  bool already_exist = false;
852  for(auto ar_new : _aspect_ratios)
853  {
854  if(fabs(ar - ar_new) < 1e-6)
855  {
856  already_exist = true;
857  break;
858  }
859  }
860  if(!already_exist)
861  {
862  _aspect_ratios.push_back(ar);
863  if(flip)
864  {
865  _aspect_ratios.push_back(1.f / ar);
866  }
867  }
868  }
869  }
870  /** Get min sizes. */
871  std::vector<float> min_sizes() const
872  {
873  return _min_sizes;
874  }
875  /** Get min variances. */
876  std::vector<float> variances() const
877  {
878  return _variances;
879  }
880  /** Get the step coordinates */
881  std::array<float, 2> steps() const
882  {
883  return _steps;
884  }
885  /** Get the image size coordinates */
887  {
888  return _img_size;
889  }
890  /** Get the offset */
891  float offset() const
892  {
893  return _offset;
894  }
895  /** Get the flip value */
896  bool flip() const
897  {
898  return _flip;
899  }
900  /** Get the clip value */
901  bool clip() const
902  {
903  return _clip;
904  }
905  /** Get max sizes. */
906  std::vector<float> max_sizes() const
907  {
908  return _max_sizes;
909  }
910  /** Get aspect ratios. */
911  std::vector<float> aspect_ratios() const
912  {
913  return _aspect_ratios;
914  }
915 
916 private:
917  std::vector<float> _min_sizes;
918  std::vector<float> _variances;
919  float _offset;
920  bool _flip;
921  bool _clip;
922  std::vector<float> _max_sizes;
923  std::vector<float> _aspect_ratios;
924  Coordinates2D _img_size;
925  std::array<float, 2> _steps;
926 };
927 
928 // Bounding Box [xmin, ymin, xmax, ymax]
929 using BBox = std::array<float, 4>;
930 // LabelBBox used for map label and bounding box
931 using LabelBBox = std::map<int, std::vector<BBox>>;
932 
933 /** Available Detection Output code types */
935 {
936  CORNER, /**< Use box corners */
937  CENTER_SIZE, /**< Use box centers and size */
938  CORNER_SIZE, /**< Use box centers and size */
939  TF_CENTER /**< Use box centers and size but flip x and y co-ordinates */
940 };
941 
942 /** Detection Output layer info */
944 {
945 public:
946  /** Default Constructor */
948  : _num_classes(),
949  _share_location(),
951  _keep_top_k(),
952  _nms_threshold(),
953  _top_k(),
954  _background_label_id(),
955  _confidence_threshold(),
956  _variance_encoded_in_target(false),
957  _eta(),
958  _num_loc_classes()
959  {
960  _num_loc_classes = _share_location ? 1 : _num_classes;
961  }
962  /** Constructor
963  *
964  * @param[in] num_classes Number of classes to be predicted.
965  * @param[in] share_location If true, bounding box are shared among different classes.
966  * @param[in] code_type Type of coding method for bbox.
967  * @param[in] keep_top_k Number of total bounding boxes to be kept per image after NMS step.
968  * @param[in] nms_threshold Threshold to be used in NMS.
969  * @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.
970  * @param[in] background_label_id (Optional) Background label ID. If there is no background class, set it as -1.
971  * @param[in] confidence_threshold (Optional) Only consider detections whose confidences are larger than a threshold. Default set to -FLT_MAX.
972  * @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.
973  * @param[in] eta (Optional) Eta.
974  */
977  : _num_classes(num_classes),
978  _share_location(share_location),
979  _code_type(code_type),
980  _keep_top_k(keep_top_k),
981  _nms_threshold(nms_threshold),
982  _top_k(top_k),
983  _background_label_id(background_label_id),
984  _confidence_threshold(confidence_threshold),
985  _variance_encoded_in_target(variance_encoded_in_target),
986  _eta(eta),
987  _num_loc_classes()
988  {
989  _num_loc_classes = _share_location ? 1 : _num_classes;
990  }
991  /** Get num classes. */
992  int num_classes() const
993  {
994  return _num_classes;
995  }
996  /** Get share location. */
997  bool share_location() const
998  {
999  return _share_location;
1000  }
1001  /** Get detection output code type. */
1003  {
1004  return _code_type;
1005  }
1006  /** Get if variance encoded in target. */
1008  {
1009  return _variance_encoded_in_target;
1010  }
1011  /** Get the number of total bounding boxes to be kept per image. */
1012  int keep_top_k() const
1013  {
1014  return _keep_top_k;
1015  }
1016  /** Get nms threshold. */
1017  float nms_threshold() const
1018  {
1019  return _nms_threshold;
1020  }
1021  /** Get eta. */
1022  float eta() const
1023  {
1024  return _eta;
1025  }
1026  /** Get background label ID. */
1028  {
1029  return _background_label_id;
1030  }
1031  /** Get confidence threshold. */
1032  float confidence_threshold() const
1033  {
1034  return _confidence_threshold;
1035  }
1036  /** Get top K. */
1037  int top_k() const
1038  {
1039  return _top_k;
1040  }
1041  /** Get number of location classes. */
1042  int num_loc_classes() const
1043  {
1044  return _num_loc_classes;
1045  }
1046 
1047 private:
1048  int _num_classes;
1049  bool _share_location;
1050  DetectionOutputLayerCodeType _code_type;
1051  int _keep_top_k;
1052  float _nms_threshold;
1053  int _top_k;
1054  int _background_label_id;
1055  float _confidence_threshold;
1056  bool _variance_encoded_in_target;
1057  float _eta;
1058  int _num_loc_classes;
1059 };
1060 
1061 /** Detection Output layer info */
1063 {
1064 public:
1065  /** Default Constructor */
1067  : _max_detections(),
1068  _max_classes_per_detection(),
1069  _nms_score_threshold(),
1070  _iou_threshold(),
1071  _num_classes(),
1072  _scales_values(),
1073  _use_regular_nms(),
1074  _detection_per_class(),
1075  _dequantize_scores()
1076  {
1077  }
1078  /** Constructor
1079  *
1080  * @param[in] max_detections Number of total detection.
1081  * @param[in] max_classes_per_detection Number of total classes to be kept after NMS step. Used in the Fast Non-Max-Suppression
1082  * @param[in] nms_score_threshold Threshold to be used in NMS
1083  * @param[in] iou_threshold Threshold to be used during the intersection over union.
1084  * @param[in] num_classes Number of classes.
1085  * @param[in] scales_values Scales values used for decode center size boxes.
1086  * @param[in] use_regular_nms (Optional) Boolean to determinate if use regular or fast nms. Defaults to false.
1087  * @param[in] detection_per_class (Optional) Number of detection per class. Used in the Regular Non-Max-Suppression. Defaults to 100.
1088  * @param[in] dequantize_scores (Optional) If the scores need to be dequantized. Defaults to true.
1089  */
1091  std::array<float, 4> scales_values, bool use_regular_nms = false, unsigned int detection_per_class = 100, bool dequantize_scores = true)
1092  : _max_detections(max_detections),
1093  _max_classes_per_detection(max_classes_per_detection),
1094  _nms_score_threshold(nms_score_threshold),
1095  _iou_threshold(iou_threshold),
1096  _num_classes(num_classes),
1097  _scales_values(scales_values),
1098  _use_regular_nms(use_regular_nms),
1099  _detection_per_class(detection_per_class),
1100  _dequantize_scores(dequantize_scores)
1101  {
1102  }
1103  /** Get max detections. */
1104  unsigned int max_detections() const
1105  {
1106  return _max_detections;
1107  }
1108  /** Get max_classes per detection. Used in the Fast Non-Max-Suppression.*/
1109  unsigned int max_classes_per_detection() const
1110  {
1111  return _max_classes_per_detection;
1112  }
1113  /** Get detection per class. Used in the Regular Non-Max-Suppression */
1114  unsigned int detection_per_class() const
1115  {
1116  return _detection_per_class;
1117  }
1118  /** Get nms threshold. */
1119  float nms_score_threshold() const
1120  {
1121  return _nms_score_threshold;
1122  }
1123  /** Get intersection over union threshold. */
1124  float iou_threshold() const
1125  {
1126  return _iou_threshold;
1127  }
1128  /** Get num classes. */
1129  unsigned int num_classes() const
1130  {
1131  return _num_classes;
1132  }
1133  /** Get if use regular nms. */
1134  bool use_regular_nms() const
1135  {
1136  return _use_regular_nms;
1137  }
1138  /** Get y scale value. */
1139  float scale_value_y() const
1140  {
1141  // Saved as [y,x,h,w]
1142  return _scales_values[0];
1143  }
1144  /** Get x scale value. */
1145  float scale_value_x() const
1146  {
1147  // Saved as [y,x,h,w]
1148  return _scales_values[1];
1149  }
1150  /** Get h scale value. */
1151  float scale_value_h() const
1152  {
1153  // Saved as [y,x,h,w]
1154  return _scales_values[2];
1155  }
1156  /** Get w scale value. */
1157  float scale_value_w() const
1158  {
1159  // Saved as [y,x,h,w]
1160  return _scales_values[3];
1161  }
1162  /** Get dequantize_scores value. */
1163  bool dequantize_scores() const
1164  {
1165  return _dequantize_scores;
1166  }
1167 
1168 private:
1169  unsigned int _max_detections;
1170  unsigned int _max_classes_per_detection;
1171  float _nms_score_threshold;
1172  float _iou_threshold;
1173  unsigned int _num_classes;
1174  std::array<float, 4> _scales_values;
1175  bool _use_regular_nms;
1176  unsigned int _detection_per_class;
1177  bool _dequantize_scores;
1178 };
1179 
1180 /** Pooling Layer Information struct*/
1182 {
1183  /** Default Constructor */
1186  pool_size(Size2D()),
1189  exclude_padding(false),
1190  is_global_pooling(false),
1191  fp_mixed_precision(false)
1192  {
1193  }
1194  /** Constructor
1195  *
1196  * @param[in] pool_type Pooling type @ref PoolingType.
1197  * @param[in] pool_size Pooling size, in elements, across x and y.
1198  * @param[in] data_layout Data layout used by the layer @ref DataLayout
1199  * @param[in] pad_stride_info (Optional) Padding and stride information @ref PadStrideInfo
1200  * @param[in] exclude_padding (Optional) Strategy when accounting padding in calculations.
1201  * True will exclude padding while false will not (Used in AVG/L2 pooling to determine the pooling area).
1202  * Defaults to false;
1203  * @param[in] fp_mixed_precision (Optional) Use wider accumulators (32 bit instead of 16 for FP16) to improve accuracy.
1204  */
1206  unsigned int pool_size,
1209  bool exclude_padding = false,
1210  bool fp_mixed_precision = false)
1211  : pool_type(pool_type),
1216  is_global_pooling(false),
1218  {
1219  }
1220 
1221  /** Constructor
1222  *
1223  * @param[in] pool_type Pooling type @ref PoolingType.
1224  * @param[in] pool_size Pooling size, in elements, across x and y.
1225  * @param[in] data_layout Data layout used by the layer @ref DataLayout
1226  * @param[in] pad_stride_info (Optional) Padding and stride information @ref PadStrideInfo
1227  * @param[in] exclude_padding (Optional) Strategy when accounting padding in calculations.
1228  * True will exclude padding while false will not (Used in AVG/L2 pooling to determine the pooling area).
1229  * Defaults to false;
1230  * @param[in] fp_mixed_precision (Optional) Use wider accumulators (32 bit instead of 16 for FP16) to improve accuracy.
1231  */
1233  Size2D pool_size,
1236  bool exclude_padding = false,
1237  bool fp_mixed_precision = false)
1238  : pool_type(pool_type),
1243  is_global_pooling(false),
1245  {
1246  }
1247 
1248  /** Constructor
1249  *
1250  * @note This constructor is used for global pooling
1251  *
1252  * @param[in] pool_type Pooling type @ref PoolingType.
1253  * @param[in] data_layout Data layout used by the layer @ref DataLayout
1254  */
1256  : pool_type(pool_type),
1257  pool_size(Size2D()),
1259  pad_stride_info(PadStrideInfo(1, 1, 0, 0)),
1260  exclude_padding(false),
1261  is_global_pooling(true),
1262  fp_mixed_precision(false)
1263  {
1264  }
1265 
1273 };
1274 
1275 /** ROI Pooling Layer Information class */
1277 {
1278 public:
1279  /** Constructor
1280  *
1281  * @param[in] pooled_width Pooled width of the layer.
1282  * @param[in] pooled_height Pooled height of the layer.
1283  * @param[in] spatial_scale Spatial scale to be applied to the ROI coordinates and dimensions.
1284  * @param[in] sampling_ratio Number of samples to include in each pooling region (if set to zero, a ceil(roi_dims/pooling_dims))
1285  */
1286  ROIPoolingLayerInfo(unsigned int pooled_width, unsigned int pooled_height, float spatial_scale, unsigned int sampling_ratio = 0)
1287  : _pooled_width(pooled_width), _pooled_height(pooled_height), _spatial_scale(spatial_scale), _sampling_ratio(sampling_ratio)
1288  {
1289  }
1290  /** Get the pooled width of the layer */
1291  unsigned int pooled_width() const
1292  {
1293  return _pooled_width;
1294  }
1295  /** Get the pooled height of the layer */
1296  unsigned int pooled_height() const
1297  {
1298  return _pooled_height;
1299  }
1300  /** Get the spatial scale */
1301  float spatial_scale() const
1302  {
1303  return _spatial_scale;
1304  }
1305  /** Get sampling ratio */
1306  unsigned int sampling_ratio() const
1307  {
1308  return _sampling_ratio;
1309  }
1310 
1311 private:
1312  unsigned int _pooled_width;
1313  unsigned int _pooled_height;
1314  float _spatial_scale;
1315  unsigned int _sampling_ratio;
1316 };
1317 
1318 /** Generate Proposals Information class */
1320 {
1321 public:
1322  /** Constructor
1323  *
1324  * @param[in] im_width Width of the original image
1325  * @param[in] im_height Height of the original image
1326  * @param[in] im_scale Scale applied to the original image
1327  * @param[in] spatial_scale (Optional)Scale applied to the feature map. Defaults to 1.0
1328  * @param[in] pre_nms_topN (Optional)Number of the best scores to be selected from the transformations. Defaults to 6000.
1329  * @param[in] post_nms_topN (Optional)Number of the best scores to be selected from the NMS operation. Defaults to 300.
1330  * @param[in] nms_thres (Optional)NMS overlap threshold. Defaults to 0.7.
1331  * @param[in] min_size (Optional)Size used to validate the anchors produced. Defaults to 16.
1332  * @param[in] values_per_roi (Optional)Values used to represent a ROI(Region of interest). Defaults to 4.
1333  */
1334  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,
1335  size_t values_per_roi = 4)
1336  : _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),
1337  _min_size(min_size), _values_per_roi(values_per_roi)
1338  {
1339  }
1340 
1341  /* Get the original height */
1342  float im_height() const
1343  {
1344  return _im_height;
1345  }
1346  /* Get the original width */
1347  float im_width() const
1348  {
1349  return _im_width;
1350  }
1351  /* Get the image scale */
1352  float im_scale() const
1353  {
1354  return _im_scale;
1355  }
1356  /* Get the value of how many best scores to select (before NMS) */
1357  int pre_nms_topN() const
1358  {
1359  return _pre_nms_topN;
1360  }
1361  /* Get the value of how many best scores to select (after NMS) */
1362  int post_nms_topN() const
1363  {
1364  return _post_nms_topN;
1365  }
1366  /* Get the NMS overlap threshold */
1367  float nms_thres() const
1368  {
1369  return _nms_thres;
1370  }
1371  /* Get the minimal size */
1372  float min_size() const
1373  {
1374  return _min_size;
1375  }
1376  /* Get the spatial scale to be applied to the feature maps */
1377  float spatial_scale() const
1378  {
1379  return _spatial_scale;
1380  }
1381  /* Get the values used to represent a ROI(Region of interest)*/
1382  size_t values_per_roi() const
1383  {
1384  return _values_per_roi;
1385  }
1386 
1387 private:
1388  float _im_height;
1389  float _im_width;
1390  float _im_scale;
1391  float _spatial_scale;
1392  int _pre_nms_topN;
1393  int _post_nms_topN;
1394  float _nms_thres;
1395  float _min_size;
1396  size_t _values_per_roi;
1397 };
1398 
1399 /** ComputeAnchors information class */
1401 {
1402 public:
1403  /** Constructor
1404  *
1405  * @param[in] feat_width Feature map width
1406  * @param[in] feat_height Feature map height
1407  * @param[in] spatial_scale Feature map scale
1408  * @param[in] values_per_roi (Optional)Values used to represent a ROI(Region Of Interest). Defaults to 4
1409  */
1411  : _feat_height(feat_height),
1412  _feat_width(feat_width),
1413  _spatial_scale(spatial_scale),
1414  _values_per_roi(values_per_roi)
1415  {
1416  }
1417 
1418  /* Get the height of the feature map */
1419  float feat_height() const
1420  {
1421  return _feat_height;
1422  }
1423 
1424  /* Get the width of the feature map */
1425  float feat_width() const
1426  {
1427  return _feat_width;
1428  }
1429 
1430  /* Get the scale of the feature map */
1431  float spatial_scale() const
1432  {
1433  return _spatial_scale;
1434  }
1435 
1436  /* Get the values used to represent a ROI(Region Of Interest)*/
1437  size_t values_per_roi() const
1438  {
1439  return _values_per_roi;
1440  }
1441 
1442 private:
1443  float _feat_height;
1444  float _feat_width;
1445  float _spatial_scale;
1446  size_t _values_per_roi;
1447 };
1448 
1449 /** Bounding Box Transform information class */
1451 {
1452 public:
1453  /** Constructor
1454  *
1455  * @param[in] img_width Width of the original image
1456  * @param[in] img_height Height, of the original image
1457  * @param[in] scale Scale of the original image
1458  * @param[in] apply_scale (Optional)Re-apply scaling after transforming the boxes. Defaults to false
1459  * @param[in] weights (Optional)Weights [wx, wy, ww, wh] for the deltas. Defaults to all ones
1460  * @param[in] correct_transform_coords (Optional)Correct bounding box transform coordinates. Defaults to false
1461  * @param[in] bbox_xform_clip (Optional)Minimum bounding box width and height after bounding box transformation in log-space. Defaults to log(1000/16)
1462  */
1463  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 =
1464  false,
1465  float bbox_xform_clip =
1466  4.135166556742356f)
1467  : _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)
1468  {
1469  }
1470 
1471  std::array<float, 4> weights() const
1472  {
1473  return _weights;
1474  }
1475 
1476  float bbox_xform_clip() const
1477  {
1478  return _bbox_xform_clip;
1479  }
1480 
1481  float img_height() const
1482  {
1483  return _img_height;
1484  }
1485 
1486  float img_width() const
1487  {
1488  return _img_width;
1489  }
1490 
1491  float scale() const
1492  {
1493  return _scale;
1494  }
1495 
1496  bool apply_scale() const
1497  {
1498  return _apply_scale;
1499  }
1500 
1502  {
1503  return _correct_transform_coords;
1504  }
1505 
1506 private:
1507  float _img_width;
1508  float _img_height;
1509  float _scale;
1510  bool _apply_scale;
1511  bool _correct_transform_coords;
1512  std::array<float, 4> _weights;
1513  float _bbox_xform_clip;
1514 };
1515 
1516 /** Activation Layer Information class */
1518 {
1519 public:
1520  /** Available activation functions */
1522  {
1523  LOGISTIC, /**< Logistic ( \f$ f(x) = \frac{1}{1 + e^{-x}} \f$ ) */
1524  TANH, /**< Hyperbolic tangent ( \f$ f(x) = a \cdot tanh(b \cdot x) \f$ ) */
1525  RELU, /**< Rectifier ( \f$ f(x) = max(0,x) \f$ ) */
1526  BOUNDED_RELU, /**< Upper Bounded Rectifier ( \f$ f(x) = min(a, max(0,x)) \f$ ) */
1527  LU_BOUNDED_RELU, /**< Lower and Upper Bounded Rectifier ( \f$ f(x) = min(a, max(b,x)) \f$ ) */
1528  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$ ) */
1529  SOFT_RELU, /**< Soft Rectifier ( \f$ f(x)= log(1+e^x) \f$ ) */
1530  ELU, /**< Exponential Linear Unit ( \f$ f(x) = \begin{cases} \alpha (exp(x) - 1) & \quad \text{if } x \text{ < 0}\\ x & \quad \text{if } x \geq \text{ 0 } \end{cases} \f$ ) */
1531  ABS, /**< Absolute ( \f$ f(x)= |x| \f$ ) */
1532  SQUARE, /**< Square ( \f$ f(x)= x^2 \f$ )*/
1533  SQRT, /**< Square root ( \f$ f(x) = \sqrt{x} \f$ )*/
1534  LINEAR, /**< Linear ( \f$ f(x)= ax + b \f$ ) */
1535  IDENTITY, /**< Identity ( \f$ f(x)= x \f$ ) */
1536  HARD_SWISH /**< Hard-swish ( \f$ f(x) = (x * relu6(x+3))/6 \f$ ) */
1537  };
1538 
1539  ActivationLayerInfo() = default;
1540  /** Default Constructor
1541  *
1542  * @param[in] f The activation function to use.
1543  * @param[in] a (Optional) The alpha parameter used by some activation functions
1544  * (@ref ActivationFunction::BOUNDED_RELU, @ref ActivationFunction::LU_BOUNDED_RELU, @ref ActivationFunction::LINEAR, @ref ActivationFunction::TANH).
1545  * @param[in] b (Optional) The beta parameter used by some activation functions (@ref ActivationFunction::LINEAR, @ref ActivationFunction::LU_BOUNDED_RELU, @ref ActivationFunction::TANH).
1546  */
1547  ActivationLayerInfo(ActivationFunction f, float a = 0.0f, float b = 0.0f)
1548  : _act(f), _a(a), _b(b), _enabled(true)
1549  {
1550  }
1551  /** Get the type of activation function */
1553  {
1554  return _act;
1555  }
1556  /** Get the alpha value */
1557  float a() const
1558  {
1559  return _a;
1560  }
1561  /** Get the beta value */
1562  float b() const
1563  {
1564  return _b;
1565  }
1566  /** Check if initialised */
1567  bool enabled() const
1568  {
1569  return _enabled;
1570  }
1571 
1572 private:
1574  float _a = {};
1575  float _b = {};
1576  bool _enabled = { false };
1577 };
1578 
1579 /** Fully connected layer info */
1581 {
1582  DataLayout weights_trained_layout{ DataLayout::NCHW }; /**< Layout that the weights have been trained with. */
1583  bool transpose_weights{ true }; /**< Transpose weights if true. */
1584  bool are_weights_reshaped{ false }; /**< Reshape the weights tensor if false. */
1585  bool retain_internal_weights{ false }; /**< Retain internal reshaped weights. */
1586  bool fp_mixed_precision{ false }; /**< Use wider accumulators (32 bit instead of 16 for FP16) to improve accuracy. */
1587  ActivationLayerInfo activation_info{}; /**< Fused activation to apply after the matrix multiplication. */
1588 
1589  /** Sets the weights trained data layout
1590  *
1591  * @param[in] layout Data layout that the weights were trained with
1592  *
1593  * @return Updated object
1594  */
1596  {
1597  weights_trained_layout = layout;
1598  return *this;
1599  }
1600  /** Sets the transpose weights flag
1601  *
1602  * @param[in] should_transpose_weights Boolean flag indicating if weights should be transposed
1603  *
1604  * @return Updated object
1605  */
1606  FullyConnectedLayerInfo &set_transpose_weights(bool should_transpose_weights)
1607  {
1608  transpose_weights = should_transpose_weights;
1609  return *this;
1610  }
1611 };
1612 
1613 /** Normalization Layer Information class */
1615 {
1616 public:
1617  /** Default Constructor
1618  *
1619  * @param[in] type The normalization type. Can be @ref NormType::IN_MAP_1D, @ref NormType::IN_MAP_2D or @ref NormType::CROSS_MAP
1620  * @param[in] norm_size The normalization size is the number of elements to normalize across. Defaults to 5.
1621  * @param[in] alpha (Optional) Alpha parameter used by normalization equation. Defaults to 0.0001.
1622  * @param[in] beta (Optional) Beta parameter used by normalization equation. Defaults to 0.5.
1623  * @param[in] kappa (Optional) Kappa parameter used by [Krichevksy 2012] Across Channel Local Brightness Normalization equation.
1624  * @param[in] is_scaled (Optional) Boolean that specifies if alpha will be scaled by the normalization size or not.
1625  * Should be false to follow [Krichevksy 2012].
1626  */
1627  NormalizationLayerInfo(NormType type, uint32_t norm_size = 5, float alpha = 0.0001f, float beta = 0.5f, float kappa = 1.f, bool is_scaled = true)
1628  : _type(type), _norm_size(norm_size), _alpha(alpha), _beta(beta), _kappa(kappa), _is_scaled(is_scaled)
1629  {
1630  }
1631  /** Get the normalization type */
1632  NormType type() const
1633  {
1634  return _type;
1635  }
1636  /** Get the normalization size */
1637  uint32_t norm_size() const
1638  {
1639  return _norm_size;
1640  }
1641  /** Get the alpha value */
1642  float alpha() const
1643  {
1644  return _alpha;
1645  }
1646  /** Get the beta value */
1647  float beta() const
1648  {
1649  return _beta;
1650  }
1651  /** Get the kappa value */
1652  float kappa() const
1653  {
1654  return _kappa;
1655  }
1656  /** Get the is_scaled value */
1657  bool is_scaled() const
1658  {
1659  return _is_scaled;
1660  }
1661  /** Check if normalization is cross map */
1662  bool is_cross_map() const
1663  {
1664  return _type == NormType::CROSS_MAP;
1665  }
1666  /** Check if normalization is not cross map */
1667  bool is_in_map() const
1668  {
1669  return !is_cross_map();
1670  }
1671  /** Return the scaling factor of the normalization function.
1672  *
1673  * If is_scaled is set to false then [Krichevksy 2012] normalization scaling is performed,
1674  * where alpha is returned plainly, else alpha is scaled by the total number of elements used for the normalization.
1675  *
1676  * @return The normalization scaling factor.
1677  */
1678  float scale_coeff() const
1679  {
1680  const uint32_t size = (_type == NormType::IN_MAP_2D) ? _norm_size * _norm_size : _norm_size;
1681  return (_is_scaled) ? (_alpha / size) : _alpha;
1682  }
1683 
1684 private:
1685  NormType _type;
1686  uint32_t _norm_size;
1687  float _alpha;
1688  float _beta;
1689  float _kappa;
1690  bool _is_scaled;
1691 };
1692 
1693 /** Convolution Layer Weights Information class. This class stores the necessary information to compute convolution layer when the weights are already reshaped */
1695 {
1696 public:
1697  /** Default constructor */
1699  : _are_reshaped(false), _kernel_width(0), _kernel_height(0), _num_kernels(0), _retain_internal_weights(false)
1700  {
1701  }
1702  /** Constructor
1703  *
1704  * @param[in] are_reshaped True if the weights have been reshaped
1705  * @param[in] kernel_width Kernel width.
1706  * @param[in] kernel_height Kernel height.
1707  * @param[in] num_kernels Number of convolution kernels.
1708  * @param[in] retain_internal_weights (Optional) True if internal reshaped weights must be retained. Used for reconfiguration purposes. Default is false.
1709  */
1710  WeightsInfo(bool are_reshaped, unsigned int kernel_width, unsigned int kernel_height, unsigned int num_kernels, bool retain_internal_weights = false)
1711  : _are_reshaped(are_reshaped), _kernel_width(kernel_width), _kernel_height(kernel_height), _num_kernels(num_kernels), _retain_internal_weights(retain_internal_weights)
1712  {
1713  }
1714  /** Flag which specifies if the weights tensor has been reshaped.
1715  *
1716  * @return True if the weights tensors has been reshaped
1717  */
1718  bool are_reshaped() const
1719  {
1720  return _are_reshaped;
1721  };
1722  /** Return the number of convolution kernels
1723  *
1724  * @return The number of convolution kernels
1725  */
1726  unsigned int num_kernels() const
1727  {
1728  return _num_kernels;
1729  };
1730  /** Return the width and height of the kernel
1731  *
1732  * @return The width and height of the kernel
1733  */
1734  std::pair<unsigned int, unsigned int> kernel_size() const
1735  {
1736  return std::make_pair(_kernel_width, _kernel_height);
1737  }
1739  {
1740  return _retain_internal_weights;
1741  }
1742 
1743 private:
1744  const bool _are_reshaped;
1745  const unsigned int _kernel_width;
1746  const unsigned int _kernel_height;
1747  const unsigned int _num_kernels;
1748  const bool _retain_internal_weights;
1749 };
1750 
1751 /** GEMM reshape information class. This class stores the necessary information about matrix A and matrix B reshape.
1752  *
1753  * The matrix A can only be reshaped through @ref CLGEMMReshapeLHSMatrixKernel or @ref NEGEMMInterleave4x4Kernel or @ref GCGEMMInterleave4x4Kernel
1754  * Note: Optionally just for @ref CLGEMMReshapeLHSMatrixKernel is it possible to set mult_interleave4x4_height, the multiplication factor for the height of the 4x4 interleaved block
1755  *
1756  * The matrix B can only be reshaped through @ref CLGEMMReshapeRHSMatrixKernel or @ref NEGEMMTranspose1xWKernel or @ref GCGEMMTranspose1xWKernel
1757  * 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
1758  *
1759  */
1760 class GEMMReshapeInfo final
1761 {
1762 public:
1763  /** Default constructor */
1765  : _m(1), _n(1), _k(1), _mult_transpose1xW_width(1), _mult_interleave4x4_height(1), _depth_output_gemm3d(0), _reinterpret_input_as_3d(false), _broadcast_bias(false)
1766  {
1767  }
1768  /** Constructor
1769  *
1770  * @param[in] m Number of matrix A rows
1771  * @param[in] n Number of matrix B columns
1772  * @param[in] k Number of matrix A columns or matrix B rows
1773  * @param[in] mult_transpose1xW_width (Optional) Multiplication factor for the width of the 1xW transposed block
1774  * @param[in] mult_interleave4x4_height (Optional) Multiplication factor for the height of the 4x4 interleaved block
1775  * @param[in] depth_output_gemm3d (Optional) Depth (third dimension) of the output tensor to be used with the GEMM3D kernel.
1776  * If 0 the output will not be reinterpreted as 3D. Default 0
1777  * @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
1778  * to perform 1x1 convolutions with the NHWC data layout)
1779  * @param[in] broadcast_bias (Optional) Broadcast the shape of the bias tensor from a vector to a matrix.
1780  */
1782  : _m(m), _n(n), _k(k), _mult_transpose1xW_width(mult_transpose1xW_width), _mult_interleave4x4_height(mult_interleave4x4_height), _depth_output_gemm3d(depth_output_gemm3d),
1783  _reinterpret_input_as_3d(reinterpret_input_as_3d), _broadcast_bias(broadcast_bias)
1784  {
1785  }
1786  /** Number of matrix A rows
1787  *
1788  * @return the number of matrix A rows
1789  */
1790  int m() const
1791  {
1792  return _m;
1793  }
1794  /** Number of matrix B columns
1795  *
1796  * @return the number of matrix B columns
1797  */
1798  int n() const
1799  {
1800  return _n;
1801  }
1802  /** Number of matrix A columns or matrix B rows
1803  *
1804  * @return the number of matrix A columns or matrix B rows
1805  */
1806  int k() const
1807  {
1808  return _k;
1809  }
1810  /** Multiplication factor for the width of the 1xW transposed block
1811  *
1812  * @return the multiplication factor for the width of the 1xW transposed block
1813  */
1815  {
1816  return _mult_transpose1xW_width;
1817  }
1818  /** Multiplication factor for the height of the 4x4 interleaved block
1819  *
1820  * @return the multiplication factor for the height of the 4x4 interleaved block
1821  */
1823  {
1824  return _mult_interleave4x4_height;
1825  }
1826  /** Depth (third dimension) of the output tensor to be used with the GEMM3D kernel
1827  *
1828  * @note GEMM3D kernel is used when the output has to be reinterpret as 3D tensor. In that case:
1829  * m = depth_output_gemm3d * output_height
1830  *
1831  * @return the depth of the output tensor to be used with the GEMM3D kernel
1832  */
1834  {
1835  return _depth_output_gemm3d;
1836  }
1837  /** Flag which specifies if the input tensor has to be reinterpreted as 3D
1838  *
1839  * @return True if the input tensor has to be reinterpreted as 3D tensor
1840  */
1842  {
1843  return _reinterpret_input_as_3d;
1844  };
1845  /** Flag which specifies whether to broadcast the shape of the bias tensor.
1846  *
1847  * @return True if the shape of the bias tensor is to be broadcasted.
1848  */
1849  bool broadcast_bias() const
1850  {
1851  return _broadcast_bias;
1852  };
1853 
1854 private:
1855  const int _m;
1856  const int _n;
1857  const int _k;
1858  const int _mult_transpose1xW_width;
1859  const int _mult_interleave4x4_height;
1860  const int _depth_output_gemm3d;
1861  const bool _reinterpret_input_as_3d;
1862  const bool _broadcast_bias;
1863 };
1864 
1866 {
1867  unsigned int c0{ 1 }; /**< Number of channels processed by the depth-wise convolution */
1868  bool transpose{ false }; /**< True if the block MxC0 (where M is the area of the filter i.e. KwxKh) has to be transposed */
1869 };
1870 
1871 /** GEMMLowp output stage type */
1873 {
1874  NONE, /**< No quantization */
1875  QUANTIZE_DOWN, /**< Quantize using an integer multiplication */
1876  QUANTIZE_DOWN_FIXEDPOINT, /**< Quantize using a fixed point multiplication */
1877  QUANTIZE_DOWN_FLOAT /**< Quantize using a floating point multiplication */
1878 };
1879 
1880 /** GEMMLowp output stage info */
1882 {
1883  GEMMLowpOutputStageType type{ GEMMLowpOutputStageType::NONE }; /**< GEMMLowp output stage type */
1884  int32_t gemmlowp_offset{ 0 }; /**< GEMMLowp output stage offset used for quantizing to QASYMM8 */
1885  int32_t gemmlowp_multiplier{ 0 }; /**< GEMMLowp output stage multiplier used for quantizing to QASYMM8 */
1886  int32_t gemmlowp_shift{ 0 }; /**< GEMMLowp output stage shift used for quantizing to uint8 */
1887  int32_t gemmlowp_min_bound{ std::numeric_limits<int32_t>::lowest() }; /**< GEMMLowp min value used to saturate down the output result before converting back to QASYMM8 */
1888  int32_t gemmlowp_max_bound{ std::numeric_limits<int32_t>::max() }; /**< GEMMLowp max value used to saturate down the output result before converting back to QASYMM8 */
1889  std::vector<int32_t> gemmlowp_multipliers{}; /**< GEMMLowp output stage multiplier used for quantizing to QASYMM8 */
1890  std::vector<int32_t> gemmlowp_shifts{}; /**< GEMMLowp output stage multiplier used for quantizing to QASYMM8 */
1891  float gemmlowp_real_multiplier{ 0 }; /**< GEMMLowp output stage real multiplier used for quantizing to QASYMM8 */
1892  bool is_quantized_per_channel{ false }; /**< GEMMLowp quantized per-channel flag */
1893  DataType output_data_type{ DataType::UNKNOWN }; /**< Output tensor data type to use if the output is not initialized */
1894 };
1895 
1896 /** GEMM LHS (Left Hand Side) matrix information */
1898 {
1899  GEMMLHSMatrixInfo() = default;
1900  GEMMLHSMatrixInfo(unsigned int m, unsigned int k, unsigned int v, bool trans, bool inter)
1901  : m0(m), k0(k), v0(v), transpose(trans), interleave(inter)
1902  {
1903  }
1904  unsigned int m0{ 1 }; /**< Number of rows processed by the matrix multiplication */
1905  unsigned int k0{ 1 }; /**< Number of partial accumulations performed by the matrix multiplication */
1906  unsigned int v0{ 1 }; /**< Number of vertical blocks of size (m0xk0) stored on the same output row */
1907  bool transpose{ true }; /**< True if the (m0xk0) block has to be transposed before been stored */
1908  bool interleave{ true }; /**< True if the v0 (m0xk0) blocks have to be interleaved in the output row */
1909 };
1910 
1911 /** GEMM RHS (Right Hand Side) matrix information */
1913 {
1914  GEMMRHSMatrixInfo() = default;
1915  GEMMRHSMatrixInfo(unsigned int n, unsigned int k, unsigned int h, bool trans, bool inter)
1916  : n0(n), k0(k), h0(h), transpose(trans), interleave(inter)
1917  {
1918  }
1919  unsigned int n0{ 1 }; /**< Number of columns processed by the matrix multiplication */
1920  unsigned int k0{ 1 }; /**< Number of partial accumulations performed by the matrix multiplication */
1921  unsigned int h0{ 1 }; /**< Number of horizontal blocks of size (k0xn0) stored on the same output row */
1922  bool transpose{ true }; /**< True if the (k0xn0) block has to be transposed before been stored */
1923  bool interleave{ true }; /**< True if the h0 (k0xn0) blocks have to be interleaved in the output row */
1924 };
1925 
1926 /** GEMM information class. This class stores the necessary information to compute GEMM functions
1927  *
1928  * This object also contains the information about how matrix A and matrix B have been reshaped
1929  *
1930  */
1932 {
1933 public:
1934  /** Default constructor */
1935  GEMMInfo() noexcept
1936  : _is_a_reshaped(false),
1937  _is_b_reshaped(false),
1938  _reshape_b_only_on_first_run(true),
1939  _depth_output_gemm3d(0),
1940  _reinterpret_input_as_3d(false),
1941  _retain_internal_weights(false),
1942  _gemmlowp_output_stage(),
1943  _fp_mixed_precision(false),
1944  _broadcast_bias(false),
1945  _pretranpose_B(true),
1946  _activation_info()
1947  {
1948  }
1949  /** Constructor
1950  *
1951  * @param[in] is_a_reshaped True if the matrix A has been reshaped
1952  * @param[in] is_b_reshaped True if the matrix B has been reshaped
1953  * @param[in] reshape_b_only_on_first_run Reshape matrix B only for the first run
1954  * @param[in] depth_output_gemm3d (Optional) Depth (third dimension) of the output tensor to be used with the GEMM3D kernel
1955  * If 0 the output will not be reinterpreted as 3D. Default 0
1956  * @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
1957  * to perform 1x1 convolutions with the NHWC data layout)
1958  * @param[in] retain_internal_weights (Optional) Retain the weights tensor from previous run
1959  * @param[in] gemmlowp_output_stage (Optional) GEMMLowp Output stage info
1960  * @param[in] fp_mixed_precision (Optional) Use wider accumulators (32 bit instead of 16 for FP16) to improve accuracy.
1961  * @param[in] broadcast_bias (Optional) Broadcast the shape of the bias tensor from a vector to a matrix.
1962  * @param[in] activation_info (Optional) Activation to apply after the matrix multiplication
1963  */
1967  : _is_a_reshaped(is_a_reshaped),
1968  _is_b_reshaped(is_b_reshaped),
1969  _reshape_b_only_on_first_run(reshape_b_only_on_first_run),
1970  _depth_output_gemm3d(depth_output_gemm3d),
1971  _reinterpret_input_as_3d(reinterpret_input_as_3d),
1972  _retain_internal_weights(retain_internal_weights),
1973  _gemmlowp_output_stage(gemmlowp_output_stage),
1974  _fp_mixed_precision(fp_mixed_precision),
1975  _broadcast_bias(broadcast_bias),
1976  _pretranpose_B(reshape_b_only_on_first_run),
1977  _activation_info(activation_info)
1978  {
1979  }
1980  /** Flag which specifies if the matrix A has been reshaped
1981  *
1982  * @return True if the matrix A has been reshaped
1983  */
1984  bool is_a_reshaped() const
1985  {
1986  return _is_a_reshaped;
1987  };
1988  /** Flag which specifies if the matrix B has been reshaped
1989  *
1990  * @return True if the matrix B has been reshaped
1991  */
1992  bool is_b_reshaped() const
1993  {
1994  return _is_b_reshaped;
1995  };
1996  /** Flag which specifies if the reshape of matrix B should executed only for the first
1997  *
1998  * @note This flag could be set to TRUE when GEMM is used to accelerate convolution layer
1999  *
2000  * @return True if the reshaped of matrix B happens only for the first run
2001  */
2003  {
2004  return _reshape_b_only_on_first_run;
2005  };
2006  /** Depth of the output when GEMM output is reinterpreted as 3D tensor
2007  *
2008  * @return the depth of the output tensor
2009  */
2011  {
2012  return _depth_output_gemm3d;
2013  };
2014  /** Flag which specifies if the input tensor has to be reinterpreted as 3D
2015  *
2016  * @return True if the input tensor has to be reinterpreted as 3D tensor
2017  */
2019  {
2020  return _reinterpret_input_as_3d;
2021  };
2022  /** Flag which specifies if the weights tensor has to be retained from previous run
2023  *
2024  * @return True if the weights tensor has to be retained
2025  */
2027  {
2028  return _retain_internal_weights;
2029  };
2030  /** GEMMLowp output stage
2031  *
2032  * @return the GEMMLowp output stage info
2033  */
2035  {
2036  return _gemmlowp_output_stage;
2037  };
2038  /** Sets GEMMLowp output stage
2039  *
2040  * @param[in] output_stage Output stage to set
2041  */
2043  {
2044  _gemmlowp_output_stage = output_stage;
2045  };
2046  /** Flag which specifies if a wider accumulator should be used.
2047  *
2048  * @return True if a wider accumulator has to be used
2049  */
2050  bool fp_mixed_precision() const
2051  {
2052  return _fp_mixed_precision;
2053  };
2054  /** Flag which specifies whether to broadcast the shape of the bias tensor.
2055  *
2056  * @return True if the shape of the bias tensor is to be broadcasted.
2057  */
2058  bool broadcast_bias() const
2059  {
2060  return _broadcast_bias;
2061  };
2062  /** Flag which specifies whether b should be pre-transposed if supported.
2063  *
2064  * @return True if b should be pre-transposed else false.
2065  */
2066  bool pretranpose_B() const
2067  {
2068  return _pretranpose_B;
2069  };
2070  /** Set pre-transpose b flag
2071  *
2072  * @param[in] flag Flag to set
2073  */
2074  void set_pretranpose_B(bool flag)
2075  {
2076  _pretranpose_B = flag;
2077  }
2078  /** Activation layer to apply after the matrix multiplication
2079  *
2080  * @return ActivationLayerInfo object
2081  */
2083  {
2084  return _activation_info;
2085  }
2086  /** Set activation layer info
2087  *
2088  * @param[in] activation_info ActivationLayerInfo object to set
2089  */
2091  {
2092  _activation_info = activation_info;
2093  }
2094 
2095 private:
2096  bool _is_a_reshaped;
2097  bool _is_b_reshaped;
2098  bool _reshape_b_only_on_first_run;
2099  int _depth_output_gemm3d;
2100  bool _reinterpret_input_as_3d;
2101  bool _retain_internal_weights;
2102  GEMMLowpOutputStageInfo _gemmlowp_output_stage;
2103  bool _fp_mixed_precision;
2104  bool _broadcast_bias;
2105  bool _pretranpose_B;
2106  ActivationLayerInfo _activation_info;
2107 };
2108 
2109 /** Winograd information */
2111 {
2112  /** Default constructor
2113  *
2114  * @param[in] output_tile_sz Width and height of the output tile
2115  * @param[in] kernel_sz Width and height of the kernel
2116  * @param[in] input_dims Width and height of the input tensor before the convolution is applied
2117  * @param[in] conv_info Convolution info (Pads, strides)
2118  * @param[in] data_layout Data layout to use for the output tensor once the convolution has been applied
2119  */
2122  {
2123  }
2124 
2125  Size2D output_tile_size{}; /**< Width and height of the output tile */
2126  Size2D kernel_size{}; /**< Width and height of the kernel*/
2127  Size2D input_dimensions{}; /**< Width and height of the input tensor before the convolution is applied */
2128  PadStrideInfo convolution_info{}; /**< Convolution info (Pads, strides,...) */
2129  DataLayout output_data_layout{ DataLayout::NCHW }; /**< Data layout to use for the output tensor once the convolution has been applied (NCHW or NHWC) */
2130 };
2131 
2132 /** IO formatting information class*/
2134 {
2135  /** Precision type used when printing floating point numbers */
2136  enum class PrecisionType
2137  {
2138  Default, /**< Default precision to the one that the current stream has */
2139  Custom, /**< Custom precision specified by the user using the precision parameter */
2140  Full /**< The maximum precision of the floating point representation */
2141  };
2142 
2143  /** Specifies the area to be printed, used by Tensor objects */
2144  enum class PrintRegion
2145  {
2146  ValidRegion, /**< Prints the valid region of the Tensor object */
2147  NoPadding, /**< Prints the Tensor object without the padding */
2148  Full /**< Print the tensor object including padding */
2149  };
2150 
2151  /** Construct a set of IO formatting information.
2152  *
2153  * @param[in] print_region Area to be printed. Used by Tensor objects. Default: ValidRegion.
2154  * @param[in] precision_type Precision type for floating point numbers. Default: stream default.
2155  * @param[in] precision Precision value for float point numbers. Default: 10.
2156  * @param[in] align_columns Whether to align columns when printed. Default: true.
2157  * @param[in] element_delim Delimeter between elements. Default: " ".
2158  * @param[in] row_delim Delimenter between rows. Default: "\n".
2159  */
2162  unsigned int precision = 10,
2163  bool align_columns = true,
2164  std::string element_delim = " ",
2165  std::string row_delim = "\n")
2172  {
2173  }
2174 
2175  /** Area to be printed by Tensor objects */
2177  /** Floating point precision type */
2179  /** Floating point precision */
2180  unsigned int precision;
2181  /** Element delimeter */
2182  std::string element_delim;
2183  /** Row delimeter */
2184  std::string row_delim;
2185  /** Align columns */
2187 };
2188 } // namespace arm_compute
2189 #endif /* ARM_COMPUTE_TYPES_H */
float scale_coeff() const
Return the scaling factor of the normalization function.
Definition: Types.h:1678
BorderMode
Methods available to handle borders.
Definition: Types.h:264
ValidRegion(const Coordinates &an_anchor, const TensorShape &a_shape, size_t num_dimensions)
Constructor for a valid region with specified number of dimensions.
Definition: Types.h:225
Rectangle type.
Definition: Types.h:431
PrecisionType precision_type
Floating point precision type.
Definition: Types.h:2178
void set_pretranpose_B(bool flag)
Set pre-transpose b flag.
Definition: Types.h:2074
constexpr float SCALE_PYRAMID_ORB
Constant value used to indicate a ORB scaled pyramid.
Definition: Types.h:115
Coordinate type.
Definition: Types.h:447
DeconvolutionMethod
Available DeconvolutionMethod.
Definition: Types.h:154
ValidRegion & set(size_t dimension, int start, size_t size)
Accessor to set the value of anchor and shape for one of the dimensions.
Definition: Types.h:252
ValidRegion & operator=(const ValidRegion &)=default
Allow instances of this class to be copied.
GEMMLHSMatrixInfo(unsigned int m, unsigned int k, unsigned int v, bool trans, bool inter)
Definition: Types.h:1900
constexpr float SCALE_PYRAMID_HALF
Constant value used to indicate a half-scale pyramid.
Definition: Types.h:112
unsigned int top
top of the border
Definition: Types.h:352
L2-norm followed by clipping.
A single plane of 32-bit macro pixel of U0, Y0, V0, Y1 byte.
ArithmeticOperation
Available element-wise operations.
Definition: Types.h:511
InterpolationPolicy
Interpolation method.
Definition: Types.h:369
int num_classes() const
Get num classes.
Definition: Types.h:992
int mult_interleave4x4_height() const
Multiplication factor for the height of the 4x4 interleaved block.
Definition: Types.h:1822
int32_t gemmlowp_multiplier
GEMMLowp output stage multiplier used for quantizing to QASYMM8.
Definition: Types.h:1885
float scale
Scale initialized to 0 by the corner detector.
Definition: Types.h:421
Generate Proposals Information class.
Definition: Types.h:1319
Second channel (used by formats with unknown channel types).
DepthwiseConvolutionFunction
Available DepthwiseConvolutionFunction.
Definition: Types.h:147
Shape of a tensor.
Definition: TensorShape.h:39
const DataLayout data_layout
Definition: Im2Col.cpp:146
float kappa() const
Get the kappa value.
Definition: Types.h:1652
Quantize using a fixed point multiplication.
uint32_t x
X coordinates.
Definition: Types.h:449
bool share_location() const
Get share location.
Definition: Types.h:997
float im_width() const
Get image width (NMS may suppress boxes whose center sits beyond the image width)
Definition: Types.h:664
FullyConnectedLayerInfo & set_weights_trained_layout(DataLayout layout)
Sets the weights trained data layout.
Definition: Types.h:1595
DetectionPostProcessLayerInfo(unsigned int max_detections, unsigned int max_classes_per_detection, float nms_score_threshold, float iou_threshold, unsigned int num_classes, std::array< float, 4 > scales_values, bool use_regular_nms=false, unsigned int detection_per_class=100, bool dequantize_scores=true)
Constructor.
Definition: Types.h:1090
float scale_value_x() const
Get x scale value.
Definition: Types.h:1145
float score_thresh() const
Get the score threshold.
Definition: Types.h:619
DataLayout output_data_layout
Data layout to use for the output tensor once the convolution has been applied (NCHW or NHWC)
Definition: Types.h:2129
DimensionRoundingType round() const
Get the rounding type.
Definition: Types.h:784
quantized, symmetric fixed-point 16-bit number
void set_activation_info(const ActivationLayerInfo &activation_info)
Set activation layer info.
Definition: Types.h:2090
BorderSize operator *(float scale)
Scale a copy of this border size.
Definition: Types.h:332
~ValidRegion()=default
Default destructor.
ROIPoolingLayerInfo(unsigned int pooled_width, unsigned int pooled_height, float spatial_scale, unsigned int sampling_ratio=0)
Constructor.
Definition: Types.h:1286
uint16_t x
Top-left x coordinate.
Definition: Types.h:559
TensorShape shape
Shape of the valid region.
Definition: Types.h:260
WinogradInfo(Size2D output_tile_sz, Size2D kernel_sz, Size2D input_dims, PadStrideInfo conv_info, DataLayout data_layout)
Default constructor.
Definition: Types.h:2120
float score
Confidence value for the detection window.
Definition: Types.h:564
Angle range: [0, 180].
bool is_in_map() const
Check if normalization is not cross map.
Definition: Types.h:1667
bool enabled() const
Check if initialised.
Definition: Types.h:1567
std::vector< PaddingInfo > PaddingList
List of padding information.
Definition: Types.h:458
ReductionOperation
Available reduction operations.
Definition: Types.h:498
Container for 2D border size.
Definition: Types.h:272
bool retain_internal_weights
Retain internal reshaped weights.
Definition: Types.h:1585
size_t values_per_roi() const
Definition: Types.h:1437
ActivationLayerInfo(ActivationFunction f, float a=0.0f, float b=0.0f)
Default Constructor.
Definition: Types.h:1547
int32_t x
X coordinates.
Definition: Types.h:418
Angle range: [0, 360].
std::map< int, std::vector< BBox > > LabelBBox
Definition: Types.h:931
PhaseType
Phase calculation type.
Definition: Types.h:409
unsigned int max_detections() const
Get max detections.
Definition: Types.h:1104
float orientation
Orientation initialized to 0 by the corner detector.
Definition: Types.h:422
Cr/V/Value channel.
unsigned int v0
Number of vertical blocks of size (m0xk0) stored on the same output row.
Definition: Types.h:1906
Prints the Tensor object without the padding.
DataLayoutDimension
[DataLayout enum definition]
Definition: Types.h:129
BoxWithNonMaximaSuppressionLimit Information class.
Definition: Types.h:593
PoolingLayerInfo(PoolingType pool_type, DataLayout data_layout)
Constructor.
Definition: Types.h:1255
Winograd information.
Definition: Types.h:2110
uint32_t norm_size() const
Get the normalization size.
Definition: Types.h:1637
1 channel, 1 U8 per channel
NormType type() const
Get the normalization type.
Definition: Types.h:1632
int mult_transpose1xW_width() const
Multiplication factor for the width of the 1xW transposed block.
Definition: Types.h:1814
int32_t tracking_status
Status initialized to 1 by the corner detector, set to 0 when the point is lost.
Definition: Types.h:423
Terminate when within epsilon of a threshold.
float a() const
Get the alpha value.
Definition: Types.h:1557
GEMM reshape information class.
Definition: Types.h:1760
PadStrideInfo convolution_info
Convolution info (Pads, strides,...)
Definition: Types.h:2128
2D Coordinates structure
Definition: types.h:28
std::vector< float > aspect_ratios() const
Get aspect ratios.
Definition: Types.h:911
PriorBoxLayerInfo(const std::vector< float > &min_sizes, const std::vector< float > &variances, float offset, bool flip=true, bool clip=false, const std::vector< float > &max_sizes={}, const std::vector< float > &aspect_ratios={}, const Coordinates2D &img_size=Coordinates2D{ 0, 0 }, const std::array< float, 2 > &steps={ { 0.f, 0.f } })
Constructor.
Definition: Types.h:834
FullyConnectedLayerInfo & set_transpose_weights(bool should_transpose_weights)
Sets the transpose weights flag.
Definition: Types.h:1606
GEMMLowpOutputStageInfo gemmlowp_output_stage() const
GEMMLowp output stage.
Definition: Types.h:2034
bool are_reshaped() const
Flag which specifies if the weights tensor has been reshaped.
Definition: Types.h:1718
half_float::half half
16-bit floating point type
Definition: Types.h:46
1 channel, 1 F32 per channel
Custom precision specified by the user using the precision parameter.
DimensionRoundingType
Dimension rounding type when down-scaling on CNNs.
Definition: Types.h:570
Normalization Layer Information class.
Definition: Types.h:1614
Unknown channel format.
Output values are defined by bilinear interpolation between the pixels.
unsigned int h0
Number of horizontal blocks of size (k0xn0) stored on the same output row.
Definition: Types.h:1921
unsigned int precision
Floating point precision.
Definition: Types.h:2180
bool is_cross_map() const
Check if normalization is cross map.
Definition: Types.h:1662
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:466
Fully connected layer info.
Definition: Types.h:1580
bool fp_mixed_precision() const
Flag which specifies if a wider accumulator should be used.
Definition: Types.h:2050
BilinearInterpolation
Bilinear Interpolation method used by LKTracker.
Definition: Types.h:377
GEMM LHS (Left Hand Side) matrix information.
Definition: Types.h:1897
bool pretranpose_B() const
Flag which specifies whether b should be pre-transposed if supported.
Definition: Types.h:2066
A 2 plane YUV format of Luma (Y) and interleaved UV data at 4:2:0 sampling.
Terminate after a maximum number of iterations.
constexpr uint8_t CONSTANT_BORDER_VALUE
Constant value of the border pixels when using BorderMode::CONSTANT.
Definition: Types.h:109
PoolingLayerInfo()
Default Constructor.
Definition: Types.h:1184
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, bool broadcast_bias=false)
Constructor.
Definition: Types.h:1781
quantized, asymmetric fixed-point 16-bit number
ThresholdType
Threshold mode.
Definition: Types.h:384
1 channel, 1 U16 per channel
unsigned int bottom
bottom of the border
Definition: Types.h:354
int32_t gemmlowp_offset
GEMMLowp output stage offset used for quantizing to QASYMM8.
Definition: Types.h:1884
float eta() const
Get eta.
Definition: Types.h:1022
int depth_output_gemm3d() const
Depth of the output when GEMM output is reinterpreted as 3D tensor.
Definition: Types.h:2010
PrintRegion print_region
Area to be printed by Tensor objects.
Definition: Types.h:2176
unsigned int pooled_width() const
Get the pooled width of the layer.
Definition: Types.h:1291
unsigned int pad_top() const
Get the top padding.
Definition: Types.h:773
Output values are defined to match the source pixel whose center is nearest to the sample position.
BorderSize & operator *=(float scale)
Scale this border size.
Definition: Types.h:316
int32_t gemmlowp_max_bound
GEMMLowp max value used to saturate down the output result before converting back to QASYMM8.
Definition: Types.h:1888
DetectionPostProcessLayerInfo()
Default Constructor.
Definition: Types.h:1066
bool retain_internal_weights() const
Flag which specifies if the weights tensor has to be retained from previous run.
Definition: Types.h:2026
DetectionOutputLayerCodeType
Available Detection Output code types.
Definition: Types.h:934
void set(size_t dimension, T value)
Accessor to set the value of one of the dimensions.
Definition: Dimensions.h:74
ConvolutionMethod
Available ConvolutionMethod.
Definition: Types.h:138
Activation Layer Information class.
Definition: Types.h:1517
GEMMLowpOutputStageType type
GEMMLowp output stage type.
Definition: Types.h:1883
float spatial_scale() const
Definition: Types.h:1431
Terminate on whichever of the other conditions occurs first.
A 2 plane YUV format of Luma (Y) and interleaved VU data at 4:2:0 sampling.
bool use_regular_nms() const
Get if use regular nms.
Definition: Types.h:1134
bool transpose
True if the (k0xn0) block has to be transposed before been stored.
Definition: Types.h:1922
bool interleave
True if the v0 (m0xk0) blocks have to be interleaved in the output row.
Definition: Types.h:1908
int top_k() const
Get top K.
Definition: Types.h:1037
constexpr BorderSize(unsigned int top_bottom, unsigned int left_right)
Border with same size for top/bottom and left/right.
Definition: Types.h:287
Copyright (c) 2017-2020 ARM Limited.
WeightsInfo()
Default constructor.
Definition: Types.h:1698
bool suppress_size() const
Get if NMS will suppress boxes based on their size/position.
Definition: Types.h:654
bool is_b_reshaped() const
Flag which specifies if the matrix B has been reshaped.
Definition: Types.h:1992
int32_t x
X coordinates.
Definition: Types.h:442
ActivationFunction
Available activation functions.
Definition: Types.h:1521
1 channel, 1 F16 per channel
Samples are taken at pixel center.
float iou_threshold() const
Get intersection over union threshold.
Definition: Types.h:1124
BoxNMSLimitInfo(float score_thresh=0.05f, float nms=0.3f, int detections=100, bool soft_nms_enabled=false, NMSType soft_nms_method=NMSType::LINEAR, 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)
Constructor.
Definition: Types.h:610
Keypoint type.
Definition: Types.h:416
uint32_t z
Z coordinates.
Definition: Types.h:451
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, size_t values_per_roi=4)
Constructor.
Definition: Types.h:1334
float strength
Strength of the point.
Definition: Types.h:420
NMSType
Available non maxima suppression types.
Definition: Types.h:585
bool is_quantized_per_channel
GEMMLowp quantized per-channel flag.
Definition: Types.h:1892
Convolution Layer Weights Information class.
Definition: Types.h:1694
std::vector< int32_t > gemmlowp_shifts
GEMMLowp output stage multiplier used for quantizing to QASYMM8.
Definition: Types.h:1890
DetectionOutputLayerInfo()
Default Constructor.
Definition: Types.h:947
1 channel, 1 S32 per channel
bool variance_encoded_in_target() const
Get if variance encoded in target.
Definition: Types.h:1007
16-bit brain floating-point number
bool transpose
True if the (m0xk0) block has to be transposed before been stored.
Definition: Types.h:1907
signed 64-bit number
int n() const
Number of matrix B columns.
Definition: Types.h:1798
3 channels, 1 U8 per channel
NormalizationLayerInfo(NormType type, uint32_t norm_size=5, float alpha=0.0001f, float beta=0.5f, float kappa=1.f, bool is_scaled=true)
Default Constructor.
Definition: Types.h:1627
FuseBatchNormalizationType
Available FuseBatchNormalizationType.
Definition: Types.h:161
unsigned int k0
Number of partial accumulations performed by the matrix multiplication.
Definition: Types.h:1920
IOFormatInfo(PrintRegion print_region=PrintRegion::ValidRegion, PrecisionType precision_type=PrecisionType::Default, unsigned int precision=10, bool align_columns=true, std::string element_delim=" ", std::string row_delim="\n")
Construct a set of IO formatting information.
Definition: Types.h:2160
float error
Tracking error initialized to 0 by the corner detector.
Definition: Types.h:424
int32_t y
Y coordinates.
Definition: Types.h:443
PoolingLayerInfo(PoolingType pool_type, Size2D pool_size, DataLayout data_layout, PadStrideInfo pad_stride_info=PadStrideInfo(), bool exclude_padding=false, bool fp_mixed_precision=false)
Constructor.
Definition: Types.h:1232
std::array< float, 2 > steps() const
Get the step coordinates.
Definition: Types.h:881
float nms() const
Get the NMS.
Definition: Types.h:624
float nms_threshold() const
Get nms threshold.
Definition: Types.h:1017
Third channel (used by formats with unknown channel types).
bool padding_is_symmetric() const
Check whether the padding is symmetric.
Definition: Types.h:745
bool is_scaled() const
Get the is_scaled value.
Definition: Types.h:1657
1 channel, 1 U32 per channel
GEMM RHS (Right Hand Side) matrix information.
Definition: Types.h:1912
Normalization applied within the same map in 1D region.
Size2D output_tile_size
Width and height of the output tile.
Definition: Types.h:2125
Channel
Available channels.
Definition: Types.h:464
Format
Image colour formats.
Definition: Types.h:54
std::string row_delim
Row delimeter.
Definition: Types.h:2184
PaddingMode
Padding mode to use for PadLayer.
Definition: Types.h:168
Print the tensor object including padding.
IO formatting information class.
Definition: Types.h:2133
uint16_t width
Width of the detection window.
Definition: Types.h:561
unsigned int n0
Number of columns processed by the matrix multiplication.
Definition: Types.h:1919
quantized, asymmetric fixed-point 8-bit number unsigned
bool are_weights_reshaped
Reshape the weights tensor if false.
Definition: Types.h:1584
int start(unsigned int d) const
Return the start of the valid region for the given dimension d.
Definition: Types.h:233
Coordinates of an item.
Definition: Coordinates.h:37
float scale_value_h() const
Get h scale value.
Definition: Types.h:1151
std::pair< unsigned int, unsigned int > stride() const
Get the stride.
Definition: Types.h:737
float scale_value_w() const
Get w scale value.
Definition: Types.h:1157
Pooling Layer Information struct.
Definition: Types.h:1181
std::vector< int32_t > gemmlowp_multipliers
GEMMLowp output stage multiplier used for quantizing to QASYMM8.
Definition: Types.h:1889
float nms_score_threshold() const
Get nms threshold.
Definition: Types.h:1119
float soft_nms_min_score_thres() const
Get soft nms min score threshold.
Definition: Types.h:649
WeightsInfo(bool are_reshaped, unsigned int kernel_width, unsigned int kernel_height, unsigned int num_kernels, bool retain_internal_weights=false)
Constructor.
Definition: Types.h:1710
std::array< float, 4 > BBox
Definition: Types.h:929
float gemmlowp_real_multiplier
GEMMLowp output stage real multiplier used for quantizing to QASYMM8.
Definition: Types.h:1891
bool dequantize_scores() const
Get dequantize_scores value.
Definition: Types.h:1163
GEMMLowp output stage info.
Definition: Types.h:1881
A 3 plane of 8 bit 4:4:4 sampled Y, U, V planes.
Samples are taken at pixel top left corner.
PriorBox layer info.
Definition: Types.h:806
float offset() const
Get the offset.
Definition: Types.h:891
Fourth channel (used by formats with unknown channel types).
DetectionOutputLayerCodeType code_type() const
Get detection output code type.
Definition: Types.h:1002
unsigned int pad_right() const
Get the right padding.
Definition: Types.h:768
float beta() const
Get the beta value.
Definition: Types.h:1647
int k() const
Number of matrix A columns or matrix B rows.
Definition: Types.h:1806
Quantize using a floating point multiplication.
Padding and stride information class.
Definition: Types.h:689
ComparisonOperation
Supported comparison operations.
Definition: Types.h:176
PoolingLayerInfo(PoolingType pool_type, unsigned int pool_size, DataLayout data_layout, PadStrideInfo pad_stride_info=PadStrideInfo(), bool exclude_padding=false, bool fp_mixed_precision=false)
Constructor.
Definition: Types.h:1205
GEMMLowpOutputStageType
GEMMLowp output stage type.
Definition: Types.h:1872
Termination
Termination criteria.
Definition: Types.h:391
Coordinates2D img_size() const
Get the image size coordinates.
Definition: Types.h:886
unsigned int c0
Number of channels processed by the depth-wise convolution.
Definition: Types.h:1867
constexpr BorderSize(unsigned int size)
Border with equal size around the 2D plane.
Definition: Types.h:281
ActivationLayerInfo activation_info
Fused activation to apply after the matrix multiplication.
Definition: Types.h:1587
bool align_columns
Align columns.
Definition: Types.h:2186
unsigned int num_kernels() const
Return the number of convolution kernels.
Definition: Types.h:1726
bool reinterpret_input_as_3d() const
Flag which specifies if the input tensor has to be reinterpreted as 3D.
Definition: Types.h:2018
Bounding Box Transform information class.
Definition: Types.h:1450
unsigned int left
left of the border
Definition: Types.h:355
GEMMInfo() noexcept
Default constructor.
Definition: Types.h:1935
PriorBoxLayerInfo()
Default Constructor.
Definition: Types.h:810
unsigned int right
right of the border
Definition: Types.h:353
Quantize using an integer multiplication.
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=false, float bbox_xform_clip=4.135166556742356f)
Constructor.
Definition: Types.h:1463
1 channel, 1 S16 per channel
bool broadcast_bias() const
Flag which specifies whether to broadcast the shape of the bias tensor.
Definition: Types.h:2058
uint16_t idx_class
Index of the class.
Definition: Types.h:563
int keep_top_k() const
Get the number of total bounding boxes to be kept per image.
Definition: Types.h:1012
Output values are determined by averaging the source pixels whose areas fall under the area of the de...
quantized, symmetric fixed-point 8-bit number
unsigned int sampling_ratio() const
Get sampling ratio.
Definition: Types.h:1306
Num samples, channels, height, width.
PrecisionType
Precision type used when printing floating point numbers.
Definition: Types.h:2136
unsigned int max_classes_per_detection() const
Get max_classes per detection.
Definition: Types.h:1109
int32_t y
Y coordinates.
Definition: Types.h:419
bool broadcast_bias() const
Flag which specifies whether to broadcast the shape of the bias tensor.
Definition: Types.h:1849
bool is_a_reshaped() const
Flag which specifies if the matrix A has been reshaped.
Definition: Types.h:1984
float scale_value_y() const
Get y scale value.
Definition: Types.h:1139
uint16_t height
Height of the detection window.
Definition: Types.h:562
PadStrideInfo(unsigned int stride_x, unsigned int stride_y, unsigned int pad_left, unsigned int pad_right, unsigned int pad_top, unsigned int pad_bottom, DimensionRoundingType round)
Constructor.
Definition: Types.h:721
Strides of an item in bytes.
Definition: Strides.h:37
quantized, symmetric per channel fixed-point 8-bit number
Convolution using Winograd.
A 3 plane of 8-bit 4:2:0 sampled Y, U, V planes.
float min_size() const
Get size suppression threshold.
Definition: Types.h:659
int32_t gemmlowp_shift
GEMMLowp output stage shift used for quantizing to uint8.
Definition: Types.h:1886
PadStrideInfo(unsigned int stride_x=1, unsigned int stride_y=1, unsigned int pad_x=0, unsigned int pad_y=0, DimensionRoundingType round=DimensionRoundingType::FLOOR)
Constructor.
Definition: Types.h:700
Detection Output layer info.
Definition: Types.h:943
4 channels, 1 U8 per channel
uint32_t y
Y coordinates.
Definition: Types.h:450
ValidRegion(const Coordinates &an_anchor, const TensorShape &a_shape)
Constructor for a valid region with default number of dimensions.
Definition: Types.h:212
PoolingType
Available pooling types.
Definition: Types.h:577
PadStrideInfo pad_stride_info
Definition: Types.h:1269
GEMMReshapeInfo()
Default constructor.
Definition: Types.h:1764
void set_gemmlowp_output_stage(GEMMLowpOutputStageInfo &output_stage)
Sets GEMMLowp output stage.
Definition: Types.h:2042
constexpr bool empty() const
Check if the entire border is zero.
Definition: Types.h:299
HOGNormType
Normalization type for Histogram of Oriented Gradients (HOG)
Definition: Types.h:544
std::pair< uint32_t, uint32_t > PaddingInfo
Padding information as a pair of unsigned int start/end.
Definition: Types.h:455
Coordinate type.
Definition: Types.h:440
int end(unsigned int d) const
Return the end of the valid region for the given dimension d.
Definition: Types.h:239
unsigned int pooled_height() const
Get the pooled height of the layer.
Definition: Types.h:1296
int m() const
Number of matrix A rows.
Definition: Types.h:1790
Borders are left undefined.
ROI Pooling Layer Information class.
Definition: Types.h:1276
Pixels outside the image are assumed to have the same value as the closest image pixel.
constexpr BorderSize()
Empty border, i.e.
Definition: Types.h:275
Class for specifying the size of an image or rectangle.
Definition: Size2D.h:34
Detection window used for the object detection.
Definition: Types.h:557
DataLayout weights_trained_layout
Layout that the weights have been trained with.
Definition: Types.h:1582
unsigned int num_dimensions() const
Returns the effective dimensionality of the tensor.
Definition: Dimensions.h:122
std::vector< float > max_sizes() const
Get max sizes.
Definition: Types.h:906
ComputeAnchors information class.
Definition: Types.h:1400
uint16_t width
Width of the rectangle.
Definition: Types.h:435
Num samples, height, width, channels.
unsigned int detection_per_class() const
Get detection per class.
Definition: Types.h:1114
bool flip() const
Get the flip value.
Definition: Types.h:896
2 channel, 1 U8 per channel
uint16_t y
Top-left y coordinate.
Definition: Types.h:560
bool fp_mixed_precision
Use wider accumulators (32 bit instead of 16 for FP16) to improve accuracy.
Definition: Types.h:1586
float spatial_scale() const
Get the spatial scale.
Definition: Types.h:1301
Threshold with two values.
uint16_t y
Top-left y coordinate.
Definition: Types.h:434
Detection Output layer info.
Definition: Types.h:1062
int depth_output_gemm3d() const
Depth (third dimension) of the output tensor to be used with the GEMM3D kernel.
Definition: Types.h:1833
constexpr bool uniform() const
Check if the border is the same size on all sides.
Definition: Types.h:305
bool interleave
True if the h0 (k0xn0) blocks have to be interleaved in the output row.
Definition: Types.h:1923
unsigned int num_classes() const
Get num classes.
Definition: Types.h:1129
Use box centers and size but flip x and y co-ordinates.
PrintRegion
Specifies the area to be printed, used by Tensor objects.
Definition: Types.h:2144
std::vector< float > variances() const
Get min variances.
Definition: Types.h:876
bool transpose_weights
Transpose weights if true.
Definition: Types.h:1583
Size2D kernel_size
Width and height of the kernel.
Definition: Types.h:2126
TensorShape & set(size_t dimension, size_t value, bool apply_dim_correction=true)
Accessor to set the value of one of the dimensions.
Definition: TensorShape.h:78
std::array< float, 4 > weights() const
Definition: Types.h:1471
bool reshape_b_only_on_first_run() const
Flag which specifies if the reshape of matrix B should executed only for the first.
Definition: Types.h:2002
constexpr BorderSize(unsigned int top, unsigned int right, unsigned int bottom, unsigned int left)
Border with different sizes.
Definition: Types.h:293
unsigned int k0
Number of partial accumulations performed by the matrix multiplication.
Definition: Types.h:1905
uint16_t x
Top-left x coordinate.
Definition: Types.h:433
GEMMRHSMatrixInfo(unsigned int n, unsigned int k, unsigned int h, bool trans, bool inter)
Definition: Types.h:1915
float alpha() const
Get the alpha value.
Definition: Types.h:1642
GEMM information class.
Definition: Types.h:1931
unsigned int m0
Number of rows processed by the matrix multiplication.
Definition: Types.h:1904
std::pair< unsigned int, unsigned int > pad() const
Get the padding.
Definition: Types.h:755
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, float confidence_threshold=std::numeric_limits< float >::lowest(), bool variance_encoded_in_target=false, float eta=1)
Constructor.
Definition: Types.h:975
void set_num_dimensions(size_t num_dimensions)
Set number of dimensions.
Definition: Dimensions.h:128
ActivationFunction activation() const
Get the type of activation function.
Definition: Types.h:1552
float b() const
Get the beta value.
Definition: Types.h:1562
quantized, asymmetric fixed-point 8-bit number signed
Prints the valid region of the Tensor object.
64-bit floating-point number
Container for valid region of a window.
Definition: Types.h:187
Threshold with one value.
SimpleTensor< T > scale(const SimpleTensor< T > &src, float scale_x, float scale_y, InterpolationPolicy policy, BorderMode border_mode, T constant_border_value, SamplingPolicy sampling_policy, bool ceil_policy_scale, bool align_corners)
Definition: Scale.cpp:187
MagnitudeType
Magnitude calculation type.
Definition: Types.h:399
int32_t gemmlowp_min_bound
GEMMLowp min value used to saturate down the output result before converting back to QASYMM8.
Definition: Types.h:1887
uint16_t height
Height of the rectangle.
Definition: Types.h:436
unsigned int pad_bottom() const
Get the bottom padding.
Definition: Types.h:778
A single plane of 32-bit macro pixel of Y0, U0, Y1, V0 bytes.
bool clip() const
Get the clip value.
Definition: Types.h:901
Default precision to the one that the current stream has.
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, GEMMLowpOutputStageInfo gemmlowp_output_stage=GEMMLowpOutputStageInfo(), bool fp_mixed_precision=false, bool broadcast_bias=false, const ActivationLayerInfo &activation_info=ActivationLayerInfo()) noexcept
Constructor.
Definition: Types.h:1964
unsigned 64-bit number
DataType output_data_type
Output tensor data type to use if the output is not initialized.
Definition: Types.h:1893
Size2D input_dimensions
Width and height of the input tensor before the convolution is applied.
Definition: Types.h:2127
DataType
Available data types.
Definition: Types.h:77
bool reinterpret_input_as_3d() const
Flag which specifies if the input tensor has to be reinterpreted as 3D.
Definition: Types.h:1841
The maximum precision of the floating point representation.
ActivationLayerInfo activation_info() const
Activation layer to apply after the matrix multiplication.
Definition: Types.h:2082
unsigned int pad_left() const
Get the left padding.
Definition: Types.h:763
ElementWiseUnary
Available element wise unary operations.
Definition: Types.h:524
DataLayout
[DataLayout enum definition]
Definition: Types.h:120
std::vector< uint32_t > Multiples
Information to produce a tiled version of a Tensor.
Definition: Types.h:461
NormType
The normalization type used for the normalization layer.
Definition: Types.h:536
signed 8-bit number
MatrixPattern
Available matrix patterns.
Definition: Types.h:481
Normalization applied cross maps.
Any other matrix pattern.
ConvertPolicy
Policy to handle overflow.
Definition: Types.h:362
NMSType soft_nms_method() const
Get soft NMS method.
Definition: Types.h:639
void limit(const BorderSize &limit)
Limit this border size.
Definition: Types.h:344
int background_label_id() const
Get background label ID.
Definition: Types.h:1027
float im_height() const
Get image height (NMS may suppress boxes whose center sits beyond the image height)
Definition: Types.h:669
NonLinearFilterFunction
Available non linear functions.
Definition: Types.h:490
Coordinates anchor
Anchor for the start of the valid region.
Definition: Types.h:259
bool transpose
True if the block MxC0 (where M is the area of the filter i.e.
Definition: Types.h:1868
ValidRegion()
Default constructor.
Definition: Types.h:190
float confidence_threshold() const
Get confidence threshold.
Definition: Types.h:1032
Normalization applied within the same map in 2D region.
bool retain_internal_weights() const
Definition: Types.h:1738
SamplingPolicy
Available Sampling Policies.
Definition: Types.h:102
float soft_nms_sigma() const
Get soft NMS sigma.
Definition: Types.h:644
std::pair< unsigned int, unsigned int > kernel_size() const
Return the width and height of the kernel.
Definition: Types.h:1734
int num_loc_classes() const
Get number of location classes.
Definition: Types.h:1042
bool soft_nms_enabled() const
Check if soft NMS is enabled.
Definition: Types.h:634
int detections_per_im() const
Get the number of detections.
Definition: Types.h:629
std::string element_delim
Element delimeter.
Definition: Types.h:2182
std::vector< float > min_sizes() const
Get min sizes.
Definition: Types.h:871
bool has_padding() const
Check whether this has any padding.
Definition: Types.h:790
ComputeAnchorsInfo(float feat_width, float feat_height, float spatial_scale, size_t values_per_roi=4)
Constructor.
Definition: Types.h:1410