mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-05-19 21:32:23 +00:00
Fix graph viewer to proto (#11862)
* Add test for case where main const initialier in subgraph * update test to use trt ep * add initializer when converting from graph viewer to proto * add comments * add comments * add comments * only add initialier that is outer scope value * make including outer scope value optional * modify python format * modify python format * modify python format * Remove test * remove redundant argument
This commit is contained in:
parent
52f2b3bf89
commit
eb41bfb7b5
1 changed files with 22 additions and 1 deletions
|
|
@ -43,12 +43,33 @@ void GraphViewerToProto(const GraphViewer& graph_view,
|
|||
}
|
||||
|
||||
if (include_initializer) {
|
||||
std::unordered_set<std::string> current_scope_initializer_set;
|
||||
|
||||
auto& initializers = graph_view.GetAllInitializedTensors();
|
||||
for (auto& it : initializers) {
|
||||
auto* p_initializer = graph_proto.add_initializer();
|
||||
*p_initializer = *(it.second);
|
||||
current_scope_initializer_set.insert(it.first);
|
||||
}
|
||||
|
||||
|
||||
// handle outer scope value which is a constant initializer
|
||||
if (include_outer_scope_args) {
|
||||
for (auto& node_idx : graph_view.GetNodesInTopologicalOrder()) {
|
||||
const auto& node = graph_view.GetNode(node_idx);
|
||||
for (const auto& input : node->InputDefs()) {
|
||||
if (current_scope_initializer_set.find(input->Name()) != current_scope_initializer_set.end()) {
|
||||
continue;
|
||||
}
|
||||
if (graph_view.IsConstantInitializer(input->Name(), true)) {
|
||||
auto* p_initializer = graph_proto.add_initializer();
|
||||
*p_initializer = *(graph_view.GetConstantInitializer(input->Name(), true));
|
||||
current_scope_initializer_set.insert(input->Name());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue