From 2a2e16c557155d62f7ecc5c062dfaa69082b7eb3 Mon Sep 17 00:00:00 2001 From: Tristan Konolige Date: Fri, 17 Jul 2020 14:14:41 -0600 Subject: [PATCH 1/3] Raise error if no operators are found in GraphTuner --- python/tvm/autotvm/graph_tuner/base_graph_tuner.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/python/tvm/autotvm/graph_tuner/base_graph_tuner.py b/python/tvm/autotvm/graph_tuner/base_graph_tuner.py index 1cc4f39d35b4..76f92bea4ce9 100644 --- a/python/tvm/autotvm/graph_tuner/base_graph_tuner.py +++ b/python/tvm/autotvm/graph_tuner/base_graph_tuner.py @@ -152,6 +152,9 @@ def __init__(self, graph, input_shapes, records, target_ops, self._graph = graph self._in_nodes_dict = get_in_nodes(self._node_list, self._target_ops, input_shapes.keys()) + if len(self._in_nodes_dict) == 0: + raise RuntimeError("Could not find any input nodes with whose " + "operator is one of %s" % self._target_ops) self._out_nodes_dict = get_out_nodes(self._in_nodes_dict) self._fetch_cfg() self._opt_out_op = OPT_OUT_OP From 85898bd73edf3a605e62ed771e1f2d5bf5c85ca5 Mon Sep 17 00:00:00 2001 From: Tristan Konolige Date: Mon, 20 Jul 2020 10:15:29 -0600 Subject: [PATCH 2/3] Raise error if key cannot be found in graph runtime inputs --- python/tvm/contrib/graph_runtime.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/python/tvm/contrib/graph_runtime.py b/python/tvm/contrib/graph_runtime.py index 326eccb674a5..22d0a8b8bc1d 100644 --- a/python/tvm/contrib/graph_runtime.py +++ b/python/tvm/contrib/graph_runtime.py @@ -152,7 +152,10 @@ def set_input(self, key=None, value=None, **params): Additional arguments """ if key is not None: - self._get_input(key).copyfrom(value) + v = self._get_input(key) + if v is None: + raise RuntimeError("Could not find '%s' in graph's inputs" % key) + v.copyfrom(value) if params: # upload big arrays first to avoid memory issue in rpc mode From 9b19059d0ab1ad4b7f77817bdc3a608516bed5fa Mon Sep 17 00:00:00 2001 From: Tristan Konolige Date: Fri, 24 Jul 2020 14:23:31 -0700 Subject: [PATCH 3/3] Detailed error message when module loader is not found --- src/runtime/library_module.cc | 19 +++++++++++++++++-- src/runtime/stackvm/stackvm_module.cc | 19 +++++++++++++++++-- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/src/runtime/library_module.cc b/src/runtime/library_module.cc index b12a9d195e2e..651e19cdbd37 100644 --- a/src/runtime/library_module.cc +++ b/src/runtime/library_module.cc @@ -133,9 +133,24 @@ runtime::Module ProcessModuleBlob(const char* mblob, ObjectPtr lib) { CHECK(stream->Read(&import_tree_row_ptr)); CHECK(stream->Read(&import_tree_child_indices)); } else { - std::string fkey = "runtime.module.loadbinary_" + tkey; + std::string loadkey = "runtime.module.loadbinary_"; + std::string fkey = loadkey + tkey; const PackedFunc* f = Registry::Get(fkey); - CHECK(f != nullptr) << "Loader of " << tkey << "(" << fkey << ") is not presented."; + if (f == nullptr) { + std::string loaders = ""; + for (auto name : Registry::ListNames()) { + if (name.rfind(loadkey, 0) == 0) { + if (loaders.size() > 0) { + loaders += ", "; + } + loaders += name.substr(loadkey.size()); + } + } + CHECK(f != nullptr) + << "Binary was created using " << tkey + << " but a loader of that name is not registered. Available loaders are " << loaders + << ". Perhaps you need to recompile with this runtime enabled."; + } Module m = (*f)(static_cast(stream)); modules.emplace_back(m); } diff --git a/src/runtime/stackvm/stackvm_module.cc b/src/runtime/stackvm/stackvm_module.cc index 9e1f1f515f4a..6c9af1cbeb42 100644 --- a/src/runtime/stackvm/stackvm_module.cc +++ b/src/runtime/stackvm/stackvm_module.cc @@ -101,9 +101,24 @@ class StackVMModuleNode : public runtime::ModuleNode { for (uint64_t i = 0; i < num_imports; ++i) { std::string tkey; CHECK(strm->Read(&tkey)); - std::string fkey = "runtime.module.loadbinary_" + tkey; + std::string loadkey = "runtime.module.loadbinary_"; + std::string fkey = loadkey + tkey; const PackedFunc* f = Registry::Get(fkey); - CHECK(f != nullptr) << "Loader of " << tkey << "(" << fkey << ") is not presented."; + if (f == nullptr) { + std::string loaders = ""; + for (auto name : Registry::ListNames()) { + if (name.rfind(loadkey, 0) == 0) { + if (loaders.size() > 0) { + loaders += ", "; + } + loaders += name.substr(loadkey.size()); + } + } + CHECK(f != nullptr) + << "Binary was created using " << tkey + << " but a loader of that name is not registered. Available loaders are " << loaders + << ". Perhaps you need to recompile with this runtime enabled."; + } Module m = (*f)(static_cast(strm)); n->imports_.emplace_back(std::move(m)); }