38 std::mt19937 gen(
library->seed());
39 std::bernoulli_distribution dist(0.5);
41 for(
int r = 0; r <
rows; ++r)
43 for(
int c = 0; c <
cols; ++c, ++v)
53 val = ((r == (rows / 2)) || (c == (cols / 2))) ? 255 : 0;
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;
60 val = (dist(gen) ? 0 : 255);
72 std::uniform_int_distribution<uint8_t> distribution_u8(0, ((cols * rows) - 1));
73 mask[distribution_u8(gen)] = 255;
81 std::mt19937 gen(
library->seed());
82 std::uniform_real_distribution<float> threshold_dist(0.f, 0.001f);
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);
89 params.
min_dist = euclidean_distance(gen);
99 std::mt19937 gen(
library->seed());
100 std::uniform_int_distribution<uint8_t> int_dist(0, 255);
101 std::uniform_int_distribution<uint8_t> threshold_dist(2, 255);
105 threshold_dist = std::uniform_int_distribution<uint8_t>(1, params.
upper_thresh - 1);
117 #pragma omp parallel for 133 #pragma omp parallel for 149 #pragma omp parallel for 165 #pragma omp parallel for 181 #pragma omp parallel for 197 #pragma omp parallel for 213 #pragma omp parallel for 229 #pragma omp parallel for 238 template <
typename T>
245 const int M = a.
shape()[1];
246 const int N = b.
shape()[0];
247 const int K = b.
shape()[1];
250 #pragma omp parallel for collapse(2) 252 for(
int y = 0; y <
M; ++y)
254 for(
int x = 0; x <
N; ++x)
257 for(
int k = 0; k <
K; ++k)
259 acc += a[y * K + k] * b[x + k *
N];
262 out[x + y *
N] = acc;
267 template <
typename T>
272 const int width = in.
shape()[0];
273 const int height = in.
shape()[1];
276 #pragma omp parallel for collapse(2) 278 for(
int y = 0; y < height; ++y)
280 for(
int x = 0; x < width; ++x)
282 const T val = in[x + y * width];
284 out[x * height + y] = val;
289 template <
typename T>
294 const int w_tile = tile.
shape()[0];
295 const int h_tile = tile.
shape()[1];
298 std::fill(tile.
data() + 0, (tile.
data() + (w_tile * h_tile)),
static_cast<T
>(0));
303 if(coord[d] < 0 || coord[d] >= static_cast<int>(in.
shape()[d]))
316 auto in_ptr =
static_cast<const T *
>(in(start_coord));
317 auto roi_ptr =
static_cast<T *
>(tile.
data());
319 const int x_in_start = std::max(0, coord[0]);
320 const int y_in_start = std::max(0, coord[1]);
321 const int x_in_end = std::min(static_cast<int>(in.
shape()[0]), coord[0] + w_tile);
322 const int y_in_end = std::min(static_cast<int>(in.
shape()[1]), coord[1] + h_tile);
325 const int n = x_in_end - x_in_start;
328 const int x_tile_start = coord[0] > 0 ? 0 : std::abs(coord[0]);
329 const int y_tile_start = coord[1] > 0 ? 0 : std::abs(coord[1]);
332 in_ptr += x_in_start;
333 in_ptr += (y_in_start * in.
shape()[0]);
336 roi_ptr += x_tile_start;
337 roi_ptr += (y_tile_start * tile.
shape()[0]);
339 for(
int y = y_in_start; y < y_in_end; ++y)
344 in_ptr += in.
shape()[0];
345 roi_ptr += tile.
shape()[0];
349 template <
typename T>
359 if(anchor[d] < 0 || ((anchor[d] + shape[d]) > in.
shape()[d]))
366 auto in_ptr =
static_cast<T *
>(in(anchor[0] + anchor[1] * in.
shape()[0]));
368 const unsigned int n = in.
shape()[0];
370 for(
unsigned int y = 0; y < shape[1]; ++y)
383 return std::pair<int, int> { min_bound, max_bound };
392 return std::pair<int, int> { min_bound, max_bound };
401 return std::pair<int, int> { min_bound, max_bound };
CannyEdgeParameters canny_edge_parameters()
Generate parameters for Canny edge algorithm.
std::pair< int, int > get_quantized_bounds(const QuantizationInfo &quant_info, float min, float max)
Helper function to compute quantized min and max bounds.
int16_t quantize_qsymm16(float value, const UniformQuantizationInfo &qinfo, RoundingPolicy rounding_policy=RoundingPolicy::TO_NEAREST_UP)
Quantize a value given a 16-bit symmetric quantization scheme.
float threshold
Threshold.
quantized, symmetric fixed-point 16-bit number
void fill_mask_from_pattern(uint8_t *mask, int cols, int rows, MatrixPattern pattern)
Fill mask with the corresponding given pattern.
float dequantize_qasymm8(uint8_t value, const INFO_TYPE &qinfo)
Dequantize a value given an unsigned 8-bit asymmetric quantization scheme.
uint8_t quantize_qasymm8(float value, const INFO_TYPE &qinfo, RoundingPolicy rounding_policy=RoundingPolicy::TO_NEAREST_UP)
Quantize a value given an unsigned 8-bit asymmetric quantization scheme.
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
void zeros(SimpleTensor< T > &in, const Coordinates &anchor, const TensorShape &shape)
Fill with zeros the input tensor in the area defined by anchor and shape.
1 channel, 1 F32 per channel
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
SimpleTensor< float > convert_from_asymmetric(const SimpleTensor< uint8_t > &src)
quantized, asymmetric fixed-point 16-bit number
void transpose_matrix(const SimpleTensor< T > &in, SimpleTensor< T > &out)
Transpose matrix.
TensorShape shape() const override
Shape of the tensor.
SimpleTensor< T > copy(const SimpleTensor< T > &src, const TensorShape &output_shape)
SimpleTensor< float > src
Copyright (c) 2017-2021 Arm Limited.
float dequantize_qasymm16(uint16_t value, const UniformQuantizationInfo &qinfo)
Dequantize a value given a 16-bit asymmetric quantization scheme.
Quantization information.
uint8_t constant_border_value
Border value.
float sensitivity
Sensitivity.
library fill(src, distribution, 0)
Parameters of Canny edge algorithm.
std::unique_ptr< AssetsLibrary > library
int8_t quantize_qasymm8_signed(float value, const INFO_TYPE &qinfo, RoundingPolicy rounding_policy=RoundingPolicy::TO_NEAREST_UP)
Quantize a value given a signed 8-bit asymmetric quantization scheme.
float dequantize_qsymm16(int16_t value, const UniformQuantizationInfo &qinfo)
Dequantize a value given a 16-bit symmetric quantization scheme.
quantized, asymmetric fixed-point 8-bit number unsigned
float min_dist
Minimum distance.
#define ARM_COMPUTE_ERROR_ON_MSG(cond, msg)
UniformQuantizationInfo uniform() const
Return per layer quantization info.
DataLayout data_layout() const override
Data layout of the tensor.
HarrisCornersParameters harris_corners_parameters()
Generate parameters for Harris Corners algorithm.
SimpleTensor< T > tile(const SimpleTensor< T > &src, const Multiples &multiples)
SimpleTensor< uint8_t > convert_to_asymmetric(const SimpleTensor< float > &src, const QuantizationInfo &quantization_info)
Convert float simple tensor into quantized using specified quantization information.
Parameters of Harris Corners algorithm.
SimpleTensor< int16_t > convert_to_symmetric(const SimpleTensor< float > &src, const QuantizationInfo &quantization_info)
Convert float simple tensor into quantized using specified quantization information.
Simple tensor object that stores elements in a consecutive chunk of memory.
std::pair< int, int > get_quantized_qasymm8_signed_bounds(const QuantizationInfo &quant_info, float min, float max)
Helper function to compute asymmetric quantized signed min and max bounds.
void get_tile(const SimpleTensor< T > &in, SimpleTensor< T > &tile, const Coordinates &coord)
Get a 2D tile from a tensor.
int8_t quantize_qsymm8_per_channel(float value, const QuantizationInfo &qinfo, size_t channel_id=0)
Quantize a value given a 8-bit symmetric per channel quantization scheme.
const QuantizationInfo qinfo
unsigned int num_dimensions() const
Returns the effective dimensionality of the tensor.
uint8_t constant_border_value
std::pair< int, int > get_symm_quantized_per_channel_bounds(const QuantizationInfo &quant_info, float min, float max, size_t channel_id)
Helper function to compute symmetric quantized min and max bounds.
int num_elements() const override
Number of elements of the tensor.
float dequantize_qasymm8_signed(int8_t value, const INFO_TYPE &qinfo)
Dequantize a value given a signed 8-bit asymmetric quantization scheme.
quantized, asymmetric fixed-point 8-bit number signed
void matrix_multiply(const SimpleTensor< T > &a, const SimpleTensor< T > &b, SimpleTensor< T > &out)
Matrix multiply between 2 float simple tensors.
QuantizationInfo quantization_info() const override
Quantization info in case of asymmetric quantized type.
static constexpr size_t num_max_dimensions
Number of dimensions the tensor has.
MatrixPattern
Available matrix patterns.
Any other matrix pattern.
SimpleTensor< float > convert_from_symmetric(const SimpleTensor< int16_t > &src)
uint16_t quantize_qasymm16(float value, const UniformQuantizationInfo &qinfo, RoundingPolicy rounding_policy=RoundingPolicy::TO_NEAREST_UP)
Quantize a value given a 16-bit asymmetric quantization scheme.
const T * data() const
Constant pointer to the underlying buffer.