From bf172d9ae3d39f67b6d14acdbffa3ddc59a11f1e Mon Sep 17 00:00:00 2001 From: Michalis Papadimitriou Date: Wed, 7 Jul 2021 18:31:49 +0300 Subject: [PATCH 1/2] Overload create_executor to accept params --- python/tvm/relay/build_module.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/python/tvm/relay/build_module.py b/python/tvm/relay/build_module.py index aa826aee57a1..b8c19ea8d4f6 100644 --- a/python/tvm/relay/build_module.py +++ b/python/tvm/relay/build_module.py @@ -511,7 +511,7 @@ def _graph_wrapper(*args, **kwargs): return _graph_wrapper -def create_executor(kind="debug", mod=None, device=None, target="llvm"): +def create_executor(kind="debug", mod=None, device=None, target="llvm", params=None): """Factory function to create an executor. Example @@ -555,6 +555,10 @@ def create_executor(kind="debug", mod=None, device=None, target="llvm"): else: device = _nd.device(str(target), 0) + # print("params " + params) + if params is not None: + mod = IRModule.from_expr(bind_params_by_name(mod["main"], params)) + if isinstance(target, str): target = Target(target) if kind == "debug": From fd4effd8e1675d3031570b007adb1a813ab22062 Mon Sep 17 00:00:00 2001 From: Michalis Papadimitriou Date: Wed, 7 Jul 2021 18:37:09 +0300 Subject: [PATCH 2/2] [fix] Add stringdoc for new param in create_executor --- python/tvm/relay/build_module.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/python/tvm/relay/build_module.py b/python/tvm/relay/build_module.py index b8c19ea8d4f6..d1cf1c9bea2f 100644 --- a/python/tvm/relay/build_module.py +++ b/python/tvm/relay/build_module.py @@ -544,6 +544,10 @@ def create_executor(kind="debug", mod=None, device=None, target="llvm", params=N target : :py:class:`tvm.Target` The corresponding context + params : dict of str to NDArray + Input parameters to the graph that do not change + during inference time. + Returns ------- executor : :py:class:`~tvm.relay.backend.interpreter.Executor` @@ -555,10 +559,9 @@ def create_executor(kind="debug", mod=None, device=None, target="llvm", params=N else: device = _nd.device(str(target), 0) - # print("params " + params) if params is not None: - mod = IRModule.from_expr(bind_params_by_name(mod["main"], params)) - + mod = IRModule.from_expr(bind_params_by_name(mod["main"], params)) + if isinstance(target, str): target = Target(target) if kind == "debug":