Skip to content

Commit

Permalink
Add mod supoort in relay.build
Browse files Browse the repository at this point in the history
  • Loading branch information
apivovarov committed Jun 23, 2019
1 parent 5629901 commit 1303012
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
7 changes: 5 additions & 2 deletions python/tvm/relay/build_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ def build(func, target=None, target_host=None, params=None):
Parameters
----------
func: relay.Function
The function to build.
func: relay.Function or relay.Module
The function or module to build.
target : str, :any:`tvm.target.Target`, or dict of str(i.e. device/context
name) to str/tvm.target.Target, optional
Expand Down Expand Up @@ -192,6 +192,9 @@ def build(func, target=None, target_host=None, params=None):

with tophub_context:
bld_mod = BuildModule()
if "tvm.relay.module.Module" in str(type(func)):
mod = func
func = mod[mod.entry_func]
graph_json, mod, params = bld_mod.build(func, target, target_host,
params)
return graph_json, mod, params
Expand Down
4 changes: 1 addition & 3 deletions tests/python/frontend/tflite/test_forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,7 @@ def run_tvm_graph(tflite_model_buf, input_data, input_node, num_output=1, target
shape_dict=shape_dict,
dtype_dict=dtype_dict)
with relay.build_config(opt_level=3):
graph, lib, params = relay.build(mod[mod.entry_func],
target,
params=params)
graph, lib, params = relay.build(mod, target, params=params)

ctx = tvm.context(target, 0)
from tvm.contrib import graph_runtime
Expand Down
2 changes: 1 addition & 1 deletion tutorials/frontend/from_tflite.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def extract(path):
# target x86 CPU
target = "llvm"
with relay.build_config(opt_level=3):
graph, lib, params = relay.build(mod[mod.entry_func], target, params=params)
graph, lib, params = relay.build(mod, target, params=params)

######################################################################
# Execute on TVM
Expand Down

0 comments on commit 1303012

Please sign in to comment.