Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2016, 2017 ARM Limited. |
| 3 | * |
| 4 | * SPDX-License-Identifier: MIT |
| 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | * of this software and associated documentation files (the "Software"), to |
| 8 | * deal in the Software without restriction, including without limitation the |
| 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
| 10 | * sell copies of the Software, and to permit persons to whom the Software is |
| 11 | * furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice shall be included in all |
| 14 | * copies or substantial portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 22 | * SOFTWARE. |
| 23 | */ |
| 24 | #ifndef __ARM_COMPUTE_TYPES_H__ |
| 25 | #define __ARM_COMPUTE_TYPES_H__ |
| 26 | |
| 27 | #include "arm_compute/core/Coordinates.h" |
Georgios Pinitas | 8795ffb | 2017-12-01 16:13:40 +0000 | [diff] [blame] | 28 | #include "arm_compute/core/Strides.h" |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 29 | #include "arm_compute/core/TensorShape.h" |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 30 | #include "support/Half.h" |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 31 | |
| 32 | #include <cstddef> |
| 33 | #include <cstdint> |
| 34 | #include <string> |
| 35 | #include <utility> |
| 36 | |
| 37 | namespace arm_compute |
| 38 | { |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 39 | /** 16-bit floating point type */ |
| 40 | using half = half_float::half; |
| 41 | |
Georgios Pinitas | 8795ffb | 2017-12-01 16:13:40 +0000 | [diff] [blame] | 42 | /** Permutation vector */ |
| 43 | using PermutationVector = Strides; |
| 44 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 45 | /** Image colour formats */ |
| 46 | enum class Format |
| 47 | { |
Daniil Efremov | 02bf80d | 2017-11-22 00:26:51 +0700 | [diff] [blame] | 48 | UNKNOWN, /**< Unknown image format */ |
| 49 | U8, /**< 1 channel, 1 U8 per channel */ |
| 50 | S16, /**< 1 channel, 1 S16 per channel */ |
| 51 | U16, /**< 1 channel, 1 U16 per channel */ |
| 52 | S32, /**< 1 channel, 1 S32 per channel */ |
| 53 | U32, /**< 1 channel, 1 U32 per channel */ |
| 54 | F16, /**< 1 channel, 1 F16 per channel */ |
| 55 | F32, /**< 1 channel, 1 F32 per channel */ |
| 56 | UV88, /**< 2 channel, 1 U8 per channel */ |
| 57 | RGB888, /**< 3 channels, 1 U8 per channel */ |
| 58 | RGBA8888, /**< 4 channels, 1 U8 per channel */ |
| 59 | YUV444, /**< A 3 plane of 8 bit 4:4:4 sampled Y, U, V planes */ |
| 60 | YUYV422, /**< A single plane of 32-bit macro pixel of Y0, U0, Y1, V0 bytes */ |
| 61 | NV12, /**< A 2 plane YUV format of Luma (Y) and interleaved UV data at 4:2:0 sampling */ |
| 62 | NV21, /**< A 2 plane YUV format of Luma (Y) and interleaved VU data at 4:2:0 sampling */ |
| 63 | IYUV, /**< A 3 plane of 8-bit 4:2:0 sampled Y, U, V planes */ |
| 64 | UYVY422 /**< A single plane of 32-bit macro pixel of U0, Y0, V0, Y1 byte */ |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 65 | }; |
| 66 | |
| 67 | /** Available data types */ |
| 68 | enum class DataType |
| 69 | { |
| 70 | UNKNOWN, |
| 71 | U8, |
| 72 | S8, |
| 73 | QS8, |
Michel Iwaniec | 0063380 | 2017-10-12 14:14:15 +0100 | [diff] [blame] | 74 | QASYMM8, |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 75 | U16, |
| 76 | S16, |
| 77 | QS16, |
| 78 | U32, |
| 79 | S32, |
Pablo Tello | f87cc7f | 2017-07-26 10:28:40 +0100 | [diff] [blame] | 80 | QS32, |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 81 | U64, |
| 82 | S64, |
| 83 | F16, |
| 84 | F32, |
| 85 | F64, |
| 86 | SIZET |
| 87 | }; |
| 88 | |
Daniil Efremov | 02bf80d | 2017-11-22 00:26:51 +0700 | [diff] [blame] | 89 | /** Available Sampling Policies */ |
| 90 | enum class SamplingPolicy |
| 91 | { |
| 92 | CENTER, /**< Samples are taken at pixel center */ |
| 93 | TOP_LEFT /**< Samples are taken at pixel top left corner */ |
| 94 | }; |
| 95 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 96 | /** Constant value of the border pixels when using BorderMode::CONSTANT */ |
| 97 | constexpr uint8_t CONSTANT_BORDER_VALUE = 199; |
| 98 | |
| 99 | /* Constant value used to indicate a half-scale pyramid */ |
| 100 | constexpr float SCALE_PYRAMID_HALF = 0.5f; |
| 101 | |
| 102 | /* Constant value used to indicate a ORB scaled pyramid */ |
| 103 | constexpr float SCALE_PYRAMID_ORB = 8.408964152537146130583778358414e-01; |
| 104 | |
Jaroslaw Rzepecki | 0a878ae | 2017-11-22 17:16:39 +0000 | [diff] [blame] | 105 | /** Rounding method */ |
| 106 | enum class RoundingPolicy |
| 107 | { |
| 108 | TO_ZERO, /**< Truncates the least significand values that are lost in operations. */ |
| 109 | TO_NEAREST_UP, /**< Rounds to nearest value; half rounds away from zero */ |
| 110 | TO_NEAREST_EVEN, /**< Rounds to nearest value; half rounds to nearest even */ |
| 111 | }; |
| 112 | |
| 113 | //forward declare round function |
| 114 | int round(float, RoundingPolicy); |
| 115 | |
Michel Iwaniec | 0063380 | 2017-10-12 14:14:15 +0100 | [diff] [blame] | 116 | /** Quantization settings (used for QASYMM8 data type) */ |
| 117 | struct QuantizationInfo |
| 118 | { |
| 119 | QuantizationInfo() |
| 120 | : scale(0.0f), offset(0) |
| 121 | { |
| 122 | } |
| 123 | |
| 124 | QuantizationInfo(float scale, int offset) |
| 125 | : scale(scale), offset(offset) |
| 126 | { |
| 127 | } |
| 128 | |
Daniil Efremov | eed841c | 2017-11-09 19:05:25 +0700 | [diff] [blame] | 129 | bool operator==(const QuantizationInfo &other) |
| 130 | { |
| 131 | return scale == other.scale && offset == other.offset; |
| 132 | } |
| 133 | |
| 134 | bool operator!=(const QuantizationInfo &other) |
| 135 | { |
| 136 | return !(*this == other); |
| 137 | } |
| 138 | |
Michel Iwaniec | 0063380 | 2017-10-12 14:14:15 +0100 | [diff] [blame] | 139 | float scale; /**< scale */ |
| 140 | int offset; /**< offset */ |
| 141 | |
| 142 | /** Quantizes a value using the scale/offset in this QuantizationInfo */ |
Jaroslaw Rzepecki | 0a878ae | 2017-11-22 17:16:39 +0000 | [diff] [blame] | 143 | uint8_t quantize(float value, RoundingPolicy rounding_policy) const |
Michel Iwaniec | 0063380 | 2017-10-12 14:14:15 +0100 | [diff] [blame] | 144 | { |
| 145 | ARM_COMPUTE_ERROR_ON_MSG(scale == 0, "QuantizationInfo::quantize: scale == 0"); |
Jaroslaw Rzepecki | 0a878ae | 2017-11-22 17:16:39 +0000 | [diff] [blame] | 146 | int quantized = arm_compute::round(value / scale, rounding_policy) + offset; |
Michel Iwaniec | 0063380 | 2017-10-12 14:14:15 +0100 | [diff] [blame] | 147 | quantized = std::max(0, std::min(quantized, 255)); |
| 148 | return quantized; |
| 149 | } |
| 150 | |
| 151 | /** Dequantizes a value using the scale/offset in this QuantizationInfo */ |
| 152 | float dequantize(uint8_t value) const |
| 153 | { |
| 154 | ARM_COMPUTE_ERROR_ON_MSG(scale == 0, "QuantizationInfo::dequantize: scale == 0"); |
Anton Lokhmotov | af6204c | 2017-11-08 09:34:19 +0000 | [diff] [blame] | 155 | float dequantized = (static_cast<int>(value) - offset) * scale; |
Michel Iwaniec | 0063380 | 2017-10-12 14:14:15 +0100 | [diff] [blame] | 156 | return dequantized; |
| 157 | } |
| 158 | |
| 159 | /** Indicates whether this QuantizationInfo has valid settings or not */ |
| 160 | bool empty() const |
| 161 | { |
| 162 | return scale == 0; |
| 163 | } |
| 164 | }; |
| 165 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 166 | struct ValidRegion |
| 167 | { |
| 168 | ValidRegion() |
| 169 | : anchor{}, shape{} |
| 170 | { |
| 171 | } |
| 172 | |
| 173 | ValidRegion(const ValidRegion &) = default; |
| 174 | ValidRegion(ValidRegion &&) = default; |
| 175 | ValidRegion &operator=(const ValidRegion &) = default; |
| 176 | ValidRegion &operator=(ValidRegion &&) = default; |
| 177 | ~ValidRegion() = default; |
| 178 | |
| 179 | ValidRegion(Coordinates anchor, TensorShape shape) |
| 180 | : anchor{ anchor }, shape{ shape } |
| 181 | { |
| 182 | } |
| 183 | |
| 184 | /** Return the start of the valid region for the given dimension @p d */ |
| 185 | int start(unsigned int d) const |
| 186 | { |
| 187 | return anchor[d]; |
| 188 | } |
| 189 | |
| 190 | /** Return the end of the valid region for the given dimension @p d */ |
| 191 | int end(unsigned int d) const |
| 192 | { |
| 193 | return anchor[d] + shape[d]; |
| 194 | } |
| 195 | |
| 196 | Coordinates anchor; |
| 197 | TensorShape shape; |
| 198 | }; |
| 199 | |
| 200 | /** Methods available to handle borders */ |
| 201 | enum class BorderMode |
| 202 | { |
| 203 | UNDEFINED, /**< Borders are left undefined */ |
| 204 | CONSTANT, /**< Pixels outside the image are assumed to have a constant value */ |
| 205 | REPLICATE /**< Pixels outside the image are assumed to have the same value as the closest image pixel */ |
| 206 | }; |
| 207 | |
| 208 | /** Container for 2D border size */ |
| 209 | struct BorderSize |
| 210 | { |
| 211 | /** Empty border, i.e. no border */ |
| 212 | constexpr BorderSize() |
| 213 | : top{ 0 }, right{ 0 }, bottom{ 0 }, left{ 0 } |
| 214 | { |
| 215 | } |
| 216 | |
| 217 | /** Border with equal size around the 2D plane */ |
Moritz Pflanzer | 7655a67 | 2017-09-23 11:57:33 +0100 | [diff] [blame] | 218 | explicit constexpr BorderSize(unsigned int size) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 219 | : top{ size }, right{ size }, bottom{ size }, left{ size } |
| 220 | { |
| 221 | } |
| 222 | |
| 223 | /** Border with same size for top/bottom and left/right */ |
| 224 | constexpr BorderSize(unsigned int top_bottom, unsigned int left_right) |
| 225 | : top{ top_bottom }, right{ left_right }, bottom{ top_bottom }, left{ left_right } |
| 226 | { |
| 227 | } |
| 228 | |
| 229 | /** Border with different sizes */ |
| 230 | constexpr BorderSize(unsigned int top, unsigned int right, unsigned int bottom, unsigned int left) |
| 231 | : top{ top }, right{ right }, bottom{ bottom }, left{ left } |
| 232 | { |
| 233 | } |
| 234 | |
| 235 | /** Check if the entire border is zero */ |
| 236 | constexpr bool empty() const |
| 237 | { |
| 238 | return top == 0 && right == 0 && bottom == 0 && left == 0; |
| 239 | } |
| 240 | |
| 241 | /** Check if the border is the same size on all sides */ |
| 242 | constexpr bool uniform() const |
| 243 | { |
| 244 | return top == right && top == bottom && top == left; |
| 245 | } |
| 246 | |
| 247 | BorderSize &operator*=(float scale) |
| 248 | { |
| 249 | top *= scale; |
| 250 | right *= scale; |
| 251 | bottom *= scale; |
| 252 | left *= scale; |
| 253 | |
| 254 | return *this; |
| 255 | } |
| 256 | |
| 257 | BorderSize operator*(float scale) |
| 258 | { |
| 259 | BorderSize size = *this; |
| 260 | size *= scale; |
| 261 | |
| 262 | return size; |
| 263 | } |
| 264 | |
| 265 | void limit(const BorderSize &limit) |
| 266 | { |
| 267 | top = std::min(top, limit.top); |
| 268 | right = std::min(right, limit.right); |
| 269 | bottom = std::min(bottom, limit.bottom); |
| 270 | left = std::min(left, limit.left); |
| 271 | } |
| 272 | |
| 273 | unsigned int top; |
| 274 | unsigned int right; |
| 275 | unsigned int bottom; |
| 276 | unsigned int left; |
| 277 | }; |
| 278 | |
| 279 | using PaddingSize = BorderSize; |
| 280 | |
| 281 | /** Policy to handle overflow */ |
| 282 | enum class ConvertPolicy |
| 283 | { |
| 284 | WRAP, /**< Wrap around */ |
| 285 | SATURATE /**< Saturate */ |
| 286 | }; |
| 287 | |
| 288 | /** Interpolation method */ |
| 289 | enum class InterpolationPolicy |
| 290 | { |
| 291 | NEAREST_NEIGHBOR, /**< Output values are defined to match the source pixel whose center is nearest to the sample position */ |
| 292 | BILINEAR, /**< Output values are defined by bilinear interpolation between the pixels */ |
| 293 | 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 */ |
| 294 | }; |
| 295 | |
| 296 | /** Bilinear Interpolation method used by LKTracker */ |
| 297 | enum class BilinearInterpolation |
| 298 | { |
| 299 | BILINEAR_OLD_NEW, |
| 300 | BILINEAR_SCHARR |
| 301 | }; |
| 302 | |
| 303 | /** Threshold mode */ |
| 304 | enum class ThresholdType |
| 305 | { |
| 306 | BINARY, /**< Threshold with one value */ |
| 307 | RANGE /**< Threshold with two values*/ |
| 308 | }; |
| 309 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 310 | /** Termination criteria */ |
| 311 | enum class Termination |
| 312 | { |
| 313 | TERM_CRITERIA_EPSILON, |
| 314 | TERM_CRITERIA_ITERATIONS, |
| 315 | TERM_CRITERIA_BOTH |
| 316 | }; |
| 317 | |
| 318 | /** Magnitude calculation type. */ |
| 319 | enum class MagnitudeType |
| 320 | { |
| 321 | L1NORM, /**< L1 normalization type */ |
| 322 | L2NORM /**< L2 normalization type */ |
| 323 | }; |
| 324 | |
| 325 | /** Phase calculation type. |
| 326 | * |
| 327 | * @note When PhaseType == SIGNED, each angle is mapped to the range 0 to 255 inclusive otherwise angles between 0 and 180 |
| 328 | */ |
| 329 | enum class PhaseType |
| 330 | { |
| 331 | SIGNED, /**< Angle range: [0, 360] */ |
| 332 | UNSIGNED /**< Angle range: [0, 180] */ |
| 333 | }; |
| 334 | |
| 335 | /** Keypoint type */ |
| 336 | struct KeyPoint |
| 337 | { |
| 338 | int32_t x{ 0 }; /**< X coordinates */ |
| 339 | int32_t y{ 0 }; /**< Y coordinates */ |
| 340 | float strength{ 0.f }; /**< Strength of the point */ |
| 341 | float scale{ 0.f }; /**< Scale initialized to 0 by the corner detector */ |
| 342 | float orientation{ 0.f }; /**< Orientation initialized to 0 by the corner detector */ |
| 343 | int32_t tracking_status{ 0 }; /**< Status initialized to 1 by the corner detector, set to 0 when the point is lost */ |
| 344 | float error{ 0.f }; /**< Tracking error initialized to 0 by the corner detector */ |
| 345 | }; |
| 346 | |
| 347 | using InternalKeypoint = std::tuple<float, float, float>; /* x,y,strength */ |
| 348 | |
| 349 | /** Rectangle type */ |
| 350 | struct Rectangle |
| 351 | { |
| 352 | uint16_t x; /**< Top-left x coordinate */ |
| 353 | uint16_t y; /**< Top-left y coordinate */ |
| 354 | uint16_t width; /**< Width of the rectangle */ |
| 355 | uint16_t height; /**< Height of the rectangle */ |
| 356 | }; |
| 357 | |
| 358 | /** Coordinate type */ |
| 359 | struct Coordinates2D |
| 360 | { |
| 361 | int32_t x; /**< X coordinates */ |
| 362 | int32_t y; /**< Y coordinates */ |
| 363 | }; |
| 364 | |
| 365 | /** Coordinate type */ |
| 366 | struct Coordinates3D |
| 367 | { |
| 368 | uint32_t x; /**< X coordinates */ |
| 369 | uint32_t y; /**< Y coordinates */ |
| 370 | uint32_t z; /**< Z coordinates */ |
| 371 | }; |
| 372 | |
Georgios Pinitas | 7b7858d | 2017-06-21 16:44:24 +0100 | [diff] [blame] | 373 | /** Region of interest */ |
| 374 | struct ROI |
| 375 | { |
| 376 | Rectangle rect; /**< Rectangle specifying the region of interest */ |
| 377 | uint16_t batch_idx; /**< The batch index of the region of interest */ |
| 378 | }; |
| 379 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 380 | /** Available channels */ |
| 381 | enum class Channel |
| 382 | { |
| 383 | UNKNOWN, /** Unknown channel format */ |
| 384 | C0, /**< First channel (used by formats with unknown channel types). */ |
| 385 | C1, /**< Second channel (used by formats with unknown channel types). */ |
| 386 | C2, /**< Third channel (used by formats with unknown channel types). */ |
| 387 | C3, /**< Fourth channel (used by formats with unknown channel types). */ |
| 388 | R, /**< Red channel. */ |
| 389 | G, /**< Green channel. */ |
| 390 | B, /**< Blue channel. */ |
| 391 | A, /**< Alpha channel. */ |
| 392 | Y, /**< Luma channel. */ |
| 393 | U, /**< Cb/U channel. */ |
| 394 | V /**< Cr/V/Value channel. */ |
| 395 | }; |
| 396 | |
| 397 | /** Available matrix patterns */ |
| 398 | enum class MatrixPattern |
| 399 | { |
| 400 | BOX, /**< Box pattern matrix. */ |
| 401 | CROSS, /**< Cross pattern matrix. */ |
| 402 | DISK, /**< Disk pattern matrix. */ |
| 403 | OTHER /**< Any other matrix pattern. */ |
| 404 | }; |
| 405 | |
| 406 | /** Available non linear functions. */ |
| 407 | enum class NonLinearFilterFunction : unsigned |
| 408 | { |
| 409 | MEDIAN = 0, /**< Non linear median filter. */ |
| 410 | MIN = 1, /**< Non linear erode. */ |
| 411 | MAX = 2, /**< Non linear dilate. */ |
| 412 | }; |
| 413 | |
Georgios Pinitas | d976958 | 2017-08-03 10:19:40 +0100 | [diff] [blame] | 414 | /** Available reduction operations */ |
| 415 | enum class ReductionOperation |
| 416 | { |
| 417 | SUM_SQUARE, /**< Sum of squares */ |
Michalis Spyrou | 04f089c | 2017-08-08 17:42:38 +0100 | [diff] [blame] | 418 | SUM, /**< Sum */ |
Georgios Pinitas | d976958 | 2017-08-03 10:19:40 +0100 | [diff] [blame] | 419 | }; |
| 420 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 421 | /** The normalization type used for the normalization layer */ |
| 422 | enum class NormType |
| 423 | { |
| 424 | IN_MAP_1D, /**< Normalization applied within the same map in 1D region */ |
| 425 | IN_MAP_2D, /**< Normalization applied within the same map in 2D region */ |
| 426 | CROSS_MAP /**< Normalization applied cross maps */ |
| 427 | }; |
| 428 | |
| 429 | /** Normalization type for Histogram of Oriented Gradients (HOG) */ |
| 430 | enum class HOGNormType |
| 431 | { |
| 432 | L2_NORM = 1, /**< L2-norm */ |
| 433 | L2HYS_NORM = 2, /**< L2-norm followed by clipping */ |
| 434 | L1_NORM = 3 /**< L1 norm */ |
| 435 | }; |
| 436 | |
| 437 | /** Detection window used for the object detection. The detection window keeps the following information: |
| 438 | * |
| 439 | * -# Geometry of the rectangular window (x/y of top-left corner and width/height) |
| 440 | * -# Index of the class used for evaluating which class the detection window belongs to |
| 441 | * -# Confidence value (score) obtained with the classifier |
| 442 | */ |
| 443 | struct DetectionWindow |
| 444 | { |
| 445 | uint16_t x{ 0 }; /**< Top-left x coordinate */ |
| 446 | uint16_t y{ 0 }; /**< Top-left y coordinate */ |
| 447 | uint16_t width{ 0 }; /**< Width of the detection window */ |
| 448 | uint16_t height{ 0 }; /**< Height of the detection window */ |
| 449 | uint16_t idx_class{ 0 }; /**< Index of the class */ |
| 450 | float score{ 0.f }; /**< Confidence value for the detection window */ |
| 451 | }; |
| 452 | |
| 453 | /** Dimension rounding type when down-scaling on CNNs |
| 454 | * @note Used in pooling and convolution layer |
| 455 | */ |
| 456 | enum class DimensionRoundingType |
| 457 | { |
| 458 | FLOOR, /**< Floor rounding */ |
| 459 | CEIL /**< Ceil rounding */ |
| 460 | }; |
| 461 | |
| 462 | /** Available pooling types */ |
| 463 | enum class PoolingType |
| 464 | { |
| 465 | MAX, /**< Max Pooling */ |
Georgios Pinitas | cdf5145 | 2017-08-31 14:21:36 +0100 | [diff] [blame] | 466 | AVG, /**< Average Pooling */ |
| 467 | L2 /**< L2 Pooling */ |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 468 | }; |
| 469 | |
| 470 | /** Padding and stride information class */ |
| 471 | class PadStrideInfo |
| 472 | { |
| 473 | public: |
| 474 | /** Constructor |
| 475 | * |
| 476 | * @param[in] stride_x (Optional) Stride, in elements, across x. Defaults to 1. |
| 477 | * @param[in] stride_y (Optional) Stride, in elements, across y. Defaults to 1. |
| 478 | * @param[in] pad_x (Optional) Padding, in elements, across x. Defaults to 0. |
| 479 | * @param[in] pad_y (Optional) Padding, in elements, across y. Defaults to 0. |
| 480 | * @param[in] round (Optional) Dimensions rounding. Defaults to @ref FLOOR. |
| 481 | */ |
| 482 | PadStrideInfo(unsigned int stride_x = 1, unsigned int stride_y = 1, |
| 483 | unsigned int pad_x = 0, unsigned int pad_y = 0, |
| 484 | DimensionRoundingType round = DimensionRoundingType::FLOOR) |
| 485 | : _stride(std::make_pair(stride_x, stride_y)), |
Jaroslaw Rzepecki | a1ed41f | 2017-10-13 11:13:58 +0100 | [diff] [blame] | 486 | _pad_left(pad_x), |
| 487 | _pad_top(pad_y), |
| 488 | _pad_right(pad_x), |
| 489 | _pad_bottom(pad_y), |
| 490 | _round_type(round) |
| 491 | { |
| 492 | } |
| 493 | /** Constructor |
| 494 | * |
| 495 | * @param[in] stride_x Stride, in elements, across x. |
| 496 | * @param[in] stride_y Stride, in elements, across y. |
| 497 | * @param[in] pad_left Padding across x on the left, in elements. |
| 498 | * @param[in] pad_top Padding across y on the top, in elements. |
| 499 | * @param[in] pad_right Padding across x on the right, in elements. |
| 500 | * @param[in] pad_bottom Padding across y on the bottom, in elements. |
| 501 | * @param[in] round Dimensions rounding. |
| 502 | */ |
| 503 | PadStrideInfo(unsigned int stride_x, unsigned int stride_y, |
| 504 | unsigned int pad_left, unsigned int pad_right, |
| 505 | unsigned int pad_top, unsigned int pad_bottom, |
| 506 | DimensionRoundingType round) |
| 507 | : _stride(std::make_pair(stride_x, stride_y)), |
| 508 | _pad_left(pad_left), |
| 509 | _pad_top(pad_top), |
| 510 | _pad_right(pad_right), |
| 511 | _pad_bottom(pad_bottom), |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 512 | _round_type(round) |
| 513 | { |
| 514 | } |
| 515 | std::pair<unsigned int, unsigned int> stride() const |
| 516 | { |
| 517 | return _stride; |
| 518 | } |
| 519 | std::pair<unsigned int, unsigned int> pad() const |
| 520 | { |
Jaroslaw Rzepecki | a1ed41f | 2017-10-13 11:13:58 +0100 | [diff] [blame] | 521 | //this accessor should be used only when padding is symmetric |
| 522 | ARM_COMPUTE_ERROR_ON(_pad_left != _pad_right || _pad_top != _pad_bottom); |
| 523 | return std::make_pair(_pad_left, _pad_top); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 524 | } |
Jaroslaw Rzepecki | a1ed41f | 2017-10-13 11:13:58 +0100 | [diff] [blame] | 525 | |
| 526 | unsigned int pad_left() const |
| 527 | { |
| 528 | return _pad_left; |
| 529 | } |
| 530 | unsigned int pad_right() const |
| 531 | { |
| 532 | return _pad_right; |
| 533 | } |
| 534 | unsigned int pad_top() const |
| 535 | { |
| 536 | return _pad_top; |
| 537 | } |
| 538 | unsigned int pad_bottom() const |
| 539 | { |
| 540 | return _pad_bottom; |
| 541 | } |
| 542 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 543 | DimensionRoundingType round() const |
| 544 | { |
| 545 | return _round_type; |
| 546 | } |
| 547 | |
Jaroslaw Rzepecki | a1ed41f | 2017-10-13 11:13:58 +0100 | [diff] [blame] | 548 | bool has_padding() const |
| 549 | { |
| 550 | return (_pad_left != 0 || _pad_top != 0 || _pad_right != 0 || _pad_bottom != 0); |
| 551 | } |
| 552 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 553 | private: |
| 554 | std::pair<unsigned int, unsigned int> _stride; |
Jaroslaw Rzepecki | a1ed41f | 2017-10-13 11:13:58 +0100 | [diff] [blame] | 555 | unsigned int _pad_left; |
| 556 | unsigned int _pad_top; |
| 557 | unsigned int _pad_right; |
| 558 | unsigned int _pad_bottom; |
| 559 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 560 | DimensionRoundingType _round_type; |
| 561 | }; |
| 562 | |
| 563 | /** Pooling Layer Information class */ |
| 564 | class PoolingLayerInfo |
| 565 | { |
| 566 | public: |
Georgios Pinitas | 4c2dd54 | 2017-11-13 12:58:41 +0000 | [diff] [blame] | 567 | /** Default Constructor */ |
| 568 | PoolingLayerInfo() |
| 569 | : _pool_type(PoolingType::MAX), _pool_size(0), _pad_stride_info(PadStrideInfo()), _exclude_padding(false), _is_global_pooling(false) |
| 570 | { |
| 571 | } |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 572 | /** Default Constructor |
| 573 | * |
Georgios Pinitas | 4c2dd54 | 2017-11-13 12:58:41 +0000 | [diff] [blame] | 574 | * @param[in] pool_type Pooling type @ref PoolingType. |
| 575 | * @param[in] pool_size Pooling size, in elements, across x and y. |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 576 | * @param[in] pad_stride_info (Optional) Padding and stride information @ref PadStrideInfo |
Georgios Pinitas | adaae7e | 2017-10-30 15:56:32 +0000 | [diff] [blame] | 577 | * @param[in] exclude_padding (Optional) Strategy when accounting padding in calculations. |
| 578 | * True will exclude padding while false will not (Used in AVG/L2 pooling to determine the pooling area). |
| 579 | * Defaults to false; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 580 | */ |
Georgios Pinitas | 4c2dd54 | 2017-11-13 12:58:41 +0000 | [diff] [blame] | 581 | explicit PoolingLayerInfo(PoolingType pool_type, |
| 582 | unsigned int pool_size, |
| 583 | PadStrideInfo pad_stride_info = PadStrideInfo(), |
| 584 | bool exclude_padding = false) |
| 585 | : _pool_type(pool_type), _pool_size(pool_size), _pad_stride_info(pad_stride_info), _exclude_padding(exclude_padding), _is_global_pooling(false) |
| 586 | { |
| 587 | } |
| 588 | /** Default Constructor |
| 589 | * |
| 590 | * @note This constructor is used for global pooling |
| 591 | * |
| 592 | * @param[in] pool_type Pooling type @ref PoolingType. |
| 593 | */ |
| 594 | explicit PoolingLayerInfo(PoolingType pool_type) |
| 595 | : _pool_type(pool_type), _pool_size(0), _pad_stride_info(PadStrideInfo(1, 1, 0, 0)), _exclude_padding(false), _is_global_pooling(true) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 596 | { |
| 597 | } |
| 598 | PoolingType pool_type() const |
| 599 | { |
| 600 | return _pool_type; |
| 601 | } |
| 602 | unsigned int pool_size() const |
| 603 | { |
| 604 | return _pool_size; |
| 605 | } |
| 606 | PadStrideInfo pad_stride_info() const |
| 607 | { |
| 608 | return _pad_stride_info; |
| 609 | } |
Georgios Pinitas | adaae7e | 2017-10-30 15:56:32 +0000 | [diff] [blame] | 610 | bool exclude_padding() const |
| 611 | { |
| 612 | return _exclude_padding; |
| 613 | } |
Georgios Pinitas | 4c2dd54 | 2017-11-13 12:58:41 +0000 | [diff] [blame] | 614 | bool is_global_pooling() const |
| 615 | { |
| 616 | return _is_global_pooling; |
| 617 | } |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 618 | |
| 619 | private: |
| 620 | PoolingType _pool_type; |
| 621 | unsigned int _pool_size; |
| 622 | PadStrideInfo _pad_stride_info; |
Georgios Pinitas | adaae7e | 2017-10-30 15:56:32 +0000 | [diff] [blame] | 623 | bool _exclude_padding; |
Georgios Pinitas | 4c2dd54 | 2017-11-13 12:58:41 +0000 | [diff] [blame] | 624 | bool _is_global_pooling; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 625 | }; |
| 626 | |
Georgios Pinitas | 7b7858d | 2017-06-21 16:44:24 +0100 | [diff] [blame] | 627 | /** ROI Pooling Layer Information class */ |
| 628 | class ROIPoolingLayerInfo |
| 629 | { |
| 630 | public: |
| 631 | /** Default Constructor |
| 632 | * |
| 633 | * @param[in] pooled_width Pooled width of the layer. |
| 634 | * @param[in] pooled_height Pooled height of the layer. |
| 635 | * @param[in] spatial_scale Spatial scale to be applied to the ROI coordinates and dimensions. |
| 636 | */ |
| 637 | ROIPoolingLayerInfo(unsigned int pooled_width, unsigned int pooled_height, float spatial_scale) |
| 638 | : _pooled_width(pooled_width), _pooled_height(pooled_height), _spatial_scale(spatial_scale) |
| 639 | { |
| 640 | } |
| 641 | unsigned int pooled_width() const |
| 642 | { |
| 643 | return _pooled_width; |
| 644 | } |
| 645 | unsigned int pooled_height() const |
| 646 | { |
| 647 | return _pooled_height; |
| 648 | } |
| 649 | float spatial_scale() const |
| 650 | { |
| 651 | return _spatial_scale; |
| 652 | } |
| 653 | |
| 654 | private: |
| 655 | unsigned int _pooled_width; |
| 656 | unsigned int _pooled_height; |
| 657 | float _spatial_scale; |
| 658 | }; |
| 659 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 660 | /** Activation Layer Information class */ |
| 661 | class ActivationLayerInfo |
| 662 | { |
| 663 | public: |
| 664 | /** Available activation functions */ |
| 665 | enum class ActivationFunction |
| 666 | { |
Georgios Pinitas | 64ebe5b | 2017-09-01 17:44:24 +0100 | [diff] [blame] | 667 | LOGISTIC, /**< Logistic ( \f$ f(x) = \frac{1}{1 + e^{-x}} \f$ ) */ |
| 668 | TANH, /**< Hyperbolic tangent ( \f$ f(x) = a \cdot tanh(b \cdot x) \f$ ) */ |
| 669 | RELU, /**< Rectifier ( \f$ f(x) = max(0,x) \f$ ) */ |
| 670 | BOUNDED_RELU, /**< Upper Bounded Rectifier ( \f$ f(x) = min(a, max(0,x)) \f$ ) */ |
| 671 | LU_BOUNDED_RELU, /**< Lower and Upper Bounded Rectifier ( \f$ f(x) = min(a, max(b,x)) \f$ ) */ |
| 672 | LEAKY_RELU, /**< Leaky Rectifier ( \f$ f(x)= log(1+e^x) \f$ ) */ |
| 673 | SOFT_RELU, /**< Soft Rectifier ( \f$ f(x)= log(1+e^x) \f$ ) */ |
| 674 | ABS, /**< Absolute ( \f$ f(x)= |x| \f$ ) */ |
| 675 | SQUARE, /**< Square ( \f$ f(x)= x^2 \f$ )*/ |
| 676 | SQRT, /**< Square root ( \f$ f(x) = \sqrt{x} \f$ )*/ |
| 677 | LINEAR /**< Linear ( \f$ f(x)= ax + b \f$ ) */ |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 678 | }; |
| 679 | |
| 680 | /** Default Constructor |
| 681 | * |
| 682 | * @param[in] f The activation function to use. |
| 683 | * @param[in] a (Optional) The alpha parameter used by some activation functions |
Georgios Pinitas | 64ebe5b | 2017-09-01 17:44:24 +0100 | [diff] [blame] | 684 | * (@ref ActivationFunction::BOUNDED_RELU, @ref ActivationFunction::LU_BOUNDED_RELU, @ref ActivationFunction::LINEAR, @ref ActivationFunction::TANH). |
| 685 | * @param[in] b (Optional) The beta parameter used by some activation functions (@ref ActivationFunction::LINEAR, @ref ActivationFunction::LU_BOUNDED_RELU, @ref ActivationFunction::TANH). |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 686 | */ |
| 687 | ActivationLayerInfo(ActivationFunction f, float a = 0.0f, float b = 0.0f) |
| 688 | : _act(f), _a(a), _b(b) |
| 689 | { |
| 690 | } |
| 691 | ActivationFunction activation() const |
| 692 | { |
| 693 | return _act; |
| 694 | } |
| 695 | float a() const |
| 696 | { |
| 697 | return _a; |
| 698 | } |
| 699 | float b() const |
| 700 | { |
| 701 | return _b; |
| 702 | } |
| 703 | |
| 704 | private: |
| 705 | ActivationFunction _act; |
| 706 | float _a; |
| 707 | float _b; |
| 708 | }; |
| 709 | |
| 710 | /** Normalization Layer Information class */ |
| 711 | class NormalizationLayerInfo |
| 712 | { |
| 713 | public: |
| 714 | /** Default Constructor |
| 715 | * |
| 716 | * @param[in] type The normalization type. Can be @ref NormType::IN_MAP_1D, @ref NormType::IN_MAP_2D or @ref NORM_TYPE::CROSS_MAP |
| 717 | * @param[in] norm_size The normalization size is the number of elements to normalize across. Defaults to 5. |
Georgios Pinitas | 41caa62 | 2017-11-16 14:37:08 +0000 | [diff] [blame] | 718 | * @param[in] alpha (Optional) Alpha parameter used by normalization equation. Defaults to 0.0001. |
| 719 | * @param[in] beta (Optional) Beta parameter used by normalization equation. Defaults to 0.5. |
| 720 | * @param[in] kappa (Optional) Kappa parameter used by [Krichevksy 2012] Across Channel Local Brightness Normalization equation. |
| 721 | * @param[in] is_scaled (Optional) Boolean that specifies if alpha will be scaled by the normalization size or not. |
| 722 | * Should be false to follow [Krichevksy 2012]. |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 723 | */ |
Georgios Pinitas | 41caa62 | 2017-11-16 14:37:08 +0000 | [diff] [blame] | 724 | NormalizationLayerInfo(NormType type, uint32_t norm_size = 5, float alpha = 0.0001f, float beta = 0.5f, float kappa = 1.f, bool is_scaled = true) |
| 725 | : _type(type), _norm_size(norm_size), _alpha(alpha), _beta(beta), _kappa(kappa), _is_scaled(is_scaled) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 726 | { |
| 727 | } |
| 728 | NormType type() const |
| 729 | { |
| 730 | return _type; |
| 731 | } |
| 732 | uint32_t norm_size() const |
| 733 | { |
| 734 | return _norm_size; |
| 735 | } |
| 736 | float alpha() const |
| 737 | { |
| 738 | return _alpha; |
| 739 | } |
| 740 | float beta() const |
| 741 | { |
| 742 | return _beta; |
| 743 | } |
| 744 | float kappa() const |
| 745 | { |
| 746 | return _kappa; |
| 747 | } |
Georgios Pinitas | 41caa62 | 2017-11-16 14:37:08 +0000 | [diff] [blame] | 748 | bool is_cross_map() const |
| 749 | { |
| 750 | return _type == NormType::CROSS_MAP; |
| 751 | } |
| 752 | bool is_in_map() const |
| 753 | { |
| 754 | return !is_cross_map(); |
| 755 | } |
| 756 | /** Return the scaling factor of the normalization function. |
| 757 | * |
| 758 | * If is_scaled is set to false then [Krichevksy 2012] normalization scaling is performed, |
| 759 | * where alpha is returned plainly, else alpha is scaled by the total number of elements used for the normalization. |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 760 | * |
| 761 | * @return The normalization scaling factor. |
| 762 | */ |
| 763 | float scale_coeff() const |
| 764 | { |
| 765 | const uint32_t size = (_type == NormType::IN_MAP_2D) ? _norm_size * _norm_size : _norm_size; |
Georgios Pinitas | 41caa62 | 2017-11-16 14:37:08 +0000 | [diff] [blame] | 766 | return (_is_scaled) ? (_alpha / size) : _alpha; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 767 | } |
| 768 | |
| 769 | private: |
| 770 | NormType _type; |
| 771 | uint32_t _norm_size; |
| 772 | float _alpha; |
| 773 | float _beta; |
| 774 | float _kappa; |
Georgios Pinitas | 41caa62 | 2017-11-16 14:37:08 +0000 | [diff] [blame] | 775 | bool _is_scaled; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 776 | }; |
| 777 | |
Gian Marco Iodice | 559d771 | 2017-08-08 08:38:09 +0100 | [diff] [blame] | 778 | /** Convolution Layer Weights Information class. This class stores the necessary information to compute convolution layer when the weights are already reshaped */ |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 779 | class WeightsInfo |
| 780 | { |
| 781 | public: |
Gian Marco Iodice | 4e28869 | 2017-06-27 11:41:59 +0100 | [diff] [blame] | 782 | /** Default constructor */ |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 783 | WeightsInfo() |
Gian Marco Iodice | 559d771 | 2017-08-08 08:38:09 +0100 | [diff] [blame] | 784 | : _are_reshaped(false), _kernel_width(0), _kernel_height(0), _num_kernels(0) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 785 | { |
| 786 | } |
| 787 | /** Constructor |
| 788 | * |
Gian Marco Iodice | 4e28869 | 2017-06-27 11:41:59 +0100 | [diff] [blame] | 789 | * @param[in] are_reshaped True if the weights have been reshaped |
| 790 | * @param[in] kernel_width Kernel width. |
| 791 | * @param[in] kernel_height Kernel height. |
Gian Marco Iodice | 559d771 | 2017-08-08 08:38:09 +0100 | [diff] [blame] | 792 | * @param[in] num_kernels Number of convolution kernels. |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 793 | */ |
Gian Marco Iodice | 559d771 | 2017-08-08 08:38:09 +0100 | [diff] [blame] | 794 | WeightsInfo(bool are_reshaped, unsigned int kernel_width, unsigned int kernel_height, unsigned int num_kernels) |
| 795 | : _are_reshaped(are_reshaped), _kernel_width(kernel_width), _kernel_height(kernel_height), _num_kernels(num_kernels) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 796 | { |
| 797 | } |
Gian Marco Iodice | 4e28869 | 2017-06-27 11:41:59 +0100 | [diff] [blame] | 798 | /** Flag which specifies if the weights tensor has been reshaped. |
| 799 | * |
| 800 | * @return True if the weights tensors has been reshaped |
| 801 | */ |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 802 | bool are_reshaped() const |
| 803 | { |
| 804 | return _are_reshaped; |
| 805 | }; |
Gian Marco Iodice | 559d771 | 2017-08-08 08:38:09 +0100 | [diff] [blame] | 806 | /** Return the number of convolution kernels |
| 807 | * |
| 808 | * @return The number of convolution kernels |
| 809 | */ |
| 810 | unsigned int num_kernels() const |
| 811 | { |
| 812 | return _num_kernels; |
| 813 | }; |
Gian Marco Iodice | 4e28869 | 2017-06-27 11:41:59 +0100 | [diff] [blame] | 814 | /** Return the width and height of the kernel |
| 815 | * |
| 816 | * @return The width and height of the kernel |
| 817 | */ |
| 818 | std::pair<unsigned int, unsigned int> kernel_size() const |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 819 | { |
Gian Marco Iodice | 4e28869 | 2017-06-27 11:41:59 +0100 | [diff] [blame] | 820 | return std::make_pair(_kernel_width, _kernel_height); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 821 | } |
| 822 | |
| 823 | private: |
| 824 | const bool _are_reshaped; |
Gian Marco Iodice | 4e28869 | 2017-06-27 11:41:59 +0100 | [diff] [blame] | 825 | const unsigned int _kernel_width; |
| 826 | const unsigned int _kernel_height; |
Gian Marco Iodice | 559d771 | 2017-08-08 08:38:09 +0100 | [diff] [blame] | 827 | const unsigned int _num_kernels; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 828 | }; |
| 829 | |
Chunosov | 5124be5 | 2017-11-22 20:42:13 +0700 | [diff] [blame] | 830 | /** GEMM Information class. This class stores the necessary information to compute GEMM functions */ |
| 831 | class GEMMInfo |
| 832 | { |
| 833 | public: |
| 834 | /** Default constructor */ |
| 835 | GEMMInfo() |
| 836 | : _is_a_reshaped(false), _is_b_reshaped(false), _reshape_b_only_on_first_run(false) |
| 837 | { |
| 838 | } |
| 839 | /** Constructor |
| 840 | * |
| 841 | * @param[in] is_a_reshaped True if the matrix A has been reshaped |
| 842 | * @param[in] is_b_reshaped True if the matrix B has been reshaped |
| 843 | * @param[in] reshape_b_only_on_first_run Reshape matrix B only for the first run |
| 844 | */ |
| 845 | GEMMInfo(bool is_a_reshaped, bool is_b_reshaped, bool reshape_b_only_on_first_run) |
| 846 | : _is_a_reshaped(is_a_reshaped), _is_b_reshaped(is_b_reshaped), _reshape_b_only_on_first_run(reshape_b_only_on_first_run) |
| 847 | { |
| 848 | } |
| 849 | /** Flag which specifies if the matrix A has been reshaped |
| 850 | * |
| 851 | * @return True if the matrix A has been reshaped |
| 852 | */ |
| 853 | bool is_a_reshaped() const |
| 854 | { |
| 855 | return _is_a_reshaped; |
| 856 | }; |
| 857 | /** Flag which specifies if the matrix B has been reshaped |
| 858 | * |
| 859 | * @return True if the matrix B has been reshaped |
| 860 | */ |
| 861 | bool is_b_reshaped() const |
| 862 | { |
| 863 | return _is_b_reshaped; |
| 864 | }; |
| 865 | /** Flag which specifies if the reshape of matrix B should executed only for the first |
| 866 | * |
| 867 | * @note This flag could be set to TRUE when GEMM is used to accelerate convolution layer |
| 868 | * |
| 869 | * @return True if the reshaped of matrix B happens only for the first run |
| 870 | */ |
| 871 | bool reshape_b_only_on_first_run() const |
| 872 | { |
| 873 | return _reshape_b_only_on_first_run; |
| 874 | }; |
| 875 | |
| 876 | private: |
| 877 | const bool _is_a_reshaped; |
| 878 | const bool _is_b_reshaped; |
| 879 | const bool _reshape_b_only_on_first_run; |
| 880 | }; |
| 881 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 882 | /** IO formatting information class*/ |
| 883 | struct IOFormatInfo |
| 884 | { |
| 885 | /** Precision type used when printing floating point numbers */ |
| 886 | enum class PrecisionType |
| 887 | { |
| 888 | Default, /**< Default precision to the one that the current stream has */ |
| 889 | Custom, /**< Custom precision specified by the user using the precision parameter */ |
| 890 | Full /**< The maximum precision of the floating point representation */ |
| 891 | }; |
| 892 | |
| 893 | /** Specifies the area to be printed, used by Tensor objects */ |
| 894 | enum class PrintRegion |
| 895 | { |
| 896 | ValidRegion, /**< Prints the valid region of the Tensor object */ |
| 897 | NoPadding, /**< Prints the Tensor object without the padding */ |
| 898 | Full /**< Print the tensor object including padding */ |
| 899 | }; |
| 900 | |
| 901 | IOFormatInfo(PrintRegion print_region = PrintRegion::ValidRegion, |
| 902 | PrecisionType precision_type = PrecisionType::Default, |
| 903 | unsigned int precision = 10, |
| 904 | bool align_columns = true, |
| 905 | std::string element_delim = " ", |
| 906 | std::string row_delim = "\n") |
| 907 | : print_region(print_region), |
| 908 | precision_type(precision_type), |
| 909 | precision(precision), |
| 910 | element_delim(element_delim), |
| 911 | row_delim(row_delim), |
| 912 | align_columns(align_columns) |
| 913 | { |
| 914 | } |
| 915 | |
| 916 | PrintRegion print_region; |
| 917 | PrecisionType precision_type; |
| 918 | unsigned int precision; |
| 919 | std::string element_delim; |
| 920 | std::string row_delim; |
| 921 | bool align_columns; |
| 922 | }; |
| 923 | } |
| 924 | #endif /* __ARM_COMPUTE_TYPES_H__ */ |