From 7254a73cb3623a807626da458f0d233ce9708500 Mon Sep 17 00:00:00 2001
From: Yifan Zhao <yifanz16@illinois.edu>
Date: Wed, 7 Jul 2021 23:05:12 -0500
Subject: [PATCH] hpvm-clang moves generated buffer to target directory

---
 hpvm/tools/hpvm-clang/main.py.in | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/hpvm/tools/hpvm-clang/main.py.in b/hpvm/tools/hpvm-clang/main.py.in
index 9d327ff74d..810cc575e6 100644
--- a/hpvm/tools/hpvm-clang/main.py.in
+++ b/hpvm/tools/hpvm-clang/main.py.in
@@ -98,12 +98,16 @@ def compile_hpvm_c(
         _run_opt(hpvm_ll_file, llvm_ll_file, passes, pass_flags),
         link_hpvm_rt(link_bitcode_ + [llvm_ll_file], hpvm_rt_linked_file),
     ]
-
-    if tensor_target != "nvdla":
+    if tensor_target == "nvdla":
+        # This doesn't generate a bitcode at all.
+        # Instead it generates hpvm-mod.nvdla and output.protobuf in *current* directory.
+        # We move them to the working directory.
+        commands.append(["mv", "hpvm-mod.nvdla", working_dir.as_posix()])
+        commands.append(["mv", "output.protobuf", working_dir.as_posix()])
+    else:
         commands.append(
             link_binary(hpvm_rt_linked_file, output_file, link_dirs, link_libs)
         )
-        
     for command in commands:
         if verbose:
             print(" ".join(command))
-- 
GitLab