Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 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_TEST_REFERENCE_REFERENCE_H__ |
| 25 | #define __ARM_COMPUTE_TEST_REFERENCE_REFERENCE_H__ |
| 26 | |
| 27 | #include "RawTensor.h" |
| 28 | #include "Types.h" |
Giorgio Arena | 2ca209e | 2017-06-13 15:49:37 +0100 | [diff] [blame] | 29 | #include "arm_compute/runtime/Array.h" |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 30 | |
Isabella Gottardi | b797fa2 | 2017-06-23 15:02:11 +0100 | [diff] [blame] | 31 | #include <map> |
Georgios Pinitas | d4f8c27 | 2017-06-30 16:16:19 +0100 | [diff] [blame] | 32 | #include <vector> |
| 33 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 34 | namespace arm_compute |
| 35 | { |
| 36 | namespace test |
| 37 | { |
| 38 | namespace validation |
| 39 | { |
| 40 | /** Interface for reference implementations. */ |
| 41 | class Reference |
| 42 | { |
| 43 | public: |
Giorgio Arena | 50f9fd7 | 2017-06-19 17:05:30 +0100 | [diff] [blame] | 44 | /** Compute reference sobel 3x3. |
| 45 | * |
| 46 | * @param[in] shape Shape of the input and output tensors. |
| 47 | * @param[in] border_mode Border mode to use for input tensor |
| 48 | * @param[in] constant_border_value Constant value to use if @p border_mode is constant |
| 49 | * |
| 50 | * @return Computed raw tensors along x and y axis. |
| 51 | */ |
| 52 | static std::pair<RawTensor, RawTensor> compute_reference_sobel_3x3(const TensorShape &shape, BorderMode border_mode, uint8_t constant_border_value); |
| 53 | /** Compute reference sobel 5x5. |
| 54 | * |
| 55 | * @param[in] shape Shape of the input and output tensors. |
| 56 | * @param[in] border_mode Border mode to use for input tensor |
| 57 | * @param[in] constant_border_value Constant value to use if @p border_mode is constant |
| 58 | * |
| 59 | * @return Computed raw tensors along x and y axis. |
| 60 | */ |
| 61 | static std::pair<RawTensor, RawTensor> compute_reference_sobel_5x5(const TensorShape &shape, BorderMode border_mode, uint8_t constant_border_value); |
Giorgio Arena | 2ca209e | 2017-06-13 15:49:37 +0100 | [diff] [blame] | 62 | /** Compute min max location. |
| 63 | * |
| 64 | * @param[in] shape Shape of the input tensors. |
| 65 | * @param[in] dt_in Data type of input tensor. |
| 66 | * @param[out] min Minimum value of tensor |
| 67 | * @param[out] max Maximum value of tensor |
| 68 | * @param[out] min_loc Array with locations of minimum values |
| 69 | * @param[out] max_loc Array with locations of maximum values |
| 70 | * @param[out] min_count Number of minimum values found |
| 71 | * @param[out] max_count Number of maximum values found |
| 72 | * |
| 73 | * @return Computed minimum, maximum values and their locations. |
| 74 | */ |
Giorgio Arena | 935deee | 2017-06-14 13:40:36 +0100 | [diff] [blame] | 75 | static void compute_reference_min_max_location(const TensorShape &shape, DataType dt_in, int32_t &min, int32_t &max, IArray<Coordinates2D> &min_loc, IArray<Coordinates2D> &max_loc, |
| 76 | uint32_t &min_count, |
Giorgio Arena | 2ca209e | 2017-06-13 15:49:37 +0100 | [diff] [blame] | 77 | uint32_t &max_count); |
Giorgio Arena | f795986 | 2017-06-13 15:19:51 +0100 | [diff] [blame] | 78 | /** Compute reference mean and standard deviation. |
| 79 | * |
| 80 | * @param[in] shape Shape of the input tensors. |
| 81 | * |
| 82 | * @return Computed mean and standard deviation. |
| 83 | */ |
| 84 | static std::pair<float, float> compute_reference_mean_and_standard_deviation(const TensorShape &shape); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 85 | /** Compute reference integral image. |
| 86 | * |
| 87 | * @param[in] shape Shape of the input and output tensors. |
| 88 | * |
| 89 | * @return Computed raw tensor. |
| 90 | */ |
| 91 | static RawTensor compute_reference_integral_image(const TensorShape &shape); |
| 92 | /** Compute reference absolute difference. |
| 93 | * |
| 94 | * @param[in] shape Shape of the input and output tensors. |
| 95 | * @param[in] dt_in0 Data type of first input tensor. |
| 96 | * @param[in] dt_in1 Data type of second input tensor. |
| 97 | * @param[in] dt_out Data type of the output tensor. |
| 98 | * |
| 99 | * @return Computed raw tensor. |
| 100 | */ |
| 101 | static RawTensor compute_reference_absolute_difference(const TensorShape &shape, DataType dt_in0, DataType dt_in1, DataType dt_out); |
| 102 | /** Compute reference accumulate. |
| 103 | * |
| 104 | * @param[in] shape Shape of the input and output tensors. |
| 105 | * |
| 106 | * @return Computed raw tensor. |
| 107 | */ |
| 108 | static RawTensor compute_reference_accumulate(const TensorShape &shape); |
| 109 | /** Compute reference accumulate. |
| 110 | * |
| 111 | * @param[in] shape Shape of the input and output tensors. |
| 112 | * @param[in] shift A uint32_t value within the range of [0, 15] |
| 113 | * |
| 114 | * @return Computed raw tensor. |
| 115 | */ |
| 116 | static RawTensor compute_reference_accumulate_squared(const TensorShape &shape, uint32_t shift); |
| 117 | /** Compute reference accumulate. |
| 118 | * |
| 119 | * @param[in] shape Shape of the input and output tensors. |
| 120 | * @param[in] alpha A float value within the range of [0, 1] |
| 121 | * |
| 122 | * @return Computed raw tensor. |
| 123 | */ |
| 124 | static RawTensor compute_reference_accumulate_weighted(const TensorShape &shape, float alpha); |
| 125 | /** Compute reference arithmetic addition. |
| 126 | * |
Michele Di Giorgio | 81f0d15 | 2017-07-11 15:00:52 +0100 | [diff] [blame] | 127 | * @param[in] shape Shape of the input and output tensors. |
| 128 | * @param[in] dt_in0 Data type of first input tensor. |
| 129 | * @param[in] dt_in1 Data type of second input tensor. |
| 130 | * @param[in] dt_out Data type of the output tensor. |
| 131 | * @param[in] convert_policy Overflow policy of the operation. |
| 132 | * @param[in] fixed_point_position (Optional) Number of bits for the fractional part of the fixed point numbers |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 133 | * |
| 134 | * @return Computed raw tensor. |
| 135 | */ |
Michele Di Giorgio | 81f0d15 | 2017-07-11 15:00:52 +0100 | [diff] [blame] | 136 | static RawTensor compute_reference_arithmetic_addition(const TensorShape &shape, DataType dt_in0, DataType dt_in1, DataType dt_out, ConvertPolicy convert_policy, int fixed_point_position = 0); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 137 | /** Compute reference arithmetic subtraction. |
| 138 | * |
Michele Di Giorgio | 81f0d15 | 2017-07-11 15:00:52 +0100 | [diff] [blame] | 139 | * @param[in] shape Shape of the input and output tensors. |
| 140 | * @param[in] dt_in0 Data type of first input tensor. |
| 141 | * @param[in] dt_in1 Data type of second input tensor. |
| 142 | * @param[in] dt_out Data type of the output tensor. |
| 143 | * @param[in] convert_policy Overflow policy of the operation. |
| 144 | * @param[in] fixed_point_position (Optional) Number of bits for the fractional part of the fixed point numbers |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 145 | * |
| 146 | * @return Computed raw tensor. |
| 147 | */ |
Michele Di Giorgio | 81f0d15 | 2017-07-11 15:00:52 +0100 | [diff] [blame] | 148 | static RawTensor compute_reference_arithmetic_subtraction(const TensorShape &shape, DataType dt_in0, DataType dt_in1, DataType dt_out, ConvertPolicy convert_policy, int fixed_point_position = 0); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 149 | /** Compute reference bitwise and. |
| 150 | * |
| 151 | * @param[in] shape Shape of the input and output tensors. |
| 152 | * |
| 153 | * @return Computed raw tensor. |
| 154 | */ |
| 155 | static RawTensor compute_reference_bitwise_and(const TensorShape &shape); |
| 156 | /** Compute reference bitwise or. |
| 157 | * |
| 158 | * @param[in] shape Shape of the input and output tensors. |
| 159 | * |
| 160 | * @return Computed raw tensor. |
| 161 | */ |
| 162 | static RawTensor compute_reference_bitwise_or(const TensorShape &shape); |
| 163 | /** Compute reference bitwise xor. |
| 164 | * |
| 165 | * @param[in] shape Shape of the input and output tensors. |
| 166 | * |
| 167 | * @return Computed raw tensor. |
| 168 | */ |
| 169 | static RawTensor compute_reference_bitwise_xor(const TensorShape &shape); |
| 170 | /** Compute reference bitwise not. |
| 171 | * |
| 172 | * @param[in] shape Shape of the input and output tensors. |
| 173 | * |
| 174 | * @return Computed raw tensor. |
| 175 | */ |
| 176 | static RawTensor compute_reference_bitwise_not(const TensorShape &shape); |
SiCong Li | bacaf9a | 2017-06-19 13:41:45 +0100 | [diff] [blame] | 177 | /** Compute reference box3x3 filter. |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 178 | * |
SiCong Li | bacaf9a | 2017-06-19 13:41:45 +0100 | [diff] [blame] | 179 | * @param[in] shape Shape of the input and output tensors. |
| 180 | * @param[in] border_mode BorderMode used by the input tensor. |
| 181 | * @param[in] constant_border_value Constant to use if @p border_mode == CONSTANT. |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 182 | * |
| 183 | * @return Computed raw tensor. |
| 184 | */ |
SiCong Li | bacaf9a | 2017-06-19 13:41:45 +0100 | [diff] [blame] | 185 | static RawTensor compute_reference_box3x3(const TensorShape &shape, BorderMode border_mode, uint8_t constant_border_value); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 186 | /** Compute reference depth convert. |
| 187 | * |
Georgios Pinitas | e222941 | 2017-07-12 12:30:40 +0100 | [diff] [blame] | 188 | * @param[in] shape Shape of the input and output tensors. |
| 189 | * @param[in] dt_in Data type of input tensor. |
| 190 | * @param[in] dt_out Data type of the output tensor. |
| 191 | * @param[in] policy Overflow policy of the operation. |
| 192 | * @param[in] shift Value for down/up conversions. Must be 0 <= shift < 8. |
| 193 | * @param[in] fixed_point_position_in (Optional) Fixed point position for the input tensor. |
| 194 | * @param[in] fixed_point_position_out (Optional) Fixed point position for the output tensor. |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 195 | * |
| 196 | * @return Computed raw tensor. |
| 197 | */ |
Georgios Pinitas | e222941 | 2017-07-12 12:30:40 +0100 | [diff] [blame] | 198 | static RawTensor compute_reference_depth_convert(const TensorShape &shape, DataType dt_in, DataType dt_out, ConvertPolicy policy, |
| 199 | uint32_t shift, uint32_t fixed_point_position_in = 0, uint32_t fixed_point_position_out = 0); |
SiCong Li | 5a53664 | 2017-06-19 14:47:05 +0100 | [diff] [blame] | 200 | /** Compute reference gaussian3x3 filter. |
| 201 | * |
| 202 | * @param[in] shape Shape of the input and output tensors. |
| 203 | * @param[in] border_mode BorderMode used by the input tensor |
| 204 | * @param[in] constant_border_value Constant to use if @p border_mode == CONSTANT |
| 205 | * |
| 206 | * @return Computed raw tensor. |
| 207 | */ |
| 208 | static RawTensor compute_reference_gaussian3x3(const TensorShape &shape, BorderMode border_mode, uint8_t constant_border_value); |
SiCong Li | 3eb263e | 2017-06-19 15:31:43 +0100 | [diff] [blame] | 209 | /** Compute reference gaussian5x5 filter. |
| 210 | * |
| 211 | * @param[in] shape Shape of the input and output tensors. |
| 212 | * @param[in] border_mode BorderMode used by the input tensor. |
| 213 | * @param[in] constant_border_value Constant to use if @p border_mode == CONSTANT. |
| 214 | * |
| 215 | * @return Computed raw tensor. |
| 216 | */ |
| 217 | static RawTensor compute_reference_gaussian5x5(const TensorShape &shape, BorderMode border_mode, uint8_t constant_border_value); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 218 | /** Compute matrix multiply function. |
| 219 | * |
| 220 | * @param[in] src_shape1 First input tensor shape |
| 221 | * @param[in] src_shape2 Second input tensor shape |
| 222 | * @param[in] src_shape3 Third input tensor shape |
| 223 | * @param[out] dst_shape Output tensor. |
| 224 | * @param[in] alpha Weight of the matrix product |
| 225 | * @param[in] beta Weight of the third matrix |
| 226 | * @param[in] dt Tensor's data type |
| 227 | * @param[in] fixed_point_position (Optional) Number of bits for the fractional part of the fixed point numbers |
| 228 | * |
| 229 | * @return Computed output tensor. |
| 230 | */ |
| 231 | static RawTensor compute_reference_gemm(const TensorShape &src_shape1, const TensorShape &src_shape2, const TensorShape &src_shape3, |
| 232 | const TensorShape &dst_shape, float alpha, float beta, DataType dt, int fixed_point_position = 0); |
Isabella Gottardi | 3b77e9d | 2017-06-22 11:05:41 +0100 | [diff] [blame] | 233 | /** Compute reference non linear filter function |
| 234 | * |
| 235 | * @param[in] shape Shape of the input and output tensors.Data type supported: U8 |
| 236 | * @param[in] function Non linear function to perform |
| 237 | * @param[in] mask_size Mask size. Supported sizes: 3, 5 |
| 238 | * @param[in] pattern Matrix pattern |
| 239 | * @param[in] mask The given mask. Will be used only if pattern is specified to PATTERN_OTHER |
| 240 | * @param[in] border_mode Strategy to use for borders. |
| 241 | * @param[in] constant_border_value (Optional) Constant value to use for borders if border_mode is set to CONSTANT. |
| 242 | * |
| 243 | * @return Computed raw tensor. |
| 244 | */ |
| 245 | static RawTensor compute_reference_non_linear_filter(const TensorShape &shape, NonLinearFilterFunction function, unsigned int mask_size, |
| 246 | MatrixPattern pattern, const uint8_t *mask, BorderMode border_mode, uint8_t constant_border_value = 0); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 247 | /** Compute reference pixel-wise multiplication |
| 248 | * |
| 249 | * @param[in] shape Shape of the input and output tensors. |
| 250 | * @param[in] dt_in0 Data type of first input tensor. |
| 251 | * @param[in] dt_in1 Data type of second input tensor. |
| 252 | * @param[in] dt_out Data type of the output tensor. |
| 253 | * @param[in] scale Non-negative scale. |
| 254 | * @param[in] convert_policy Overflow policy of the operation. |
| 255 | * @param[in] rounding_policy Rounding policy of the operation. |
| 256 | * |
| 257 | * @return Computed raw tensor. |
| 258 | */ |
| 259 | static RawTensor compute_reference_pixel_wise_multiplication(const TensorShape &shape, DataType dt_in0, DataType dt_in1, DataType dt_out, float scale, ConvertPolicy convert_policy, |
| 260 | RoundingPolicy rounding_policy); |
| 261 | /** Compute reference pixel-wise multiplication. |
| 262 | * |
| 263 | * @param[in] shape Shape of the input and output tensors. |
| 264 | * @param[in] dt_in0 Data type of first input tensor. |
| 265 | * @param[in] dt_in1 Data type of second input tensor. |
| 266 | * @param[in] dt_out Data type of the output tensor. |
| 267 | * @param[in] scale Scale to apply after multiplication. Must be positive. |
| 268 | * @param[in] fixed_point_position Fixed point position that expresses the number of bits for the fractional part of the number. |
| 269 | * @param[in] convert_policy Overflow policy of the operation. |
| 270 | * @param[in] rounding_policy Rounding policy of the operation. |
| 271 | * |
| 272 | * @return Computed raw tensor. |
| 273 | */ |
| 274 | static RawTensor compute_reference_fixed_point_pixel_wise_multiplication(const TensorShape &shape, DataType dt_in0, DataType dt_in1, DataType dt_out, float scale, int fixed_point_position, |
| 275 | ConvertPolicy convert_policy, RoundingPolicy rounding_policy); |
Isabella Gottardi | b797fa2 | 2017-06-23 15:02:11 +0100 | [diff] [blame] | 276 | /** Compute reference Table Lookup. |
| 277 | * |
| 278 | * @param[in] shape Shape of the input and output tensors. |
| 279 | * @param[in] dt_inout Data type of input/output tensor. |
| 280 | * @param[in] lut Input lookup table. |
| 281 | * |
| 282 | * @return Computed raw tensor. |
| 283 | */ |
| 284 | template <typename T> |
| 285 | static RawTensor compute_reference_table_lookup(const TensorShape &shape, DataType dt_inout, std::map<T, T> &lut); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 286 | /** Compute reference threshold. |
| 287 | * |
| 288 | * @param[in] shape Shape of the input and output tensors. |
| 289 | * @param[in] threshold Threshold. When the threshold type is RANGE, this is used as the lower threshold. |
| 290 | * @param[in] false_value value to set when the condition is not respected. |
| 291 | * @param[in] true_value value to set when the condition is respected. |
| 292 | * @param[in] type Thresholding type. Either RANGE or BINARY. |
| 293 | * @param[in] upper Upper threshold. Only used when the thresholding type is RANGE. |
| 294 | * |
| 295 | * @return Computed raw tensor. |
| 296 | */ |
| 297 | static RawTensor compute_reference_threshold(const TensorShape &shape, uint8_t threshold, uint8_t false_value, uint8_t true_value, ThresholdType type, uint8_t upper); |
| 298 | /** Compute reference activation layer. |
| 299 | * |
| 300 | * @param[in] shape Shape of the input and output tensors. |
| 301 | * @param[in] dt Data type of the tensors. |
| 302 | * @param[in] act_info Activation layer information. |
| 303 | * @param[in] fixed_point_position (Optional)Number of bits for the fractional part of fixed point numbers. |
| 304 | * |
| 305 | * @return Computed raw tensor. |
| 306 | */ |
| 307 | static RawTensor compute_reference_activation_layer(const TensorShape &shape, DataType dt, ActivationLayerInfo act_info, int fixed_point_position = 0); |
| 308 | /** Compute reference batch normalization layer. |
| 309 | * |
| 310 | * @param[in] shape0 Shape of the input and output tensors. |
| 311 | * @param[in] shape1 Shape of the vector tensors. |
| 312 | * @param[in] dt Data type of all input and output tensors. |
| 313 | * @param[in] epsilon Small value to avoid division with zero. |
| 314 | * @param[in] fixed_point_position Fixed point position. |
| 315 | * |
| 316 | * @return Computed raw tensor. |
| 317 | */ |
| 318 | static RawTensor compute_reference_batch_normalization_layer(const TensorShape &shape0, const TensorShape &shape1, DataType dt, float epsilon, int fixed_point_position = 0); |
Georgios Pinitas | ac4e873 | 2017-07-05 17:02:25 +0100 | [diff] [blame] | 319 | /** Compute reference convolution layer |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 320 | * |
| 321 | * @param[in] input_shape Shape for the input tensor |
| 322 | * @param[in] weights_shape Shape for the weights tensor |
| 323 | * @param[in] bias_shape Shape for the bias tensor |
| 324 | * @param[in] output_shape Shape for the output tensor |
| 325 | * @param[in] dt Data type to use |
| 326 | * @param[in] conv_info Pads and strides information for the convolution layer |
| 327 | * @param[in] fixed_point_position Number of bits for the fractional part of the fixed point numbers |
| 328 | * |
| 329 | * @return Computed raw tensor. |
| 330 | */ |
| 331 | static RawTensor compute_reference_convolution_layer(const TensorShape &input_shape, const TensorShape &weights_shape, const TensorShape &bias_shape, const TensorShape &output_shape, DataType dt, |
| 332 | const PadStrideInfo &conv_info, int fixed_point_position); |
Georgios Pinitas | ac4e873 | 2017-07-05 17:02:25 +0100 | [diff] [blame] | 333 | /** Compute reference depth concatenation layer |
| 334 | * |
| 335 | * @param[in] shapes Input tensor shapes (All dimensions should match apart from DimZ) |
| 336 | * @param[in] dt Data type to use |
| 337 | * @param[in] fixed_point_position (Optional) Number of bits for the fractional part of the fixed point numbers |
| 338 | * |
| 339 | * @return Computed raw tensor. |
| 340 | */ |
| 341 | static RawTensor compute_reference_depth_concatenate_layer(const std::vector<TensorShape> &shapes, DataType dt, int fixed_point_position = 0); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 342 | /** Compute reference for fully connected layer function |
| 343 | * |
| 344 | * @param[in] input_shape Shape for the input tensor |
| 345 | * @param[in] weights_shape Shape for the weights tensor |
| 346 | * @param[in] bias_shape Shape for the bias tensor |
| 347 | * @param[in] output_shape Shape for the output tensor |
| 348 | * @param[in] dt Data type to use |
| 349 | * @param[in] transpose_weights Transpose the weights if true |
| 350 | * @param[in] fixed_point_position Number of bits for the fractional part of the fixed point numbers |
| 351 | * |
| 352 | * @return Computed raw tensor. |
| 353 | */ |
| 354 | static RawTensor compute_reference_fully_connected_layer(const TensorShape &input_shape, const TensorShape &weights_shape, const TensorShape &bias_shape, const TensorShape &output_shape, DataType dt, |
| 355 | bool transpose_weights, int fixed_point_position); |
| 356 | /** Compute reference normalization layer. |
| 357 | * |
| 358 | * @param[in] shape Shape of the input and output tensors. |
| 359 | * @param[in] dt Data type of input and output tensors. |
| 360 | * @param[in] norm_info Normalization Layer information. |
| 361 | * @param[in] fixed_point_position (Optional) Fixed point position that expresses the number of bits for the fractional part of the number when the tensor's data type is QS8 or QS16 (default = 0). |
| 362 | * |
| 363 | * @return Computed raw tensor. |
| 364 | */ |
| 365 | static RawTensor compute_reference_normalization_layer(const TensorShape &shape, DataType dt, NormalizationLayerInfo norm_info, int fixed_point_position = 0); |
| 366 | /** Compute reference pooling layer. |
| 367 | * |
| 368 | * @param[in] shape_in Shape of the input tensor. |
| 369 | * @param[in] shape_out Shape of the output tensor. |
| 370 | * @param[in] dt Data type of input and output tensors. |
| 371 | * @param[in] pool_info Pooling Layer information. |
| 372 | * @param[in] fixed_point_position (Optional) Number of bits for the fractional part of the fixed point numbers. |
| 373 | * |
| 374 | * @return Computed raw tensor. |
| 375 | */ |
| 376 | static RawTensor compute_reference_pooling_layer(const TensorShape &shape_in, const TensorShape &shape_out, DataType dt, PoolingLayerInfo pool_info, int fixed_point_position = 0); |
Georgios Pinitas | 7b7858d | 2017-06-21 16:44:24 +0100 | [diff] [blame] | 377 | /** Compute reference roi pooling layer. |
| 378 | * |
| 379 | * @param[in] shape Shape of the input tensor. |
| 380 | * @param[in] dt Data type of input and output tensors. |
| 381 | * @param[in] rois Region of interest vector. |
| 382 | * @param[in] pool_info ROI Pooling Layer information. |
| 383 | */ |
| 384 | static RawTensor compute_reference_roi_pooling_layer(const TensorShape &shape, DataType dt, const std::vector<ROI> &rois, const ROIPoolingLayerInfo &pool_info); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 385 | /** Compute reference softmax layer. |
| 386 | * |
| 387 | * @param[in] shape Shape of the input and output tensors. |
| 388 | * @param[in] dt Data type of input and output tensors. |
| 389 | * @param[in] fixed_point_position (Optional) Number of bits for the fractional part of the fixed point numbers |
| 390 | * |
| 391 | * @return Computed raw tensor. |
| 392 | */ |
| 393 | static RawTensor compute_reference_softmax_layer(const TensorShape &shape, DataType dt, int fixed_point_position = 0); |
| 394 | /** Compute reference fixed point operation. |
| 395 | * |
| 396 | * @param[in] shape Shape of the input and output tensors. |
| 397 | * @param[in] dt_in Data type of the input tensor. |
| 398 | * @param[in] dt_out Data type of the output tensor. |
| 399 | * @param[in] op Fixed point operation to perform. |
| 400 | * @param[in] fixed_point_position Number of bits for the fractional part of the fixed point numbers |
| 401 | * |
| 402 | * @return Computed raw tensor. |
| 403 | */ |
| 404 | static RawTensor compute_reference_fixed_point_operation(const TensorShape &shape, DataType dt_in, DataType dt_out, FixedPointOp op, int fixed_point_position); |
| 405 | |
| 406 | protected: |
| 407 | Reference() = default; |
| 408 | ~Reference() = default; |
| 409 | }; |
| 410 | } // namespace validation |
| 411 | } // namespace test |
| 412 | } // namespace arm_compute |
Anthony Barbier | ac69aa1 | 2017-07-03 17:39:37 +0100 | [diff] [blame] | 413 | #endif /* __ARM_COMPUTE_TEST_REFERENCE_REFERENCE_H__ */ |