[Runtime] Allow parameter sharing between modules (#3489)
authorYong Sun <findsun@gmail.com>
Tue, 3 Sep 2019 03:53:42 +0000 (20:53 -0700)
committerHaichen Shen <shenhaichen@gmail.com>
Tue, 3 Sep 2019 03:53:42 +0000 (20:53 -0700)
commit224cc243b4e54a77d011644fe7d81bdee8e8116b
treef26ade088aa600e68f6a93f90b8278ec13ad7921
parent0fa308e9ef982385148f4b0e14200d155e369b05
[Runtime] Allow parameter sharing between modules (#3489)

As GraphRuntime does not provide control-flow logics, we have to split
our model to two parts. While we need to share parameters between them
to save memory usage.

Solution:
1) add "lazy_init_input" in graph's attributes
   "attrs": {
     ... ...
     "lazy_init_input": [
       "list_str",
       [
         "p0"
       ]
     ]
    }
2) allow un-allocated NDArray entry in SetupStorage
3) utilize "set_input_zero_copy" function to set parameters
include/tvm/runtime/ndarray.h
src/runtime/graph/graph_runtime.cc
src/runtime/graph/graph_runtime.h
src/runtime/ndarray.cc
tests/cpp/build_module_test.cc