Traversing Relay Graph order (source to sink, sink to source)

Dear All,

I am new to TVM. and I am wondering what facilities does TVM/Relay support to traverse the network graph?

Assuming I have a DAG, can I traverse from the sink to the source? and vise versa?

Thanks. D.

Hi All,

I was able to traverse the graph using post_order_visit (expr, fvisit)

However, this function starts from the source of DAG. I want to traverse the DAG from the reverse order. Is there a way to do it for the relay expressions?

Both orders can be implemented using post_order_visit.

Postorder. In this case the first node that processes “do something” would be the source node in a DAG.

def visit(self, node):
   super().visit(node)
   // do something

Preorder. In this case the first node that processes “do something” would be the last node in a DAG.

def visit(self, node):
   // do something
   super().visit(node)