huajsj commented on code in PR #11405:
URL: https://github.com/apache/tvm/pull/11405#discussion_r880075731


##########
python/tvm/relay/testing/graph_split.py:
##########
@@ -0,0 +1,205 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""
+Graph split Helper function.
+========================
+Helper definition for graph split.
+"""
+import tvm
+from tvm import relay
+from tvm.relay import transform, build_module
+from tvm.relay.testing import run_opt_pass
+
+
+def graph_split(function, split_config, parameters=None):
+    """Splitting the graph into a list of subgraphs
+
+    Parameters:
+    -----------
+    function: tvm.relay.function.Function
+        The function in which the splitting happen.
+
+    split_config: Array[Dict[str, str/integer]]
+        The operator name and the number of the repeated operator name in the 
function.
+        For example a network like following
+        %1 = nn.add(%data,  meta[relay.Constant][0])
+        %2 = nn.multiply(%1,  meta[relay.Constant][1])
+        %3 = nn.add(%2,  meta[relay.Constant][2])
+        %4 = nn.multiply(%3,  meta[relay.Constant][3])
+        if a splliting solution want to split function as the second 'nn.add', 
like following
+
+        #subgraph 1
+        %1 = nn.add(%data,  meta[relay.Constant][0])
+        %2 = nn.multiply(%1,  meta[relay.Constant][1])
+        %3 = nn.add(%2,  meta[relay.Constant][2])
+
+        #subgraph 2
+        %1 = nn.multiply(%data,  meta[relay.Constant][0])
+
+        the split_config should like following
+        split_config = [{"operator_name":"add", "operator_index": 1}]

Review Comment:
   the "[{"operator_name":"add", "operator_index": 1}]" means the second "add" 
operator, so the operator_index is 1 instead of 3.
   the reason that use the "number of repeated" is because the "index" of 
operator may change after some transform operation. to avoid such issue we use 
"number of repeated" to replace the "index".



-- 
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: commits-unsubscr...@tvm.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to