From 29e948053c7cba4922c5389be6f6a0676c33366a Mon Sep 17 00:00:00 2001 From: Siva Date: Sun, 26 Jan 2025 12:54:04 +0530 Subject: [PATCH] [ADRENO][WINDOWS] Windows build dependencies for Adreno target This brings in basic support for Adreno target on Windows platforms and the tools we generally use for Adreno --- .gitmodules | 3 +++ 3rdparty/zlib | 1 + LICENSE | 1 + apps/cpp_rtvm/CMakeLists.txt | 17 +++++++++++++---- apps/cpp_rtvm/main.cc | 4 ---- apps/cpp_rtvm/tvm_runner.cc | 3 ++- licenses/LICENSE.zlib.txt | 22 ++++++++++++++++++++++ python/tvm/driver/tvmc/config_options.py | 6 ++++++ 8 files changed, 48 insertions(+), 9 deletions(-) create mode 160000 3rdparty/zlib create mode 100644 licenses/LICENSE.zlib.txt diff --git a/.gitmodules b/.gitmodules index cb22b3d3d38e..a1187967f77f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -28,3 +28,6 @@ [submodule "3rdparty/flashinfer"] path = 3rdparty/flashinfer url = https://github.com/flashinfer-ai/flashinfer.git +[submodule "3rdparty/zlib"] + path = 3rdparty/zlib + url = https://github.com/madler/zlib.git diff --git a/3rdparty/zlib b/3rdparty/zlib new file mode 160000 index 000000000000..ef24c4c75021 --- /dev/null +++ b/3rdparty/zlib @@ -0,0 +1 @@ +Subproject commit ef24c4c7502169f016dcd2a26923dbaf3216748c diff --git a/LICENSE b/LICENSE index 82c7871cc65b..f6126d011a9a 100644 --- a/LICENSE +++ b/LICENSE @@ -242,6 +242,7 @@ The Unlicense ------------- 3rdparty/rang +3rdparty/zlib BSD 3-Clause "New" or "Revised" License --------------------------------------- diff --git a/apps/cpp_rtvm/CMakeLists.txt b/apps/cpp_rtvm/CMakeLists.txt index 0f20920af400..b8f2d50e47aa 100644 --- a/apps/cpp_rtvm/CMakeLists.txt +++ b/apps/cpp_rtvm/CMakeLists.txt @@ -13,8 +13,11 @@ set(TVM_RUNNER_SOURCES set(RTVM_LINKER_LIBS "") if(WIN32) - list(APPEND RTVM_SOURCES ../cpp_rpc/win32_process.cc) - list(APPEND TVM_RUNNER_SOURCES ../cpp_rpc/win32_process.cc) + file(GLOB ZLIB_SRC + "../../3rdparty/zlib/*.c" + ) + list(APPEND RTVM_SOURCES ${ZLIB_SRC}) + list(APPEND TVM_RUNNER_SOURCES ${ZLIB_SRC}) endif() # Set output to same directory as the other TVM libs @@ -55,6 +58,7 @@ target_include_directories( rtvm PUBLIC "../../include" PUBLIC "../../3rdparty/cnpy" + PUBLIC "../../3rdparty/zlib" PUBLIC DLPACK_PATH PUBLIC DMLC_PATH ) @@ -72,9 +76,13 @@ if (BUILD_FOR_ANDROID AND USE_HEXAGON) endif() if(BUILD_STATIC_RUNTIME) - list(APPEND RTVM_LINKER_LIBS -Wl,--whole-archive tvm_runtime -Wl,--no-whole-archive z) + list(APPEND RTVM_LINKER_LIBS -Wl,--whole-archive tvm_runtime -Wl,--no-whole-archive) else() - list(APPEND RTVM_LINKER_LIBS tvm_runtime z) + list(APPEND RTVM_LINKER_LIBS tvm_runtime) +endif() + +if(NOT WIN32) + list(APPEND RTVM_LINKER_LIBS z) endif() target_link_libraries(rtvm ${RTVM_LINKER_LIBS}) @@ -84,6 +92,7 @@ target_include_directories( tvm_runner_objs PUBLIC "../../include" PUBLIC "../../3rdparty/cnpy" + PUBLIC "../../3rdparty/zlib" PUBLIC DLPACK_PATH PUBLIC DMLC_PATH ) diff --git a/apps/cpp_rtvm/main.cc b/apps/cpp_rtvm/main.cc index 2efd7f4a9413..ee3d4d2583c8 100644 --- a/apps/cpp_rtvm/main.cc +++ b/apps/cpp_rtvm/main.cc @@ -39,10 +39,6 @@ #include "../../src/support/utils.h" #include "tvm_runner.h" -#if defined(_WIN32) -#include "../cpp_rpc/win32_process.h" -#endif - using namespace std; using namespace tvm::runtime; using namespace tvm::support; diff --git a/apps/cpp_rtvm/tvm_runner.cc b/apps/cpp_rtvm/tvm_runner.cc index 7d6dbc23ee76..945b541cfa03 100644 --- a/apps/cpp_rtvm/tvm_runner.cc +++ b/apps/cpp_rtvm/tvm_runner.cc @@ -154,7 +154,8 @@ void TVMRunner::UsePreCompiledPrograms(std::string file_name) { if (f_get != nullptr && f_set != nullptr) { std::ifstream ifs(file_name, std::ios::in | std::ios::binary); if (ifs.fail()) { - auto bytes = String(f_get()); + std::string ss = f_get(); + auto bytes = tvm::String(ss); std::ofstream fs(file_name, std::ofstream::binary); fs.write(bytes.c_str(), bytes.size()); } else { diff --git a/licenses/LICENSE.zlib.txt b/licenses/LICENSE.zlib.txt new file mode 100644 index 000000000000..b517acd5764a --- /dev/null +++ b/licenses/LICENSE.zlib.txt @@ -0,0 +1,22 @@ +Copyright notice: + + (C) 1995-2024 Jean-loup Gailly and Mark Adler + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jean-loup Gailly Mark Adler + jloup@gzip.org madler@alumni.caltech.edu diff --git a/python/tvm/driver/tvmc/config_options.py b/python/tvm/driver/tvmc/config_options.py index c384c89b1a2b..6ba89d650ec4 100644 --- a/python/tvm/driver/tvmc/config_options.py +++ b/python/tvm/driver/tvmc/config_options.py @@ -59,6 +59,12 @@ def get_configs_json_dir() -> str: candidate_paths.extend( [os.path.abspath(os.path.join(lib_path, "..")) for lib_path in libinfo.find_lib_path()] ) + candidate_paths.extend( + [ + os.path.abspath(os.path.join(lib_path, "../..")) + for lib_path in libinfo.find_lib_path() + ] + ) for path in candidate_paths: configs_path = os.path.join(os.path.dirname(path), "configs") if os.path.isdir(configs_path):