From eb67eadbc64d7cebd6f7602351882697ee8d4b2f Mon Sep 17 00:00:00 2001 From: Ke Zhang Date: Wed, 2 Jan 2019 13:10:33 -0800 Subject: [PATCH] add initializer for sub-graph. (#269) --- onnxruntime/core/graph/function.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/onnxruntime/core/graph/function.cc b/onnxruntime/core/graph/function.cc index 6212da6a2e..d9fc45fbac 100644 --- a/onnxruntime/core/graph/function.cc +++ b/onnxruntime/core/graph/function.cc @@ -117,6 +117,14 @@ FunctionImpl::FunctionImpl(const onnxruntime::Graph& graph, } sub_graph.AddNode(node->Name(), node->OpType(), node->Description(), inputs, outputs, &node->GetAttributes(), node->Domain()); } + + for (auto input : meta_def->inputs) { + const onnx::TensorProto* initializer = nullptr; + if (graph.GetInitializedTensor(input, initializer)) { + sub_graph.AddInitializedTensor(*initializer); + } + } + //TODO: if we reuse the nodes in parent graph, maybe we don't need to resolve it. ORT_ENFORCE(sub_graph.Resolve().IsOK()); }