Hello~ I have a graph , and I am using two DFPatternCallbacks to match different nodes and do some rewrite with them(codes are like i post below), however, the two DFPatternCallbacks scan the whole graph not at the same time, which means second DFPatternCallback deals with a graph that has been rewritten by first DFPatternCallback .
class Call1(DFPatternCallback):
def __init__(self):
#define the pattern1
def callback(self,pre,post,node_map):
#rewrite the pattern1
class Call2(DFPatternCallback):
def __init__(self):
#define the pattern2
def callback(self,pre,post,node_map):
#rewrite the pattern2
def myrewrite():
def wrapped_func(mod,_):
mod["main"]=rewrite([Call1(),Call2()],mod["main"])
return mod
return wrapped_func
What I want to do is scan the whole graph, get a node and match it with two patterns, if it matches one,do some rewriting. I am wondering how can i do this?