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/09/16 22:24:10 UTC

[tvm] branch main updated: [Hexagon] Add debug option to hexagon pytest (#12795)

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 bb80f19ea8 [Hexagon] Add debug option to hexagon pytest (#12795)
bb80f19ea8 is described below

commit bb80f19ea8493af71c6130301f1b479143d213ee
Author: Mehrdad Hessar <mh...@octoml.ai>
AuthorDate: Fri Sep 16 15:24:03 2022 -0700

    [Hexagon] Add debug option to hexagon pytest (#12795)
    
    * add debug option to hexagon pytest
    
    * address comment
---
 python/tvm/contrib/hexagon/build.py         |  9 +++++----
 python/tvm/contrib/hexagon/pytest_plugin.py | 21 +++++++++++++++++----
 2 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/python/tvm/contrib/hexagon/build.py b/python/tvm/contrib/hexagon/build.py
index fe7434f738..8960d110b8 100644
--- a/python/tvm/contrib/hexagon/build.py
+++ b/python/tvm/contrib/hexagon/build.py
@@ -145,7 +145,7 @@ class HexagonLauncherRPC(metaclass=abc.ABCMeta):
         ...
 
     @abc.abstractmethod
-    def stop_server(self):
+    def stop_server(self, cleanup=True):
         """Stop the RPC server"""
         ...
 
@@ -509,11 +509,12 @@ class HexagonLauncherAndroid(HexagonLauncherRPC):
         self._copy_binaries()
         self._run_server_script()
 
-    def stop_server(self):
+    def stop_server(self, cleanup=True):
         """Abstract method implementation. See description in HexagonLauncherRPC."""
         self._cleanup_port_forwarding()
         self._terminate_remote()
-        self.cleanup_directory()
+        if cleanup:
+            self.cleanup_directory()
 
 
 class HexagonLauncherSimulator(HexagonLauncherRPC):
@@ -617,7 +618,7 @@ class HexagonLauncherSimulator(HexagonLauncherRPC):
     def cleanup_directory(self):
         """Abstract method implementation. See description in HexagonLauncherRPC."""
 
-    def stop_server(self):
+    def stop_server(self, cleanup=True):
         """Abstract method implementation. See description in HexagonLauncherRPC."""
         self._server_process.terminate()
 
diff --git a/python/tvm/contrib/hexagon/pytest_plugin.py b/python/tvm/contrib/hexagon/pytest_plugin.py
index 0b9f65540c..03f4a1a143 100644
--- a/python/tvm/contrib/hexagon/pytest_plugin.py
+++ b/python/tvm/contrib/hexagon/pytest_plugin.py
@@ -158,7 +158,7 @@ def adb_server_socket() -> str:
 
 @pytest.fixture(scope="session")
 def hexagon_server_process(
-    request, rpc_server_port_for_session, adb_server_socket, skip_rpc
+    request, rpc_server_port_for_session, adb_server_socket, skip_rpc, hexagon_debug
 ) -> HexagonLauncherRPC:
     """Initials and returns hexagon launcher if ANDROID_SERIAL_NUMBER is defined.
     This launcher is started only once per test session.
@@ -194,7 +194,7 @@ def hexagon_server_process(
             yield {"launcher": launcher, "device_adr": device_adr}
         finally:
             if not skip_rpc:
-                launcher.stop_server()
+                launcher.stop_server(cleanup=(not hexagon_debug))
 
 
 def read_device_list():
@@ -221,6 +221,7 @@ def hexagon_launcher(
     tvm_tracker_host,
     tvm_tracker_port,
     adb_server_socket,
+    hexagon_debug,
 ) -> HexagonLauncherRPC:
     """Initials and returns hexagon launcher which reuses RPC info and Android serial number."""
     android_serial_num = android_serial_number()
@@ -246,8 +247,9 @@ def hexagon_launcher(
         yield launcher
     finally:
         if android_serial_num == ["simulator"]:
-            launcher.stop_server()
-        launcher.cleanup_directory()
+            launcher.stop_server(cleanup=(not hexagon_debug))
+        elif not hexagon_debug:
+            launcher.cleanup_directory()
 
 
 @pytest.fixture
@@ -297,6 +299,11 @@ def skip_rpc(request) -> bool:
     return request.config.getoption("--skip-rpc")
 
 
+@pytest.fixture(scope="session")
+def hexagon_debug(request) -> bool:
+    return request.config.getoption("--hexagon-debug")
+
+
 def pytest_addoption(parser):
     parser.addoption("--gtest_args", action="store", default="")
 
@@ -306,6 +313,12 @@ def pytest_addoption(parser):
         default=False,
         help="If set true, the RPC server initialization on Android would be skipped",
     )
+    parser.addoption(
+        "--hexagon-debug",
+        action="store_true",
+        default=False,
+        help="If set true, it will keep the hexagon test directories on the target.",
+    )
 
 
 def pytest_generate_tests(metafunc):