You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by ar...@apache.org on 2022/04/19 15:53:18 UTC

[tvm] branch main updated: [Hexagon] Refactor test scripts (#11026)

This is an automated email from the ASF dual-hosted git repository.

areusch pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm.git


The following commit(s) were added to refs/heads/main by this push:
     new a945586868 [Hexagon] Refactor test scripts (#11026)
a945586868 is described below

commit a94558686834c4ff7e4d90e4bc1fde5451ce445d
Author: Mehrdad Hessar <mh...@octoml.ai>
AuthorDate: Tue Apr 19 08:53:13 2022 -0700

    [Hexagon] Refactor test scripts (#11026)
    
    * Refactor hexagon test scripts
    
    * rever removing the script
---
 Jenkinsfile                                        |  6 +----
 jenkins/Jenkinsfile.j2                             |  4 ----
 .../test_hexagon/test_2d_physical_buffers.py       |  3 ---
 .../contrib/test_hexagon/test_cache_read_write.py  |  3 ---
 tests/python/contrib/test_hexagon/test_launcher.py | 21 ----------------
 tests/scripts/task_python_hexagon.sh               | 28 ++++++++++++++++++++--
 6 files changed, 27 insertions(+), 38 deletions(-)

diff --git a/Jenkinsfile b/Jenkinsfile
index e7d7c7da86..da5a124eb3 100755
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -45,7 +45,7 @@
 // 'python3 jenkins/generate.py'
 // Note: This timestamp is here to ensure that updates to the Jenkinsfile are
 // always rebased on main before merging:
-// Generated at 2022-04-15T11:19:32.757632
+// Generated at 2022-04-15T21:28:54.806304
 
 import org.jenkinsci.plugins.pipeline.modeldefinition.Utils
 // NOTE: these lines are scanned by docker/dev_common.sh. Please update the regex as needed. -->
@@ -851,10 +851,6 @@ stage('Test') {
                 script: "${docker_run} ${ci_hexagon} ./tests/scripts/task_python_hexagon.sh",
                 label: 'Run Hexagon tests',
               )
-              sh (
-                script: "${docker_run} ${ci_hexagon} ./tests/scripts/task_python_hexagon_simulator.sh",
-                label: 'Run Hexagon tests on simulator',
-              )
             } finally {
               junit 'build/pytest-results/*.xml'
             }
diff --git a/jenkins/Jenkinsfile.j2 b/jenkins/Jenkinsfile.j2
index f58a2e1cdf..fa6beb2299 100644
--- a/jenkins/Jenkinsfile.j2
+++ b/jenkins/Jenkinsfile.j2
@@ -674,10 +674,6 @@ stage('Test') {
       script: "${docker_run} ${ci_hexagon} ./tests/scripts/task_python_hexagon.sh",
       label: 'Run Hexagon tests',
     )
-    sh (
-      script: "${docker_run} ${ci_hexagon} ./tests/scripts/task_python_hexagon_simulator.sh",
-      label: 'Run Hexagon tests on simulator',
-    )
   {% endcall %}
   {% call m.test_step(name="test: QEMU", node="CPU", ws="tvm/test-qemu") %}
     unpack_lib('qemu', microtvm_lib)
diff --git a/tests/python/contrib/test_hexagon/test_2d_physical_buffers.py b/tests/python/contrib/test_hexagon/test_2d_physical_buffers.py
index d9dcabf70e..9de55996b0 100755
--- a/tests/python/contrib/test_hexagon/test_2d_physical_buffers.py
+++ b/tests/python/contrib/test_hexagon/test_2d_physical_buffers.py
@@ -302,9 +302,6 @@ class TestElementWise:
         output_layout,
         hexagon_session,
     ):
-        if hexagon_session is None:
-            pytest.skip(msg="Skip hardware test, ANDROID_SERIAL_NUMBER is not set.")
-
         if input_layout == "nchw-8h8w32c-2d":
             input_axis_separators = [4]
         else:
diff --git a/tests/python/contrib/test_hexagon/test_cache_read_write.py b/tests/python/contrib/test_hexagon/test_cache_read_write.py
index e5595485a2..8f94531871 100644
--- a/tests/python/contrib/test_hexagon/test_cache_read_write.py
+++ b/tests/python/contrib/test_hexagon/test_cache_read_write.py
@@ -81,9 +81,6 @@ def verify(hexagon_session, s, x, y, z, size):
         s, [x, y, z], tvm.target.Target(target_hexagon, host=target_hexagon), name="dmacpy"
     )
 
-    if hexagon_session is None:
-        pytest.skip("Skip hardware test since ANDROID_SERIAL_NUMBER is not set.")
-
     mod = hexagon_session.load_module(func)
     xt = tvm.nd.array(
         np.random.randint(low=-128, high=127, size=size, dtype=x.dtype),
diff --git a/tests/python/contrib/test_hexagon/test_launcher.py b/tests/python/contrib/test_hexagon/test_launcher.py
index dbc581ae3d..c2152cf623 100644
--- a/tests/python/contrib/test_hexagon/test_launcher.py
+++ b/tests/python/contrib/test_hexagon/test_launcher.py
@@ -46,9 +46,6 @@ def test_add(hexagon_session):
         sched, [A, B, C], tvm.target.Target(target_hexagon, host=target_hexagon), name="add"
     )
 
