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-vta.git


The following commit(s) were added to refs/heads/main by this push:
     new f187a39  Make VTA C++ Deploy Compatible with latest TVM. (#22)
f187a39 is described below

commit f187a39f273961b1c2acc52088cc0a2305e5b247
Author: Hua Jiang <[email protected]>
AuthorDate: Thu Mar 11 06:41:04 2021 -0800

    Make VTA C++ Deploy Compatible with latest TVM. (#22)
    
    Issue:
    c++ deployment get broken after recently TVM change,
    first issue is lastest TVM use some c++14 feature in
    header file that caused current compile fail.
    
    second issue is lastest TVM did more strict format/type
    check that make the restnet export logic failed.
    
    Solution:
    Fix the said issue to make logic work.
---
 apps/deploy/Makefile         |  2 +-
 apps/deploy/resnet_export.py | 24 ++++++++++++++++++++----
 2 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/apps/deploy/Makefile b/apps/deploy/Makefile
index 777cb89..1d14d88 100644
--- a/apps/deploy/Makefile
+++ b/apps/deploy/Makefile
@@ -28,7 +28,7 @@ ifeq (${TARGET}, sim)
        VTA_LIB=vta_fsim
 endif
 
-PKG_CFLAGS = -std=c++11 -O0 -g -fPIC\
+PKG_CFLAGS = -std=c++14 -O0 -g -fPIC\
                                                 -I${TVM_ROOT}/include\
                                                 -I${TVM_ROOT}/vta/include\
                                                 -I${DMLC_CORE}/include\
diff --git a/apps/deploy/resnet_export.py b/apps/deploy/resnet_export.py
index ad248bc..7a7bd61 100644
--- a/apps/deploy/resnet_export.py
+++ b/apps/deploy/resnet_export.py
@@ -61,7 +61,7 @@ def merge_transform_to_mxnet_model(mod):
     entry = mod["main"]
     anf = run_opt_pass(entry.body, transform.ToANormalForm())
     call = anf.value
-    data, weights = call.args
+    call_data, weights = call.args
     first_op = op.nn.conv2d(
         simple_net,
         weights,
@@ -73,9 +73,25 @@ def merge_transform_to_mxnet_model(mod):
         kernel_size=call.attrs.kernel_size,
         out_dtype=call.attrs.out_dtype)
     net = relay.expr.Let(anf.var, first_op, anf.body)
-    net = run_opt_pass(net, transform.ToGraphNormalForm())
-
-    mod['main'] = net
+    new_params = [data]
+    for indx in range(len(entry.params)):
+        '''
+        By pass first parameter which is input data and get replace with
+        new data format(from (1, 224, 224, 3) to (224,224,3))
+        '''
+        if (indx > 0):
+            new_params.append(entry.params[indx])
+    '''
+    Add param information to fix free varaible found error
+    '''
+    func = tvm.relay.Function(new_params,
+                              net,
+                              entry.ret_type,
+                              entry.type_params,
+                              entry.attrs)
+    func = run_opt_pass(func, transform.ToGraphNormalForm())
+
+    mod['main'] = func
     return mod
 
 def compile_mxnet_gulon_resnet(_env, _model):

Reply via email to