62 return *
reinterpret_cast<const uint8_t *
>(ptr);
64 return *
reinterpret_cast<const int8_t *
>(ptr);
66 return *
reinterpret_cast<const qint8_t *
>(ptr);
68 return *
reinterpret_cast<const uint16_t *
>(ptr);
70 return *
reinterpret_cast<const int16_t *
>(ptr);
72 return *
reinterpret_cast<const qint16_t *
>(ptr);
74 return *
reinterpret_cast<const uint32_t *
>(ptr);
76 return *
reinterpret_cast<const int32_t *
>(ptr);
78 return *
reinterpret_cast<const uint64_t *
>(ptr);
80 return *
reinterpret_cast<const int64_t *
>(ptr);
82 return *
reinterpret_cast<const half *
>(ptr);
84 return *
reinterpret_cast<const float *
>(ptr);
86 return *
reinterpret_cast<const double *
>(ptr);
88 return *
reinterpret_cast<const size_t *
>(ptr);
94 void check_border_element(
const IAccessor &tensor,
const Coordinates &
id,
96 int64_t &num_elements, int64_t &num_mismatches)
99 const auto ptr =
static_cast<const uint8_t *
>(tensor(
id));
103 Coordinates border_id{
id };
109 else if(static_cast<size_t>(
id.x()) >= tensor.shape().x())
111 border_id.set(0, tensor.shape().x() - 1);
118 else if(static_cast<size_t>(
id.y()) >= tensor.shape().y())
120 border_id.set(1, tensor.shape().y() - 1);
123 border_value = tensor(border_id);
127 for(
int channel = 0; channel < tensor.num_channels(); ++channel)
129 const size_t channel_offset = channel * channel_size;
130 const double target = get_double_data(ptr + channel_offset, tensor.data_type());
131 const double reference = get_double_data(static_cast<const uint8_t *>(border_value) + channel_offset, tensor.data_type());
133 if(!compare<AbsoluteTolerance<double>>(target, reference))
185 int64_t num_mismatches = 0;
186 int64_t num_elements = 0;
190 for(
int element_idx = 0; element_idx < tensor.
num_elements(); ++element_idx)
194 const auto ptr =
static_cast<const uint8_t *
>(tensor(
id));
197 for(
int channel = 0; channel < tensor.
num_channels(); ++channel)
199 const size_t channel_offset = channel * channel_size;
200 const double target = get_double_data(ptr + channel_offset, tensor.
data_type());
201 const double reference = get_double_data(reference_value, tensor.
data_type());
220 const float percent_mismatches =
static_cast<float>(num_mismatches) / num_elements * 100.f;
222 ARM_COMPUTE_TEST_INFO(num_mismatches <<
" values (" << std::fixed << std::setprecision(2) << percent_mismatches <<
"%) mismatched");
238 int64_t num_mismatches = 0;
239 int64_t num_elements = 0;
240 const int slice_size = tensor.
shape()[0] * tensor.
shape()[1];
242 for(
int element_idx = 0; element_idx < tensor.
num_elements(); element_idx += slice_size)
247 for(
int y = -border_size.
top; y < 0; ++y)
251 for(
int x = -border_size.
left; x < static_cast<int>(tensor.
shape()[0]) + static_cast<int>(border_size.
right); ++x)
255 check_border_element(tensor,
id, border_mode, border_value, num_elements, num_mismatches);
260 for(
int y = tensor.
shape()[1]; y < static_cast<int>(tensor.
shape()[1]) + static_cast<int>(border_size.
bottom); ++y)
264 for(
int x = -border_size.
left; x < static_cast<int>(tensor.
shape()[0]) + static_cast<int>(border_size.
right); ++x)
268 check_border_element(tensor,
id, border_mode, border_value, num_elements, num_mismatches);
273 for(
int y = 0; y < static_cast<int>(tensor.
shape()[1]); ++y)
278 for(
int x = -border_size.
left; x < 0; ++x)
282 check_border_element(tensor,
id, border_mode, border_value, num_elements, num_mismatches);
286 for(
int x = tensor.
shape()[0]; x < static_cast<int>(tensor.
shape()[0]) + static_cast<int>(border_size.
right); ++x)
290 check_border_element(tensor,
id, border_mode, border_value, num_elements, num_mismatches);
297 const float percent_mismatches =
static_cast<float>(num_mismatches) / num_elements * 100.f;
299 ARM_COMPUTE_TEST_INFO(num_mismatches <<
" values (" << std::fixed << std::setprecision(2) << percent_mismatches <<
"%) mismatched");
304 void validate(std::vector<unsigned int> classified_labels, std::vector<unsigned int> expected_labels)
308 int64_t num_mismatches = 0;
309 const int num_elements =
std::min(classified_labels.size(), expected_labels.size());
311 for(
int i = 0; i < num_elements; ++i)
313 if(classified_labels[i] != expected_labels[i])
322 const float percent_mismatches =
static_cast<float>(num_mismatches) / num_elements * 100.f;
324 ARM_COMPUTE_TEST_INFO(num_mismatches <<
" values (" << std::fixed << std::setprecision(2) << percent_mismatches <<
"%) mismatched");
BorderMode
Methods available to handle borders.
#define ARM_COMPUTE_ERROR(...)
Print the given message then throw an std::runtime_error.
unsigned int top
top of the border
quantized, symmetric fixed-point 16-bit number
fixed_point< T > min(fixed_point< T > x, fixed_point< T > y)
Class reprensenting an absolute tolerance value.
quantized, symmetric fixed-point 8-bit number
TensorShape shape
Shape of the valid region.
Container for 2D border size.
1 channel, 1 U8 per channel
size_t element_size_from_data_type(DataType dt)
The size in bytes of the data type.
half_float::half half
16-bit floating point type
1 channel, 1 F32 per channel
1 channel, 1 U16 per channel
unsigned int bottom
bottom of the border
void set(size_t dimension, T value)
Accessor to set the value of one of the dimensions.
#define ARM_COMPUTE_EXPECT_EQUAL(X, Y, LEVEL)
virtual TensorShape shape() const =0
Shape of the tensor.
#define ARM_COMPUTE_TEST_INFO(INFO)
This file contains all available output stages for GEMMLowp on OpenCL.
1 channel, 1 F16 per channel
1 channel, 1 S32 per channel
validate(dst.info() ->valid_region(), dst_valid_region)
1 channel, 1 U32 per channel
int16_t qint16_t
16 bit fixed point scalar value
virtual int num_elements() const =0
Number of elements of the tensor.
Coordinates index2coord(const TensorShape &shape, int index)
Convert a linear index into n-dimensional coordinates.
unsigned int left
left of the border
unsigned int right
right of the border
1 channel, 1 S16 per channel
#define ARM_COMPUTE_ASSERT(X)
int8_t qint8_t
8 bit fixed point scalar value
unsigned int num_dimensions() const
Returns the effective dimensionality of the tensor.
virtual DataType data_type() const =0
Data type of the tensor.
Borders are left undefined.
Pixels outside the image are assumed to have the same value as the closest image pixel.
Common interface to provide information and access to tensor like structures.
Pixels outside the image are assumed to have a constant value.
64-bit floating-point number
Container for valid region of a window.
virtual int num_channels() const =0
Number of channels of the tensor.
DataType
Available data types.
Coordinates anchor
Anchor for the start of the valid region.