ONNX Runtime 源码阅读:子图(sub-graph)应该如何理解?
在 ONNX Runtime 源码(onnxruntime/core/framework/graph_partitioner.cc
,函数GraphPartitioner::Partition
)中,有这么一段注释:
NOTE: A 'sub-graph' is a subset of nodes within the current Graph instance.
The control flow nodes have nested Graph instance/s which are also called subgraphs,
but are completely separate Graph instances and not a subset of nodes within a single Graph instance.
也就是说,ONNX Runtime 中提到的子图有两类:
- 一类是 Graph 实例中节点(nodes)的子集节点,也就是对整图进行切分时所划分的子集;
- 另一类是控制流节点(e.g., if & loop)中提到的子图,但是这些子图是完全独立的 Graph 实例,而非某个 Graph 实例的子集节点