[IE TESTS] GatherTree single layer test has been created. (#2006)
* [IE TESTS] GatherTree op ref function has been created. * [IE TESTS] Added GatherTree single layer test * [IE TESTS] Fixed code styles. * [IE TESTS] GatherTree test FP32 precion was enabled. * [IE TESTS] Refactoring of Builder::makeConstatn procedure The refactoring is aimed at managing the range of random data for the constants initialization procedure. * [IE TESTS] GatherTree test was extended with constants * [IE TESTS] GatherTree ref rewritten to non-templated function. * [IE TESTS] GatherTree test inp shape indx enum removed. * Revert "[IE TESTS] Refactoring of Builder::makeConstatn procedure" This reverts commit 2648172e00ccca266d39e8775b890b8a8395f57c. * [IE TESTS] makeConstant was augmented with random data range parameters. * [IE TESTS] GatherTree test was rewritten using makeConstant function. * [IE TESTS] GaterTree test call templated makeConstant * [IE TESTS] GaterTree test code style fix
This commit is contained in:
@@ -24,27 +24,28 @@ makeParams(const element::Type &type, const std::vector<std::pair<std::string, s
|
||||
|
||||
template<typename T>
|
||||
std::shared_ptr<Node> makeConstant(const element::Type &type, const std::vector<size_t> &shape,
|
||||
const std::vector<T> &data, bool random = false) {
|
||||
const std::vector<T> &data, bool random = false,
|
||||
uint32_t upTo = 10, uint32_t startFrom = 1) {
|
||||
std::shared_ptr<ngraph::Node> weightsNode;
|
||||
|
||||
#define makeNode(TYPE) \
|
||||
case TYPE: \
|
||||
weightsNode = std::make_shared<ngraph::opset1::Constant>( \
|
||||
type, shape, \
|
||||
random ? NGraphFunctions::Utils::generateVector<TYPE>(ngraph::shape_size(shape)) : \
|
||||
random ? NGraphFunctions::Utils::generateVector<TYPE>(ngraph::shape_size(shape), upTo, startFrom) : \
|
||||
NGraphFunctions::Utils::castVector<T, ngraph::helpers::nGraphTypesTrait<TYPE>::value_type >(data)); \
|
||||
break;
|
||||
switch (type) {
|
||||
case ngraph::element::Type_t::bf16:
|
||||
weightsNode = std::make_shared<ngraph::opset1::Constant>(
|
||||
type, shape,
|
||||
random ? NGraphFunctions::Utils::generateBF16Vector(ngraph::shape_size(shape)) :
|
||||
random ? NGraphFunctions::Utils::generateBF16Vector(ngraph::shape_size(shape), upTo, startFrom) :
|
||||
NGraphFunctions::Utils::castVector<T, ngraph::bfloat16>(data));
|
||||
break;
|
||||
case ngraph::element::Type_t::f16:
|
||||
weightsNode = std::make_shared<ngraph::opset1::Constant>(
|
||||
type, shape,
|
||||
random ? NGraphFunctions::Utils::generateF16Vector(ngraph::shape_size(shape)) :
|
||||
random ? NGraphFunctions::Utils::generateF16Vector(ngraph::shape_size(shape), upTo, startFrom) :
|
||||
NGraphFunctions::Utils::castVector<T, ngraph::float16>(data));
|
||||
break;
|
||||
makeNode(ngraph::element::Type_t::f32);
|
||||
|
||||
@@ -17,13 +17,13 @@ namespace Utils {
|
||||
|
||||
template<ngraph::element::Type_t dType>
|
||||
std::vector<typename ngraph::helpers::nGraphTypesTrait<dType>::value_type> inline
|
||||
generateVector(size_t vec_len) {
|
||||
generateVector(size_t vec_len, uint32_t upTo = 10, uint32_t startFrom = 1) {
|
||||
std::vector<typename ngraph::helpers::nGraphTypesTrait<dType>::value_type> res;
|
||||
|
||||
std::mt19937 gen(
|
||||
static_cast<unsigned long>(std::chrono::high_resolution_clock::now().time_since_epoch().count()));
|
||||
// chose values between this range to avoid type overrun (e.g. in case of I8 precision)
|
||||
std::uniform_int_distribution<unsigned long> dist(1, 10);
|
||||
std::uniform_int_distribution<unsigned long> dist(startFrom, upTo);
|
||||
|
||||
for (int i = 0; i < vec_len; i++) {
|
||||
res.push_back(
|
||||
@@ -32,13 +32,13 @@ generateVector(size_t vec_len) {
|
||||
return res;
|
||||
}
|
||||
|
||||
std::vector<ngraph::float16> inline generateF16Vector(size_t vec_len) {
|
||||
std::vector<ngraph::float16> inline generateF16Vector(size_t vec_len, uint32_t upTo = 10, uint32_t startFrom = 1) {
|
||||
std::vector<ngraph::float16> res;
|
||||
|
||||
std::mt19937 gen(
|
||||
static_cast<unsigned long>(std::chrono::high_resolution_clock::now().time_since_epoch().count()));
|
||||
// chose values between this range to avoid type overrun (e.g. in case of I8 precision)
|
||||
std::uniform_int_distribution<unsigned long> dist(1, 10);
|
||||
std::uniform_int_distribution<unsigned long> dist(startFrom, upTo);
|
||||
|
||||
for (int i = 0; i < vec_len; i++) {
|
||||
res.emplace_back(ngraph::float16(static_cast<float>(dist(gen))));
|
||||
@@ -46,13 +46,13 @@ std::vector<ngraph::float16> inline generateF16Vector(size_t vec_len) {
|
||||
return res;
|
||||
}
|
||||
|
||||
std::vector<ngraph::bfloat16> inline generateBF16Vector(size_t vec_len) {
|
||||
std::vector<ngraph::bfloat16> inline generateBF16Vector(size_t vec_len, uint32_t upTo = 10, uint32_t startFrom = 1) {
|
||||
std::vector<ngraph::bfloat16> res;
|
||||
|
||||
std::mt19937 gen(
|
||||
static_cast<unsigned long>(std::chrono::high_resolution_clock::now().time_since_epoch().count()));
|
||||
// chose values between this range to avoid type overrun (e.g. in case of I8 precision)
|
||||
std::uniform_int_distribution<unsigned long> dist(1, 10);
|
||||
std::uniform_int_distribution<unsigned long> dist(startFrom, upTo);
|
||||
|
||||
for (int i = 0; i < vec_len; i++) {
|
||||
res.emplace_back(ngraph::bfloat16(static_cast<float>(dist(gen))));
|
||||
|
||||
Reference in New Issue
Block a user