Update SmartReshape tests to check tensor and node names (#68694) (#9633)

* add name checks but some tets in sss fail

* delete <utility> header

* update SS squeeze tests

* move util functions and correct node replacement

* delete anonymous namespace
This commit is contained in:
Smirnov Grigorii 2022-01-20 15:29:29 +03:00 committed by GitHub
parent 686dad066a
commit 29c3b8e201
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 134 additions and 40 deletions

View File

@ -106,10 +106,8 @@ ngraph::pass::StridedSliceSqueeze::StridedSliceSqueeze() {
shrink_axis_mask,
ellipsis_mask);
replace_node(squeeze, new_slice);
new_slice->set_friendly_name(slice->get_friendly_name());
copy_runtime_info(slice, new_slice);
return true;
return replace_output_update_name(squeeze->output(0),
new_slice->output(squeeze->input_value(0).get_index()));
};
auto m = std::make_shared<ngraph::pattern::Matcher>(squeeze_label /*, matcher_name */);
register_matcher(m, callback);

View File

@ -8,6 +8,8 @@
#include <ngraph/opsets/opset5.hpp>
#include <cpp/ie_cnn_network.h>
#include "common_test_utils/ngraph_test_utils.hpp"
TEST(SmartReshapeTests, MimickingSBS) {
std::shared_ptr<ngraph::Function> f(nullptr);
@ -18,7 +20,11 @@ TEST(SmartReshapeTests, MimickingSBS) {
}
InferenceEngine::CNNNetwork network(f);
auto unh = std::make_shared<ngraph::pass::UniqueNamesHolder>();
init_unique_names(f, unh);
ASSERT_NO_THROW(network.setBatchSize(2));
check_unique_names(f, unh);
ASSERT_TRUE(network.getFunction()->get_results()[0]->get_output_partial_shape(0).compatible({12, 4}));
ASSERT_TRUE(network.getFunction()->get_parameters()[0]->get_partial_shape().compatible({2, 2, 3, 4}));
@ -33,7 +39,11 @@ TEST(SmartReshapeTests, MimickingSBS_1) {
}
InferenceEngine::CNNNetwork network(f);
auto unh = std::make_shared<ngraph::pass::UniqueNamesHolder>();
init_unique_names(f, unh);
ASSERT_NO_THROW(network.setBatchSize(2));
check_unique_names(f, unh);
ASSERT_TRUE(network.getFunction()->get_results()[0]->get_output_partial_shape(0).compatible({2, 24}));
ASSERT_TRUE(network.getFunction()->get_parameters()[0]->get_partial_shape().compatible({2, 2, 3, 4}));
@ -48,7 +58,11 @@ TEST(SmartReshapeTests, MimickingSBS_2) {
}
InferenceEngine::CNNNetwork network(f);
auto unh = std::make_shared<ngraph::pass::UniqueNamesHolder>();
init_unique_names(f, unh);
ASSERT_NO_THROW(network.setBatchSize(1));
check_unique_names(f, unh);
ASSERT_TRUE(network.getFunction()->get_results()[0]->get_output_partial_shape(0).compatible({6, 4}));
ASSERT_TRUE(network.getFunction()->get_parameters()[0]->get_partial_shape().compatible({1, 2, 3, 4}));

View File

@ -9,6 +9,7 @@
#include <ngraph/opsets/opset5.hpp>
#include <cpp/ie_cnn_network.h>
#include "common_test_utils/ngraph_test_utils.hpp"
TEST(SmartReshapeTests, Proposal1Scales) {
std::shared_ptr<ngraph::Function> f(nullptr);
@ -37,7 +38,10 @@ TEST(SmartReshapeTests, Proposal1Scales) {
}
InferenceEngine::CNNNetwork network(f);
auto unh = std::make_shared<ngraph::pass::UniqueNamesHolder>();
init_unique_names(f, unh);
ASSERT_NO_THROW(network.setBatchSize(2));
check_unique_names(f, unh);
ASSERT_TRUE(network.getFunction()->get_results()[0]->get_output_partial_shape(0).compatible({600, 5}));
}
@ -68,6 +72,11 @@ TEST(SmartReshapeTests, Proposal4Scales) {
}
InferenceEngine::CNNNetwork network(f);
auto unh = std::make_shared<ngraph::pass::UniqueNamesHolder>();
init_unique_names(f, unh);
ASSERT_NO_THROW(network.setBatchSize(2));
check_unique_names(f, unh);
ASSERT_TRUE(network.getFunction()->get_results()[0]->get_output_partial_shape(0).compatible({600, 5}));
}