-    if hexagon_session is None:
-        pytest.skip(msg="Skip hardware test, ANDROID_SERIAL_NUMBER is not set.")
-
     mod = hexagon_session.load_module(func)
 
     A_data = tvm.nd.array(np.array([2, 3], dtype=dtype), device=hexagon_session.device)
@@ -74,9 +71,6 @@ def test_add_vtcm(hexagon_session):
         sched, [A, B, C], tvm.target.Target(target_hexagon, host=target_hexagon), name="add"
     )
 
-    if hexagon_session is None:
-        pytest.skip(msg="Skip hardware test, ANDROID_SERIAL_NUMBER is not set.")
-
     mod = hexagon_session.load_module(func)
     A_data = tvm.nd.empty(A.shape, A.dtype, hexagon_session.device, "global.vtcm")
     A_data.copyfrom(np.array([2, 3]))
@@ -110,9 +104,6 @@ class TestMatMul:
             schedule, [X, Y, Z], tvm.target.Target(target_hexagon, host=target_hexagon)
         )
 
-        if hexagon_session is None:
-            pytest.skip(msg="Skip hardware test, ANDROID_SERIAL_NUMBER is not set.")
-
         mod = hexagon_session.load_module(func)
 
         x = np.random.uniform(size=[i.value for i in X.shape]).astype(X.dtype)
@@ -170,9 +161,6 @@ def test_graph_executor(hexagon_session):
             executor=executor,
         )
 
-    if hexagon_session is None:
-        pytest.skip(msg="Skip hardware test since ANDROID_SERIAL_NUMBER is not set.")
-
     graph_mod = hexagon_session.get_executor_from_factory(lowered)
     graph_mod.set_input(**params)
     graph_mod.run(**inputs)
@@ -237,9 +225,6 @@ def test_graph_executor_multiple_conv2d(hexagon_session):
             executor=executor,
         )
 
-    if hexagon_session is None:
-        pytest.skip(msg="Skip hardware test since ANDROID_SERIAL_NUMBER is not set.")
-
     weight1_data = np.random.rand(w1_shape[0], w1_shape[1], w1_shape[2], w1_shape[3]).astype(
         dtype=dtype
     )
@@ -324,9 +309,6 @@ def test_aot_executor(hexagon_session):
             executor=Executor("aot", {"unpacked-api": False, "interface-api": "packed"}),
         )
 
-    if hexagon_session is None:
-        pytest.skip(msg="Skip hardware test, ANDROID_SERIAL_NUMBER is not set.")
-
     aot_mod = hexagon_session.get_executor_from_factory(lowered)
     aot_mod.set_input(**inputs)
     aot_mod.run()
@@ -404,9 +386,6 @@ def test_aot_executor_multiple_conv2d(hexagon_session):
             executor=Executor("aot", {"unpacked-api": False, "interface-api": "packed"}),
         )
 
-    if hexagon_session is None:
-        pytest.skip(msg="Skip hardware test, ANDROID_SERIAL_NUMBER is not set.")
-
     aot_mod = hexagon_session.get_executor_from_factory(lowered)
     aot_mod.set_input(**inputs)
     aot_mod.run()
diff --git a/tests/scripts/task_python_hexagon.sh b/tests/scripts/task_python_hexagon.sh
index 82c1fbe585..274b348f09 100755
--- a/tests/scripts/task_python_hexagon.sh
+++ b/tests/scripts/task_python_hexagon.sh
@@ -18,10 +18,34 @@
 
 set -e
 set -u
-set -x
 
-source tests/scripts/setup-pytest-env.sh
+device_serial="simulator"
+if [ $# -ge 1 ] && [[ "$1" = "--device" ]]; then
+    shift 1
+    device_serial="$1"
+    shift
+fi
 
+source tests/scripts/setup-pytest-env.sh
 make cython3
 
+if [[ "${device_serial}" == "simulator" ]]; then
+    export TVM_TRACKER_PORT=9190
+    export TVM_TRACKER_HOST=0.0.0.0
+    env PYTHONPATH=python python3 -m tvm.exec.rpc_tracker --host "${TVM_TRACKER_HOST}" --port "${TVM_TRACKER_PORT}" &
+    TRACKER_PID=$!
+    sleep 5   # Wait for tracker to bind
+
+    # Temporary workaround for symbol visibility
+    export HEXAGON_SHARED_LINK_FLAGS="-Lbuild/hexagon_api_output -lhexagon_rpc_sim"
+
+    # HEXAGON_TOOLCHAIN is already set
+    export HEXAGON_SDK_ROOT=${HEXAGON_SDK_PATH}
+fi
+
+export ANDROID_SERIAL_NUMBER=${device_serial}
 run_pytest ctypes python-contrib-hexagon tests/python/contrib/test_hexagon
+
+if [[ "${device_serial}" == "simulator" ]]; then
+    kill ${TRACKER_PID}
+fi