masahi commented on a change in pull request #8702:
URL: https://github.com/apache/tvm/pull/8702#discussion_r704891354



##########
File path: tests/python/relay/test_pipeline_executor.py
##########
@@ -0,0 +1,273 @@
+# 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.
+
+import pytest
+import numpy as np
+import tvm
+import tvm.testing
+from tvm import relay
+from tvm.relay import transform
+from tvm.contrib import graph_executor, pipeline_executor
+
+
+def get_mannual_mod():
+    """
+    # Get list of module that represent a subgraph.
+    """
+    mods = []
+    dshape = (3, 3)
+    data = relay.var("data_0", relay.TensorType(dshape, "float32"))
+    data21 = relay.var("data_1", relay.TensorType(dshape, "float32"))
+    data_net1_output_1 = relay.var("data_0", relay.TensorType(dshape, 
"float32"))
+    data_net1_output_2 = relay.var("data_1", relay.TensorType(dshape, 
"float32"))
+    data_net2_output_1 = relay.var("data_0", relay.TensorType(dshape, 
"float32"))
+    mvalue1 = np.full((1), 1).astype("float32")
+    mvalue2 = np.full((1), 2).astype("float32")
+    mvalue3 = np.full((1), 3).astype("float32")
+    mv1 = relay.Constant(tvm.nd.array(mvalue1))
+    mv2 = relay.Constant(tvm.nd.array(mvalue2))
+    mv3 = relay.Constant(tvm.nd.array(mvalue3))
+
+    """
+    # Net1 have three output, output3 is final output.
+    """
+
+    net_output1 = relay.add(data, mv1)
+    net_output2 = relay.subtract(data, mv2)
+    net_output3 = relay.multiply(data, mv3)
+
+    """
+    # Net2 use net1 output1 as input.
+    """
+    net2 = relay.add(data_net1_output_1, mv2)
+    net2 = relay.add(net2, data21)
+    net2 = relay.add(net2, mv3)
+
+    """
+    # Net3 use net2 output1 and net1 outpu2 as input.
+    """
+    net3 = relay.multiply(data_net2_output_1, mv3)
+    net3 = relay.add(net3, data_net1_output_2)
+
+    mods.append(
+        tvm.IRModule.from_expr(
+            relay.Function([data], relay.Tuple([net_output1, net_output2, 
net_output3]))
+        )
+    )
+    mods.append(tvm.IRModule.from_expr(relay.Function([data_net1_output_1, 
data21], net2)))
+    mods.append(
+        tvm.IRModule.from_expr(relay.Function([data_net1_output_2, 
data_net2_output_1], net3))
+    )
+
+    return mods, dshape
+
+
+def get_manual_conf(mods, target):
+    """
+    # This function use to generate manual pipe line configueration,
+    # the result use to verify if the pipe configuration can generate
+    # correct result.
+    """
+    mod_config = {}
+    """
+    # Set configure
+    """
+
+    """
+    # Third output is final output, second output for mod3, first for mod2
+    # input
+    """
+    pipe_config1 = {
+        "mod_idx": 1,
+        "output": [
+            {"output_idx": 0, "dependent": [{"mod_idx": 2, "input_name": 
"data_0"}]},
+            {"output_idx": 1, "dependent": [{"mod_idx": 3, "input_name": 
"data_0"}]},
+            {"output_idx": 2, "dependent": [{"mod_idx": 0, "input_name": 
"0"}]},
+        ],
+    }
+    mod_config[mods[0]] = {
+        "pipeline": pipe_config1,
+        "target_host": None,
+        "mod_name": "default",
+        "build": None,
+        "params": None,
+        "target": target[0],
+        "dev": target[1],
+    }
+
+    pipe_config2 = {
+        "mod_idx": 2,
+        "output": [
+            {"output_idx": 0, "dependent": [{"mod_idx": 3, "input_name": 
"data_1"}]},
+        ],
+    }
+    mod_config[mods[1]] = {
+        "pipeline": pipe_config2,
+        "target_host": None,
+        "mod_name": "default",
+        "build": None,
+        "params": None,
+        "target": "llvm",
+        "dev": tvm.cpu(0),
+    }
+
+    pipe_config3 = {
+        "mod_idx": 3,
+        "output": [{"output_idx": 0, "dependent": [{"mod_idx": 0, 
"input_name": "1"}]}],
+    }
+    mod_config[mods[2]] = {
+        "pipeline": pipe_config3,
+        "target_host": None,
+        "mod_name": "default",
+        "build": None,
+        "params": None,
+        "target": "llvm",
+        "dev": tvm.cpu(0),
+    }
+    return mod_config
+
+
+def test_pipe_config_check():
+    """
+    #Get 3 pipeline module.
+    """
+    (mod1, mod2, mod3), dshape = get_mannual_mod()
+    """
+    # Try invalid input/output name exepect runtime error

Review comment:
       typo




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