Moritz Pflanzer | 3ce3ff4 | 2017-07-21 17:41:02 +0100 | [diff] [blame] | 1 | /* |
Pablo Tello | 3dd5b68 | 2019-03-04 14:14:02 +0000 | [diff] [blame] | 2 | * Copyright (c) 2017-2019 ARM Limited. |
Moritz Pflanzer | 3ce3ff4 | 2017-07-21 17:41:02 +0100 | [diff] [blame] | 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 | */ |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 24 | #include "tests/validation/Helpers.h" |
Moritz Pflanzer | 3ce3ff4 | 2017-07-21 17:41:02 +0100 | [diff] [blame] | 25 | |
Giorgio Arena | 1f9ca1d | 2018-03-01 11:13:45 +0000 | [diff] [blame] | 26 | #include <algorithm> |
| 27 | #include <cmath> |
| 28 | |
Moritz Pflanzer | 3ce3ff4 | 2017-07-21 17:41:02 +0100 | [diff] [blame] | 29 | namespace arm_compute |
| 30 | { |
| 31 | namespace test |
| 32 | { |
| 33 | namespace validation |
| 34 | { |
Moritz Pflanzer | 6c6597c | 2017-09-24 12:09:41 +0100 | [diff] [blame] | 35 | void fill_mask_from_pattern(uint8_t *mask, int cols, int rows, MatrixPattern pattern) |
| 36 | { |
| 37 | unsigned int v = 0; |
| 38 | std::mt19937 gen(library->seed()); |
| 39 | std::bernoulli_distribution dist(0.5); |
| 40 | |
| 41 | for(int r = 0; r < rows; ++r) |
| 42 | { |
| 43 | for(int c = 0; c < cols; ++c, ++v) |
| 44 | { |
| 45 | uint8_t val = 0; |
| 46 | |
| 47 | switch(pattern) |
| 48 | { |
| 49 | case MatrixPattern::BOX: |
| 50 | val = 255; |
| 51 | break; |
| 52 | case MatrixPattern::CROSS: |
| 53 | val = ((r == (rows / 2)) || (c == (cols / 2))) ? 255 : 0; |
| 54 | break; |
| 55 | case MatrixPattern::DISK: |
| 56 | val = (((r - rows / 2.0f + 0.5f) * (r - rows / 2.0f + 0.5f)) / ((rows / 2.0f) * (rows / 2.0f)) + ((c - cols / 2.0f + 0.5f) * (c - cols / 2.0f + 0.5f)) / ((cols / 2.0f) * |
| 57 | (cols / 2.0f))) <= 1.0f ? 255 : 0; |
| 58 | break; |
| 59 | case MatrixPattern::OTHER: |
| 60 | val = (dist(gen) ? 0 : 255); |
| 61 | break; |
| 62 | default: |
| 63 | return; |
| 64 | } |
| 65 | |
| 66 | mask[v] = val; |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | if(pattern == MatrixPattern::OTHER) |
| 71 | { |
| 72 | std::uniform_int_distribution<uint8_t> distribution_u8(0, ((cols * rows) - 1)); |
| 73 | mask[distribution_u8(gen)] = 255; |
| 74 | } |
| 75 | } |
| 76 | |
Moritz Pflanzer | 6c6597c | 2017-09-24 12:09:41 +0100 | [diff] [blame] | 77 | HarrisCornersParameters harris_corners_parameters() |
| 78 | { |
| 79 | HarrisCornersParameters params; |
| 80 | |
| 81 | std::mt19937 gen(library->seed()); |
Vidhya Sudhan Loganathan | 851a322 | 2018-05-11 14:26:51 +0100 | [diff] [blame] | 82 | std::uniform_real_distribution<float> threshold_dist(0.f, 0.001f); |
Moritz Pflanzer | 6c6597c | 2017-09-24 12:09:41 +0100 | [diff] [blame] | 83 | std::uniform_real_distribution<float> sensitivity(0.04f, 0.15f); |
| 84 | std::uniform_real_distribution<float> euclidean_distance(0.f, 30.f); |
| 85 | std::uniform_int_distribution<uint8_t> int_dist(0, 255); |
| 86 | |
| 87 | params.threshold = threshold_dist(gen); |
| 88 | params.sensitivity = sensitivity(gen); |
| 89 | params.min_dist = euclidean_distance(gen); |
| 90 | params.constant_border_value = int_dist(gen); |
| 91 | |
| 92 | return params; |
| 93 | } |
Anton Lokhmotov | af6204c | 2017-11-08 09:34:19 +0000 | [diff] [blame] | 94 | |
Abe Mbise | 1b99338 | 2017-12-19 13:51:59 +0000 | [diff] [blame] | 95 | CannyEdgeParameters canny_edge_parameters() |
| 96 | { |
| 97 | CannyEdgeParameters params; |
| 98 | |
| 99 | std::mt19937 gen(library->seed()); |
| 100 | std::uniform_int_distribution<uint8_t> int_dist(0, 255); |
Michele Di Giorgio | ef91516 | 2018-07-30 12:01:44 +0100 | [diff] [blame] | 101 | std::uniform_int_distribution<uint8_t> threshold_dist(2, 255); |
Abe Mbise | 1b99338 | 2017-12-19 13:51:59 +0000 | [diff] [blame] | 102 | |
| 103 | params.constant_border_value = int_dist(gen); |
Michele Di Giorgio | ef91516 | 2018-07-30 12:01:44 +0100 | [diff] [blame] | 104 | params.upper_thresh = threshold_dist(gen); // upper_threshold >= 2 |
Michele Di Giorgio | bb71fe5 | 2018-06-20 11:45:35 +0100 | [diff] [blame] | 105 | threshold_dist = std::uniform_int_distribution<uint8_t>(1, params.upper_thresh - 1); |
Michele Di Giorgio | ef91516 | 2018-07-30 12:01:44 +0100 | [diff] [blame] | 106 | params.lower_thresh = threshold_dist(gen); // lower_threshold >= 1 && lower_threshold < upper_threshold |
Abe Mbise | 1b99338 | 2017-12-19 13:51:59 +0000 | [diff] [blame] | 107 | |
| 108 | return params; |
| 109 | } |
| 110 | |
Michalis Spyrou | ed7b27d | 2019-11-27 16:04:17 +0000 | [diff] [blame] | 111 | template <> |
Anton Lokhmotov | af6204c | 2017-11-08 09:34:19 +0000 | [diff] [blame] | 112 | SimpleTensor<float> convert_from_asymmetric(const SimpleTensor<uint8_t> &src) |
| 113 | { |
Georgios Pinitas | 4c5469b | 2019-05-21 13:32:43 +0100 | [diff] [blame] | 114 | const UniformQuantizationInfo &quantization_info = src.quantization_info().uniform(); |
| 115 | SimpleTensor<float> dst{ src.shape(), DataType::F32, 1, QuantizationInfo(), src.data_layout() }; |
Michalis Spyrou | 57dac84 | 2018-03-01 16:03:50 +0000 | [diff] [blame] | 116 | |
Anton Lokhmotov | af6204c | 2017-11-08 09:34:19 +0000 | [diff] [blame] | 117 | for(int i = 0; i < src.num_elements(); ++i) |
| 118 | { |
Georgios Pinitas | 4c5469b | 2019-05-21 13:32:43 +0100 | [diff] [blame] | 119 | dst[i] = dequantize_qasymm8(src[i], quantization_info); |
Anton Lokhmotov | af6204c | 2017-11-08 09:34:19 +0000 | [diff] [blame] | 120 | } |
| 121 | return dst; |
| 122 | } |
| 123 | |
Michalis Spyrou | ed7b27d | 2019-11-27 16:04:17 +0000 | [diff] [blame] | 124 | template <> |
Georgios Pinitas | 6e1791b | 2019-12-02 19:01:25 +0000 | [diff] [blame] | 125 | SimpleTensor<float> convert_from_asymmetric(const SimpleTensor<int8_t> &src) |
| 126 | { |
| 127 | const UniformQuantizationInfo &quantization_info = src.quantization_info().uniform(); |
| 128 | SimpleTensor<float> dst{ src.shape(), DataType::F32, 1, QuantizationInfo(), src.data_layout() }; |
| 129 | |
| 130 | for(int i = 0; i < src.num_elements(); ++i) |
| 131 | { |
| 132 | dst[i] = dequantize_qasymm8_signed(src[i], quantization_info); |
| 133 | } |
| 134 | return dst; |
| 135 | } |
| 136 | |
| 137 | template <> |
Michele Di Giorgio | 578a9fc | 2019-08-23 11:49:04 +0100 | [diff] [blame] | 138 | SimpleTensor<float> convert_from_asymmetric(const SimpleTensor<uint16_t> &src) |
| 139 | { |
| 140 | const UniformQuantizationInfo &quantization_info = src.quantization_info().uniform(); |
| 141 | SimpleTensor<float> dst{ src.shape(), DataType::F32, 1, QuantizationInfo(), src.data_layout() }; |
| 142 | |
| 143 | for(int i = 0; i < src.num_elements(); ++i) |
| 144 | { |
| 145 | dst[i] = dequantize_qasymm16(src[i], quantization_info); |
| 146 | } |
| 147 | return dst; |
| 148 | } |
| 149 | |
Michele Di Giorgio | 4aff98f | 2019-08-28 16:27:26 +0100 | [diff] [blame] | 150 | template <> |
Anton Lokhmotov | af6204c | 2017-11-08 09:34:19 +0000 | [diff] [blame] | 151 | SimpleTensor<uint8_t> convert_to_asymmetric(const SimpleTensor<float> &src, const QuantizationInfo &quantization_info) |
| 152 | { |
Georgios Pinitas | 4c5469b | 2019-05-21 13:32:43 +0100 | [diff] [blame] | 153 | SimpleTensor<uint8_t> dst{ src.shape(), DataType::QASYMM8, 1, quantization_info }; |
| 154 | const UniformQuantizationInfo &qinfo = quantization_info.uniform(); |
| 155 | |
Anton Lokhmotov | af6204c | 2017-11-08 09:34:19 +0000 | [diff] [blame] | 156 | for(int i = 0; i < src.num_elements(); ++i) |
| 157 | { |
Georgios Pinitas | 4c5469b | 2019-05-21 13:32:43 +0100 | [diff] [blame] | 158 | dst[i] = quantize_qasymm8(src[i], qinfo); |
Anton Lokhmotov | af6204c | 2017-11-08 09:34:19 +0000 | [diff] [blame] | 159 | } |
| 160 | return dst; |
| 161 | } |
Giorgio Arena | 1f9ca1d | 2018-03-01 11:13:45 +0000 | [diff] [blame] | 162 | |
Manuel Bottini | 3689fcd | 2019-06-14 17:18:12 +0100 | [diff] [blame] | 163 | template <> |
Sang-Hoon Park | ae6ef7c | 2019-11-13 16:51:45 +0000 | [diff] [blame] | 164 | SimpleTensor<int8_t> convert_to_asymmetric(const SimpleTensor<float> &src, const QuantizationInfo &quantization_info) |
| 165 | { |
| 166 | SimpleTensor<int8_t> dst{ src.shape(), DataType::QASYMM8_SIGNED, 1, quantization_info }; |
| 167 | const UniformQuantizationInfo &qinfo = quantization_info.uniform(); |
| 168 | |
| 169 | for(int i = 0; i < src.num_elements(); ++i) |
| 170 | { |
| 171 | dst[i] = quantize_qasymm8_signed(src[i], qinfo); |
| 172 | } |
| 173 | return dst; |
| 174 | } |
| 175 | |
Michalis Spyrou | ed7b27d | 2019-11-27 16:04:17 +0000 | [diff] [blame] | 176 | template <> |
Michele Di Giorgio | 4aff98f | 2019-08-28 16:27:26 +0100 | [diff] [blame] | 177 | SimpleTensor<uint16_t> convert_to_asymmetric(const SimpleTensor<float> &src, const QuantizationInfo &quantization_info) |
| 178 | { |
| 179 | SimpleTensor<uint16_t> dst{ src.shape(), DataType::QASYMM16, 1, quantization_info }; |
| 180 | const UniformQuantizationInfo &qinfo = quantization_info.uniform(); |
| 181 | |
| 182 | for(int i = 0; i < src.num_elements(); ++i) |
| 183 | { |
| 184 | dst[i] = quantize_qasymm16(src[i], qinfo); |
| 185 | } |
| 186 | return dst; |
| 187 | } |
| 188 | |
| 189 | template <> |
Manuel Bottini | 3689fcd | 2019-06-14 17:18:12 +0100 | [diff] [blame] | 190 | SimpleTensor<int16_t> convert_to_symmetric(const SimpleTensor<float> &src, const QuantizationInfo &quantization_info) |
| 191 | { |
| 192 | SimpleTensor<int16_t> dst{ src.shape(), DataType::QSYMM16, 1, quantization_info }; |
| 193 | const UniformQuantizationInfo &qinfo = quantization_info.uniform(); |
| 194 | |
| 195 | for(int i = 0; i < src.num_elements(); ++i) |
| 196 | { |
| 197 | dst[i] = quantize_qsymm16(src[i], qinfo); |
| 198 | } |
| 199 | return dst; |
| 200 | } |
| 201 | |
| 202 | template <> |
| 203 | SimpleTensor<float> convert_from_symmetric(const SimpleTensor<int16_t> &src) |
| 204 | { |
| 205 | const UniformQuantizationInfo &quantization_info = src.quantization_info().uniform(); |
| 206 | SimpleTensor<float> dst{ src.shape(), DataType::F32, 1, QuantizationInfo(), src.data_layout() }; |
| 207 | |
| 208 | for(int i = 0; i < src.num_elements(); ++i) |
| 209 | { |
| 210 | dst[i] = dequantize_qsymm16(src[i], quantization_info); |
| 211 | } |
| 212 | return dst; |
| 213 | } |
| 214 | |
Vidhya Sudhan Loganathan | 71ecf39 | 2018-08-31 16:10:16 +0100 | [diff] [blame] | 215 | template <typename T> |
| 216 | void matrix_multiply(const SimpleTensor<T> &a, const SimpleTensor<T> &b, SimpleTensor<T> &out) |
Giorgio Arena | 1f9ca1d | 2018-03-01 11:13:45 +0000 | [diff] [blame] | 217 | { |
| 218 | ARM_COMPUTE_ERROR_ON(a.shape()[0] != b.shape()[1]); |
| 219 | ARM_COMPUTE_ERROR_ON(a.shape()[1] != out.shape()[1]); |
| 220 | ARM_COMPUTE_ERROR_ON(b.shape()[0] != out.shape()[0]); |
| 221 | |
| 222 | const int M = a.shape()[1]; // Rows |
| 223 | const int N = b.shape()[0]; // Cols |
| 224 | const int K = b.shape()[1]; |
| 225 | |
| 226 | for(int y = 0; y < M; ++y) |
| 227 | { |
| 228 | for(int x = 0; x < N; ++x) |
| 229 | { |
| 230 | float acc = 0.0f; |
| 231 | for(int k = 0; k < K; ++k) |
| 232 | { |
| 233 | acc += a[y * K + k] * b[x + k * N]; |
| 234 | } |
| 235 | |
| 236 | out[x + y * N] = acc; |
| 237 | } |
| 238 | } |
| 239 | } |
| 240 | |
Vidhya Sudhan Loganathan | 71ecf39 | 2018-08-31 16:10:16 +0100 | [diff] [blame] | 241 | template <typename T> |
| 242 | void transpose_matrix(const SimpleTensor<T> &in, SimpleTensor<T> &out) |
Giorgio Arena | 1f9ca1d | 2018-03-01 11:13:45 +0000 | [diff] [blame] | 243 | { |
| 244 | ARM_COMPUTE_ERROR_ON((in.shape()[0] != out.shape()[1]) || (in.shape()[1] != out.shape()[0])); |
| 245 | |
| 246 | const int width = in.shape()[0]; |
| 247 | const int height = in.shape()[1]; |
| 248 | |
| 249 | for(int y = 0; y < height; ++y) |
| 250 | { |
| 251 | for(int x = 0; x < width; ++x) |
| 252 | { |
Gian Marco Iodice | 5ba5e09 | 2018-12-06 17:13:09 +0000 | [diff] [blame] | 253 | const T val = in[x + y * width]; |
Giorgio Arena | 1f9ca1d | 2018-03-01 11:13:45 +0000 | [diff] [blame] | 254 | |
| 255 | out[x * height + y] = val; |
| 256 | } |
| 257 | } |
| 258 | } |
| 259 | |
| 260 | template <typename T> |
| 261 | void get_tile(const SimpleTensor<T> &in, SimpleTensor<T> &tile, const Coordinates &coord) |
| 262 | { |
Gian Marco Iodice | f1c2bf0 | 2018-06-13 14:05:54 +0100 | [diff] [blame] | 263 | ARM_COMPUTE_ERROR_ON(tile.shape().num_dimensions() > 2); |
Giorgio Arena | 1f9ca1d | 2018-03-01 11:13:45 +0000 | [diff] [blame] | 264 | |
| 265 | const int w_tile = tile.shape()[0]; |
| 266 | const int h_tile = tile.shape()[1]; |
| 267 | |
| 268 | // Fill the tile with zeros |
| 269 | std::fill(tile.data() + 0, (tile.data() + (w_tile * h_tile)), static_cast<T>(0)); |
| 270 | |
| 271 | // Check if with the dimensions greater than 2 we could have out-of-bound reads |
| 272 | for(size_t d = 2; d < Coordinates::num_max_dimensions; ++d) |
| 273 | { |
| 274 | if(coord[d] < 0 || coord[d] >= static_cast<int>(in.shape()[d])) |
| 275 | { |
| 276 | ARM_COMPUTE_ERROR("coord[d] < 0 || coord[d] >= in.shape()[d] with d >= 2"); |
| 277 | } |
| 278 | } |
| 279 | |
| 280 | // Since we could have out-of-bound reads along the X and Y dimensions, |
| 281 | // we start calculating the input address with x = 0 and y = 0 |
| 282 | Coordinates start_coord = coord; |
| 283 | start_coord[0] = 0; |
| 284 | start_coord[1] = 0; |
| 285 | |
| 286 | // Get input and roi pointers |
| 287 | auto in_ptr = static_cast<const T *>(in(start_coord)); |
| 288 | auto roi_ptr = static_cast<T *>(tile.data()); |
| 289 | |
| 290 | const int x_in_start = std::max(0, coord[0]); |
| 291 | const int y_in_start = std::max(0, coord[1]); |
| 292 | const int x_in_end = std::min(static_cast<int>(in.shape()[0]), coord[0] + w_tile); |
| 293 | const int y_in_end = std::min(static_cast<int>(in.shape()[1]), coord[1] + h_tile); |
| 294 | |
| 295 | // Number of elements to copy per row |
| 296 | const int n = x_in_end - x_in_start; |
| 297 | |
| 298 | // Starting coordinates for the ROI |
| 299 | const int x_tile_start = coord[0] > 0 ? 0 : std::abs(coord[0]); |
| 300 | const int y_tile_start = coord[1] > 0 ? 0 : std::abs(coord[1]); |
| 301 | |
| 302 | // Update input pointer |
| 303 | in_ptr += x_in_start; |
| 304 | in_ptr += (y_in_start * in.shape()[0]); |
| 305 | |
| 306 | // Update ROI pointer |
| 307 | roi_ptr += x_tile_start; |
| 308 | roi_ptr += (y_tile_start * tile.shape()[0]); |
| 309 | |
| 310 | for(int y = y_in_start; y < y_in_end; ++y) |
| 311 | { |
| 312 | // Copy per row |
| 313 | std::copy(in_ptr, in_ptr + n, roi_ptr); |
| 314 | |
| 315 | in_ptr += in.shape()[0]; |
| 316 | roi_ptr += tile.shape()[0]; |
| 317 | } |
| 318 | } |
| 319 | |
Gian Marco Iodice | f1c2bf0 | 2018-06-13 14:05:54 +0100 | [diff] [blame] | 320 | template <typename T> |
| 321 | void zeros(SimpleTensor<T> &in, const Coordinates &anchor, const TensorShape &shape) |
| 322 | { |
| 323 | ARM_COMPUTE_ERROR_ON(anchor.num_dimensions() != shape.num_dimensions()); |
| 324 | ARM_COMPUTE_ERROR_ON(in.shape().num_dimensions() > 2); |
| 325 | ARM_COMPUTE_ERROR_ON(shape.num_dimensions() > 2); |
| 326 | |
| 327 | // Check if with the dimensions greater than 2 we could have out-of-bound reads |
| 328 | for(size_t d = 0; d < Coordinates::num_max_dimensions; ++d) |
| 329 | { |
| 330 | if(anchor[d] < 0 || ((anchor[d] + shape[d]) > in.shape()[d])) |
| 331 | { |
| 332 | ARM_COMPUTE_ERROR("anchor[d] < 0 || (anchor[d] + shape[d]) > in.shape()[d]"); |
| 333 | } |
| 334 | } |
| 335 | |
| 336 | // Get input pointer |
| 337 | auto in_ptr = static_cast<T *>(in(anchor[0] + anchor[1] * in.shape()[0])); |
| 338 | |
| 339 | const unsigned int n = in.shape()[0]; |
| 340 | |
| 341 | for(unsigned int y = 0; y < shape[1]; ++y) |
| 342 | { |
| 343 | std::fill(in_ptr, in_ptr + shape[0], 0); |
| 344 | in_ptr += n; |
| 345 | } |
| 346 | } |
| 347 | |
Michele Di Giorgio | ed5a492 | 2018-09-13 16:22:01 +0100 | [diff] [blame] | 348 | std::pair<int, int> get_quantized_bounds(const QuantizationInfo &quant_info, float min, float max) |
| 349 | { |
| 350 | ARM_COMPUTE_ERROR_ON_MSG(min > max, "min must be lower equal than max"); |
| 351 | |
Georgios Pinitas | 4c5469b | 2019-05-21 13:32:43 +0100 | [diff] [blame] | 352 | const int min_bound = quantize_qasymm8(min, quant_info.uniform()); |
| 353 | const int max_bound = quantize_qasymm8(max, quant_info.uniform()); |
Michalis Spyrou | bcfd09a | 2019-05-01 13:03:59 +0100 | [diff] [blame] | 354 | return std::pair<int, int> { min_bound, max_bound }; |
Michele Di Giorgio | ed5a492 | 2018-09-13 16:22:01 +0100 | [diff] [blame] | 355 | } |
| 356 | |
Georgios Pinitas | 6e1791b | 2019-12-02 19:01:25 +0000 | [diff] [blame] | 357 | std::pair<int, int> get_quantized_qasymm8_signed_bounds(const QuantizationInfo &quant_info, float min, float max) |
| 358 | { |
| 359 | ARM_COMPUTE_ERROR_ON_MSG(min > max, "min must be lower equal than max"); |
| 360 | |
| 361 | const int min_bound = quantize_qasymm8_signed(min, quant_info.uniform()); |
| 362 | const int max_bound = quantize_qasymm8_signed(max, quant_info.uniform()); |
| 363 | return std::pair<int, int> { min_bound, max_bound }; |
| 364 | } |
| 365 | |
Georgios Pinitas | dbdea0d | 2019-10-16 19:21:40 +0100 | [diff] [blame] | 366 | std::pair<int, int> get_symm_quantized_per_channel_bounds(const QuantizationInfo &quant_info, float min, float max, size_t channel_id) |
| 367 | { |
| 368 | ARM_COMPUTE_ERROR_ON_MSG(min > max, "min must be lower equal than max"); |
| 369 | |
| 370 | const int min_bound = quantize_qsymm8_per_channel(min, quant_info, channel_id); |
| 371 | const int max_bound = quantize_qsymm8_per_channel(max, quant_info, channel_id); |
| 372 | return std::pair<int, int> { min_bound, max_bound }; |
| 373 | } |
| 374 | |
Giorgio Arena | 1f9ca1d | 2018-03-01 11:13:45 +0000 | [diff] [blame] | 375 | template void get_tile(const SimpleTensor<float> &in, SimpleTensor<float> &roi, const Coordinates &coord); |
Vidhya Sudhan Loganathan | 71ecf39 | 2018-08-31 16:10:16 +0100 | [diff] [blame] | 376 | template void get_tile(const SimpleTensor<half> &in, SimpleTensor<half> &roi, const Coordinates &coord); |
Gian Marco Iodice | 5ba5e09 | 2018-12-06 17:13:09 +0000 | [diff] [blame] | 377 | template void get_tile(const SimpleTensor<int> &in, SimpleTensor<int> &roi, const Coordinates &coord); |
| 378 | template void get_tile(const SimpleTensor<short> &in, SimpleTensor<short> &roi, const Coordinates &coord); |
| 379 | template void get_tile(const SimpleTensor<char> &in, SimpleTensor<char> &roi, const Coordinates &coord); |
Gian Marco Iodice | f1c2bf0 | 2018-06-13 14:05:54 +0100 | [diff] [blame] | 380 | template void zeros(SimpleTensor<float> &in, const Coordinates &anchor, const TensorShape &shape); |
Vidhya Sudhan Loganathan | 71ecf39 | 2018-08-31 16:10:16 +0100 | [diff] [blame] | 381 | template void zeros(SimpleTensor<half> &in, const Coordinates &anchor, const TensorShape &shape); |
| 382 | template void transpose_matrix(const SimpleTensor<float> &in, SimpleTensor<float> &out); |
| 383 | template void transpose_matrix(const SimpleTensor<half> &in, SimpleTensor<half> &out); |
Gian Marco Iodice | 5ba5e09 | 2018-12-06 17:13:09 +0000 | [diff] [blame] | 384 | template void transpose_matrix(const SimpleTensor<int> &in, SimpleTensor<int> &out); |
| 385 | template void transpose_matrix(const SimpleTensor<short> &in, SimpleTensor<short> &out); |
| 386 | template void transpose_matrix(const SimpleTensor<char> &in, SimpleTensor<char> &out); |
Vidhya Sudhan Loganathan | 71ecf39 | 2018-08-31 16:10:16 +0100 | [diff] [blame] | 387 | template void matrix_multiply(const SimpleTensor<float> &a, const SimpleTensor<float> &b, SimpleTensor<float> &out); |
| 388 | template void matrix_multiply(const SimpleTensor<half> &a, const SimpleTensor<half> &b, SimpleTensor<half> &out); |
| 389 | |
Moritz Pflanzer | 3ce3ff4 | 2017-07-21 17:41:02 +0100 | [diff] [blame] | 390 | } // namespace validation |
| 391 | } // namespace test |
| 392 | } // namespace arm_compute |