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(