Compute Library
 22.08
Types.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016-2022 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 
35 #include "support/Bfloat16.h"
36 #include "support/Half.h"
37 
38 #include <cmath>
39 #include <cstddef>
40 #include <cstdint>
41 #include <map>
42 #include <string>
43 #include <utility>
44 
45 namespace arm_compute
46 {
47 /** 16-bit floating point type */
49 
50 /** Permutation vector */
52 /** Bidirectional strides */
54 
55 /** Image colour formats */
56 enum class Format
57 {
58  UNKNOWN, /**< Unknown image format */
59  U8, /**< 1 channel, 1 U8 per channel */
60  S16, /**< 1 channel, 1 S16 per channel */
61  U16, /**< 1 channel, 1 U16 per channel */
62  S32, /**< 1 channel, 1 S32 per channel */
63  U32, /**< 1 channel, 1 U32 per channel */
64  BFLOAT16, /**< 16-bit brain floating-point number */
65  F16, /**< 1 channel, 1 F16 per channel */
66  F32, /**< 1 channel, 1 F32 per channel */
67  UV88, /**< 2 channel, 1 U8 per channel */
68  RGB888, /**< 3 channels, 1 U8 per channel */
69  RGBA8888, /**< 4 channels, 1 U8 per channel */
70  YUV444, /**< A 3 plane of 8 bit 4:4:4 sampled Y, U, V planes */
71  YUYV422, /**< A single plane of 32-bit macro pixel of Y0, U0, Y1, V0 bytes */
72  NV12, /**< A 2 plane YUV format of Luma (Y) and interleaved UV data at 4:2:0 sampling */
73  NV21, /**< A 2 plane YUV format of Luma (Y) and interleaved VU data at 4:2:0 sampling */
74  IYUV, /**< A 3 plane of 8-bit 4:2:0 sampled Y, U, V planes */
75  UYVY422 /**< A single plane of 32-bit macro pixel of U0, Y0, V0, Y1 byte */
76 };
77 
78 /** Available data types */
79 enum class DataType
80 {
81  UNKNOWN, /**< Unknown data type */
82  U8, /**< unsigned 8-bit number */
83  S8, /**< signed 8-bit number */
84  QSYMM8, /**< quantized, symmetric fixed-point 8-bit number */
85  QASYMM8, /**< quantized, asymmetric fixed-point 8-bit number unsigned */
86  QASYMM8_SIGNED, /**< quantized, asymmetric fixed-point 8-bit number signed */
87  QSYMM8_PER_CHANNEL, /**< quantized, symmetric per channel fixed-point 8-bit number */
88  U16, /**< unsigned 16-bit number */
89  S16, /**< signed 16-bit number */
90  QSYMM16, /**< quantized, symmetric fixed-point 16-bit number */
91  QASYMM16, /**< quantized, asymmetric fixed-point 16-bit number */
92  U32, /**< unsigned 32-bit number */
93  S32, /**< signed 32-bit number */
94  U64, /**< unsigned 64-bit number */
95  S64, /**< signed 64-bit number */
96  BFLOAT16, /**< 16-bit brain floating-point number */
97  F16, /**< 16-bit floating-point number */
98  F32, /**< 32-bit floating-point number */
99  F64, /**< 64-bit floating-point number */
100  SIZET /**< size_t */
101 };
102 
103 /** Available Sampling Policies */
104 enum class SamplingPolicy
105 {
106  CENTER, /**< Samples are taken at pixel center */
107  TOP_LEFT /**< Samples are taken at pixel top left corner */
108 };
109 
110 /** [DataLayout enum definition] **/
111 
112 /** Supported tensor data layouts */
113 enum class DataLayout
114 {
115  UNKNOWN, /**< Unknown data layout */
116  NCHW, /**< Num samples, channels, height, width */
117  NHWC, /**< Num samples, height, width, channels */
118  NCDHW, /**< Num samples, channels, depth, height, width */
119  NDHWC /**< Num samples, depth, height, width, channels */
120 };
121 /** [DataLayout enum definition] **/
122 
123 /** Supported tensor data layout dimensions */
125 {
126  CHANNEL, /**< channel */
127  HEIGHT, /**< height */
128  WIDTH, /**< width */
129  DEPTH, /**< depth */
130  BATCHES /**< batches */
131 };
132 
133 /** Available ConvolutionMethod*/
135 {
136  GEMM, /**< Convolution using GEMM */
137  GEMM_CONV2D, /**< Direct 2D GEMM convolution */
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  {
212  anchor.set_num_dimensions(std::max(anchor.num_dimensions(), shape.num_dimensions()));
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  /** Check whether two valid regions are equal.
257  *
258  * @param[in] lhs LHS valid region
259  * @param[in] rhs RHS valid region
260  *
261  * @return True if the valid regions are the same.
262  */
263  inline friend bool operator==(const ValidRegion &lhs, const ValidRegion &rhs);
264 
265  Coordinates anchor; /**< Anchor for the start of the valid region. */
266  TensorShape shape; /**< Shape of the valid region. */
267 };
268 inline bool operator==(const ValidRegion &lhs, const ValidRegion &rhs)
269 {
270  return (lhs.anchor == rhs.anchor) && (lhs.shape == rhs.shape);
271 }
272 
273 /** Methods available to handle borders */
274 enum class BorderMode
275 {
276  UNDEFINED, /**< Borders are left undefined */
277  CONSTANT, /**< Pixels outside the image are assumed to have a constant value */
278  REPLICATE /**< Pixels outside the image are assumed to have the same value as the closest image pixel */
279 };
280 
281 /** Container for 2D border size */
283 {
284  /** Empty border, i.e. no border */
285  constexpr BorderSize() noexcept
286  : top{ 0 },
287  right{ 0 },
288  bottom{ 0 },
289  left{ 0 }
290  {
291  }
292 
293  /** Border with equal size around the 2D plane */
294  explicit constexpr BorderSize(unsigned int size) noexcept
295  : top{ size },
296  right{ size },
297  bottom{ size },
298  left{ size }
299  {
300  }
301 
302  /** Border with same size for top/bottom and left/right */
303  constexpr BorderSize(unsigned int top_bottom, unsigned int left_right)
304  : top{ top_bottom }, right{ left_right }, bottom{ top_bottom }, left{ left_right }
305  {
306  }
307 
308  /** Border with different sizes */
309  constexpr BorderSize(unsigned int top, unsigned int right, unsigned int bottom, unsigned int left)
310  : top{ top }, right{ right }, bottom{ bottom }, left{ left }
311  {
312  }
313 
314  /** Check if the entire border is zero */
315  constexpr bool empty() const
316  {
317  return top == 0 && right == 0 && bottom == 0 && left == 0;
318  }
319 
320  /** Check if the border is the same size on all sides */
321  constexpr bool uniform() const
322  {
323  return top == right && top == bottom && top == left;
324  }
325 
326  /** Scale this border size.
327  *
328  * @param[in] scale Scale to multiply border size by.
329  *
330  * @return *this.
331  */
333  {
334  top *= scale;
335  right *= scale;
336  bottom *= scale;
337  left *= scale;
338 
339  return *this;
340  }
341 
342  /** Scale a copy of this border size.
343  *
344  * @param[in] scale Scale to multiply border size by.
345  *
346  * @return a scaled copy of this.
347  */
349  {
350  BorderSize size = *this;
351  size *= scale;
352 
353  return size;
354  }
355 
356  /** Check equality with another BorderSize struct
357  *
358  * @param[in] rhs other struct to check against
359  *
360  * @return true if they are equal
361  */
362  bool operator==(const BorderSize &rhs) const
363  {
364  return (top == rhs.top) && (right == rhs.right) && (bottom == rhs.bottom) && (left == rhs.left);
365  }
366 
367  /** Check non-equality with another BorderSize struct
368  *
369  * @param[in] rhs other struct to check against
370  *
371  * @return true if they are different
372  */
373  bool operator!=(const BorderSize &rhs) const
374  {
375  return !(*this == rhs);
376  }
377 
378  /** Limit this border size.
379  *
380  * @param[in] limit Border size to limit this border size to.
381  */
382  void limit(const BorderSize &limit)
383  {
384  top = std::min(top, limit.top);
385  right = std::min(right, limit.right);
386  bottom = std::min(bottom, limit.bottom);
387  left = std::min(left, limit.left);
388  }
389 
390  unsigned int top; /**< top of the border */
391  unsigned int right; /**< right of the border */
392  unsigned int bottom; /**< bottom of the border */
393  unsigned int left; /**< left of the border */
394 };
395 
396 /** Container for 2D padding size */
398 
399 /** Policy to handle integer overflow
400  * @note: This is ignored by floating point operations where the overflow behavior adheres to the IEEE-754 standard
401  * which states that in case of overflow ┬▒infinity is returned for the round-to-nearest modes (and follows the
402  * rounding rules for the directed rounding modes) by default.
403  */
404 enum class ConvertPolicy
405 {
406  WRAP, /**< Wrap around */
407  SATURATE /**< Saturate */
408 };
409 
410 /** Interpolation method */
412 {
413  NEAREST_NEIGHBOR, /**< Output values are defined to match the source pixel whose center is nearest to the sample position */
414  BILINEAR, /**< Output values are defined by bilinear interpolation between the pixels */
415  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 */
416 };
417 
418 /** Bilinear Interpolation method used by LKTracker */
420 {
421  BILINEAR_OLD_NEW, /**< Old-new method */
422  BILINEAR_SCHARR /**< Scharr method */
423 };
424 
425 /** Rectangle type */
426 struct Rectangle
427 {
428  uint16_t x; /**< Top-left x coordinate */
429  uint16_t y; /**< Top-left y coordinate */
430  uint16_t width; /**< Width of the rectangle */
431  uint16_t height; /**< Height of the rectangle */
432 };
433 
434 /** Coordinate type */
436 {
437  int32_t x; /**< X coordinates */
438  int32_t y; /**< Y coordinates */
439 };
440 
441 /** Coordinate type */
443 {
444  uint32_t x; /**< X coordinates */
445  uint32_t y; /**< Y coordinates */
446  uint32_t z; /**< Z coordinates */
447 };
448 
449 /** Padding information as a pair of unsigned int start/end */
450 using PaddingInfo = std::pair<uint32_t, uint32_t>;
451 
452 /** List of padding information */
453 using PaddingList = std::vector<PaddingInfo>;
454 
455 /** Information to produce a tiled version of a Tensor */
456 using Multiples = std::vector<uint32_t>;
457 
458 /** Available channels */
459 enum class Channel
460 {
461  UNKNOWN, /** Unknown channel format */
462  C0, /**< First channel (used by formats with unknown channel types). */
463  C1, /**< Second channel (used by formats with unknown channel types). */
464  C2, /**< Third channel (used by formats with unknown channel types). */
465  C3, /**< Fourth channel (used by formats with unknown channel types). */
466  R, /**< Red channel. */
467  G, /**< Green channel. */
468  B, /**< Blue channel. */
469  A, /**< Alpha channel. */
470  Y, /**< Luma channel. */
471  U, /**< Cb/U channel. */
472  V /**< Cr/V/Value channel. */
473 };
474 
475 /** Available reduction operations */
477 {
478  ARG_IDX_MAX, /**< Index of the max value */
479  ARG_IDX_MIN, /**< Index of the min value */
480  MEAN_SUM, /**< Mean of sum */
481  PROD, /**< Product */
482  SUM_SQUARE, /**< Sum of squares */
483  SUM, /**< Sum */
484  MIN, /**< Min */
485  MAX, /**< Max */
486 };
487 
488 /** Available element-wise operations */
490 {
491  ADD, /**< (x + y) */
492  SUB, /**< (x - y) */
493  DIV, /**< (x / y) */
494  MIN, /**< Min(x, y) */
495  MAX, /**< Max(x, y) */
496  SQUARED_DIFF, /**< (x - y)^2 */
497  POWER, /**< x ^ y */
498  PRELU, /**< y*x if x < 0, x otherwise */
499 };
500 
501 /** Available element wise unary operations */
503 {
504  RSQRT, /**< Reverse square root */
505  EXP, /**< Exponential */
506  NEG, /**< Negate */
507  LOG, /**< Natural Logarithm */
508  ABS, /**< Absolute value */
509  SIN, /**< Sine */
510  ROUND, /**< Round */
511  LOGICAL_NOT, /**< Logical Not */
512 };
513 
514 /** Available bitwise operations */
516 {
517  AND, /**< Bitwise AND operation */
518  NOT, /**< Bitwise NOT operation */
519  OR, /**< Bitwise OR operation */
520  XOR, /**< Bitwise XOR operation */
521 };
522 
523 /** The normalization type used for the normalization layer */
524 enum class NormType
525 {
526  IN_MAP_1D, /**< Normalization applied within the same map in 1D region */
527  IN_MAP_2D, /**< Normalization applied within the same map in 2D region */
528  CROSS_MAP /**< Normalization applied cross maps */
529 };
530 
531 /** Detection window used for the object detection. The detection window keeps the following information:
532  *
533  * -# Geometry of the rectangular window (x/y of top-left corner and width/height)
534  * -# Index of the class used for evaluating which class the detection window belongs to
535  * -# Confidence value (score) obtained with the classifier
536  */
538 {
539  uint16_t x{ 0 }; /**< Top-left x coordinate */
540  uint16_t y{ 0 }; /**< Top-left y coordinate */
541  uint16_t width{ 0 }; /**< Width of the detection window */
542  uint16_t height{ 0 }; /**< Height of the detection window */
543  uint16_t idx_class{ 0 }; /**< Index of the class */
544  float score{ 0.f }; /**< Confidence value for the detection window */
545 };
546 
547 /** Dimension rounding type when down-scaling on CNNs
548  * @note Used in pooling and convolution layer
549  */
551 {
552  FLOOR, /**< Floor rounding */
553  CEIL /**< Ceil rounding */
554 };
555 
556 /** Available pooling types */
557 enum class PoolingType
558 {
559  MAX, /**< Max Pooling */
560  AVG, /**< Average Pooling */
561  L2 /**< L2 Pooling */
562 };
563 
564 /** Available non maxima suppression types */
565 enum class NMSType
566 {
567  LINEAR, /**< Linear NMS */
568  GAUSSIAN, /**< Gaussian NMS */
569  ORIGINAL /**< Original NMS */
570 };
571 
572 /** BoxWithNonMaximaSuppressionLimit Information class */
573 class BoxNMSLimitInfo final
574 {
575 public:
576  /** Constructor
577  *
578  * @param[in] score_thresh (Optional) Score threshold.
579  * @param[in] nms (Optional) NMS value
580  * @param[in] detections (Optional) Number of detections
581  * @param[in] soft_nms_enabled (Optional) Enable SoftNMS
582  * @param[in] soft_nms_method (Optional) Soft NMS method
583  * @param[in] soft_nms_sigma (Optional) Soft NMS sigma value
584  * @param[in] soft_nms_min_score_thres (Optional) Soft NMS minimum score threshold
585  * @param[in] suppress_size (Optional) Filter out boxes based on their size. Defaults to false
586  * @param[in] min_size (Optional) Smaller boxes than min_size will be filtered out. Defaults to 1
587  * @param[in] im_width (Optional) Boxes whose centers (on the x axis) is beyond im_width will be filtered. Defaults to 1
588  * @param[in] im_height (Optional) Boxes whose centers (on the y axis) is beyond im_height will be filtered. Defaults to 1
589  */
590  BoxNMSLimitInfo(float score_thresh = 0.05f, float nms = 0.3f,
591  int detections = 100, bool soft_nms_enabled = false,
592  NMSType soft_nms_method = NMSType::LINEAR,
593  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)
594  : _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),
595  _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)
596  {
597  }
598  /** Get the score threshold */
599  float score_thresh() const
600  {
601  return _score_thresh;
602  }
603  /** Get the NMS */
604  float nms() const
605  {
606  return _nms;
607  }
608  /** Get the number of detections */
609  int detections_per_im() const
610  {
611  return _detections_per_im;
612  }
613  /** Check if soft NMS is enabled */
614  bool soft_nms_enabled() const
615  {
616  return _soft_nms_enabled;
617  }
618  /** Get soft NMS method */
620  {
621  return _soft_nms_method;
622  }
623  /** Get soft NMS sigma */
624  float soft_nms_sigma() const
625  {
626  return _soft_nms_sigma;
627  }
628  /** Get soft nms min score threshold */
630  {
631  return _soft_nms_min_score_thres;
632  }
633  /** Get if NMS will suppress boxes based on their size/position */
634  bool suppress_size() const
635  {
636  return _suppress_size;
637  }
638  /** Get size suppression threshold */
639  float min_size() const
640  {
641  return _min_size;
642  }
643  /** Get image width (NMS may suppress boxes whose center sits beyond the image width) */
644  float im_width() const
645  {
646  return _im_width;
647  }
648  /** Get image height (NMS may suppress boxes whose center sits beyond the image height) */
649  float im_height() const
650  {
651  return _im_height;
652  }
653 
654 private:
655  float _score_thresh;
656  float _nms;
657  int _detections_per_im;
658  bool _soft_nms_enabled;
659  NMSType _soft_nms_method;
660  float _soft_nms_sigma;
661  float _soft_nms_min_score_thres;
662  bool _suppress_size;
663  float _min_size;
664  float _im_width;
665  float _im_height;
666 };
667 
668 /** Padding and stride information class */
670 {
671 public:
672  /** Constructor
673  *
674  * @param[in] stride_x (Optional) Stride, in elements, across x. Defaults to 1.
675  * @param[in] stride_y (Optional) Stride, in elements, across y. Defaults to 1.
676  * @param[in] pad_x (Optional) Padding, in elements, across x. Defaults to 0.
677  * @param[in] pad_y (Optional) Padding, in elements, across y. Defaults to 0.
678  * @param[in] round (Optional) Dimensions rounding. Defaults to @ref FLOOR.
679  */
680  PadStrideInfo(unsigned int stride_x = 1, unsigned int stride_y = 1,
681  unsigned int pad_x = 0, unsigned int pad_y = 0,
683  : _stride(std::make_pair(stride_x, stride_y)),
684  _pad_left(pad_x),
685  _pad_top(pad_y),
686  _pad_right(pad_x),
687  _pad_bottom(pad_y),
688  _round_type(round)
689  {
690  }
691  /** Constructor
692  *
693  * @param[in] stride_x Stride, in elements, across x.
694  * @param[in] stride_y Stride, in elements, across y.
695  * @param[in] pad_left Padding across x on the left, in elements.
696  * @param[in] pad_right Padding across x on the right, in elements.
697  * @param[in] pad_top Padding across y on the top, in elements.
698  * @param[in] pad_bottom Padding across y on the bottom, in elements.
699  * @param[in] round Dimensions rounding.
700  */
701  PadStrideInfo(unsigned int stride_x, unsigned int stride_y,
702  unsigned int pad_left, unsigned int pad_right,
703  unsigned int pad_top, unsigned int pad_bottom,
705  : _stride(std::make_pair(stride_x, stride_y)),
706  _pad_left(pad_left),
707  _pad_top(pad_top),
708  _pad_right(pad_right),
709  _pad_bottom(pad_bottom),
710  _round_type(round)
711  {
712  }
713  /** Get the stride.
714  *
715  * @return a pair: stride x, stride y.
716  */
717  std::pair<unsigned int, unsigned int> stride() const
718  {
719  return _stride;
720  }
721  /** Check whether the padding is symmetric.
722  *
723  * @return True if the padding is symmetric.
724  */
725  bool padding_is_symmetric() const
726  {
727  return (_pad_left == _pad_right) && (_pad_top == _pad_bottom);
728  }
729  /** Get the padding.
730  *
731  * @note This should only be used when the padding is symmetric.
732  *
733  * @return a pair: padding left/right, padding top/bottom
734  */
735  std::pair<unsigned int, unsigned int> pad() const
736  {
737  //this accessor should be used only when padding is symmetric
738  ARM_COMPUTE_ERROR_ON(!padding_is_symmetric());
739  return std::make_pair(_pad_left, _pad_top);
740  }
741 
742  /** Get the left padding */
743  unsigned int pad_left() const
744  {
745  return _pad_left;
746  }
747  /** Get the right padding */
748  unsigned int pad_right() const
749  {
750  return _pad_right;
751  }
752  /** Get the top padding */
753  unsigned int pad_top() const
754  {
755  return _pad_top;
756  }
757  /** Get the bottom padding */
758  unsigned int pad_bottom() const
759  {
760  return _pad_bottom;
761  }
762 
763  /** Get the rounding type */
765  {
766  return _round_type;
767  }
768 
769  /** Check whether this has any padding */
770  bool has_padding() const
771  {
772  return (_pad_left != 0 || _pad_top != 0 || _pad_right != 0 || _pad_bottom != 0);
773  }
774 
775 private:
776  std::pair<unsigned int, unsigned int> _stride;
777  unsigned int _pad_left;
778  unsigned int _pad_top;
779  unsigned int _pad_right;
780  unsigned int _pad_bottom;
781 
782  DimensionRoundingType _round_type;
783 };
784 
785 /** Padding information for 3D operations like Conv3d */
786 struct Padding3D
787 {
788  Padding3D() noexcept
789  {
790  }
791 
792  Padding3D(size_t pad_x, size_t pad_y, size_t pad_z)
793  : left(pad_x), right(pad_x), top(pad_y), bottom(pad_y), front(pad_z), back(pad_z)
794  {
795  }
796 
797  Padding3D(size_t left, size_t right, size_t top, size_t bottom, size_t front, size_t back)
798  : left(left), right(right), top(top), bottom(bottom), front(front), back(back)
799  {
800  }
801 
802  size_t left = { 0 }; /**< Padding across the width dimenstion on the left, in elements. */
803  size_t right = { 0 }; /**< Padding across the width dimenstion on the right, in elements. */
804  size_t top = { 0 }; /**< Padding across the height dimenstion on the top, in elements. */
805  size_t bottom = { 0 }; /**< Padding across the height dimenstion on the bottom, in elements. */
806  size_t front = { 0 }; /**< Padding across the depth dimenstion on the front, in elements. */
807  size_t back = { 0 }; /**< Padding across the depth dimenstion on the back, in elements. */
808 };
809 
810 /** PriorBox layer info */
811 class PriorBoxLayerInfo final
812 {
813 public:
814  /** Default Constructor */
816  : _min_sizes(),
817  _variances(),
818  _offset(),
819  _flip(true),
820  _clip(false),
821  _max_sizes(),
822  _aspect_ratios(),
823  _img_size(),
824  _steps()
825  {
826  }
827  /** Constructor
828  *
829  * @param[in] min_sizes Min sizes vector.
830  * @param[in] variances Variances vector.
831  * @param[in] offset Offset value.
832  * @param[in] flip (Optional) Flip the aspect ratios.
833  * @param[in] clip (Optional) Clip coordinates so that they're within [0,1].
834  * @param[in] max_sizes (Optional) Max sizes vector.
835  * @param[in] aspect_ratios (Optional) Aspect ratios of the boxes.
836  * @param[in] img_size (Optional) Image size.
837  * @param[in] steps (Optional) Step values.
838  */
839  PriorBoxLayerInfo(const std::vector<float> &min_sizes, const std::vector<float> &variances, float offset, bool flip = true, bool clip = false,
840  const std::vector<float> &max_sizes = {}, const std::vector<float> &aspect_ratios = {},
841  const Coordinates2D &img_size = Coordinates2D{ 0, 0 }, const std::array<float, 2> &steps = { { 0.f, 0.f } })
842  : _min_sizes(min_sizes),
843  _variances(variances),
844  _offset(offset),
845  _flip(flip),
846  _clip(clip),
847  _max_sizes(max_sizes),
848  _aspect_ratios(),
849  _img_size(img_size),
850  _steps(steps)
851  {
852  _aspect_ratios.push_back(1.);
853  for(unsigned int i = 0; i < aspect_ratios.size(); ++i)
854  {
855  float ar = aspect_ratios[i];
856  bool already_exist = false;
857  for(auto ar_new : _aspect_ratios)
858  {
859  if(fabs(ar - ar_new) < 1e-6)
860  {
861  already_exist = true;
862  break;
863  }
864  }
865  if(!already_exist)
866  {
867  _aspect_ratios.push_back(ar);
868  if(flip)
869  {
870  _aspect_ratios.push_back(1.f / ar);
871  }
872  }
873  }
874  }
875  /** Get min sizes. */
876  std::vector<float> min_sizes() const
877  {
878  return _min_sizes;
879  }
880  /** Get min variances. */
881  std::vector<float> variances() const
882  {
883  return _variances;
884  }
885  /** Get the step coordinates */
886  std::array<float, 2> steps() const
887  {
888  return _steps;
889  }
890  /** Get the image size coordinates */
892  {
893  return _img_size;
894  }
895  /** Get the offset */
896  float offset() const
897  {
898  return _offset;
899  }
900  /** Get the flip value */
901  bool flip() const
902  {
903  return _flip;
904  }
905  /** Get the clip value */
906  bool clip() const
907  {
908  return _clip;
909  }
910  /** Get max sizes. */
911  std::vector<float> max_sizes() const
912  {
913  return _max_sizes;
914  }
915  /** Get aspect ratios. */
916  std::vector<float> aspect_ratios() const
917  {
918  return _aspect_ratios;
919  }
920 
921 private:
922  std::vector<float> _min_sizes;
923  std::vector<float> _variances;
924  float _offset;
925  bool _flip;
926  bool _clip;
927  std::vector<float> _max_sizes;
928  std::vector<float> _aspect_ratios;
929  Coordinates2D _img_size;
930  std::array<float, 2> _steps;
931 };
932 
933 // Bounding Box [xmin, ymin, xmax, ymax]
934 using BBox = std::array<float, 4>;
935 // LabelBBox used for map label and bounding box
936 using LabelBBox = std::map<int, std::vector<BBox>>;
937 
938 /** Available Detection Output code types */
940 {
941  CORNER, /**< Use box corners */
942  CENTER_SIZE, /**< Use box centers and size */
943  CORNER_SIZE, /**< Use box centers and size */
944  TF_CENTER /**< Use box centers and size but flip x and y co-ordinates */
945 };
946 
947 /** Detection Output layer info */
949 {
950 public:
951  /** Default Constructor */
953  : _num_classes(),
954  _share_location(),
956  _keep_top_k(),
957  _nms_threshold(),
958  _top_k(),
959  _background_label_id(),
960  _confidence_threshold(),
961  _variance_encoded_in_target(false),
962  _eta(),
963  _num_loc_classes()
964  {
965  _num_loc_classes = _share_location ? 1 : _num_classes;
966  }
967  /** Constructor
968  *
969  * @param[in] num_classes Number of classes to be predicted.
970  * @param[in] share_location If true, bounding box are shared among different classes.
971  * @param[in] code_type Type of coding method for bbox.
972  * @param[in] keep_top_k Number of total bounding boxes to be kept per image after NMS step.
973  * @param[in] nms_threshold Threshold to be used in NMS.
974  * @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.
975  * @param[in] background_label_id (Optional) Background label ID. If there is no background class, set it as -1.
976  * @param[in] confidence_threshold (Optional) Only consider detections whose confidences are larger than a threshold. Default set to -FLT_MAX.
977  * @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.
978  * @param[in] eta (Optional) Eta.
979  */
980  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,
981  float confidence_threshold = std::numeric_limits<float>::lowest(), bool variance_encoded_in_target = false, float eta = 1)
982  : _num_classes(num_classes),
983  _share_location(share_location),
984  _code_type(code_type),
985  _keep_top_k(keep_top_k),
986  _nms_threshold(nms_threshold),
987  _top_k(top_k),
988  _background_label_id(background_label_id),
989  _confidence_threshold(confidence_threshold),
990  _variance_encoded_in_target(variance_encoded_in_target),
991  _eta(eta),
992  _num_loc_classes()
993  {
994  _num_loc_classes = _share_location ? 1 : _num_classes;
995  }
996  /** Get num classes. */
997  int num_classes() const
998  {
999  return _num_classes;
1000  }
1001  /** Get share location. */
1002  bool share_location() const
1003  {
1004  return _share_location;
1005  }
1006  /** Get detection output code type. */
1008  {
1009  return _code_type;
1010  }
1011  /** Get if variance encoded in target. */
1013  {
1014  return _variance_encoded_in_target;
1015  }
1016  /** Get the number of total bounding boxes to be kept per image. */
1017  int keep_top_k() const
1018  {
1019  return _keep_top_k;
1020  }
1021  /** Get nms threshold. */
1022  float nms_threshold() const
1023  {
1024  return _nms_threshold;
1025  }
1026  /** Get eta. */
1027  float eta() const
1028  {
1029  return _eta;
1030  }
1031  /** Get background label ID. */
1033  {
1034  return _background_label_id;
1035  }
1036  /** Get confidence threshold. */
1037  float confidence_threshold() const
1038  {
1039  return _confidence_threshold;
1040  }
1041  /** Get top K. */
1042  int top_k() const
1043  {
1044  return _top_k;
1045  }
1046  /** Get number of location classes. */
1047  int num_loc_classes() const
1048  {
1049  return _num_loc_classes;
1050  }
1051 
1052 private:
1053  int _num_classes;
1054  bool _share_location;
1055  DetectionOutputLayerCodeType _code_type;
1056  int _keep_top_k;
1057  float _nms_threshold;
1058  int _top_k;
1059  int _background_label_id;
1060  float _confidence_threshold;
1061  bool _variance_encoded_in_target;
1062  float _eta;
1063  int _num_loc_classes;
1064 };
1065 
1066 /** Detection Output layer info */
1068 {
1069 public:
1070  /** Default Constructor */
1072  : _max_detections(),
1073  _max_classes_per_detection(),
1074  _nms_score_threshold(),
1075  _iou_threshold(),
1076  _num_classes(),
1077  _scales_values(),
1078  _use_regular_nms(),
1079  _detection_per_class(),
1080  _dequantize_scores()
1081  {
1082  }
1083  /** Constructor
1084  *
1085  * @param[in] max_detections Number of total detection.
1086  * @param[in] max_classes_per_detection Number of total classes to be kept after NMS step. Used in the Fast Non-Max-Suppression
1087  * @param[in] nms_score_threshold Threshold to be used in NMS
1088  * @param[in] iou_threshold Threshold to be used during the intersection over union.
1089  * @param[in] num_classes Number of classes.
1090  * @param[in] scales_values Scales values used for decode center size boxes.
1091  * @param[in] use_regular_nms (Optional) Boolean to determinate if use regular or fast nms. Defaults to false.
1092  * @param[in] detection_per_class (Optional) Number of detection per class. Used in the Regular Non-Max-Suppression. Defaults to 100.
1093  * @param[in] dequantize_scores (Optional) If the scores need to be dequantized. Defaults to true.
1094  */
1095  DetectionPostProcessLayerInfo(unsigned int max_detections, unsigned int max_classes_per_detection, float nms_score_threshold, float iou_threshold, unsigned int num_classes,
1096  std::array<float, 4> scales_values, bool use_regular_nms = false, unsigned int detection_per_class = 100, bool dequantize_scores = true)
1097  : _max_detections(max_detections),
1098  _max_classes_per_detection(max_classes_per_detection),
1099  _nms_score_threshold(nms_score_threshold),
1100  _iou_threshold(iou_threshold),
1101  _num_classes(num_classes),
1102  _scales_values(scales_values),
1103  _use_regular_nms(use_regular_nms),
1104  _detection_per_class(detection_per_class),
1105  _dequantize_scores(dequantize_scores)
1106  {
1107  }
1108  /** Get max detections. */
1109  unsigned int max_detections() const
1110  {
1111  return _max_detections;
1112  }
1113  /** Get max_classes per detection. Used in the Fast Non-Max-Suppression.*/
1114  unsigned int max_classes_per_detection() const
1115  {
1116  return _max_classes_per_detection;
1117  }
1118  /** Get detection per class. Used in the Regular Non-Max-Suppression */
1119  unsigned int detection_per_class() const
1120  {
1121  return _detection_per_class;
1122  }
1123  /** Get nms threshold. */
1124  float nms_score_threshold() const
1125  {
1126  return _nms_score_threshold;
1127  }
1128  /** Get intersection over union threshold. */
1129  float iou_threshold() const
1130  {
1131  return _iou_threshold;
1132  }
1133  /** Get num classes. */
1134  unsigned int num_classes() const
1135  {
1136  return _num_classes;
1137  }
1138  /** Get if use regular nms. */
1139  bool use_regular_nms() const
1140  {
1141  return _use_regular_nms;
1142  }
1143  /** Get y scale value. */
1144  float scale_value_y() const
1145  {
1146  // Saved as [y,x,h,w]
1147  return _scales_values[0];
1148  }
1149  /** Get x scale value. */
1150  float scale_value_x() const
1151  {
1152  // Saved as [y,x,h,w]
1153  return _scales_values[1];
1154  }
1155  /** Get h scale value. */
1156  float scale_value_h() const
1157  {
1158  // Saved as [y,x,h,w]
1159  return _scales_values[2];
1160  }
1161  /** Get w scale value. */
1162  float scale_value_w() const
1163  {
1164  // Saved as [y,x,h,w]
1165  return _scales_values[3];
1166  }
1167  /** Get dequantize_scores value. */
1168  bool dequantize_scores() const
1169  {
1170  return _dequantize_scores;
1171  }
1172 
1173 private:
1174  unsigned int _max_detections;
1175  unsigned int _max_classes_per_detection;
1176  float _nms_score_threshold;
1177  float _iou_threshold;
1178  unsigned int _num_classes;
1179  std::array<float, 4> _scales_values;
1180  bool _use_regular_nms;
1181  unsigned int _detection_per_class;
1182  bool _dequantize_scores;
1183 };
1184 
1185 /** Pooling Layer Information struct*/
1187 {
1188  /** Default Constructor */
1190  : pool_type(PoolingType::MAX),
1191  pool_size(Size2D()),
1193  pad_stride_info(PadStrideInfo()),
1194  exclude_padding(false),
1195  is_global_pooling(false),
1196  fp_mixed_precision(false)
1197  {
1198  }
1199  /** Constructor
1200  *
1201  * @param[in] pool_type Pooling type @ref PoolingType.
1202  * @param[in] pool_size Pooling size, in elements, across x and y.
1203  * @param[in] data_layout Data layout used by the layer @ref DataLayout
1204  * @param[in] pad_stride_info (Optional) Padding and stride information @ref PadStrideInfo
1205  * @param[in] exclude_padding (Optional) Strategy when accounting padding in calculations.
1206  * True will exclude padding while false will not (Used in AVG/L2 pooling to determine the pooling area).
1207  * Defaults to false;
1208  * @param[in] fp_mixed_precision (Optional) Use wider accumulators (32 bit instead of 16 for FP16) to improve accuracy.
1209  */
1210  explicit PoolingLayerInfo(PoolingType pool_type,
1211  unsigned int pool_size,
1213  PadStrideInfo pad_stride_info = PadStrideInfo(),
1214  bool exclude_padding = false,
1215  bool fp_mixed_precision = false)
1216  : pool_type(pool_type),
1217  pool_size(Size2D(pool_size, pool_size)),
1218  data_layout(data_layout),
1219  pad_stride_info(pad_stride_info),
1220  exclude_padding(exclude_padding),
1221  is_global_pooling(false),
1222  fp_mixed_precision(fp_mixed_precision)
1223  {
1224  }
1225 
1226  /** Constructor
1227  *
1228  * @param[in] pool_type Pooling type @ref PoolingType.
1229  * @param[in] pool_size Pooling size, in elements, across x and y.
1230  * @param[in] data_layout Data layout used by the layer @ref DataLayout
1231  * @param[in] pad_stride_info (Optional) Padding and stride information @ref PadStrideInfo
1232  * @param[in] exclude_padding (Optional) Strategy when accounting padding in calculations.
1233  * True will exclude padding while false will not (Used in AVG/L2 pooling to determine the pooling area).
1234  * Defaults to false;
1235  * @param[in] fp_mixed_precision (Optional) Use wider accumulators (32 bit instead of 16 for FP16) to improve accuracy.
1236  */
1237  explicit PoolingLayerInfo(PoolingType pool_type,
1238  Size2D pool_size,
1239  DataLayout data_layout,
1240  PadStrideInfo pad_stride_info = PadStrideInfo(),
1241  bool exclude_padding = false,
1242  bool fp_mixed_precision = false)
1243  : pool_type(pool_type),
1244  pool_size(pool_size),
1245  data_layout(data_layout),
1246  pad_stride_info(pad_stride_info),
1247  exclude_padding(exclude_padding),
1248  is_global_pooling(false),
1249  fp_mixed_precision(fp_mixed_precision)
1250  {
1251  }
1252 
1253  /** Constructor
1254  *
1255  * @note This constructor is used for global pooling
1256  *
1257  * @param[in] pool_type Pooling type @ref PoolingType.
1258  * @param[in] data_layout Data layout used by the layer @ref DataLayout
1259  */
1260  explicit PoolingLayerInfo(PoolingType pool_type, DataLayout data_layout)
1261  : pool_type(pool_type),
1262  pool_size(Size2D()),
1263  data_layout(data_layout),
1264  pad_stride_info(PadStrideInfo(1, 1, 0, 0)),
1265  exclude_padding(false),
1266  is_global_pooling(true),
1267  fp_mixed_precision(false)
1268  {
1269  }
1270 
1278 };
1279 
1280 /** Pooling Layer Information struct*/
1282 {
1283  /** Default Constructor */
1285  : pool_type(PoolingType::MAX),
1286  pool_size(Size3D()),
1287  stride(Size3D()),
1288  padding(Padding3D()),
1289  exclude_padding(false),
1290  is_global_pooling(false),
1291  fp_mixed_precision(false),
1292  round_type(DimensionRoundingType::FLOOR)
1293  {
1294  }
1295  /** Constructor
1296  *
1297  * @param[in] pool_type Pooling type @ref PoolingType.
1298  * @param[in] pool_size Pooling size, in elements, across x, y and z.
1299  * @param[in] stride (Optional) stride information @ref Size3D
1300  * @param[in] padding (Optional) padding information @ref Padding3D
1301  * @param[in] exclude_padding (Optional) Strategy when accounting padding in calculations.
1302  * True will exclude padding while false will not (Used in AVG/L2 pooling to determine the pooling area).
1303  * Defaults to false;
1304  * @param[in] fp_mixed_precision (Optional) Use wider accumulators (32 bit instead of 16 for FP16) to improve accuracy.
1305  * @param[in] round_type (Optional) Dimensions rounding. Defaults to @ref FLOOR
1306  */
1307  explicit Pooling3dLayerInfo(PoolingType pool_type,
1308  unsigned int pool_size,
1309  Size3D stride = Size3D(1U, 1U, 1U),
1310  Padding3D padding = Padding3D(),
1311  bool exclude_padding = false,
1312  bool fp_mixed_precision = false,
1314  : pool_type(pool_type),
1315  pool_size(Size3D(pool_size, pool_size, pool_size)),
1316  stride(stride),
1317  padding(padding),
1318  exclude_padding(exclude_padding),
1319  is_global_pooling(false),
1320  fp_mixed_precision(fp_mixed_precision),
1321  round_type(round_type)
1322  {
1323  }
1324 
1325  /** Constructor
1326  *
1327  * @param[in] pool_type Pooling type @ref PoolingType.
1328  * @param[in] pool_size Pooling size, in elements, across x, y and z.
1329  * @param[in] stride (Optional) stride information @ref Size3D
1330  * @param[in] padding (Optional) padding information @ref Padding3D
1331  * @param[in] exclude_padding (Optional) Strategy when accounting padding in calculations.
1332  * True will exclude padding while false will not (Used in AVG/L2 pooling to determine the pooling area).
1333  * Defaults to false;
1334  * @param[in] fp_mixed_precision (Optional) Use wider accumulators (32 bit instead of 16 for FP16) to improve accuracy.
1335  * @param[in] round_type (Optional) Dimensions rounding. Defaults to @ref FLOOR
1336  */
1337  explicit Pooling3dLayerInfo(PoolingType pool_type,
1338  Size3D pool_size,
1339  Size3D stride = Size3D(1U, 1U, 1U),
1340  Padding3D padding = Padding3D(),
1341  bool exclude_padding = false,
1342  bool fp_mixed_precision = false,
1344  : pool_type(pool_type),
1345  pool_size(pool_size),
1346  stride(stride),
1347  padding(padding),
1348  exclude_padding(exclude_padding),
1349  is_global_pooling(false),
1350  fp_mixed_precision(fp_mixed_precision),
1351  round_type(round_type)
1352  {
1353  }
1354 
1355  /** Constructor
1356  *
1357  * @note This constructor is used for global pooling
1358  *
1359  * @param[in] pool_type Pooling type @ref PoolingType.
1360  */
1361  explicit Pooling3dLayerInfo(PoolingType pool_type)
1362  : pool_type(pool_type),
1363  pool_size(Size3D()),
1364  stride(Size3D(1U, 1U, 1U)),
1365  padding(Padding3D(0, 0, 0)),
1366  exclude_padding(false),
1367  is_global_pooling(true),
1368  fp_mixed_precision(false),
1369  round_type(DimensionRoundingType::FLOOR)
1370  {
1371  }
1372 
1381 };
1382 
1383 /** ROI Pooling Layer Information class */
1385 {
1386 public:
1387  /** Constructor
1388  *
1389  * @param[in] pooled_width Pooled width of the layer.
1390  * @param[in] pooled_height Pooled height of the layer.
1391  * @param[in] spatial_scale Spatial scale to be applied to the ROI coordinates and dimensions.
1392  * @param[in] sampling_ratio Number of samples to include in each pooling region (if set to zero, a ceil(roi_dims/pooling_dims))
1393  */
1394  ROIPoolingLayerInfo(unsigned int pooled_width, unsigned int pooled_height, float spatial_scale, unsigned int sampling_ratio = 0)
1395  : _pooled_width(pooled_width), _pooled_height(pooled_height), _spatial_scale(spatial_scale), _sampling_ratio(sampling_ratio)
1396  {
1397  }
1398  /** Get the pooled width of the layer */
1399  unsigned int pooled_width() const
1400  {
1401  return _pooled_width;
1402  }
1403  /** Get the pooled height of the layer */
1404  unsigned int pooled_height() const
1405  {
1406  return _pooled_height;
1407  }
1408  /** Get the spatial scale */
1409  float spatial_scale() const
1410  {
1411  return _spatial_scale;
1412  }
1413  /** Get sampling ratio */
1414  unsigned int sampling_ratio() const
1415  {
1416  return _sampling_ratio;
1417  }
1418 
1419 private:
1420  unsigned int _pooled_width;
1421  unsigned int _pooled_height;
1422  float _spatial_scale;
1423  unsigned int _sampling_ratio;
1424 };
1425 
1426 /** Generate Proposals Information class */
1428 {
1429 public:
1430  /** Constructor
1431  *
1432  * @param[in] im_width Width of the original image
1433  * @param[in] im_height Height of the original image
1434  * @param[in] im_scale Scale applied to the original image
1435  * @param[in] spatial_scale (Optional)Scale applied to the feature map. Defaults to 1.0
1436  * @param[in] pre_nms_topN (Optional)Number of the best scores to be selected from the transformations. Defaults to 6000.
1437  * @param[in] post_nms_topN (Optional)Number of the best scores to be selected from the NMS operation. Defaults to 300.
1438  * @param[in] nms_thres (Optional)NMS overlap threshold. Defaults to 0.7.
1439  * @param[in] min_size (Optional)Size used to validate the anchors produced. Defaults to 16.
1440  * @param[in] values_per_roi (Optional)Values used to represent a ROI(Region of interest). Defaults to 4.
1441  */
1442  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,
1443  size_t values_per_roi = 4)
1444  : _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),
1445  _min_size(min_size), _values_per_roi(values_per_roi)
1446  {
1447  }
1448 
1449  /* Get the original height */
1450  float im_height() const
1451  {
1452  return _im_height;
1453  }
1454  /* Get the original width */
1455  float im_width() const
1456  {
1457  return _im_width;
1458  }
1459  /* Get the image scale */
1460  float im_scale() const
1461  {
1462  return _im_scale;
1463  }
1464  /* Get the value of how many best scores to select (before NMS) */
1465  int pre_nms_topN() const
1466  {
1467  return _pre_nms_topN;
1468  }
1469  /* Get the value of how many best scores to select (after NMS) */
1470  int post_nms_topN() const
1471  {
1472  return _post_nms_topN;
1473  }
1474  /* Get the NMS overlap threshold */
1475  float nms_thres() const
1476  {
1477  return _nms_thres;
1478  }
1479  /* Get the minimal size */
1480  float min_size() const
1481  {
1482  return _min_size;
1483  }
1484  /* Get the spatial scale to be applied to the feature maps */
1485  float spatial_scale() const
1486  {
1487  return _spatial_scale;
1488  }
1489  /* Get the values used to represent a ROI(Region of interest)*/
1490  size_t values_per_roi() const
1491  {
1492  return _values_per_roi;
1493  }
1494 
1495 private:
1496  float _im_height;
1497  float _im_width;
1498  float _im_scale;
1499  float _spatial_scale;
1500  int _pre_nms_topN;
1501  int _post_nms_topN;
1502  float _nms_thres;
1503  float _min_size;
1504  size_t _values_per_roi;
1505 };
1506 
1507 /** ComputeAnchors information class */
1509 {
1510 public:
1511  /** Constructor
1512  *
1513  * @param[in] feat_width Feature map width
1514  * @param[in] feat_height Feature map height
1515  * @param[in] spatial_scale Feature map scale
1516  * @param[in] values_per_roi (Optional)Values used to represent a ROI(Region Of Interest). Defaults to 4
1517  */
1518  ComputeAnchorsInfo(float feat_width, float feat_height, float spatial_scale, size_t values_per_roi = 4)
1519  : _feat_height(feat_height),
1520  _feat_width(feat_width),
1521  _spatial_scale(spatial_scale),
1522  _values_per_roi(values_per_roi)
1523  {
1524  }
1525 
1526  /* Get the height of the feature map */
1527  float feat_height() const
1528  {
1529  return _feat_height;
1530  }
1531 
1532  /* Get the width of the feature map */
1533  float feat_width() const
1534  {
1535  return _feat_width;
1536  }
1537 
1538  /* Get the scale of the feature map */
1539  float spatial_scale() const
1540  {
1541  return _spatial_scale;
1542  }
1543 
1544  /* Get the values used to represent a ROI(Region Of Interest)*/
1545  size_t values_per_roi() const
1546  {
1547  return _values_per_roi;
1548  }
1549 
1550 private:
1551  float _feat_height;
1552  float _feat_width;
1553  float _spatial_scale;
1554  size_t _values_per_roi;
1555 };
1556 
1557 /** Bounding Box Transform information class */
1559 {
1560 public:
1561  /** Constructor
1562  *
1563  * @param[in] img_width Width of the original image
1564  * @param[in] img_height Height, of the original image
1565  * @param[in] scale Scale of the original image
1566  * @param[in] apply_scale (Optional)Re-apply scaling after transforming the boxes. Defaults to false
1567  * @param[in] weights (Optional)Weights [wx, wy, ww, wh] for the deltas. Defaults to all ones
1568  * @param[in] correct_transform_coords (Optional)Correct bounding box transform coordinates. Defaults to false
1569  * @param[in] bbox_xform_clip (Optional)Minimum bounding box width and height after bounding box transformation in log-space. Defaults to log(1000/16)
1570  */
1571  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 =
1572  false,
1573  float bbox_xform_clip =
1574  4.135166556742356f)
1575  : _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)
1576  {
1577  }
1578 
1579  std::array<float, 4> weights() const
1580  {
1581  return _weights;
1582  }
1583 
1584  float bbox_xform_clip() const
1585  {
1586  return _bbox_xform_clip;
1587  }
1588 
1589  float img_height() const
1590  {
1591  return _img_height;
1592  }
1593 
1594  float img_width() const
1595  {
1596  return _img_width;
1597  }
1598 
1599  float scale() const
1600  {
1601  return _scale;
1602  }
1603 
1604  bool apply_scale() const
1605  {
1606  return _apply_scale;
1607  }
1608 
1610  {
1611  return _correct_transform_coords;
1612  }
1613 
1614 private:
1615  float _img_width;
1616  float _img_height;
1617  float _scale;
1618  bool _apply_scale;
1619  bool _correct_transform_coords;
1620  std::array<float, 4> _weights;
1621  float _bbox_xform_clip;
1622 };
1623 
1624 /** Activation Layer Information class */
1626 {
1627 public:
1628  /** Available activation functions */
1630  {
1631  LOGISTIC, /**< Logistic ( \f$ f(x) = \frac{1}{1 + e^{-x}} \f$ ) */
1632  TANH, /**< Hyperbolic tangent ( \f$ f(x) = a \cdot tanh(b \cdot x) \f$ ) */
1633  RELU, /**< Rectifier ( \f$ f(x) = max(0,x) \f$ ) */
1634  BOUNDED_RELU, /**< Upper Bounded Rectifier ( \f$ f(x) = min(a, max(0,x)) \f$ ) */
1635  LU_BOUNDED_RELU, /**< Lower and Upper Bounded Rectifier ( \f$ f(x) = min(a, max(b,x)) \f$ ) */
1636  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$ ) */
1637  SOFT_RELU, /**< Soft Rectifier ( \f$ f(x)= log(1+e^x) \f$ ) */
1638  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$ ) */
1639  ABS, /**< Absolute ( \f$ f(x)= |x| \f$ ) */
1640  SQUARE, /**< Square ( \f$ f(x)= x^2 \f$ )*/
1641  SQRT, /**< Square root ( \f$ f(x) = \sqrt{x} \f$ )*/
1642  LINEAR, /**< Linear ( \f$ f(x)= ax + b \f$ ) */
1643  IDENTITY, /**< Identity ( \f$ f(x)= x \f$ ) */
1644  HARD_SWISH /**< Hard-swish ( \f$ f(x) = (x * relu6(x+3))/6 \f$ ) */
1645  };
1646 
1647  /** Lookup table */
1648  using LookupTable256 = std::array<qasymm8_t, 256>;
1649 
1650  ActivationLayerInfo() = default;
1651  /** Default Constructor
1652  *
1653  * @param[in] f The activation function to use.
1654  * @param[in] a (Optional) The alpha parameter used by some activation functions
1655  * (@ref ActivationFunction::BOUNDED_RELU, @ref ActivationFunction::LU_BOUNDED_RELU, @ref ActivationFunction::LINEAR, @ref ActivationFunction::TANH).
1656  * @param[in] b (Optional) The beta parameter used by some activation functions (@ref ActivationFunction::LINEAR, @ref ActivationFunction::LU_BOUNDED_RELU, @ref ActivationFunction::TANH).
1657  */
1658  ActivationLayerInfo(ActivationFunction f, float a = 0.0f, float b = 0.0f)
1659  : _act(f), _a(a), _b(b), _enabled(true)
1660  {
1661  }
1662  /** Get the type of activation function */
1664  {
1665  return _act;
1666  }
1667  /** Get the alpha value */
1668  float a() const
1669  {
1670  return _a;
1671  }
1672  /** Get the beta value */
1673  float b() const
1674  {
1675  return _b;
1676  }
1677  /** Check if initialised */
1678  bool enabled() const
1679  {
1680  return _enabled;
1681  }
1682 
1683 #ifdef __aarch64__
1684  const LookupTable256 &lut() const
1685  {
1686  return _lut;
1687  }
1688 
1689  void init_lut(const UniformQuantizationInfo &qi_in, const UniformQuantizationInfo &qi_out)
1690  {
1691  if(_act == ActivationFunction::HARD_SWISH)
1692  {
1693  qasymm8_hard_swish_populate_table(_lut, qi_in, qi_out);
1694  }
1695  else if(_act == ActivationFunction::LEAKY_RELU)
1696  {
1697  qasymm8_leaky_relu_populate_table(_lut, qi_in, qi_out, _a);
1698  }
1699  }
1700 #endif // __aarch64__
1701 
1703  {
1704 #ifdef __aarch64__
1705  auto supported = (data_type == DataType::QASYMM8 && (act_func == ActivationFunction::HARD_SWISH || act_func == ActivationFunction::LEAKY_RELU));
1706  return supported;
1707 #else // __aarch64__
1708  ARM_COMPUTE_UNUSED(act_func);
1709  ARM_COMPUTE_UNUSED(data_type);
1710  return false;
1711 #endif // __aarch64__
1712  }
1713 
1714 private:
1716  float _a = {};
1717  float _b = {};
1718  bool _enabled = { false };
1719 
1720 #ifdef __aarch64__
1721  LookupTable256 _lut = {};
1722 
1723  static inline void qasymm8_hard_swish_populate_table(LookupTable256 &lut, const UniformQuantizationInfo &qi_in, const UniformQuantizationInfo &qi_out)
1724  {
1725  for(size_t i = 0; i < lut.size(); ++i)
1726  {
1727  lut[i] = qasymm8_hard_swish(i, qi_in, qi_out);
1728  }
1729  }
1730 
1731  static inline void qasymm8_leaky_relu_populate_table(LookupTable256 &lut, const UniformQuantizationInfo &qi_in, const UniformQuantizationInfo &qi_out, float alpha)
1732  {
1733  for(size_t i = 0; i < lut.size(); ++i)
1734  {
1735  lut[i] = qasymm8_leaky_relu(i, qi_in, qi_out, alpha);
1736  }
1737  }
1738 #endif // __aarch64__
1739 };
1740 
1741 /** Fully connected layer info */
1743 {
1744  /* Fused-activation parameters */
1745  ActivationLayerInfo activation_info{}; /**< Fused activation to apply after the matrix multiplication. */
1746  /* Information about weights */
1747  DataLayout weights_trained_layout{ DataLayout::NCHW }; /**< Layout that the weights have been trained with. */
1748  bool transpose_weights{ true }; /**< Transpose weights if true. */
1749  bool are_weights_reshaped{ false }; /**< Reshape the weights tensor if false. */
1750  bool retain_internal_weights{ false }; /**< Retain internal reshaped weights. */
1751  bool enable_fast_math{ false }; /**< Enable fast math computation. */
1752  /* Other parameters */
1753  bool fp_mixed_precision{ false }; /**< Use wider accumulators (32 bit instead of 16 for FP16) to improve accuracy. */
1754 
1755  /** Sets the weights trained data layout
1756  *
1757  * @param[in] layout Data layout that the weights were trained with
1758  *
1759  * @return Updated object
1760  */
1762  {
1763  weights_trained_layout = layout;
1764  return *this;
1765  }
1766  /** Sets the transpose weights flag
1767  *
1768  * @param[in] should_transpose_weights Boolean flag indicating if weights should be transposed
1769  *
1770  * @return Updated object
1771  */
1772  FullyConnectedLayerInfo &set_transpose_weights(bool should_transpose_weights)
1773  {
1774  transpose_weights = should_transpose_weights;
1775  return *this;
1776  }
1777 };
1778 
1779 /** Normalization Layer Information class */
1781 {
1782 public:
1783  /** Default Constructor
1784  *
1785  * @param[in] type The normalization type. Can be @ref NormType::IN_MAP_1D, @ref NormType::IN_MAP_2D or @ref NormType::CROSS_MAP
1786  * @param[in] norm_size The normalization size is the number of elements to normalize across. Defaults to 5.
1787  * @param[in] alpha (Optional) Alpha parameter used by normalization equation. Defaults to 0.0001.
1788  * @param[in] beta (Optional) Beta parameter used by normalization equation. Defaults to 0.5.
1789  * @param[in] kappa (Optional) Kappa parameter used by [Krichevksy 2012] Across Channel Local Brightness Normalization equation.
1790  * @param[in] is_scaled (Optional) Boolean that specifies if alpha will be scaled by the normalization size or not.
1791  * Should be false to follow [Krichevksy 2012].
1792  */
1793  NormalizationLayerInfo(NormType type, uint32_t norm_size = 5, float alpha = 0.0001f, float beta = 0.5f, float kappa = 1.f, bool is_scaled = true)
1794  : _type(type), _norm_size(norm_size), _alpha(alpha), _beta(beta), _kappa(kappa), _is_scaled(is_scaled)
1795  {
1796  }
1797  /** Get the normalization type */
1798  NormType type() const
1799  {
1800  return _type;
1801  }
1802  /** Get the normalization size */
1803  uint32_t norm_size() const
1804  {
1805  return _norm_size;
1806  }
1807  /** Get the alpha value */
1808  float alpha() const
1809  {
1810  return _alpha;
1811  }
1812  /** Get the beta value */
1813  float beta() const
1814  {
1815  return _beta;
1816  }
1817  /** Get the kappa value */
1818  float kappa() const
1819  {
1820  return _kappa;
1821  }
1822  /** Get the is_scaled value */
1823  bool is_scaled() const
1824  {
1825  return _is_scaled;
1826  }
1827  /** Check if normalization is cross map */
1828  bool is_cross_map() const
1829  {
1830  return _type == NormType::CROSS_MAP;
1831  }
1832  /** Check if normalization is not cross map */
1833  bool is_in_map() const
1834  {
1835  return !is_cross_map();
1836  }
1837  /** Return the scaling factor of the normalization function.
1838  *
1839  * If is_scaled is set to false then [Krichevksy 2012] normalization scaling is performed,
1840  * where alpha is returned plainly, else alpha is scaled by the total number of elements used for the normalization.
1841  *
1842  * @return The normalization scaling factor.
1843  */
1844  float scale_coeff() const
1845  {
1846  const uint32_t size = (_type == NormType::IN_MAP_2D) ? _norm_size * _norm_size : _norm_size;
1847  return (_is_scaled) ? (_alpha / size) : _alpha;
1848  }
1849 
1850 private:
1851  NormType _type;
1852  uint32_t _norm_size;
1853  float _alpha;
1854  float _beta;
1855  float _kappa;
1856  bool _is_scaled;
1857 };
1858 
1860 {
1861 public:
1862  /** Default Constructor
1863  *
1864  * @param[in] begin_mask (Optional) If the ith bit of begin_mask is set, starts[i] is ignored and the fullest possible range in that dimension is used instead.
1865  * @param[in] end_mask (Optional) If the ith bit of end_mask is set, ends[i] is ignored and the fullest possible range in that dimension is used instead.
1866  * @param[in] shrink_axis_mask (Optional) If the ith bit of shrink_axis_mask is set, it implies that the ith specification shrinks the dimensionality by 1.
1867  */
1868  StridedSliceLayerInfo(int32_t begin_mask = 0, int32_t end_mask = 0, int32_t shrink_axis_mask = 0)
1869  : _begin_mask(begin_mask), _end_mask(end_mask), _shrink_axis_mask(shrink_axis_mask)
1870  {
1871  }
1872 
1873  /* Get the begin mask value */
1874  int32_t begin_mask() const
1875  {
1876  return _begin_mask;
1877  }
1878 
1879  /* Get the end mask value */
1880  int32_t end_mask() const
1881  {
1882  return _end_mask;
1883  }
1884 
1885  /* Get the shrink axis mask value */
1886  int32_t shrink_axis_mask() const
1887  {
1888  return _shrink_axis_mask;
1889  }
1890 
1891 private:
1892  int32_t _begin_mask;
1893  int32_t _end_mask;
1894  int32_t _shrink_axis_mask;
1895 };
1896 
1897 /** Memory layouts for the weights tensor.
1898  *
1899  * * UNSPECIFIED is used to select kernels that do not run in
1900  * variable weights mode.
1901  *
1902  * * ANY is used to query the kernel database to retrieve any of the
1903  * kernels that runs in variable weights mode. Once a kernel is
1904  * found, the specific format expected by the kernel can be
1905  * retrieved by the user for reordering the weights tensor
1906  * accordingly.
1907  *
1908  * The other values OHWIo{interleave_by}i{block_by} describe the
1909  * memory layout of a 4D tensor with layout OHWI that has been
1910  * transformed into a 4D tensor with dimensions O'HWI' where:
1911  *
1912  * O' = first multiple of {interleave_by} s.t. O<=O'
1913  * I' = first multiple of {block_by} s.t. I<=I'
1914  *
1915  * The total size of the dst tensor is O' x H x W x I'
1916  *
1917  * The access function of the tensor with layout
1918  * OHWIo{interleave_by}i{block_by} and size O'HWI' is a 6-parameter
1919  * access function, where the 6 parameters are computed as follows:
1920  *
1921  * x5 = floor(o/{interleave_by}) RANGE [0, O'/{interleave_by} -1] SIZE: O'/{interleave_by}
1922  *
1923  * x4 = h RANGE [0, H-1] SIZE: H
1924  * x3 = w RANGE [0, W-1] SIZE: W
1925  * x2 = floor(i/{block_by}) RANGE [0, I'/{block_by} -1] SIZE: I'/{block_by}
1926  * x1 = o%{interleave_by} RANGE [0, {interleave_by} -1] SIZE: {interleave_by}
1927  * x0 = i%{block_by} RANGE [0, {block_by} -1] SIZE: {block_by}
1928  * TOTAL SIZE: O' * H * W * I'
1929  *
1930  * 4D 6D
1931  * ----------------- -----------------------------------
1932  * value(o, h, w, i) = x5 * H * W * I' * {interleave_by}
1933  * + x4 * W * I' * {interleave_by}
1934  * + x3 * I' * {interleave_by}
1935  * + x2 * {interleave_by} * {block_by}
1936  * + x1 * {block_by}
1937  * + x0
1938  *
1939  * Notice that in arm_gemm the 4D tensor of dimension O'HWI' created
1940  * for the OHWIo{interleave_by}i{block_by} format is in reality seen
1941  * as a 2D tensor, where the number of rows is O'/{interleave_by}
1942  * and the number of columns is {interleave_by} * H * W * I'.
1943  *
1944  * The postfix *_bf16 is for the memory layout needed for the
1945  * fast-mode kernels, in which the weights are passed in bfloat16
1946  * format.
1947  */
1948 enum class WeightFormat
1949 {
1950  UNSPECIFIED = 0x1,
1951  ANY = 0x2,
1952  OHWI = 0x100100,
1953  OHWIo2 = 0x100200,
1954  OHWIo4 = 0x100400,
1955  OHWIo8 = 0x100800,
1956  OHWIo16 = 0x101000,
1957  OHWIo32 = 0x102000,
1958  OHWIo64 = 0x104000,
1959  OHWIo128 = 0x108000,
1960  OHWIo4i2 = 0x200400,
1961  OHWIo4i2_bf16 = 0x200410,
1962  OHWIo8i2 = 0x200800,
1963  OHWIo8i2_bf16 = 0x200810,
1964  OHWIo16i2 = 0x201000,
1965  OHWIo16i2_bf16 = 0x201010,
1966  OHWIo32i2 = 0x202000,
1967  OHWIo32i2_bf16 = 0x202010,
1968  OHWIo64i2 = 0x204000,
1969  OHWIo64i2_bf16 = 0x204010,
1970  OHWIo4i4 = 0x400400,
1971  OHWIo4i4_bf16 = 0x400410,
1972  OHWIo8i4 = 0x400800,
1973  OHWIo8i4_bf16 = 0x400810,
1974  OHWIo16i4 = 0x401000,
1975  OHWIo16i4_bf16 = 0x401010,
1976  OHWIo32i4 = 0x402000,
1977  OHWIo32i4_bf16 = 0x402010,
1978  OHWIo64i4 = 0x404000,
1979  OHWIo64i4_bf16 = 0x404010,
1980  OHWIo2i8 = 0x800200,
1981  OHWIo4i8 = 0x800400,
1982  OHWIo8i8 = 0x800800,
1983  OHWIo16i8 = 0x801000,
1984  OHWIo32i8 = 0x802000,
1985  OHWIo64i8 = 0x804000
1986 };
1987 // OHWIo<interleave_by>i<block_by>
1988 inline int interleave_by(const WeightFormat wf)
1989 {
1990  return (static_cast<int>(wf) >> 8) & 0xFFF;
1991 }
1992 inline int block_by(const WeightFormat wf)
1993 {
1994  return (static_cast<int>(wf) >> 20) & 0xF;
1995 }
1996 inline bool is_fixed_format(const WeightFormat &wf)
1997 {
1998  return wf != WeightFormat::UNSPECIFIED && wf != WeightFormat::ANY;
1999 }
2001 {
2002  return (static_cast<int>(wf) >> 4) & 0x1;
2003 }
2004 
2005 /** Convolution Layer Weights Information class. This class stores the necessary information to compute convolution layer when the weights are already reshaped */
2007 {
2008 public:
2009  /** Default constructor */
2011  : _are_reshaped(false), _kernel_width(0), _kernel_height(0), _num_kernels(0), _retain_internal_weights(false), _weight_format(arm_compute::WeightFormat::UNSPECIFIED)
2012  {
2013  }
2014  /** Constructor
2015  *
2016  * @param[in] are_reshaped True if the weights have been reshaped
2017  * @param[in] kernel_width Kernel width.
2018  * @param[in] kernel_height Kernel height.
2019  * @param[in] num_kernels Number of convolution kernels.
2020  * @param[in] retain_internal_weights (Optional) True if internal reshaped weights must be retained. Used for reconfiguration purposes. Default is false.
2021  * @param[in] weight_format (Optional) arm_gemm:WeightFormat enumeration requested by the user. Default is arm_compute::WeightFormat::UNSPECIFIED.
2022  */
2023  WeightsInfo(bool are_reshaped, unsigned int kernel_width, unsigned int kernel_height, unsigned int num_kernels, bool retain_internal_weights = false,
2025  : _are_reshaped(are_reshaped), _kernel_width(kernel_width), _kernel_height(kernel_height), _num_kernels(num_kernels), _retain_internal_weights(retain_internal_weights), _weight_format(weight_format)
2026  {
2027  }
2028  /** Flag which specifies if the weights tensor has been reshaped.
2029  *
2030  * @return True if the weights tensors has been reshaped
2031  */
2032  bool are_reshaped() const
2033  {
2034  return _are_reshaped;
2035  };
2036  /** Return the number of convolution kernels
2037  *
2038  * @return The number of convolution kernels
2039  */
2040  unsigned int num_kernels() const
2041  {
2042  return _num_kernels;
2043  };
2044  /** Return the width and height of the kernel
2045  *
2046  * @return The width and height of the kernel
2047  */
2048  std::pair<unsigned int, unsigned int> kernel_size() const
2049  {
2050  return std::make_pair(_kernel_width, _kernel_height);
2051  }
2053  {
2054  return _retain_internal_weights;
2055  }
2057  {
2058  return _weight_format;
2059  }
2061  {
2062  _weight_format = weight_format;
2063  }
2064 
2065  unsigned int kernel_width() const
2066  {
2067  return _kernel_width;
2068  }
2069  unsigned int kernel_height() const
2070  {
2071  return _kernel_height;
2072  }
2073 
2074 private:
2075  bool _are_reshaped;
2076  unsigned int _kernel_width;
2077  unsigned int _kernel_height;
2078  unsigned int _num_kernels;
2079  bool _retain_internal_weights;
2080  arm_compute::WeightFormat _weight_format;
2081 };
2082 
2083 /** GEMM reshape information class. This class stores the necessary information about matrix A and matrix B reshape.
2084  *
2085  * The matrix A can only be reshaped through @ref opencl::kernels::ClGemmReshapeLhsMatrixKernel or @ref cpu::kernels::CpuGemmInterleave4x4Kernel
2086  * Note: Optionally just for @ref opencl::kernels::ClGemmReshapeLhsMatrixKernel is it possible to set mult_interleave4x4_height, the multiplication factor for the height of the 4x4 interleaved block
2087  *
2088  * The matrix B can only be reshaped through @ref opencl::kernels::ClGemmReshapeRhsMatrixKernel or @ref cpu::kernels::CpuGemmTranspose1xWKernel
2089  * Note: Optionally just for @ref opencl::kernels::ClGemmReshapeRhsMatrixKernel is it possible to set mult_transpose1xW_width, the multiplication factor for the width of the 1xW transposed block
2090  *
2091  */
2092 class GEMMReshapeInfo final
2093 {
2094 public:
2095  /** Default constructor */
2097  : _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)
2098  {
2099  }
2100  /** Constructor
2101  *
2102  * @param[in] m Number of matrix A rows
2103  * @param[in] n Number of matrix B columns
2104  * @param[in] k Number of matrix A columns or matrix B rows
2105  * @param[in] mult_transpose1xW_width (Optional) Multiplication factor for the width of the 1xW transposed block
2106  * @param[in] mult_interleave4x4_height (Optional) Multiplication factor for the height of the 4x4 interleaved block
2107  * @param[in] depth_output_gemm3d (Optional) Depth (third dimension) of the output tensor to be used with the GEMM3D kernel.
2108  * If 0 the output will not be reinterpreted as 3D. Default 0
2109  * @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
2110  * to perform 1x1 convolutions with the NHWC data layout)
2111  * @param[in] broadcast_bias (Optional) Broadcast the shape of the bias tensor from a vector to a matrix.
2112  */
2113  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)
2114  : _m(m), _n(n), _k(k), _mult_transpose1xW_width(mult_transpose1xW_width), _mult_interleave4x4_height(mult_interleave4x4_height), _depth_output_gemm3d(depth_output_gemm3d),
2115  _reinterpret_input_as_3d(reinterpret_input_as_3d), _broadcast_bias(broadcast_bias)
2116  {
2117  }
2118  /** Number of matrix A rows
2119  *
2120  * @return the number of matrix A rows
2121  */
2122  int m() const
2123  {
2124  return _m;
2125  }
2126  /** Number of matrix B columns
2127  *
2128  * @return the number of matrix B columns
2129  */
2130  int n() const
2131  {
2132  return _n;
2133  }
2134  /** Number of matrix A columns or matrix B rows
2135  *
2136  * @return the number of matrix A columns or matrix B rows
2137  */
2138  int k() const
2139  {
2140  return _k;
2141  }
2142  /** Multiplication factor for the width of the 1xW transposed block
2143  *
2144  * @return the multiplication factor for the width of the 1xW transposed block
2145  */
2147  {
2148  return _mult_transpose1xW_width;
2149  }
2150  /** Multiplication factor for the height of the 4x4 interleaved block
2151  *
2152  * @return the multiplication factor for the height of the 4x4 interleaved block
2153  */
2155  {
2156  return _mult_interleave4x4_height;
2157  }
2158  /** Depth (third dimension) of the output tensor to be used with the GEMM3D kernel
2159  *
2160  * @note GEMM3D kernel is used when the output has to be reinterpret as 3D tensor. In that case:
2161  * m = depth_output_gemm3d * output_height
2162  *
2163  * @return the depth of the output tensor to be used with the GEMM3D kernel
2164  */
2166  {
2167  return _depth_output_gemm3d;
2168  }
2169  /** Flag which specifies if the input tensor has to be reinterpreted as 3D
2170  *
2171  * @return True if the input tensor has to be reinterpreted as 3D tensor
2172  */
2174  {
2175  return _reinterpret_input_as_3d;
2176  };
2177  /** Flag which specifies whether to broadcast the shape of the bias tensor.
2178  *
2179  * @return True if the shape of the bias tensor is to be broadcasted.
2180  */
2181  bool broadcast_bias() const
2182  {
2183  return _broadcast_bias;
2184  };
2185 
2186 private:
2187  int _m;
2188  int _n;
2189  int _k;
2190  int _mult_transpose1xW_width;
2191  int _mult_interleave4x4_height;
2192  int _depth_output_gemm3d;
2193  bool _reinterpret_input_as_3d;
2194  bool _broadcast_bias;
2195 };
2196 
2198 {
2199  ConvolutionInfo() = default;
2200  ConvolutionInfo(const PadStrideInfo &pad_stride_info, unsigned int depth_multiplier, const ActivationLayerInfo &act_info, const Size2D &dilation)
2201  : pad_stride_info(pad_stride_info), depth_multiplier(depth_multiplier), act_info(act_info), dilation(dilation)
2202  {
2203  }
2204  PadStrideInfo pad_stride_info{}; /**< Convolution info (Pads, strides,...) */
2205  unsigned int depth_multiplier{ 1 }; /**< Multiplier to apply to input's depth to retrieve the output depth. Defaults to 1 */
2206  ActivationLayerInfo act_info{}; /**< Fused activation to apply after convolution. */
2207  Size2D dilation{ Size2D(1, 1) }; /**< Dilation, in elements, across x and y. Defaults to (1, 1). */
2208 };
2209 
2210 /** GEMMLowp output stage type */
2212 {
2213  NONE, /**< No quantization */
2214  QUANTIZE_DOWN, /**< Quantize using an integer multiplication */
2215  QUANTIZE_DOWN_FIXEDPOINT, /**< Quantize using a fixed point multiplication */
2216  QUANTIZE_DOWN_FLOAT /**< Quantize using a floating point multiplication */
2217 };
2218 
2219 /** GEMMLowp output stage info */
2221 {
2222  GEMMLowpOutputStageType type{ GEMMLowpOutputStageType::NONE }; /**< GEMMLowp output stage type */
2223  int32_t gemmlowp_offset{ 0 }; /**< GEMMLowp output stage offset used for quantizing to QASYMM8 */
2224  int32_t gemmlowp_multiplier{ 0 }; /**< GEMMLowp output stage multiplier used for quantizing to QASYMM8 */
2225  int32_t gemmlowp_shift{ 0 }; /**< GEMMLowp output stage shift used for quantizing to uint8 */
2226  int32_t gemmlowp_min_bound{ std::numeric_limits<int32_t>::lowest() }; /**< GEMMLowp min value used to saturate down the output result before converting back to QASYMM8 */
2227  int32_t gemmlowp_max_bound{ std::numeric_limits<int32_t>::max() }; /**< GEMMLowp max value used to saturate down the output result before converting back to QASYMM8 */
2228  std::vector<int32_t> gemmlowp_multipliers{}; /**< GEMMLowp output stage multiplier used for quantizing to QASYMM8 */
2229  std::vector<int32_t> gemmlowp_shifts{}; /**< GEMMLowp output stage multiplier used for quantizing to QASYMM8 */
2230  float gemmlowp_real_multiplier{ 0 }; /**< GEMMLowp output stage real multiplier used for quantizing to QASYMM8 */
2231  bool is_quantized_per_channel{ false }; /**< GEMMLowp quantized per-channel flag */
2232  DataType output_data_type{ DataType::UNKNOWN }; /**< Output tensor data type to use if the output is not initialized */
2233 };
2234 
2235 /** GEMM LHS (Left Hand Side) matrix information */
2237 {
2238  GEMMLHSMatrixInfo() = default;
2239  GEMMLHSMatrixInfo(unsigned int m, unsigned int k, unsigned int v, bool trans, bool inter)
2240  : m0(m), k0(k), v0(v), transpose(trans), interleave(inter)
2241  {
2242  }
2243  unsigned int m0{ 1 }; /**< Number of rows processed by the matrix multiplication */
2244  unsigned int k0{ 1 }; /**< Number of partial accumulations performed by the matrix multiplication */
2245  unsigned int v0{ 1 }; /**< Number of vertical blocks of size (m0xk0) stored on the same output row */
2246  bool transpose{ true }; /**< True if the (m0xk0) block has to be transposed before been stored */
2247  bool interleave{ true }; /**< True if the v0 (m0xk0) blocks have to be interleaved in the output row */
2248 };
2249 
2250 /** GEMM RHS (Right Hand Side) matrix information */
2252 {
2253  GEMMRHSMatrixInfo() = default;
2254  GEMMRHSMatrixInfo(unsigned int n, unsigned int k, unsigned int h, bool trans, bool inter, bool export_to_cl_img)
2255  : n0(n), k0(k), h0(h), transpose(trans), interleave(inter), export_to_cl_image(export_to_cl_img)
2256  {
2257  }
2258  unsigned int n0{ 1 }; /**< Number of columns processed by the matrix multiplication */
2259  unsigned int k0{ 1 }; /**< Number of partial accumulations performed by the matrix multiplication */
2260  unsigned int h0{ 1 }; /**< Number of horizontal blocks of size (k0xn0) stored on the same output row */
2261  bool transpose{ true }; /**< True if the (k0xn0) block has to be transposed before been stored */
2262  bool interleave{ true }; /**< True if the h0 (k0xn0) blocks have to be interleaved in the output row */
2263  bool export_to_cl_image{ false }; /**< True if the reshaped rhs has to be exported to cl_image. n0 must be equal to 4 */
2264 };
2265 
2266 class ITensorInfo;
2267 /** GEMM information class. This class stores the necessary information to compute GEMM functions
2268  *
2269  * This object also contains the information about how matrix A and matrix B have been reshaped
2270  *
2271  */
2273 {
2274 public:
2275  /** Default constructor */
2276  GEMMInfo() noexcept
2277  : _is_a_reshaped(false),
2278  _is_b_reshaped(false),
2279  _reshape_b_only_on_first_run(true),
2280  _depth_output_gemm3d(0),
2281  _reinterpret_input_as_3d(false),
2282  _retain_internal_weights(false),
2283  _gemmlowp_output_stage(),
2284  _fast_math(false),
2285  _fp_mixed_precision(false),
2286  _broadcast_bias(false),
2287  _pretranspose_A(false),
2288  _pretranspose_B(false),
2289  _activation_info(),
2290  _post_ops(),
2291  _fixed_format(false),
2292  _weight_format(arm_compute::WeightFormat::UNSPECIFIED)
2293  {
2294  }
2295  /** Constructor
2296  *
2297  * @param[in] is_a_reshaped True if the matrix A has been reshaped
2298  * @param[in] is_b_reshaped True if the matrix B has been reshaped
2299  * @param[in] reshape_b_only_on_first_run Reshape matrix B only for the first run
2300  * @param[in] depth_output_gemm3d (Optional) Depth (third dimension) of the output tensor to be used with the GEMM3D kernel
2301  * If 0 the output will not be reinterpreted as 3D. Default 0
2302  * @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
2303  * to perform 1x1 convolutions with the NHWC data layout)
2304  * @param[in] retain_internal_weights (Optional) Retain the weights tensor from previous run
2305  * @param[in] gemmlowp_output_stage (Optional) GEMMLowp Output stage info
2306  * @param[in] fp_mixed_precision (Optional) Use wider accumulators (32 bit instead of 16 for FP16) to improve accuracy.
2307  * @param[in] fast_math (Optional) Use a data type of shorter width to improve performance
2308  * @param[in] broadcast_bias (Optional) Broadcast the shape of the bias tensor from a vector to a matrix.
2309  * @param[in] activation_info (Optional) Activation to apply after the matrix multiplication
2310  * @param[in] post_ops (Optional) A sequence of post operations that are performed after the main operation.
2311  * @param[in] fixed_format (Optional) Specify the selection of fixed format kernels for variable weights support in GEMM. These kernels expect the weights tensor to be in amemory format that is fixed by the kernel itself. For more information, see arm_compute::WeightFormat.
2312  * @param[in] weight_format (Optional) arm_gemm:WeightFormat enumeration requested by the user. Default is arm_compute::WeightFormat::UNSPECIFIED.
2313  */
2314  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,
2315  GEMMLowpOutputStageInfo gemmlowp_output_stage = GEMMLowpOutputStageInfo(), bool fp_mixed_precision = false, bool fast_math = false, bool broadcast_bias = false,
2317  bool fixed_format = false, arm_compute::WeightFormat weight_format = arm_compute::WeightFormat::UNSPECIFIED) noexcept
2318  : _is_a_reshaped(is_a_reshaped),
2319  _is_b_reshaped(is_b_reshaped),
2320  _reshape_b_only_on_first_run(reshape_b_only_on_first_run),
2321  _depth_output_gemm3d(depth_output_gemm3d),
2322  _reinterpret_input_as_3d(reinterpret_input_as_3d),
2323  _retain_internal_weights(retain_internal_weights),
2324  _gemmlowp_output_stage(gemmlowp_output_stage),
2325  _fast_math(fast_math),
2326  _fp_mixed_precision(fp_mixed_precision),
2327  _broadcast_bias(broadcast_bias),
2328  _pretranspose_A(false),
2329  _pretranspose_B(false),
2330  _activation_info(activation_info),
2331  _post_ops(post_ops),
2332  _fixed_format(fixed_format),
2333  _weight_format(weight_format)
2334  {
2335  }
2336  /** Flag which specifies if the matrix A has been reshaped
2337  *
2338  * @return True if the matrix A has been reshaped
2339  */
2340  bool is_a_reshaped() const
2341  {
2342  return _is_a_reshaped;
2343  };
2344  /** Flag which specifies if the matrix B has been reshaped
2345  *
2346  * @return True if the matrix B has been reshaped
2347  */
2348  bool is_b_reshaped() const
2349  {
2350  return _is_b_reshaped;
2351  };
2352  /** Flag which specifies if the reshape of matrix B should executed only for the first
2353  *
2354  * @note This flag could be set to TRUE when GEMM is used to accelerate convolution layer
2355  *
2356  * @return True if the reshaped of matrix B happens only for the first run
2357  */
2359  {
2360  return _reshape_b_only_on_first_run;
2361  };
2362  /** Depth of the output when GEMM output is reinterpreted as 3D tensor
2363  *
2364  * @return the depth of the output tensor
2365  */
2367  {
2368  return _depth_output_gemm3d;
2369  };
2370  /** Flag which specifies if the input tensor has to be reinterpreted as 3D
2371  *
2372  * @return True if the input tensor has to be reinterpreted as 3D tensor
2373  */
2375  {
2376  return _reinterpret_input_as_3d;
2377  };
2378  /** Flag which specifies if the weights tensor has to be retained from previous run
2379  *
2380  * @return True if the weights tensor has to be retained
2381  */
2383  {
2384  return _retain_internal_weights;
2385  };
2386  /** GEMMLowp output stage
2387  *
2388  * @return the GEMMLowp output stage info
2389  */
2391  {
2392  return _gemmlowp_output_stage;
2393  };
2394  /** Sets GEMMLowp output stage
2395  *
2396  * @param[in] output_stage Output stage to set
2397  */
2399  {
2400  _gemmlowp_output_stage = output_stage;
2401  };
2402  /** Flag which specifies if a wider accumulator should be used.
2403  *
2404  * @return True if a wider accumulator has to be used
2405  */
2406  bool fp_mixed_precision() const
2407  {
2408  return _fp_mixed_precision;
2409  };
2410  /** Flag which specifies if a shorter accumulator to be used.
2411  *
2412  * @return True if a shorter accumulator has to be used
2413  */
2414  bool fast_math() const
2415  {
2416  return _fast_math;
2417  };
2418  /** Set fast math flag
2419  *
2420  * @param[in] fast_math Flag to set
2421  */
2422  void set_fast_math(bool fast_math)
2423  {
2424  _fast_math = fast_math;
2425  }
2426  /** Flag which specifies whether to broadcast the shape of the bias tensor.
2427  *
2428  * @return True if the shape of the bias tensor is to be broadcasted.
2429  */
2430  bool broadcast_bias() const
2431  {
2432  return _broadcast_bias;
2433  };
2434  /** Flag which specifies whether A should be pre-transposed if supported.
2435  *
2436  * @return True if A should be pre-transposed else false.
2437  */
2438  bool pretranspose_A() const
2439  {
2440  return _pretranspose_A;
2441  };
2442  /** Set pre-transpose A flag
2443  *
2444  * @param[in] flag Flag to set
2445  */
2446  void set_pretranspose_A(bool flag)
2447  {
2448  _pretranspose_A = flag;
2449  }
2450  /** Flag which specifies whether b should be pre-transposed if supported.
2451  *
2452  * @return True if b should be pre-transposed else false.
2453  */
2454  bool pretranspose_B() const
2455  {
2456  return _pretranspose_B;
2457  };
2458  /** Set pre-transpose b flag
2459  *
2460  * @param[in] flag Flag to set
2461  */
2462  void set_pretranspose_B(bool flag)
2463  {
2464  _pretranspose_B = flag;
2465  }
2466  /** Activation layer to apply after the matrix multiplication
2467  *
2468  * @return ActivationLayerInfo object
2469  */
2471  {
2472  return _activation_info;
2473  }
2474  /** Set activation layer info
2475  *
2476  * @param[in] activation_info ActivationLayerInfo object to set
2477  */
2478  void set_activation_info(const ActivationLayerInfo &activation_info)
2479  {
2480  _activation_info = activation_info;
2481  }
2482  /** Post operations to apply after the matrix multiplication
2483  *
2484  * @return experimental::PostOpList object
2485  */
2487  {
2488  return _post_ops;
2489  }
2490  /** Set post ops
2491  *
2492  * @param[in] post_ops experimental::PostOpList object to set
2493  */
2495  {
2496  _post_ops = post_ops;
2497  }
2498  /** Flag which specifies if the GEMM operation is running fixed-format kernels.
2499  *
2500  * @return True if the GEMM operation is running fixed-format kernel else false.
2501  */
2502  bool fixed_format() const
2503  {
2504  return _fixed_format;
2505  }
2506 
2507  /** Set fixed-format flag
2508  *
2509  * @param[in] fixed_format sets whether or not to use fixed-format kernels
2510  */
2511  void set_fixed_format(bool fixed_format)
2512  {
2513  _fixed_format = fixed_format;
2514  }
2515 
2517  {
2518  return _weight_format;
2519  }
2520 
2521  /** Set weight format to be used
2522  *
2523  * @param[in] weight_format arm_compute::WeightFormat enumeration
2524  */
2526  {
2527  _weight_format = weight_format;
2528  }
2529 
2530 private:
2531  bool _is_a_reshaped;
2532  bool _is_b_reshaped;
2533  bool _reshape_b_only_on_first_run;
2534  int _depth_output_gemm3d;
2535  bool _reinterpret_input_as_3d;
2536  bool _retain_internal_weights;
2537  GEMMLowpOutputStageInfo _gemmlowp_output_stage;
2538  bool _fast_math;
2539  bool _fp_mixed_precision;
2540  bool _broadcast_bias;
2541  bool _pretranspose_A;
2542  bool _pretranspose_B;
2543  ActivationLayerInfo _activation_info;
2545  bool _fixed_format;
2546  arm_compute::WeightFormat _weight_format;
2547 };
2548 
2549 /** Winograd information */
2551 {
2552  /** Default constructor
2553  *
2554  * @param[in] output_tile_sz Width and height of the output tile
2555  * @param[in] kernel_sz Width and height of the kernel
2556  * @param[in] input_dims Width and height of the input tensor before the convolution is applied
2557  * @param[in] conv_info Convolution info (Pads, strides)
2558  * @param[in] data_layout Data layout to use for the output tensor once the convolution has been applied
2559  */
2560  WinogradInfo(Size2D output_tile_sz, Size2D kernel_sz, Size2D input_dims, PadStrideInfo conv_info, DataLayout data_layout)
2561  : output_tile_size(output_tile_sz), kernel_size(kernel_sz), input_dimensions(input_dims), convolution_info(conv_info), output_data_layout(data_layout)
2562  {
2563  }
2564 
2565  Size2D output_tile_size{}; /**< Width and height of the output tile */
2566  Size2D kernel_size{}; /**< Width and height of the kernel*/
2567  Size2D input_dimensions{}; /**< Width and height of the input tensor before the convolution is applied */
2568  PadStrideInfo convolution_info{}; /**< Convolution info (Pads, strides,...) */
2569  DataLayout output_data_layout{ DataLayout::NCHW }; /**< Data layout to use for the output tensor once the convolution has been applied (NCHW or NHWC) */
2570 };
2571 
2572 /** IO formatting information class*/
2574 {
2575  /** Precision type used when printing floating point numbers */
2576  enum class PrecisionType
2577  {
2578  Default, /**< Default precision to the one that the current stream has */
2579  Custom, /**< Custom precision specified by the user using the precision parameter */
2580  Full /**< The maximum precision of the floating point representation */
2581  };
2582 
2583  /** Specifies the area to be printed, used by Tensor objects */
2584  enum class PrintRegion
2585  {
2586  ValidRegion, /**< Prints the valid region of the Tensor object */
2587  NoPadding, /**< Prints the Tensor object without the padding */
2588  Full /**< Print the tensor object including padding */
2589  };
2590 
2591  /** Construct a set of IO formatting information.
2592  *
2593  * @param[in] print_region Area to be printed. Used by Tensor objects. Default: ValidRegion.
2594  * @param[in] precision_type Precision type for floating point numbers. Default: stream default.
2595  * @param[in] precision Precision value for float point numbers. Default: 10.
2596  * @param[in] align_columns Whether to align columns when printed. Default: true.
2597  * @param[in] element_delim Delimeter between elements. Default: " ".
2598  * @param[in] row_delim Delimenter between rows. Default: "\n".
2599  */
2600  IOFormatInfo(PrintRegion print_region = PrintRegion::ValidRegion,
2601  PrecisionType precision_type = PrecisionType::Default,
2602  unsigned int precision = 10,
2603  bool align_columns = true,
2604  std::string element_delim = " ",
2605  std::string row_delim = "\n")
2606  : print_region(print_region),
2607  precision_type(precision_type),
2608  precision(precision),
2609  element_delim(element_delim),
2610  row_delim(row_delim),
2611  align_columns(align_columns)
2612  {
2613  }
2614 
2615  /** Area to be printed by Tensor objects */
2617  /** Floating point precision type */
2619  /** Floating point precision */
2620  unsigned int precision;
2621  /** Element delimeter */
2622  std::string element_delim;
2623  /** Row delimeter */
2624  std::string row_delim;
2625  /** Align columns */
2627 };
2628 } // namespace arm_compute
2629 #endif /* ARM_COMPUTE_TYPES_H */
float scale_coeff() const
Return the scaling factor of the normalization function.
Definition: Types.h:1844
BorderMode
Methods available to handle borders.
Definition: Types.h:274
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:426
PrecisionType precision_type
Floating point precision type.
Definition: Types.h:2618
Pooling3dLayerInfo(PoolingType pool_type)
Constructor.
Definition: Types.h:1361
Coordinate type.
Definition: Types.h:442
DeconvolutionMethod
Available DeconvolutionMethod.
Definition: Types.h:151
__global uchar * offset(const Image *img, int x, int y)
Get the pointer position of a Image.
Definition: helpers.h:1084
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
GEMMLHSMatrixInfo(unsigned int m, unsigned int k, unsigned int v, bool trans, bool inter)
Definition: Types.h:2239
unsigned int top
top of the border
Definition: Types.h:390
A single plane of 32-bit macro pixel of U0, Y0, V0, Y1 byte.
ArithmeticOperation
Available element-wise operations.
Definition: Types.h:489
InterpolationPolicy
Interpolation method.
Definition: Types.h:411
int num_classes() const
Get num classes.
Definition: Types.h:997
int mult_interleave4x4_height() const
Multiplication factor for the height of the 4x4 interleaved block.
Definition: Types.h:2154
Generate Proposals Information class.
Definition: Types.h:1427
Second channel (used by formats with unknown channel types).
DepthwiseConvolutionFunction
Available DepthwiseConvolutionFunction.
Definition: Types.h:144
Shape of a tensor.
Definition: TensorShape.h:39
float kappa() const
Get the kappa value.
Definition: Types.h:1818
Quantize using a fixed point multiplication.
experimental::PostOpList< ITensorInfo * > post_ops
void set_fixed_format(bool fixed_format)
Set fixed-format flag.
Definition: Types.h:2511
uint32_t x
X coordinates.
Definition: Types.h:444
bool share_location() const
Get share location.
Definition: Types.h:1002
float im_width() const
Get image width (NMS may suppress boxes whose center sits beyond the image width) ...
Definition: Types.h:644
FullyConnectedLayerInfo & set_weights_trained_layout(DataLayout layout)
Sets the weights trained data layout.
Definition: Types.h:1761
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:1095
float scale_value_x() const
Get x scale value.
Definition: Types.h:1150
float score_thresh() const
Get the score threshold.
Definition: Types.h:599
DimensionRoundingType round() const
Get the rounding type.
Definition: Types.h:764
quantized, symmetric fixed-point 16-bit number
void set_activation_info(const ActivationLayerInfo &activation_info)
Set activation layer info.
Definition: Types.h:2478
bool pretranspose_A() const
Flag which specifies whether A should be pre-transposed if supported.
Definition: Types.h:2438
WeightsInfo(bool are_reshaped, unsigned int kernel_width, unsigned int kernel_height, unsigned int num_kernels, bool retain_internal_weights=false, arm_compute::WeightFormat weight_format=arm_compute::WeightFormat::UNSPECIFIED)
Constructor.
Definition: Types.h:2023
ROIPoolingLayerInfo(unsigned int pooled_width, unsigned int pooled_height, float spatial_scale, unsigned int sampling_ratio=0)
Constructor.
Definition: Types.h:1394
Padding3D() noexcept
Definition: Types.h:788
TensorShape shape
Shape of the valid region.
Definition: Types.h:266
WinogradInfo(Size2D output_tile_sz, Size2D kernel_sz, Size2D input_dims, PadStrideInfo conv_info, DataLayout data_layout)
Default constructor.
Definition: Types.h:2560
bool is_in_map() const
Check if normalization is not cross map.
Definition: Types.h:1833
bool enabled() const
Check if initialised.
Definition: Types.h:1678
GEMMRHSMatrixInfo(unsigned int n, unsigned int k, unsigned int h, bool trans, bool inter, bool export_to_cl_img)
Definition: Types.h:2254
std::vector< PaddingInfo > PaddingList
List of padding information.
Definition: Types.h:453
ReductionOperation
Available reduction operations.
Definition: Types.h:476
int interleave_by(const WeightFormat wf)
Definition: Types.h:1988
SimpleTensor< float > b
Definition: DFT.cpp:157
Container for 2D border size.
Definition: Types.h:282
size_t values_per_roi() const
Definition: Types.h:1545
ActivationLayerInfo(ActivationFunction f, float a=0.0f, float b=0.0f)
Default Constructor.
Definition: Types.h:1658
std::map< int, std::vector< BBox > > LabelBBox
Definition: Types.h:936
unsigned int max_detections() const
Get max detections.
Definition: Types.h:1109
Cr/V/Value channel.
DataLayoutDimension
[DataLayout enum definition]
Definition: Types.h:124
BoxWithNonMaximaSuppressionLimit Information class.
Definition: Types.h:573
PoolingLayerInfo(PoolingType pool_type, DataLayout data_layout)
Constructor.
Definition: Types.h:1260
Winograd information.
Definition: Types.h:2550
uint32_t norm_size() const
Get the normalization size.
Definition: Types.h:1803
1 channel, 1 U8 per channel
NormType type() const
Get the normalization type.
Definition: Types.h:1798
int mult_transpose1xW_width() const
Multiplication factor for the width of the 1xW transposed block.
Definition: Types.h:2146
float a() const
Get the alpha value.
Definition: Types.h:1668
GEMM reshape information class.
Definition: Types.h:2092
std::vector< float > aspect_ratios() const
Get aspect ratios.
Definition: Types.h:916
void set_post_ops(const experimental::PostOpList< ITensorInfo *> &post_ops)
Set post ops.
Definition: Types.h:2494
Class for specifying the size of a 3D shape or object.
Definition: Size3D.h:32
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:839
FullyConnectedLayerInfo & set_transpose_weights(bool should_transpose_weights)
Sets the transpose weights flag.
Definition: Types.h:1772
GEMMLowpOutputStageInfo gemmlowp_output_stage() const
GEMMLowp output stage.
Definition: Types.h:2390
bool are_reshaped() const
Flag which specifies if the weights tensor has been reshaped.
Definition: Types.h:2032
half_float::half half
16-bit floating point type
Definition: Types.h:48
1 channel, 1 F32 per channel
Pooling3dLayerInfo(PoolingType pool_type, Size3D pool_size, Size3D stride=Size3D(1U, 1U, 1U), Padding3D padding=Padding3D(), bool exclude_padding=false, bool fp_mixed_precision=false, DimensionRoundingType round_type=DimensionRoundingType::FLOOR)
Constructor.
Definition: Types.h:1337
DimensionRoundingType
Dimension rounding type when down-scaling on CNNs.
Definition: Types.h:550
Normalization Layer Information class.
Definition: Types.h:1780
Unknown channel format.
Padding3D(size_t pad_x, size_t pad_y, size_t pad_z)
Definition: Types.h:792
Output values are defined by bilinear interpolation between the pixels.
void set_weight_format(arm_compute::WeightFormat weight_format)
Definition: Types.h:2060
unsigned int precision
Floating point precision.
Definition: Types.h:2620
bool is_cross_map() const
Check if normalization is cross map.
Definition: Types.h:1828
#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
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 fast_math=false, bool broadcast_bias=false, const ActivationLayerInfo &activation_info=ActivationLayerInfo(), const experimental::PostOpList< ITensorInfo *> &post_ops=experimental::PostOpList< ITensorInfo *>(), bool fixed_format=false, arm_compute::WeightFormat weight_format=arm_compute::WeightFormat::UNSPECIFIED) noexcept
Constructor.
Definition: Types.h:2314
Fully connected layer info.
Definition: Types.h:1742
bool fp_mixed_precision() const
Flag which specifies if a wider accumulator should be used.
Definition: Types.h:2406
BilinearInterpolation
Bilinear Interpolation method used by LKTracker.
Definition: Types.h:419
GEMM LHS (Left Hand Side) matrix information.
Definition: Types.h:2236
Store the tensor&#39;s metadata.
Definition: ITensorInfo.h:40
A 2 plane YUV format of Luma (Y) and interleaved UV data at 4:2:0 sampling.
PoolingLayerInfo()
Default Constructor.
Definition: Types.h:1189
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:2113
Quantization info when assuming per layer quantization.
quantized, asymmetric fixed-point 16-bit number
1 channel, 1 U16 per channel
unsigned int bottom
bottom of the border
Definition: Types.h:392
WeightFormat
Memory layouts for the weights tensor.
Definition: Types.h:1948
float eta() const
Get eta.
Definition: Types.h:1027
int depth_output_gemm3d() const
Depth of the output when GEMM output is reinterpreted as 3D tensor.
Definition: Types.h:2366
PrintRegion print_region
Area to be printed by Tensor objects.
Definition: Types.h:2616
unsigned int pooled_width() const
Get the pooled width of the layer.
Definition: Types.h:1399
unsigned int pad_top() const
Get the top padding.
Definition: Types.h:753
bool operator==(const Dimensions< T > &lhs, const Dimensions< T > &rhs)
Check that given dimensions are equal.
Definition: Dimensions.h:276
Output values are defined to match the source pixel whose center is nearest to the sample position...
Bitwise NOT operation.
DetectionPostProcessLayerInfo()
Default Constructor.
Definition: Types.h:1071
bool retain_internal_weights() const
Flag which specifies if the weights tensor has to be retained from previous run.
Definition: Types.h:2382
DetectionOutputLayerCodeType
Available Detection Output code types.
Definition: Types.h:939
ConvolutionMethod
Available ConvolutionMethod.
Definition: Types.h:134
Activation Layer Information class.
Definition: Types.h:1625
decltype(strategy::transforms) typedef type
float spatial_scale() const
Definition: Types.h:1539
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:1139
int top_k() const
Get top K.
Definition: Types.h:1042
constexpr BorderSize(unsigned int top_bottom, unsigned int left_right)
Border with same size for top/bottom and left/right.
Definition: Types.h:303
Copyright (c) 2017-2022 Arm Limited.
WeightsInfo()
Default constructor.
Definition: Types.h:2010
bool suppress_size() const
Get if NMS will suppress boxes based on their size/position.
Definition: Types.h:634
bool is_b_reshaped() const
Flag which specifies if the matrix B has been reshaped.
Definition: Types.h:2348
int32_t x
X coordinates.
Definition: Types.h:437
ActivationFunction
Available activation functions.
Definition: Types.h:1629
1 channel, 1 F16 per channel
Samples are taken at pixel center.
float iou_threshold() const
Get intersection over union threshold.
Definition: Types.h:1129
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:590
uint32_t z
Z coordinates.
Definition: Types.h:446
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:1442
NMSType
Available non maxima suppression types.
Definition: Types.h:565
Convolution Layer Weights Information class.
Definition: Types.h:2006
DetectionOutputLayerInfo()
Default Constructor.
Definition: Types.h:952
1 channel, 1 S32 per channel
bool variance_encoded_in_target() const
Get if variance encoded in target.
Definition: Types.h:1012
16-bit brain floating-point number
signed 64-bit number
int n() const
Number of matrix B columns.
Definition: Types.h:2130
Pooling3dLayerInfo() noexcept
Default Constructor.
Definition: Types.h:1284
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:1793
void set_pretranspose_B(bool flag)
Set pre-transpose b flag.
Definition: Types.h:2462
FuseBatchNormalizationType
Available FuseBatchNormalizationType.
Definition: Types.h:158
const OutputStage & output_stage
int32_t y
Y coordinates.
Definition: Types.h:438
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:1237
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Definition: Error.h:152
std::array< float, 2 > steps() const
Get the step coordinates.
Definition: Types.h:886
float nms() const
Get the NMS.
Definition: Types.h:604
float nms_threshold() const
Get nms threshold.
Definition: Types.h:1022
ConvolutionInfo(const PadStrideInfo &pad_stride_info, unsigned int depth_multiplier, const ActivationLayerInfo &act_info, const Size2D &dilation)
Definition: Types.h:2200
Third channel (used by formats with unknown channel types).
bool padding_is_symmetric() const
Check whether the padding is symmetric.
Definition: Types.h:725
bool is_scaled() const
Get the is_scaled value.
Definition: Types.h:1823
1 channel, 1 U32 per channel
GEMM RHS (Right Hand Side) matrix information.
Definition: Types.h:2251
Normalization applied within the same map in 1D region.
Channel
Available channels.
Definition: Types.h:459
Format
Image colour formats.
Definition: Types.h:56
std::string row_delim
Row delimeter.
Definition: Types.h:2624
PaddingMode
Padding mode to use for PadLayer.
Definition: Types.h:165
IO formatting information class.
Definition: Types.h:2573
DimensionRoundingType round_type
Definition: Types.h:1380
quantized, asymmetric fixed-point 8-bit number unsigned
Pooling3dLayerInfo(PoolingType pool_type, unsigned int pool_size, Size3D stride=Size3D(1U, 1U, 1U), Padding3D padding=Padding3D(), bool exclude_padding=false, bool fp_mixed_precision=false, DimensionRoundingType round_type=DimensionRoundingType::FLOOR)
Constructor.
Definition: Types.h:1307
bool is_fixed_format(const WeightFormat &wf)
Definition: Types.h:1996
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
Pooling Layer Information struct.
Definition: Types.h:1281
float scale_value_h() const
Get h scale value.
Definition: Types.h:1156
std::pair< unsigned int, unsigned int > stride() const
Get the stride.
Definition: Types.h:717
float scale_value_w() const
Get w scale value.
Definition: Types.h:1162
Pooling Layer Information struct.
Definition: Types.h:1186
float nms_score_threshold() const
Get nms threshold.
Definition: Types.h:1124
float soft_nms_min_score_thres() const
Get soft nms min score threshold.
Definition: Types.h:629
BitwiseOperation
Available bitwise operations.
Definition: Types.h:515
std::array< float, 4 > BBox
Definition: Types.h:934
unsigned int kernel_height() const
Definition: Types.h:2069
bool dequantize_scores() const
Get dequantize_scores value.
Definition: Types.h:1168
GEMMLowp output stage info.
Definition: Types.h:2220
unsigned int kernel_width() const
Definition: Types.h:2065
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:811
float offset() const
Get the offset.
Definition: Types.h:896
Fourth channel (used by formats with unknown channel types).
DetectionOutputLayerCodeType code_type() const
Get detection output code type.
Definition: Types.h:1007
unsigned int pad_right() const
Get the right padding.
Definition: Types.h:748
float beta() const
Get the beta value.
Definition: Types.h:1813
int k() const
Number of matrix A columns or matrix B rows.
Definition: Types.h:2138
int block_by(const WeightFormat wf)
Definition: Types.h:1992
Quantize using a floating point multiplication.
Padding and stride information class.
Definition: Types.h:669
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:1210
GEMMLowpOutputStageType
GEMMLowp output stage type.
Definition: Types.h:2211
Coordinates2D img_size() const
Get the image size coordinates.
Definition: Types.h:891
bool align_columns
Align columns.
Definition: Types.h:2626
unsigned int num_kernels() const
Return the number of convolution kernels.
Definition: Types.h:2040
void set_pretranspose_A(bool flag)
Set pre-transpose A flag.
Definition: Types.h:2446
bool reinterpret_input_as_3d() const
Flag which specifies if the input tensor has to be reinterpreted as 3D.
Definition: Types.h:2374
Bounding Box Transform information class.
Definition: Types.h:1558
unsigned int left
left of the border
Definition: Types.h:393
constexpr BorderSize(unsigned int size) noexcept
Border with equal size around the 2D plane.
Definition: Types.h:294
GEMMInfo() noexcept
Default constructor.
Definition: Types.h:2276
PriorBoxLayerInfo()
Default Constructor.
Definition: Types.h:815
unsigned int right
right of the border
Definition: Types.h:391
y*x if x < 0, x otherwise
Num samples, depth, height, width, channels.
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:1571
1 channel, 1 S16 per channel
qasymm8_t qasymm8_leaky_relu(qasymm8_t in, const UniformQuantizationInfo &qi_in, const UniformQuantizationInfo &qi_out, float alpha)
bool broadcast_bias() const
Flag which specifies whether to broadcast the shape of the bias tensor.
Definition: Types.h:2430
bool pretranspose_B() const
Flag which specifies whether b should be pre-transposed if supported.
Definition: Types.h:2454
int keep_top_k() const
Get the number of total bounding boxes to be kept per image.
Definition: Types.h:1017
Output values are determined by averaging the source pixels whose areas fall under the area of the de...
Num samples, channels, depth, height, width.
quantized, symmetric fixed-point 8-bit number
unsigned int sampling_ratio() const
Get sampling ratio.
Definition: Types.h:1414
Num samples, channels, height, width.
PrecisionType
Precision type used when printing floating point numbers.
Definition: Types.h:2576
qasymm8_t qasymm8_hard_swish(qasymm8_t in, const UniformQuantizationInfo &qi_in, const UniformQuantizationInfo &qi_out)
unsigned int max_classes_per_detection() const
Get max_classes per detection.
Definition: Types.h:1114
bool broadcast_bias() const
Flag which specifies whether to broadcast the shape of the bias tensor.
Definition: Types.h:2181
bool is_a_reshaped() const
Flag which specifies if the matrix A has been reshaped.
Definition: Types.h:2340
int round(float x, RoundingPolicy rounding_policy)
Return a rounded value of x.
Definition: Rounding.cpp:35
float scale_value_y() const
Get y scale value.
Definition: Types.h:1144
const experimental::PostOpList< ITensorInfo * > & post_ops() const
Post operations to apply after the matrix multiplication.
Definition: Types.h:2486
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:701
Strides of an item in bytes.
Definition: Strides.h:37
quantized, symmetric per channel fixed-point 8-bit number
Convolution using Winograd.
bool operator==(const BorderSize &rhs) const
Check equality with another BorderSize struct.
Definition: Types.h:362
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:639
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:680
Detection Output layer info.
Definition: Types.h:948
4 channels, 1 U8 per channel
uint32_t y
Y coordinates.
Definition: Types.h:445
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:557
Bitwise XOR operation.
PadStrideInfo pad_stride_info
Definition: Types.h:1274
GEMMReshapeInfo()
Default constructor.
Definition: Types.h:2096
void set_gemmlowp_output_stage(GEMMLowpOutputStageInfo &output_stage)
Sets GEMMLowp output stage.
Definition: Types.h:2398
constexpr bool empty() const
Check if the entire border is zero.
Definition: Types.h:315
int32_t shrink_axis_mask() const
Definition: Types.h:1886
bool is_fixed_format_fast_math(const WeightFormat &wf)
Definition: Types.h:2000
std::pair< uint32_t, uint32_t > PaddingInfo
Padding information as a pair of unsigned int start/end.
Definition: Types.h:450
Coordinate type.
Definition: Types.h:435
int end(unsigned int d) const
Return the end of the valid region for the given dimension d.
Definition: Types.h:236
Bitwise AND operation.
unsigned int pooled_height() const
Get the pooled height of the layer.
Definition: Types.h:1404
int m() const
Number of matrix A rows.
Definition: Types.h:2122
bool fast_math() const
Flag which specifies if a shorter accumulator to be used.
Definition: Types.h:2414
Borders are left undefined.
ROI Pooling Layer Information class.
Definition: Types.h:1384
Pixels outside the image are assumed to have the same value as the closest image pixel.
Bitwise OR operation.
Class for specifying the size of an image or rectangle.
Definition: Size2D.h:34
Detection window used for the object detection.
Definition: Types.h:537
std::vector< float > max_sizes() const
Get max sizes.
Definition: Types.h:911
ComputeAnchors information class.
Definition: Types.h:1508
uint16_t width
Width of the rectangle.
Definition: Types.h:430
Num samples, height, width, channels.
unsigned int detection_per_class() const
Get detection per class.
Definition: Types.h:1119
bool flip() const
Get the flip value.
Definition: Types.h:901
2 channel, 1 U8 per channel
float spatial_scale() const
Get the spatial scale.
Definition: Types.h:1409
uint16_t y
Top-left y coordinate.
Definition: Types.h:429
Detection Output layer info.
Definition: Types.h:1067
int depth_output_gemm3d() const
Depth (third dimension) of the output tensor to be used with the GEMM3D kernel.
Definition: Types.h:2165
constexpr bool uniform() const
Check if the border is the same size on all sides.
Definition: Types.h:321
unsigned int num_classes() const
Get num classes.
Definition: Types.h:1134
Use box centers and size but flip x and y co-ordinates.
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="\)
Construct a set of IO formatting information.
Definition: Types.h:2600
PrintRegion
Specifies the area to be printed, used by Tensor objects.
Definition: Types.h:2584
std::vector< float > variances() const
Get min variances.
Definition: Types.h:881
arm_compute::WeightFormat weight_format() const
Definition: Types.h:2056
std::array< float, 4 > weights() const
Definition: Types.h:1579
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:2358
constexpr BorderSize(unsigned int top, unsigned int right, unsigned int bottom, unsigned int left)
Border with different sizes.
Definition: Types.h:309
uint16_t x
Top-left x coordinate.
Definition: Types.h:428
float alpha() const
Get the alpha value.
Definition: Types.h:1808
GEMM information class.
Definition: Types.h:2272
SimpleTensor< T > transpose(const SimpleTensor< T > &src)
Definition: Transpose.cpp:38
BorderSize operator*(float scale)
Scale a copy of this border size.
Definition: Types.h:348
std::pair< unsigned int, unsigned int > pad() const
Get the padding.
Definition: Types.h:735
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:980
ActivationFunction activation() const
Get the type of activation function.
Definition: Types.h:1663
float b() const
Get the beta value.
Definition: Types.h:1673
quantized, asymmetric fixed-point 8-bit number signed
bool fixed_format() const
Flag which specifies if the GEMM operation is running fixed-format kernels.
Definition: Types.h:2502
64-bit floating-point number
Container for valid region of a window.
Definition: Types.h:184
Padding3D(size_t left, size_t right, size_t top, size_t bottom, size_t front, size_t back)
Definition: Types.h:797
constexpr BorderSize() noexcept
Empty border, i.e.
Definition: Types.h:285
bool operator!=(const BorderSize &rhs) const
Check non-equality with another BorderSize struct.
Definition: Types.h:373
uint16_t height
Height of the rectangle.
Definition: Types.h:431
unsigned int pad_bottom() const
Get the bottom padding.
Definition: Types.h:758
A single plane of 32-bit macro pixel of Y0, U0, Y1, V0 bytes.
bool clip() const
Get the clip value.
Definition: Types.h:906
unsigned 64-bit number
DataType
Available data types.
Definition: Types.h:79
bool reinterpret_input_as_3d() const
Flag which specifies if the input tensor has to be reinterpreted as 3D.
Definition: Types.h:2173
ActivationLayerInfo activation_info() const
Activation layer to apply after the matrix multiplication.
Definition: Types.h:2470
unsigned int pad_left() const
Get the left padding.
Definition: Types.h:743
ElementWiseUnary
Available element wise unary operations.
Definition: Types.h:502
DataLayout
[DataLayout enum definition]
Definition: Types.h:113
std::vector< uint32_t > Multiples
Information to produce a tiled version of a Tensor.
Definition: Types.h:456
NormType
The normalization type used for the normalization layer.
Definition: Types.h:524
signed 8-bit number
A sequence of PostOps that can be appended to the end of other operators.
Definition: IPostOp.h:119
Normalization applied cross maps.
BorderSize & operator*=(float scale)
Scale this border size.
Definition: Types.h:332
Convolution using GEMM.
ConvertPolicy
Policy to handle integer overflow.
Definition: Types.h:404
NMSType soft_nms_method() const
Get soft NMS method.
Definition: Types.h:619
void limit(const BorderSize &limit)
Limit this border size.
Definition: Types.h:382
int background_label_id() const
Get background label ID.
Definition: Types.h:1032
float im_height() const
Get image height (NMS may suppress boxes whose center sits beyond the image height) ...
Definition: Types.h:649
Coordinates anchor
Anchor for the start of the valid region.
Definition: Types.h:265
static bool is_lut_supported(ActivationFunction act_func, DataType data_type)
Definition: Types.h:1702
ValidRegion()
Default constructor.
Definition: Types.h:187
float confidence_threshold() const
Get confidence threshold.
Definition: Types.h:1037
Normalization applied within the same map in 2D region.
bool retain_internal_weights() const
Definition: Types.h:2052
StridedSliceLayerInfo(int32_t begin_mask=0, int32_t end_mask=0, int32_t shrink_axis_mask=0)
Default Constructor.
Definition: Types.h:1868
SamplingPolicy
Available Sampling Policies.
Definition: Types.h:104
float soft_nms_sigma() const
Get soft NMS sigma.
Definition: Types.h:624
std::pair< unsigned int, unsigned int > kernel_size() const
Return the width and height of the kernel.
Definition: Types.h:2048
int num_loc_classes() const
Get number of location classes.
Definition: Types.h:1047
bool soft_nms_enabled() const
Check if soft NMS is enabled.
Definition: Types.h:614
int detections_per_im() const
Get the number of detections.
Definition: Types.h:609
std::string element_delim
Element delimeter.
Definition: Types.h:2622
arm_compute::WeightFormat weight_format() const
Definition: Types.h:2516
void set_fast_math(bool fast_math)
Set fast math flag.
Definition: Types.h:2422
std::vector< float > min_sizes() const
Get min sizes.
Definition: Types.h:876
void set_weight_format(arm_compute::WeightFormat weight_format)
Set weight format to be used.
Definition: Types.h:2525
std::array< qasymm8_t, 256 > LookupTable256
Lookup table.
Definition: Types.h:1648
bool has_padding() const
Check whether this has any padding.
Definition: Types.h:770
Padding information for 3D operations like Conv3d.
Definition: Types.h:786
ComputeAnchorsInfo(float feat_width, float feat_height, float spatial_scale, size_t values_per_roi=4)
Constructor.
Definition: Types.h:1518