megengine.utils.comp_graph_tools.graph_traversal¶
- graph_traversal(outputs)[源代码]¶
一个用于遍历计算图并返回足够有用的信息的辅助函数。
- 参数
outputs (
VarNode
) – 模型输出。- 返回
tuple (map_oprs, map_vars, var2oprs, opr2receivers, indegree2opr, opr2indegree)
WHERE
map_oprs is dict from opr_id to actual opr
map_vars is dict from var_id to actual var
var2oprs is dict from var to dest oprs along with index
opr2receivers is dict from current opr to next opr
indegree2opr is dict from in_degree to opr in computing graph
opr2indegree is dict from opr in computing graph to in_degree
(indegree2opr, opr2indegree) 只会在函数 get_oprs_seq 中被用于拓扑排序。