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