View File

@ -8,12 +8,13 @@
#include <ngraph/opsets/opset5.hpp>
#include <cpp/ie_cnn_network.h>
#include "common_test_utils/ngraph_test_utils.hpp"
TEST(SmartReshapeTests, Reshape1d) {
std::shared_ptr<ngraph::Function> f(nullptr);
{
auto input = std::make_shared<ngraph::opset5::Parameter>(ngraph::element::f32, ngraph::PartialShape::dynamic());
input->set_friendly_name("input");
auto reshape = std::make_shared<ngraph::opset5::Reshape>(input, ngraph::opset5::Constant::create(ngraph::element::i64, {1}, {5}), true);
f = std::make_shared<ngraph::Function>(ngraph::NodeVector{reshape}, ngraph::ParameterVector{input});
}
@ -23,7 +24,10 @@ TEST(SmartReshapeTests, Reshape1d) {
ASSERT_TRUE(network.getFunction()->get_results()[0]->get_output_partial_shape(0).compatible(ngraph::PartialShape::dynamic()));
ASSERT_TRUE(network.getFunction()->get_parameters()[0]->get_partial_shape().compatible({5}));
ASSERT_NO_THROW(network.reshape(InferenceEngine::ICNNNetwork::InputShapes{{"input", {1, 3, 300, 300}}}));
auto unh = std::make_shared<ngraph::pass::UniqueNamesHolder>();
init_unique_names(f, unh);
ASSERT_NO_THROW(network.reshape(InferenceEngine::ICNNNetwork::InputShapes{{f->get_parameters()[0]->get_friendly_name(), {1, 3, 300, 300}}}));
check_unique_names(f, unh);
ASSERT_TRUE(network.getFunction()->get_results()[0]->get_output_partial_shape(0).compatible({270000}));
ASSERT_TRUE(network.getFunction()->get_parameters()[0]->get_partial_shape().compatible({1, 3, 300, 300}));
@ -34,7 +38,6 @@ TEST(SmartReshapeTests, Reshape1d_negative) {
{
auto input = std::make_shared<ngraph::opset5::Parameter>(ngraph::element::f32, ngraph::PartialShape::dynamic());
auto pattern = std::make_shared<ngraph::opset5::Parameter>(ngraph::element::i64, ngraph::Shape{1});
input->set_friendly_name("input");
auto reshape = std::make_shared<ngraph::opset5::Reshape>(input, pattern, false);
f = std::make_shared<ngraph::Function>(ngraph::NodeVector{reshape}, ngraph::ParameterVector{input, pattern});
}
@ -44,7 +47,10 @@ TEST(SmartReshapeTests, Reshape1d_negative) {
ASSERT_TRUE(network.getFunction()->get_results()[0]->get_output_partial_shape(0).compatible(ngraph::PartialShape::dynamic()));
ASSERT_TRUE(network.getFunction()->get_parameters()[0]->get_partial_shape().is_dynamic());
ASSERT_NO_THROW(network.reshape(InferenceEngine::ICNNNetwork::InputShapes{{"input", {1, 3, 300, 300}}}));
auto unh = std::make_shared<ngraph::pass::UniqueNamesHolder>();
init_unique_names(f, unh);
ASSERT_NO_THROW(network.reshape(InferenceEngine::ICNNNetwork::InputShapes{{f->get_parameters()[0]->get_friendly_name(), {1, 3, 300, 300}}}));
check_unique_names(f, unh);
ASSERT_TRUE(network.getFunction()->get_results()[0]->get_output_partial_shape(0).compatible({270000}));
ASSERT_TRUE(network.getFunction()->get_parameters()[0]->get_partial_shape().compatible({1, 3, 300, 300}));

View File

@ -8,6 +8,7 @@
#include <ngraph/opsets/opset5.hpp>
#include <cpp/ie_cnn_network.h>
#include "common_test_utils/ngraph_test_utils.hpp"
TEST(SmartReshapeTests, SS_Squeeze) {
std::shared_ptr<ngraph::Function> f(nullptr);
@ -20,17 +21,20 @@ TEST(SmartReshapeTests, SS_Squeeze) {
ngraph::opset5::Constant::create(ngraph::element::i64, {2}, {1, 1}),
std::vector<int64_t>{1, 1}, std::vector<int64_t>{1, 1});
auto squeeze = std::make_shared<ngraph::opset5::Squeeze>(ss, ngraph::opset5::Constant::create(ngraph::element::i64, {1}, {0}));
auto relu = std::make_shared<ngraph::opset5::Relu>(squeeze);
f = std::make_shared<ngraph::Function>(ngraph::NodeVector{squeeze}, ngraph::ParameterVector{input});
f = std::make_shared<ngraph::Function>(ngraph::NodeVector{relu}, ngraph::ParameterVector{input});
}
InferenceEngine::CNNNetwork network(f);
ASSERT_TRUE(network.getFunction()->get_results()[0]->get_output_partial_shape(0).compatible({3})) <<
network.getFunction()->get_results()[0]->get_output_partial_shape(0);
ASSERT_TRUE(network.getFunction()->get_parameters()[0]->get_partial_shape().compatible({1, 3}));
auto unh = std::make_shared<ngraph::pass::UniqueNamesHolder>();
init_unique_names(f, unh);
ASSERT_NO_THROW(network.setBatchSize(2));
check_unique_names(f, unh);
ASSERT_TRUE(network.getFunction()->get_results()[0]->get_output_partial_shape(0).compatible({3})) <<
network.getFunction()->get_results()[0]->get_output_partial_shape(0);
@ -48,8 +52,9 @@ TEST(SmartReshapeTests, SS_Squeeze_partial_begin_end_mask) {
ngraph::opset5::Constant::create(ngraph::element::i64, {3}, {1, 1, 1}),
std::vector<int64_t>{0}, std::vector<int64_t>{1}); // begin_mask.size() is no larger than axis that is going to be squeezed.
auto squeeze = std::make_shared<ngraph::opset5::Squeeze>(ss, ngraph::opset5::Constant::create(ngraph::element::i64, {1}, {1}));
auto relu = std::make_shared<ngraph::opset5::Relu>(squeeze);
f = std::make_shared<ngraph::Function>(ngraph::NodeVector{squeeze}, ngraph::ParameterVector{input});
f = std::make_shared<ngraph::Function>(ngraph::NodeVector{relu}, ngraph::ParameterVector{input});
}
InferenceEngine::CNNNetwork network(f);
@ -58,8 +63,11 @@ TEST(SmartReshapeTests, SS_Squeeze_partial_begin_end_mask) {
network.getFunction()->get_results()[0]->get_output_partial_shape(0);
ASSERT_TRUE(network.getFunction()->get_parameters()[0]->get_partial_shape().compatible({1, 128, 768}));
auto unh = std::make_shared<ngraph::pass::UniqueNamesHolder>();
init_unique_names(f, unh);
auto inputname = network.getFunction()->get_parameters()[0]->get_friendly_name();
ASSERT_NO_THROW(network.reshape(InferenceEngine::ICNNNetwork::InputShapes{{inputname, {2, 128, 768}}}));
check_unique_names(f, unh);
ASSERT_TRUE(network.getFunction()->get_results()[0]->get_output_partial_shape(0).compatible({2, 768})) <<
network.getFunction()->get_results()[0]->get_output_partial_shape(0);
@ -78,8 +86,9 @@ TEST(SmartReshapeTests, SS_Squeeze_partial_begin_end) {
ngraph::opset5::Constant::create(ngraph::element::i64, {1}, {1}),
std::vector<int64_t>{1, 1, 1}, std::vector<int64_t>{1, 1, 1});
auto squeeze = std::make_shared<ngraph::opset5::Squeeze>(ss, ngraph::opset5::Constant::create(ngraph::element::i64, {1}, {1}));
auto relu = std::make_shared<ngraph::opset5::Relu>(squeeze);
f = std::make_shared<ngraph::Function>(ngraph::NodeVector{squeeze}, ngraph::ParameterVector{input});
f = std::make_shared<ngraph::Function>(ngraph::NodeVector{relu}, ngraph::ParameterVector{input});
}
InferenceEngine::CNNNetwork network(f);
@ -88,8 +97,11 @@ TEST(SmartReshapeTests, SS_Squeeze_partial_begin_end) {
network.getFunction()->get_results()[0]->get_output_partial_shape(0);
ASSERT_TRUE(network.getFunction()->get_parameters()[0]->get_partial_shape().compatible({1, 1, 768}));
auto unh = std::make_shared<ngraph::pass::UniqueNamesHolder>();
init_unique_names(f, unh);
auto inputname = network.getFunction()->get_parameters()[0]->get_friendly_name();
ASSERT_NO_THROW(network.reshape(InferenceEngine::ICNNNetwork::InputShapes{{inputname, {2, 1, 768}}}));
check_unique_names(f, unh);
ASSERT_TRUE(network.getFunction()->get_results()[0]->get_output_partial_shape(0).compatible({2, 768})) <<
network.getFunction()->get_results()[0]->get_output_partial_shape(0);
@ -118,7 +130,10 @@ TEST(SmartReshapeTests, SS_Squeeze_mask_use_negative) {
network.getFunction()->get_results()[0]->get_output_partial_shape(0);
ASSERT_TRUE(network.getFunction()->get_parameters()[0]->get_partial_shape().compatible({1, 3}));
auto unh = std::make_shared<ngraph::pass::UniqueNamesHolder>();
init_unique_names(f, unh);
ASSERT_ANY_THROW(network.setBatchSize(2));
check_unique_names(f, unh);
}
@ -133,8 +148,9 @@ TEST(SmartReshapeTests, SS_Squeeze_negative_stride_negative) {
ngraph::opset5::Constant::create(ngraph::element::i64, {2}, {-1, -1}),
std::vector<int64_t>{1, 1}, std::vector<int64_t>{1, 1});
auto squeeze = std::make_shared<ngraph::opset5::Squeeze>(ss, ngraph::opset5::Constant::create(ngraph::element::i64, {1}, {0}));
auto relu = std::make_shared<ngraph::opset5::Relu>(squeeze);
f = std::make_shared<ngraph::Function>(ngraph::NodeVector{squeeze}, ngraph::ParameterVector{input});
f = std::make_shared<ngraph::Function>(ngraph::NodeVector{relu}, ngraph::ParameterVector{input});
}
@ -144,7 +160,10 @@ TEST(SmartReshapeTests, SS_Squeeze_negative_stride_negative) {
network.getFunction()->get_results()[0]->get_output_partial_shape(0);
ASSERT_TRUE(network.getFunction()->get_parameters()[0]->get_partial_shape().compatible({1, 3}));
auto unh = std::make_shared<ngraph::pass::UniqueNamesHolder>();
init_unique_names(f, unh);
ASSERT_ANY_THROW(network.setBatchSize(2));
check_unique_names(f, unh);
}
TEST(SmartReshapeTests, SS_SharedSqueezes) {
@ -159,8 +178,9 @@ TEST(SmartReshapeTests, SS_SharedSqueezes) {
std::vector<int64_t>{1, 1}, std::vector<int64_t>{1, 1});
auto squeeze_1 = std::make_shared<ngraph::opset5::Squeeze>(ss, ngraph::opset5::Constant::create(ngraph::element::i64, {1}, {0}));
auto squeeze_2 = std::make_shared<ngraph::opset5::Squeeze>(ss, ngraph::opset5::Constant::create(ngraph::element::i64, {1}, {0}));
f = std::make_shared<ngraph::Function>(ngraph::NodeVector{squeeze_1, squeeze_2}, ngraph::ParameterVector{input});
auto relu_1 = std::make_shared<ngraph::opset5::Relu>(squeeze_1);
auto relu_2 = std::make_shared<ngraph::opset5::Relu>(squeeze_2);
f = std::make_shared<ngraph::Function>(ngraph::NodeVector{relu_1, relu_2}, ngraph::ParameterVector{input});
}
InferenceEngine::CNNNetwork network(f);
@ -169,7 +189,10 @@ TEST(SmartReshapeTests, SS_SharedSqueezes) {
network.getFunction()->get_results()[0]->get_output_partial_shape(0);
ASSERT_TRUE(network.getFunction()->get_parameters()[0]->get_partial_shape().compatible({1, 3}));
auto unh = std::make_shared<ngraph::pass::UniqueNamesHolder>();
init_unique_names(f, unh);
ASSERT_NO_THROW(network.setBatchSize(2));
check_unique_names(f, unh);
ASSERT_TRUE(network.getFunction()->get_results()[0]->get_output_partial_shape(0).compatible({3})) <<
network.getFunction()->get_results()[0]->get_output_partial_shape(0);
@ -188,8 +211,9 @@ TEST(SmartReshapeTests, SS_SqueezeNegativeAxes) {
ngraph::opset5::Constant::create(ngraph::element::i64, {6}, {1, 1, 1, 1, 1, 1}),
std::vector<int64_t>{1, 1, 1, 1, 1, 1}, std::vector<int64_t>{1, 1, 1, 1, 1, 1});
auto squeeze = std::make_shared<ngraph::opset5::Squeeze>(ss, ngraph::opset5::Constant::create(ngraph::element::i64, {3}, {-2, 0, -4}));
auto relu = std::make_shared<ngraph::opset5::Relu>(squeeze);
f = std::make_shared<ngraph::Function>(ngraph::NodeVector{squeeze}, ngraph::ParameterVector{input});
f = std::make_shared<ngraph::Function>(ngraph::NodeVector{relu}, ngraph::ParameterVector{input});
}
InferenceEngine::CNNNetwork network(f);
@ -198,7 +222,10 @@ TEST(SmartReshapeTests, SS_SqueezeNegativeAxes) {
network.getFunction()->get_results()[0]->get_output_partial_shape(0);
ASSERT_TRUE(network.getFunction()->get_parameters()[0]->get_partial_shape().compatible({1, 3, 1, 8, 1, 2}));
auto unh = std::make_shared<ngraph::pass::UniqueNamesHolder>();
init_unique_names(f, unh);
ASSERT_NO_THROW(network.setBatchSize(2));
check_unique_names(f, unh);
ASSERT_TRUE(network.getFunction()->get_results()[0]->get_output_partial_shape(0).compatible({3, 8, 2})) <<
network.getFunction()->get_results()[0]->get_output_partial_shape(0);
@ -226,7 +253,10 @@ TEST(SmartReshapeTests, Squeeze_SSNegativeAxes) {
network.getFunction()->get_results()[0]->get_output_partial_shape(0);
ASSERT_TRUE(network.getFunction()->get_parameters()[0]->get_partial_shape().compatible({1, 3, 1, 8, 1, 2}));
auto unh = std::make_shared<ngraph::pass::UniqueNamesHolder>();
init_unique_names(f, unh);
ASSERT_NO_THROW(network.setBatchSize(2));
check_unique_names(f, unh);
ASSERT_TRUE(network.getFunction()->get_results()[0]->get_output_partial_shape(0).compatible({3, 8, 2})) <<
network.getFunction()->get_results()[0]->get_output_partial_shape(0);

View File

@ -8,8 +8,11 @@
#include <ngraph/opsets/opset5.hpp>
#include <cpp/ie_cnn_network.h>
#include "common_test_utils/ngraph_test_utils.hpp"
using namespace ngraph;
TEST(SmartReshapeTests, TensorIteratorStaticParameters) {
std::shared_ptr<ngraph::Function> f(nullptr);
{
@ -17,9 +20,6 @@ TEST(SmartReshapeTests, TensorIteratorStaticParameters) {
auto X = std::make_shared<opset5::Parameter>(element::f32, Shape{1, 1, 1});
auto Y = std::make_shared<opset5::Parameter>(element::f32, Shape{1, 1, 1});
auto M = std::make_shared<opset5::Parameter>(element::f32, Shape{1, 1, 1});
X->set_friendly_name("X");
Y->set_friendly_name("Y");
M->set_friendly_name("M");
// Set up the cell body, a function from (Xi, Yi) -> (Zo)
// Body parameters
@ -60,7 +60,13 @@ TEST(SmartReshapeTests, TensorIteratorStaticParameters) {
ASSERT_TRUE(network.getFunction()->get_results()[2]->get_output_partial_shape(0).compatible({1, 1, 1}));
ASSERT_TRUE(network.getFunction()->get_results()[3]->get_output_partial_shape(0).compatible({1, 1, 1}));
ASSERT_NO_THROW(network.reshape(InferenceEngine::ICNNNetwork::InputShapes{{"X", {32, 1, 10}}, {"Y", {32, 10, 1}}, {"M", {32, 1, 10}}}));
auto unh = std::make_shared<ngraph::pass::UniqueNamesHolder>();
init_unique_names(f, unh);
ASSERT_NO_THROW(network.reshape(InferenceEngine::ICNNNetwork::InputShapes{
{f->get_parameters()[0]->get_friendly_name(), {32, 1, 10}},
{f->get_parameters()[1]->get_friendly_name(), {32, 10, 1}},
{f->get_parameters()[2]->get_friendly_name(), {32, 1, 10}}}));
check_unique_names(f, unh);
ASSERT_TRUE(network.getFunction()->get_results()[0]->get_output_partial_shape(0).compatible({}));
ASSERT_TRUE(network.getFunction()->get_results()[1]->get_output_partial_shape(0).compatible({32, 1, 10}));
@ -76,9 +82,6 @@ TEST(SmartReshapeTests, TensorIteratorDynamicParameters) {
auto X = std::make_shared<opset5::Parameter>(element::f32, Shape{1, 1, 1});
auto Y = std::make_shared<opset5::Parameter>(element::f32, Shape{1, 1, 1});
auto M = std::make_shared<opset5::Parameter>(element::f32, Shape{1, 1, 1});
X->set_friendly_name("X");
Y->set_friendly_name("Y");
M->set_friendly_name("M");
// Set up the cell body, a function from (Xi, Yi) -> (Zo)
// Body parameters
@ -119,7 +122,13 @@ TEST(SmartReshapeTests, TensorIteratorDynamicParameters) {
ASSERT_TRUE(network.getFunction()->get_results()[2]->get_output_partial_shape(0).compatible({1, 1, 1}));
ASSERT_TRUE(network.getFunction()->get_results()[3]->get_output_partial_shape(0).compatible({1, 1, 1}));
ASSERT_NO_THROW(network.reshape(InferenceEngine::ICNNNetwork::InputShapes{{"X", {32, 1, 10}}, {"Y", {32, 10, 1}}, {"M", {32, 1, 10}}}));
auto unh = std::make_shared<ngraph::pass::UniqueNamesHolder>();
init_unique_names(f, unh);
ASSERT_NO_THROW(network.reshape(InferenceEngine::ICNNNetwork::InputShapes{
{f->get_parameters()[0]->get_friendly_name(), {32, 1, 10}},
{f->get_parameters()[1]->get_friendly_name(), {32, 10, 1}},
{f->get_parameters()[2]->get_friendly_name(), {32, 1, 10}}}));
check_unique_names(f, unh);
ASSERT_TRUE(network.getFunction()->get_results()[0]->get_output_partial_shape(0).compatible({}));
ASSERT_TRUE(network.getFunction()->get_results()[1]->get_output_partial_shape(0).compatible({32, 1, 10}));
@ -135,9 +144,6 @@ TEST(SmartReshapeTests, LoopStaticParameters) {
auto X = std::make_shared<opset5::Parameter>(element::f32, PartialShape::dynamic());
auto Y = std::make_shared<opset5::Parameter>(element::f32, PartialShape::dynamic());
auto M = std::make_shared<opset5::Parameter>(element::f32, PartialShape::dynamic());
X->set_friendly_name("X");
Y->set_friendly_name("Y");
M->set_friendly_name("M");
// Set up the cell body, a function from (Xi, Yi) -> (Zo)
// Body parameters
@ -184,7 +190,13 @@ TEST(SmartReshapeTests, LoopStaticParameters) {
ASSERT_TRUE(network.getFunction()->get_results()[2]->get_output_partial_shape(0).compatible(PartialShape::dynamic()));
ASSERT_TRUE(network.getFunction()->get_results()[3]->get_output_partial_shape(0).compatible(PartialShape::dynamic()));
ASSERT_NO_THROW(network.reshape(InferenceEngine::ICNNNetwork::InputShapes{{"X", {32, 1, 10}}, {"Y", {32, 10, 1}}, {"M", {32, 1, 10}}}));
auto unh = std::make_shared<ngraph::pass::UniqueNamesHolder>();
init_unique_names(f, unh);
ASSERT_NO_THROW(network.reshape(InferenceEngine::ICNNNetwork::InputShapes{
{f->get_parameters()[0]->get_friendly_name(), {32, 1, 10}},
{f->get_parameters()[1]->get_friendly_name(), {32, 10, 1}},
{f->get_parameters()[2]->get_friendly_name(), {32, 1, 10}}}));
check_unique_names(f, unh);
ASSERT_TRUE(network.getFunction()->get_results()[0]->get_output_partial_shape(0).compatible({}));
ASSERT_TRUE(network.getFunction()->get_results()[1]->get_output_partial_shape(0).compatible({32, 1, 10}));
@ -200,9 +212,6 @@ TEST(SmartReshapeTests, LoopDynamicParameters) {
auto X = std::make_shared<opset5::Parameter>(element::f32, PartialShape::dynamic());
auto Y = std::make_shared<opset5::Parameter>(element::f32, PartialShape::dynamic());
auto M = std::make_shared<opset5::Parameter>(element::f32, PartialShape::dynamic());
X->set_friendly_name("X");
Y->set_friendly_name("Y");
M->set_friendly_name("M");
// Set up the cell body, a function from (Xi, Yi) -> (Zo)
// Body parameters
@ -249,7 +258,13 @@ TEST(SmartReshapeTests, LoopDynamicParameters) {
ASSERT_TRUE(network.getFunction()->get_results()[2]->get_output_partial_shape(0).compatible(PartialShape::dynamic()));
ASSERT_TRUE(network.getFunction()->get_results()[3]->get_output_partial_shape(0).compatible(PartialShape::dynamic()));
ASSERT_NO_THROW(network.reshape(InferenceEngine::ICNNNetwork::InputShapes{{"X", {32, 1, 10}}, {"Y", {32, 10, 1}}, {"M", {32, 1, 10}}}));
auto unh = std::make_shared<ngraph::pass::UniqueNamesHolder>();
init_unique_names(f, unh);
ASSERT_NO_THROW(network.reshape(InferenceEngine::ICNNNetwork::InputShapes{
{f->get_parameters()[0]->get_friendly_name(), {32, 1, 10}},
{f->get_parameters()[1]->get_friendly_name(), {32, 10, 1}},
{f->get_parameters()[2]->get_friendly_name(), {32, 1, 10}}}));
check_unique_names(f, unh);
ASSERT_TRUE(network.getFunction()->get_results()[0]->get_output_partial_shape(0).compatible({}));
ASSERT_TRUE(network.getFunction()->get_results()[1]->get_output_partial_shape(0).compatible({32, 1, 10}));
@ -267,9 +282,6 @@ TEST(SmartReshapeTests, LoopParentParametersUsedInBody) {
auto add_Y = std::make_shared<opset5::Add>(Y,
std::make_shared<ngraph::opset5::Constant>(ngraph::element::f32, ngraph::Shape{}, std::vector<float>{0.f}));
auto M = std::make_shared<opset5::Parameter>(element::f32, PartialShape::dynamic());
X->set_friendly_name("X");
Y->set_friendly_name("Y");
M->set_friendly_name("M");
// Set up the cell body, a function from (Xi, add_Y) -> (Zo)
// Body parameters
@ -317,7 +329,13 @@ TEST(SmartReshapeTests, LoopParentParametersUsedInBody) {
ASSERT_TRUE(network.getFunction()->get_results()[2]->get_output_partial_shape(0).compatible(PartialShape::dynamic()));
ASSERT_TRUE(network.getFunction()->get_results()[3]->get_output_partial_shape(0).compatible(PartialShape::dynamic()));
ASSERT_NO_THROW(network.reshape(InferenceEngine::ICNNNetwork::InputShapes{{"X", {4, 3, 2}}, {"Y", {4, 3, 2}}, {"M", {4, 3, 2}}}));
auto unh = std::make_shared<ngraph::pass::UniqueNamesHolder>();
init_unique_names(f, unh);
ASSERT_NO_THROW(network.reshape(InferenceEngine::ICNNNetwork::InputShapes{
{f->get_parameters()[0]->get_friendly_name(), {4, 3, 2}},
{f->get_parameters()[1]->get_friendly_name(), {4, 3, 2}},
{f->get_parameters()[2]->get_friendly_name(), {4, 3, 2}}}));
check_unique_names(f, unh);
ASSERT_TRUE(network.getFunction()->get_results()[0]->get_output_partial_shape(0).compatible({}));
ASSERT_TRUE(network.getFunction()->get_results()[1]->get_output_partial_shape(0).compatible({4, 3, 2}));
@ -335,9 +353,6 @@ TEST(SmartReshapeTests, TensorIteratorParentParameterUsedInBody) {
auto add_Y = std::make_shared<opset5::Add>(Y,
std::make_shared<ngraph::opset5::Constant>(ngraph::element::f32, ngraph::Shape{}, std::vector<float>{0.f}));
auto M = std::make_shared<opset5::Parameter>(element::f32, Shape{1, 1, 1});
X->set_friendly_name("X");
Y->set_friendly_name("Y");
M->set_friendly_name("M");
// Set up the cell body, a function from (Xi, add_Y) -> (Zo)
// Body parameters
@ -379,7 +394,13 @@ TEST(SmartReshapeTests, TensorIteratorParentParameterUsedInBody) {
ASSERT_TRUE(network.getFunction()->get_results()[2]->get_output_partial_shape(0).compatible({1, 1, 1}));
ASSERT_TRUE(network.getFunction()->get_results()[3]->get_output_partial_shape(0).compatible({1, 1, 1}));
ASSERT_NO_THROW(network.reshape(InferenceEngine::ICNNNetwork::InputShapes{{"X", {32, 1, 10}}, {"Y", {1, 1, 1}}, {"M", {32, 1, 10}}}));
auto unh = std::make_shared<ngraph::pass::UniqueNamesHolder>();
init_unique_names(f, unh);
ASSERT_NO_THROW(network.reshape(InferenceEngine::ICNNNetwork::InputShapes{
{f->get_parameters()[0]->get_friendly_name(), {32, 1, 10}},
{f->get_parameters()[1]->get_friendly_name(), {1, 1, 1}},
{f->get_parameters()[2]->get_friendly_name(), {32, 1, 10}}}));
check_unique_names(f, unh);
ASSERT_TRUE(network.getFunction()->get_results()[0]->get_output_partial_shape(0).compatible({}));
ASSERT_TRUE(network.getFunction()->get_results()[1]->get_output_partial_shape(0).compatible({32, 1, 10}));

View File

@ -244,3 +244,15 @@ void TransformationTestsF::accuracy_check(std::shared_ptr<ov::Model> ref_functio
GTEST_FATAL_FAILURE_("Unknown failure occurred.");
}
}
void init_unique_names(std::shared_ptr<ngraph::Function> f, const std::shared_ptr<ngraph::pass::UniqueNamesHolder>& unh) {
ngraph::pass::Manager manager;
manager.register_pass<ngraph::pass::InitUniqueNames>(unh);
manager.run_passes(f);
}
void check_unique_names(std::shared_ptr<ngraph::Function> f, const std::shared_ptr<ngraph::pass::UniqueNamesHolder>& unh) {
ngraph::pass::Manager manager;
manager.register_pass<ngraph::pass::CheckUniqueNames>(unh, true);
manager.run_passes(f);
}

View File

@ -90,3 +90,7 @@ private:
bool m_soft_names_comparison{true};
bool m_enable_accuracy_check{false};
};
void init_unique_names(std::shared_ptr<ngraph::Function> f, const std::shared_ptr<ngraph::pass::UniqueNamesHolder>& unh);
void check_unique_names(std::shared_ptr<ngraph::Function> f, const std::shared_ptr<ngraph::pass::UniqueNamesHolder>& unh);