From 410a36604efdf045f68051eae3a55284e58ac173 Mon Sep 17 00:00:00 2001
From: Yifan Zhao <yifanz16@illinois.edu>
Date: Sat, 13 Mar 2021 20:05:47 -0600
Subject: [PATCH] Use readInputBatch not copyInputBatch

---
 .../torch2hpvm/torch2hpvm/template_hpvm_inspect.cpp.in     | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/hpvm/projects/torch2hpvm/torch2hpvm/template_hpvm_inspect.cpp.in b/hpvm/projects/torch2hpvm/torch2hpvm/template_hpvm_inspect.cpp.in
index 015b0aea3c..4fb25a5574 100644
--- a/hpvm/projects/torch2hpvm/torch2hpvm/template_hpvm_inspect.cpp.in
+++ b/hpvm/projects/torch2hpvm/torch2hpvm/template_hpvm_inspect.cpp.in
@@ -118,10 +118,11 @@ int main(){
 {% endfor %}
 
   RootIn* args = static_cast<RootIn*>(malloc(sizeof(RootIn)));
-  void* {{input_name}} = create4DTensor(0, nchw, batch_size, {{input_shape|join(', ')}});
 {% for n in root_inputs %}
+{% if n != input_name %}
   args->{{n}} = {{n}};
   args->{{n}}_bytes = 0;
+{% endif %}
 {% endfor %}
 
   int ret = 0;
@@ -135,7 +136,9 @@ int main(){
     auto* fp = open_fifo("{{fifo_path_w}}", "wb");
     for (int i = 0; i < batch_count; i++){
       int start = i * batch_size, end = start + batch_size;
-      copyInputBatch(input_pth, start, end, {{input_shape|join(', ')}}, {{input_name}});
+      void *{{input_name}} = readInputBatch(input_pth, 0, start, end, {{input_shape|join(', ')}});
+      args->input = {{input_name}};
+      args->input_bytes = 0;
 
       void* dfg = __hpvm__launch(0, root, (void*) args);
       __hpvm__wait(dfg);
-- 
GitLab