diff --git a/hpvm/scripts/hpvm_installer.py b/hpvm/scripts/hpvm_installer.py index ae06ca12f6914f748da061d5ed64a1106c5123aa..c6e465438a84b8b33147dcbc616dcdcdafee6a9f 100755 --- a/hpvm/scripts/hpvm_installer.py +++ b/hpvm/scripts/hpvm_installer.py @@ -18,6 +18,14 @@ MODEL_PARAMS_TAR = Path("model_params.tar.gz") MODEL_PARAMS_DIR = ROOT_DIR / "test/dnn_benchmarks/model_params" MODEL_PARAMS_LINK = "https://databank.illinois.edu/datafiles/o3izd/download" +NVDLA_URL = "https://github.com/nvdla/sw.git" +NVDLA_DIR = ROOT_DIR / "sw" +NVDLA_UMD_DIR = NVDLA_DIR / "umd" +PROTOBUF_DIR = NVDLA_UMD_DIR / "external/protobuf-2.6" +PROTOBUF_STATIC_LIB = PROTOBUF_DIR / "src/.libs/libprotobuf.a" +COMPILER_APPS_DIR = NVDLA_UMD_DIR / "apps/compiler" +COMPILER_CORE_DIR = NVDLA_UMD_DIR / "core/src/compiler" + LINKS = [ "CMakeLists.txt", "cmake", @@ -262,6 +270,14 @@ def check_download_model_params(): if MODEL_PARAMS_TAR.is_file(): MODEL_PARAMS_TAR.unlink() +def check_download_nvdla_sw(): + if NVDLA_DIR.is_dir(): + print("Found NVDLA compiler, not downloading it again.") + return + print(f"Downloading the NVDLA compiler...") + print(f"=============================") + check_call(["git", "clone", NVDLA_URL]) + def link_and_patch(): from os import symlink @@ -282,6 +298,17 @@ def link_and_patch(): chdir(cwd) +def build_nvdla_compiler(): + print("Building NVDLA compiler...") + chdir(PROTOBUF_DIR) + check_call(["./autogen.sh"]) + check_call(["./configure"]) + check_call(["make"]) + check_call(["cp", PROTOBUF_STATIC_LIB, COMPILER_CORE_DIR]) + check_call(["cp", PROTOBUF_STATIC_LIB, COMPILER_APPS_DIR]) + chdir(NVDLA_UMD_DIR) + check_call(["make", "TOP=" + str(NVDLA_UMD_DIR)]) + def build( build_dir: Path, nthreads: int, @@ -295,6 +322,7 @@ def build( cwd = Path.cwd() chdir(build_dir) + build_nvdla_compiler() cmake_args = [ "cmake", str(ROOT_DIR / "llvm"), @@ -359,6 +387,7 @@ def main(): if not args.no_pypkg: check_python_version() print_args(args) + check_download_nvdla_sw() check_download_llvm_clang() link_and_patch() if not args.no_params: