[IE TESTS][CONFORMANCE] Change data_generation initialization to avoid incorrect value (#18193)
* [IE TESTS][CONFORMANCE] Fix data generation * fix cpu tests * CPP Lint * Update ranges.hpp * change start_from and range according typo * Update deformable_convolution.cpp * clenup * Update activation.cpp * Update deformable_convolution.cpp * Update grid_sample.cpp * Fix tests -> change start_from type
This commit is contained in:
@@ -27,14 +27,42 @@ namespace ov {
|
||||
namespace test {
|
||||
namespace utils {
|
||||
|
||||
// todo: remove w/a to generate correct constant data (replace parameter to const) in conformance with defined range
|
||||
struct ConstRanges {
|
||||
static double max, min;
|
||||
static bool is_defined;
|
||||
|
||||
static void set(double _min, double _max) {
|
||||
min = _min;
|
||||
max = _max;
|
||||
is_defined = true;
|
||||
}
|
||||
|
||||
static void reset() {
|
||||
min = std::numeric_limits<double>::max();
|
||||
max = std::numeric_limits<double>::min();
|
||||
is_defined = false;
|
||||
}
|
||||
};
|
||||
|
||||
struct InputGenerateData {
|
||||
int32_t start_from;
|
||||
double_t start_from;
|
||||
uint32_t range;
|
||||
int32_t resolution;
|
||||
int seed;
|
||||
|
||||
InputGenerateData(int32_t _start_from = 0, uint32_t _range = 10, int32_t _resolution = 1, int _seed = 1)
|
||||
: start_from(_start_from), range(_range), resolution(_resolution), seed(_seed) {}
|
||||
InputGenerateData(double_t _start_from = 0, uint32_t _range = 10, int32_t _resolution = 1, int _seed = 1)
|
||||
: start_from(_start_from), range(_range), resolution(_resolution), seed(_seed) {
|
||||
if (ConstRanges::is_defined) {
|
||||
auto min_orig = start_from;
|
||||
auto max_orig = start_from + range * resolution;
|
||||
auto min_ref = ConstRanges::min;
|
||||
auto max_ref = ConstRanges::max;
|
||||
if (min_orig < min_ref || min_orig == 0)
|
||||
start_from = min_ref;
|
||||
range = (max_orig > max_ref || max_orig == 10 ? max_ref : max_orig - start_from) - start_from;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
static std::map<ov::NodeTypeInfo, std::vector<std::vector<InputGenerateData>>> inputRanges = {
|
||||
|
||||
@@ -18,6 +18,10 @@ namespace ov {
|
||||
namespace test {
|
||||
namespace utils {
|
||||
|
||||
double ConstRanges::max = std::numeric_limits<double>::min();
|
||||
double ConstRanges::min = std::numeric_limits<double>::max();
|
||||
bool ConstRanges::is_defined = false;
|
||||
|
||||
namespace {
|
||||
|
||||
/**
|
||||
|
||||
@@ -193,8 +193,15 @@ fill_data_roi(ov::runtime::Tensor& tensor, const uint32_t range, const int heigh
|
||||
|
||||
template<class T>
|
||||
void inline
|
||||
fill_data_random(T *pointer, std::size_t size, const uint32_t range = 10, int32_t start_from = 0, const int32_t k = 1,
|
||||
fill_data_random(T *pointer, std::size_t size, const uint32_t range = 10, double_t start_from = 0, const int32_t k = 1,
|
||||
const int seed = 1) {
|
||||
if (range == 0) {
|
||||
for (std::size_t i = 0; i < size; i++) {
|
||||
pointer[i] = static_cast<T>(start_from);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
testing::internal::Random random(seed);
|
||||
const uint32_t k_range = k * range; // range with respect to k
|
||||
random.Generate(k_range);
|
||||
@@ -202,7 +209,6 @@ fill_data_random(T *pointer, std::size_t size, const uint32_t range = 10, int32_
|
||||
if (start_from < 0 && !std::is_signed<T>::value) {
|
||||
start_from = 0;
|
||||
}
|
||||
|
||||
for (std::size_t i = 0; i < size; i++) {
|
||||
pointer[i] = static_cast<T>(start_from + static_cast<T>(random.Generate(k_range)) / k);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ ov::Tensor create_and_fill_tensor(
|
||||
const ov::element::Type element_type,
|
||||
const ov::Shape &shape,
|
||||
const uint32_t range = 10,
|
||||
const int32_t start_from = 0,
|
||||
const double_t start_from = 0,
|
||||
const int32_t resolution = 1,
|
||||
const int seed = 1);
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ ov::Tensor create_and_fill_tensor(
|
||||
const ov::element::Type element_type,
|
||||
const ov::Shape& shape,
|
||||
const uint32_t range,
|
||||
const int32_t start_from,
|
||||
const double_t start_from,
|
||||
const int32_t resolution,
|
||||
const int seed) {
|
||||
auto tensor = ov::Tensor{element_type, shape};
|
||||
|
||||
Reference in New Issue
Block a user