From 9f826945162e149fbe14cc05afd918282873a082 Mon Sep 17 00:00:00 2001 From: Dmitriy Smirnov Date: Tue, 2 Mar 2021 11:39:53 +0000 Subject: [PATCH] [BYOC] Exclude external params from Graph Runtime This patch exculdes external params from created Graph Runtime module to prevent duplication as the external params will be also serialized from Metadata module. Change-Id: I47eda7e53b85f0b840445b60d33c2939b1cf99a0 --- python/tvm/relay/build_module.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/python/tvm/relay/build_module.py b/python/tvm/relay/build_module.py index f05e105ed2a2..6bdb19121526 100644 --- a/python/tvm/relay/build_module.py +++ b/python/tvm/relay/build_module.py @@ -267,7 +267,15 @@ def build(mod, target=None, target_host=None, params=None, mod_name="default"): with tophub_context: bld_mod = BuildModule() graph_json, mod, params = bld_mod.build(mod, target, target_host, params) - mod = _graph_runtime_factory.GraphRuntimeFactoryModule(graph_json, mod, mod_name, params) + + # exclude external params + external_prefixes = set([_.type_key for _ in bld_mod.mod["get_external_modules"]()]) + local_params = { + k: v for k, v in params.items() if not k.startswith(tuple(external_prefixes)) + } + mod = _graph_runtime_factory.GraphRuntimeFactoryModule( + graph_json, mod, mod_name, local_params + ) return mod