mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-05-29 23:06:41 +00:00
fix errors for node with empty name for vitis ai (#16949)
### Description Fixed the issue of finding nodes with empty name for vitis ai. ### Motivation and Context <!-- - Why is this change required? What problem does it solve? - If it fixes an open issue, please link to the issue here. --> It is required because we encountered this error when testing newly created models.
This commit is contained in:
parent
246cb3a197
commit
b8bbc898c6
1 changed files with 4 additions and 10 deletions
|
|
@ -27,19 +27,13 @@ std::vector<const Node*> node_arg_names_to_nodes(const GraphViewer& graph,
|
|||
|
||||
static std::vector<NodeIndex> node_names_to_nodes(const GraphViewer& graph,
|
||||
const std::vector<std::string>& node_names) {
|
||||
auto find_node = [&](const std::string& node_name) -> NodeIndex {
|
||||
for (auto& n : graph.Nodes()) {
|
||||
if (n.Name() == node_name) {
|
||||
return n.Index();
|
||||
}
|
||||
}
|
||||
vai_assert(false, std::string("cannot find node: " + node_name));
|
||||
return onnxruntime::NodeIndex(-1);
|
||||
};
|
||||
auto ret = std::vector<NodeIndex>();
|
||||
ret.reserve(node_names.size());
|
||||
for (auto& onnx_node_name : node_names) {
|
||||
ret.push_back(find_node(onnx_node_name));
|
||||
// onnnx_node_name is actually node arg name.
|
||||
auto node = graph.GetProducerNode(onnx_node_name);
|
||||
vai_assert(node != nullptr, std::string("cannot find producer. onnx_node_arg_name=" + onnx_node_name));
|
||||
ret.push_back(node->Index());
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue