Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not throw an exception if we have 2 result op for one tensor #6844

Merged
merged 1 commit into from
Jul 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -88,23 +88,23 @@ void CNNNetworkNGraphImpl::createDataForResult(const ::ngraph::Output<::ngraph::

void CNNNetworkNGraphImpl::validateFunctionNames() const {
// nGraph function parameters and pre-Results operations should have unique names
std::unordered_set<std::string> unique_names;
std::unordered_map<std::string, std::shared_ptr<ngraph::Node>> unique_names;
for (const auto& param : _ngraph_function->get_parameters()) {
if (unique_names.count(param->get_friendly_name())) {
IE_THROW() << "Function contains several inputs with one friendly name!";
}
unique_names.insert(param->get_friendly_name());
unique_names.insert({param->get_friendly_name(), param});
}
for (const auto& result : _ngraph_function->get_results()) {
const auto& parent = result->get_input_node_shared_ptr(0);
auto name = parent->get_friendly_name();
if (parent->get_output_size() > 1) {
name += "." + std::to_string(result->get_input_source_output(0).get_index());
}
if (unique_names.count(name) && !ngraph::op::is_parameter(parent)) {
if (unique_names.count(name) && !ngraph::op::is_parameter(parent) && parent != unique_names.at(name)) {
IE_THROW() << "Function contains several inputs and outputs with one friendly name!";
}
unique_names.insert(name);
unique_names.insert({name, parent});
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,26 @@ TEST(CNNNGraphImplTests, TestReshapeWithSameShape) {
ASSERT_NO_THROW(net.reshape({{"input", SizeVector({1, 4000})}}));
}

TEST(CNNNGraphImplTests, TestTwoResultsFromOneTensor) {
std::shared_ptr<ngraph::Function> ngraph;
{
ngraph::PartialShape shape({1, 3, 22, 22});
ngraph::element::Type type(ngraph::element::Type_t::f32);
auto param = std::make_shared<ngraph::op::Parameter>(type, shape);
auto relu = std::make_shared<ngraph::op::Relu>(param);
auto result1 = std::make_shared<ngraph::op::Result>(relu);
auto result2 = std::make_shared<ngraph::op::Result>(relu);

ngraph::ParameterVector params = {param};
ngraph::ResultVector results = {result1, result2};

ngraph = std::make_shared<ngraph::Function>(results, params);
}

InferenceEngine::CNNNetwork cnnNet(ngraph);
ASSERT_NO_THROW(auto convertedNet = std::make_shared<details::CNNNetworkImpl>(cnnNet));
}

TEST(CNNNGraphImplTests, TestInvalidReshape) {
std::shared_ptr<ngraph::Function> f;
{
Expand Down