41 #pragma omp parallel for 43 for(
int i = 0; i <
src.num_elements(); ++i)
57 #pragma omp parallel for 59 for(
int i = 0; i <
src.num_elements(); ++i)
73 #pragma omp parallel for 75 for(
int i = 0; i <
src.num_elements(); ++i)
89 #pragma omp parallel for 91 for(
int i = 0; i <
src.num_elements(); ++i)
105 #pragma omp parallel for 107 for(
int i = 0; i <
src.num_elements(); ++i)
121 #pragma omp parallel for 123 for(
int i = 0; i <
src.num_elements(); ++i)
137 #pragma omp parallel for 139 for(
int i = 0; i <
src.num_elements(); ++i)
153 #pragma omp parallel for 155 for(
int i = 0; i <
src.num_elements(); ++i)
162 template <
typename T>
169 const int M = a.
shape()[1];
170 const int N =
b.shape()[0];
171 const int K =
b.shape()[1];
174 #pragma omp parallel for collapse(2) 176 for(
int y = 0; y <
M; ++y)
178 for(
int x = 0; x <
N; ++x)
181 for(
int k = 0; k <
K; ++k)
183 acc += a[y *
K + k] *
b[x + k *
N];
186 out[x + y *
N] = acc;
191 template <
typename T>
196 const int width = in.
shape()[0];
197 const int height = in.
shape()[1];
200 #pragma omp parallel for collapse(2) 202 for(
int y = 0; y < height; ++y)
204 for(
int x = 0; x < width; ++x)
206 const T val = in[x + y * width];
208 out[x * height + y] = val;
213 template <
typename T>
218 const int w_tile =
tile.shape()[0];
219 const int h_tile =
tile.shape()[1];
222 std::fill(
tile.data() + 0, (
tile.data() + (w_tile * h_tile)), static_cast<T>(0));
227 if(coord[d] < 0 || coord[d] >= static_cast<int>(in.
shape()[d]))
240 auto in_ptr = static_cast<const T *>(in(start_coord));
241 auto roi_ptr = static_cast<T *>(
tile.data());
243 const int x_in_start = std::max(0, coord[0]);
244 const int y_in_start = std::max(0, coord[1]);
245 const int x_in_end = std::min(static_cast<int>(in.
shape()[0]), coord[0] + w_tile);
246 const int y_in_end = std::min(static_cast<int>(in.
shape()[1]), coord[1] + h_tile);
249 const int n = x_in_end - x_in_start;
252 const int x_tile_start = coord[0] > 0 ? 0 : std::abs(coord[0]);
253 const int y_tile_start = coord[1] > 0 ? 0 : std::abs(coord[1]);
256 in_ptr += x_in_start;
257 in_ptr += (y_in_start * in.
shape()[0]);
260 roi_ptr += x_tile_start;
261 roi_ptr += (y_tile_start *
tile.shape()[0]);
263 for(
int y = y_in_start; y < y_in_end; ++y)
268 in_ptr += in.
shape()[0];
269 roi_ptr +=
tile.shape()[0];
273 template <
typename T>
283 if(anchor[d] < 0 || ((anchor[d] +
shape[d]) > in.
shape()[d]))
290 auto in_ptr = static_cast<T *>(in(anchor[0] + anchor[1] * in.
shape()[0]));
292 const unsigned int n = in.
shape()[0];
294 for(
unsigned int y = 0; y <
shape[1]; ++y)
307 return std::pair<int, int> { min_bound, max_bound };
316 return std::pair<int, int> { min_bound, max_bound };
325 return std::pair<int, int> { min_bound, max_bound };
332 constexpr
unsigned int lower = 1
U;
333 constexpr
unsigned int upper = 16
U;
335 std::uniform_int_distribution<unsigned int>
distribution(lower, upper);
336 size_t seed_offset = 0;
342 std::mt19937 gen(
library->seed() + seed_offset++);
347 tensor->info()->extend_padding(
PaddingSize(0
U, right, 0
U, left));
void add_padding_x(std::initializer_list< ITensor * > tensors, const DataLayout &data_layout)
Add random padding along the X axis (between 1 and 16 columns per side) to all the input tensors.
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.
quantized, symmetric fixed-point 16-bit number
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.
const DataLayout data_layout
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)
Interface for CPU tensor.
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.
library fill(src, distribution, 0)
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
#define ARM_COMPUTE_ERROR_ON_MSG(cond, msg)
UniformQuantizationInfo uniform() const
Return per layer quantization info.
std::uniform_real_distribution< float > distribution(-5.f, 5.f)
BorderSize PaddingSize
Container for 2D padding size.
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.
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.
Num samples, height, width, channels.
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.
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.
static constexpr size_t num_max_dimensions
Number of dimensions the tensor has.
DataLayout
[DataLayout enum definition]
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.