This is an automated email from the ASF dual-hosted git repository.
tqchen 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 8de396c6fb [Hexagon] Add support for v75 (#17123)
8de396c6fb is described below
commit 8de396c6fba06a2aa681a2aeb5dba12c133701fc
Author: Anirudh Sundar Subramaniam <[email protected]>
AuthorDate: Mon Jul 1 18:26:02 2024 +0530
[Hexagon] Add support for v75 (#17123)
Add support for executing v75 (Snapdragon 8 gen 3). This PR just adds
the support, but to build and execute for v75, the Hexagon SDK used
should be 5.4+.
---
apps/hexagon_launcher/README.md | 16 ++++++++--------
cmake/config.cmake | 2 +-
cmake/modules/HexagonSDK.cmake | 6 +++++-
python/tvm/contrib/hexagon/session.py | 15 ++++++++++-----
python/tvm/target/target.py | 3 ++-
src/runtime/hexagon/README.md | 4 ++--
src/runtime/hexagon/rpc/simulator/session.cc | 7 +++++++
tests/python/contrib/test_hexagon/README.md | 2 +-
8 files changed, 36 insertions(+), 19 deletions(-)
diff --git a/apps/hexagon_launcher/README.md b/apps/hexagon_launcher/README.md
index 69d9fdc98a..be0015b17a 100644
--- a/apps/hexagon_launcher/README.md
+++ b/apps/hexagon_launcher/README.md
@@ -43,10 +43,10 @@ Create a subdirectory for the build files, and run `cmake`
with the
following variables set:
```
-cmake -DCMAKE_C_COMPILER=/path/to/hexagon-clang \
- -DCMAKE_CXX_COMPILER=/path/to/hexagon-clang++ \
- -DUSE_HEXAGON_ARCH=v65|v66|v68|v69|v73 \
- -DUSE_HEXAGON_SDK=/path/to/hexagon/SDK \
+cmake -DCMAKE_C_COMPILER=/path/to/hexagon-clang \
+ -DCMAKE_CXX_COMPILER=/path/to/hexagon-clang++ \
+ -DUSE_HEXAGON_ARCH=v65|v66|v68|v69|v73|v75 \
+ -DUSE_HEXAGON_SDK=/path/to/hexagon/SDK \
/path/to/apps/hexagon_launcher/cmake/hexagon
```
@@ -60,10 +60,10 @@ the TVM runtime for Hexagon will be built as a part of the
process.
```
cmake
-DCMAKE_TOOLCHAIN_FILE=/path/to/android-ndk/build/cmake/android.toolchain.cmake
\
- -DANDROID_ABI=arm64-v8a \
- -DANDROID_PLATFORM=android-28 \
- -DUSE_HEXAGON_SDK=/p/Hexagon_SDK/4.3.0.0 \
- -DUSE_HEXAGON_ARCH=v65|v66|v68|v69|v73 \
+ -DANDROID_ABI=arm64-v8a \
+ -DANDROID_PLATFORM=android-28 \
+ -DUSE_HEXAGON_SDK=/p/Hexagon_SDK/4.3.0.0 \
+ -DUSE_HEXAGON_ARCH=v65|v66|v68|v69|v73|v75 \
/path/to/apps/hexagon_launcher/cmake/android
```
diff --git a/cmake/config.cmake b/cmake/config.cmake
index 5847acc298..416eec0dcb 100644
--- a/cmake/config.cmake
+++ b/cmake/config.cmake
@@ -367,7 +367,7 @@ set(USE_HEXAGON_RPC OFF)
# compiling _by_ TVM). This applies to components like the TVM runtime, but is
# also used to select correct include/library paths from the Hexagon SDK when
# building runtime for Android.
-# Valid values are v65, v66, v68, v69, v73.
+# Valid values are v65, v66, v68, v69, v73, v75.
set(USE_HEXAGON_ARCH "v68")
# Whether use MRVL codegen
diff --git a/cmake/modules/HexagonSDK.cmake b/cmake/modules/HexagonSDK.cmake
index 9196396646..5ca889afbf 100644
--- a/cmake/modules/HexagonSDK.cmake
+++ b/cmake/modules/HexagonSDK.cmake
@@ -109,11 +109,12 @@ function(_get_hexagon_sdk_property_impl
set(_hexarch_dir_v68 "computev68")
set(_hexarch_dir_v69 "computev69")
set(_hexarch_dir_v73 "computev73")
+ set(_hexarch_dir_v75 "computev75")
set(_hexarch_dir_str "_hexarch_dir_${_hexagon_arch}")
set(_hexarch_dir "${${_hexarch_dir_str}}")
if(NOT _hexarch_dir)
- message(SEND_ERROR "Please set Hexagon architecture to one of v65, v66,
v68, v69, v73")
+ message(SEND_ERROR "Please set Hexagon architecture to one of v65, v66,
v68, v69, v73, v75")
endif()
if(_property STREQUAL "VERSION")
@@ -160,6 +161,9 @@ function(_get_hexagon_sdk_property_impl
elseif(_property STREQUAL "QURT_INCLUDE")
# Set the Hexagon arch directory for runtime linker.
set(_rtld_dir "hexagon_toolv84_${_hexagon_arch}")
+ if(_hexagon_arch STREQUAL "v75")
+ set(_rtld_dir "hexagon_toolv87_v75") # Use hexagon_toolv87_v75 for v75
+ endif()
if(_hexagon_arch STREQUAL "v69")
set(_rtld_dir "hexagon_toolv84_v68") # Use hexagon_toolv84_v68 for v69
endif()
diff --git a/python/tvm/contrib/hexagon/session.py
b/python/tvm/contrib/hexagon/session.py
index fc0c96fbe5..9f11668234 100644
--- a/python/tvm/contrib/hexagon/session.py
+++ b/python/tvm/contrib/hexagon/session.py
@@ -286,7 +286,9 @@ class Session:
graph_json, graph_debug_mod, self.device, dump_root=str(dump_root)
)
- def get_executor_from_factory(self, module: Union[ExecutorFactoryModule,
relax.Executable]):
+ def get_executor_from_factory(
+ self, module: Union[ExecutorFactoryModule, relax.Executable],
hexagon_arch: str = "v68"
+ ):
"""Create a local GraphModule which consumes a remote libmod.
Parameters
@@ -296,13 +298,15 @@ class Session:
The module to upload to the remote
session and load.
+ hexagon_arch : str
+ The hexagon arch to be used
"""
if isinstance(module, AOTExecutorFactoryModule):
return self._aot_executor_from_factory(module)
if isinstance(module, GraphExecutorFactoryModule):
return self._graph_executor_from_factory(module)
if isinstance(module, relax.Executable):
- return self._relax_vm_executable_executor(module)
+ return self._relax_vm_executable_executor(module,
hexagon_arch=hexagon_arch)
raise TypeError(f"Unsupported executor type: {type(module)}")
@@ -354,7 +358,7 @@ class Session:
"""
return self.get_graph_executor(module.get_graph_json(),
module.get_lib())
- def _relax_vm_executable_executor(self, vm_exec: relax.Executable):
+ def _relax_vm_executable_executor(self, vm_exec: relax.Executable,
hexagon_arch: str):
"""Create a local TVM module which consumes a remote vm executable.
Paramters
@@ -363,7 +367,8 @@ class Session:
vm_exec : relax.Executable
The Relax VM Executable to upload to the remote and load. This
will typically be the
output of `relax.build`.
-
+ hexagon_arch : str
+ The hexagon arch to be used
Returns
-------
TVMModule :
@@ -377,7 +382,7 @@ class Session:
vm_exec.mod.export_library(
path_exec,
fcompile=hexagon.create_aot_shared,
- hexagon_arch="v68",
+ hexagon_arch=hexagon_arch,
)
path = self.upload(path_exec, "exec.so")
diff --git a/python/tvm/target/target.py b/python/tvm/target/target.py
index ec74cbcdb6..c4199c72c2 100644
--- a/python/tvm/target/target.py
+++ b/python/tvm/target/target.py
@@ -715,7 +715,7 @@ def hexagon(cpu_ver="v68", **kwargs):
return int(m.group(1))
# Check for valid codegen cpu
- valid_hex = ["v65", "v66", "v67", "v67t", "v68", "v69", "v71", "v73"]
+ valid_hex = ["v65", "v66", "v67", "v67t", "v68", "v69", "v71", "v73",
"v75"]
try:
cpu_ver = cpu_ver[cpu_ver.index("v") :].lower()
assert cpu_ver in valid_hex
@@ -731,6 +731,7 @@ def hexagon(cpu_ver="v68", **kwargs):
"v68": 4 * one_mb,
"v69": 8 * one_mb,
"v73": 8 * one_mb,
+ "v75": 8 * one_mb,
}
return default_vtcm_sizes.get(cpu_ver, 0)
diff --git a/src/runtime/hexagon/README.md b/src/runtime/hexagon/README.md
index 6e68a40034..7c7528d814 100644
--- a/src/runtime/hexagon/README.md
+++ b/src/runtime/hexagon/README.md
@@ -54,7 +54,7 @@ ANDROID_ABI=aarch64-v8a
ANDROID_PLATFORM=android-28
CMAKE_TOOLCHAIN_FILE=/path/to/android-ndk/build/cmake/android.toolchain.cmake
USE_HEXAGON=ON
-USE_HEXAGON_ARCH=v65|v66|v68|v69|v73
+USE_HEXAGON_ARCH=v65|v66|v68|v69|v73|v75
USE_HEXAGON_SDK=/path/to/sdk
```
@@ -63,7 +63,7 @@ Building for Hexagon requires setting the C/C++ compiler to
`hexagon-clang/++`:
CMAKE_C_COMPILER=hexagon-clang
CMAKE_CXX_COMPILER=hexagon-clang++
USE_HEXAGON=ON
-USE_HEXAGON_ARCH=v65|v66|v68|v69|v73
+USE_HEXAGON_ARCH=v65|v66|v68|v69|v73|v75
USE_HEXAGON_SDK=/path/to/sdk
USE_RPC=OFF
USE_LIBBACKTRACE=OFF
diff --git a/src/runtime/hexagon/rpc/simulator/session.cc
b/src/runtime/hexagon/rpc/simulator/session.cc
index 6a805b0ef1..bec400ce60 100644
--- a/src/runtime/hexagon/rpc/simulator/session.cc
+++ b/src/runtime/hexagon/rpc/simulator/session.cc
@@ -457,6 +457,10 @@ std::string SimulatorRPCChannel::Cpu_::str() const {
#ifdef HEX_CPU_ID_V73NA_1
case HEX_CPU_V73:
return "v73";
+#endif
+#ifdef HEX_CPU_ID_V75NA_1
+ case HEX_CPU_V75:
+ return "v75";
#endif
default:
break;
@@ -574,6 +578,9 @@ std::optional<HEXAPI_Cpu> SimulatorRPCChannel::GetCPU(const
detail::MaybeString&
#endif
#ifdef HEX_CPU_ID_V73NA_1
.Case("v73", HEX_CPU_V73)
+#endif
+#ifdef HEX_CPU_ID_V75NA_1
+ .Case("v75", HEX_CPU_V75)
#endif
.Default(std::nullopt);
}
diff --git a/tests/python/contrib/test_hexagon/README.md
b/tests/python/contrib/test_hexagon/README.md
index d3698b6da0..bf37debcb3 100644
--- a/tests/python/contrib/test_hexagon/README.md
+++ b/tests/python/contrib/test_hexagon/README.md
@@ -49,7 +49,7 @@ cd build
cmake -DANDROID_ABI=arm64-v8a \
-DANDROID_PLATFORM=android-28 \
-DUSE_ANDROID_TOOLCHAIN="path to
`android-ndk/build/cmake/android.toolchain.cmake` file" \
- -DUSE_HEXAGON_ARCH=v65|v66|v68|v69|v73 \
+ -DUSE_HEXAGON_ARCH=v65|v66|v68|v69|v73|v75 \
-DUSE_HEXAGON_SDK="path to Hexagon SDK" \
-DUSE_HEXAGON_TOOLCHAIN="path to Hexagon toolchain `Tools`
sub-directory which explained above" \
-DUSE_OUTPUT_BINARY_DIR="path to `build/hexagon_api_output` which is a
sub-directory of `tvm`" ..