lixiaoquan commented on pull request #5656:
URL: https://github.com/apache/incubator-tvm/pull/5656#issuecomment-633940335
Original MergeComposite can apply on any IR, but PatternLang seems can't do
that yet.
I run into a issue that if try to match a pattern on IR containing control
flow, it will hang or crash.
```
diff --git a/tests/python/frontend/tensorflow/test_control_flow.py
b/tests/python/frontend/tensorflow/test_control_flow.py
index 9777a8dc4..e80cda65c 100644
--- a/tests/python/frontend/tensorflow/test_control_flow.py
+++ b/tests/python/frontend/tensorflow/test_control_flow.py
@@ -25,10 +25,22 @@ import numpy as np
from tvm import nd
from tvm import relay
from tvm.relay.frontend.tensorflow import from_tensorflow
+from tvm.relay.dataflow_pattern import *
+add_pattern = is_op('add')(wildcard(), wildcard())
+sub_pattern = is_op('subtract')(wildcard(), wildcard())
+class TestRewrite(DFPatternCallback):
+ def __init__(self):
+ self.pattern = add_pattern
+ def callback(self, pre, post, node_map):
+ return post.args[0] - post.args[1]
+
def check_equal(graph, tf_out, input_map=None):
mod, params = from_tensorflow(graph.as_graph_def(add_shapes=True))
+
+ partition(TestRewrite().pattern, mod['main'].body)
+
if input_map is not None:
params.update(input_map)
ex = relay.create_executor('vm', mod=mod)
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]