From f6d4a5bc93bd0f7add70f59fce323f7068708c71 Mon Sep 17 00:00:00 2001 From: Mateusz Bencer Date: Fri, 30 Jul 2021 10:55:45 +0200 Subject: [PATCH] Fixed problem with model_inputs method in ONNX Editor (#6860) --- ngraph/frontend/onnx/onnx_import/src/editor.cpp | 2 +- ngraph/test/onnx/onnx_editor.cpp | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ngraph/frontend/onnx/onnx_import/src/editor.cpp b/ngraph/frontend/onnx/onnx_import/src/editor.cpp index 172f0748a42cfa..81737b8a9ed6cd 100644 --- a/ngraph/frontend/onnx/onnx_import/src/editor.cpp +++ b/ngraph/frontend/onnx/onnx_import/src/editor.cpp @@ -385,9 +385,9 @@ std::vector onnx_editor::ONNXModelEditor::model_inputs() const { const auto& graph = m_pimpl->m_model_proto->graph(); std::vector inputs; - inputs.reserve(graph.input_size() - graph.initializer_size()); for (const auto& in : graph.input()) { + // ignore inputs which are initializers if (std::find_if(graph.initializer().begin(), graph.initializer().end(), [&in](const TensorProto& initializer) { diff --git a/ngraph/test/onnx/onnx_editor.cpp b/ngraph/test/onnx/onnx_editor.cpp index c08db423744a72..707a121bea1a3e 100644 --- a/ngraph/test/onnx/onnx_editor.cpp +++ b/ngraph/test/onnx/onnx_editor.cpp @@ -1508,6 +1508,15 @@ NGRAPH_TEST(onnx_editor, model_inputs) EXPECT_TRUE(inputs == (std::vector{"in1", "in2", "in3"})); // in4 is initializer } +NGRAPH_TEST(onnx_editor, model_inputs_with_non_input_initializers) +{ + ONNXModelEditor editor{file_util::path_join( + SERIALIZED_ZOO, "onnx/instance_norm_dynamic.prototxt")}; + + const auto inputs = editor.model_inputs(); + EXPECT_TRUE(inputs == (std::vector{"input"})); +} + NGRAPH_TEST(onnx_editor, model_output) { ONNXModelEditor editor{file_util::path_join(