zxybazh commented on code in PR #13356:
URL: https://github.com/apache/tvm/pull/13356#discussion_r1019663641


##########
python/tvm/meta_schedule/testing/torchbench/run.py:
##########
@@ -431,6 +431,26 @@ def forward(*args):
     return forward
 
 
+def should_skip_subgraph(graph_module: torch.fx.GraphModule) -> bool:
+    """
+    Returns whether it should skip optimizing the input graph module.
+    The graph could be empyt or only containing nodes calling function
+    for side effect.
+    """
+    graph = graph_module.graph
+
+    if len(graph.nodes) == 0:
+        return True
+
+    inputs = [n for n in graph.nodes if n.op == "placeholder"]
+    outputs = [n for n in graph.nodes if n.op == "output"]
+
+    if len(inputs) == 0 and all(output.args == ((),) for output in outputs):

Review Comment:
   ```suggestion
       return len(inputs) == 0 and all(output.args == ((),) for output in 
outputs)
   ```



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to