62 return *
reinterpret_cast<const uint8_t *
>(ptr);
64 return *
reinterpret_cast<const int8_t *
>(ptr);
66 return *
reinterpret_cast<const uint16_t *
>(ptr);
68 return *
reinterpret_cast<const int16_t *
>(ptr);
70 return *
reinterpret_cast<const uint32_t *
>(ptr);
72 return *
reinterpret_cast<const int32_t *
>(ptr);
74 return *
reinterpret_cast<const uint64_t *
>(ptr);
76 return *
reinterpret_cast<const int64_t *
>(ptr);
78 return *
reinterpret_cast<const half *
>(ptr);
80 return *
reinterpret_cast<const float *
>(ptr);
82 return *
reinterpret_cast<const double *
>(ptr);
84 return *
reinterpret_cast<const size_t *
>(ptr);
90 void check_border_element(
const IAccessor &
tensor,
const Coordinates &
id,
91 const BorderMode &border_mode,
const void *border_value,
92 int64_t &num_elements, int64_t &num_mismatches)
95 const auto ptr =
static_cast<const uint8_t *
>(
tensor(
id));
99 Coordinates border_id{
id };
105 else if(
static_cast<size_t>(
id.x()) >=
tensor.shape().x())
107 border_id.set(0,
tensor.shape().x() - 1);
114 else if(
static_cast<size_t>(
id.y()) >=
tensor.shape().y())
116 border_id.set(1,
tensor.shape().y() - 1);
119 border_value =
tensor(border_id);
123 for(
int channel = 0; channel <
tensor.num_channels(); ++channel)
125 const size_t channel_offset = channel * channel_size;
126 const double target = get_double_data(ptr + channel_offset,
tensor.data_type());
127 const double reference = get_double_data(
static_cast<const uint8_t *
>(border_value) + channel_offset,
tensor.data_type());
129 if(!
compare<AbsoluteTolerance<double>>(target, reference))
181 int64_t num_mismatches = 0;
182 int64_t num_elements = 0;
186 const uint32_t tensor_num_elements =
tensor.num_elements();
187 for(uint32_t element_idx = 0; element_idx < tensor_num_elements; ++element_idx)
191 const auto ptr =
static_cast<const uint8_t *
>(
tensor(
id));
194 for(
int channel = 0; channel <
tensor.num_channels(); ++channel)
196 const size_t channel_offset = channel * channel_size;
197 const double target = get_double_data(ptr + channel_offset,
tensor.data_type());
198 const double reference = get_double_data(reference_value,
tensor.data_type());
217 const float percent_mismatches =
static_cast<float>(num_mismatches) / num_elements * 100.f;
219 ARM_COMPUTE_TEST_INFO(num_mismatches <<
" values (" << std::fixed << std::setprecision(2) << percent_mismatches <<
"%) mismatched");
235 int64_t num_mismatches = 0;
236 int64_t num_elements = 0;
237 const int slice_size =
tensor.shape()[0] *
tensor.shape()[1];
239 for(
int element_idx = 0; element_idx <
tensor.num_elements(); element_idx += slice_size)
244 for(
int y = -border_size.
top; y < 0; ++y)
248 for(
int x = -border_size.
left; x <
static_cast<int>(
tensor.shape()[0]) +
static_cast<int>(border_size.
right); ++x)
252 check_border_element(
tensor,
id, border_mode, border_value, num_elements, num_mismatches);
257 for(
int y =
tensor.shape()[1]; y <
static_cast<int>(
tensor.shape()[1]) +
static_cast<int>(border_size.
bottom); ++y)
261 for(
int x = -border_size.
left; x <
static_cast<int>(
tensor.shape()[0]) +
static_cast<int>(border_size.
right); ++x)
265 check_border_element(
tensor,
id, border_mode, border_value, num_elements, num_mismatches);
270 for(
int y = 0; y < static_cast<int>(
tensor.shape()[1]); ++y)
275 for(
int x = -border_size.
left; x < 0; ++x)
279 check_border_element(
tensor,
id, border_mode, border_value, num_elements, num_mismatches);
283 for(
int x =
tensor.shape()[0]; x <
static_cast<int>(
tensor.shape()[0]) +
static_cast<int>(border_size.
right); ++x)
287 check_border_element(
tensor,
id, border_mode, border_value, num_elements, num_mismatches);
294 const float percent_mismatches =
static_cast<float>(num_mismatches) / num_elements * 100.f;
296 ARM_COMPUTE_TEST_INFO(num_mismatches <<
" values (" << std::fixed << std::setprecision(2) << percent_mismatches <<
"%) mismatched");
301 void validate(std::vector<unsigned int> classified_labels, std::vector<unsigned int> expected_labels)
305 int64_t num_mismatches = 0;
306 const int num_elements = std::min(classified_labels.size(), expected_labels.size());
308 for(
int i = 0; i < num_elements; ++i)
310 if(classified_labels[i] != expected_labels[i])
319 const float percent_mismatches =
static_cast<float>(num_mismatches) / num_elements * 100.f;
321 ARM_COMPUTE_TEST_INFO(num_mismatches <<
" values (" << std::fixed << std::setprecision(2) << percent_mismatches <<
"%) mismatched");