Skip to content

Commit

Permalink
[COMPILE] More debug message when compile error (apache#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
tqchen authored and sergei-mironov committed Aug 8, 2018
1 parent a81b025 commit 9037fd1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
15 changes: 12 additions & 3 deletions nnvm/python/nnvm/compiler/build_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,18 @@ def build_config(**kwargs):


@tvm.register_func("nnvm.compiler.lower")
def _lower(sch, inputs, func_name):
f = tvm.lower(sch, inputs, name=func_name)
logging.debug("lower function %s", func_name)
def _lower(sch, inputs, func_name, graph):
import traceback
# pylint: disable=broad-except
try:
f = tvm.lower(sch, inputs, name=func_name)
logging.debug("lower function %s", func_name)
except Exception:
msg = traceback.format_exc()
msg += "Error during compile graph\n"
msg += "--------------------------\n"
msg += graph.ir(join_entry_attrs=["shape"])
raise RuntimeError(msg)
return f if isinstance(
f, (tvm.container.Array, tuple, list)) else [f]

Expand Down
2 changes: 1 addition & 1 deletion nnvm/python/nnvm/frontend/onnx.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ def from_onnx(graph):
-------
sym : nnvm.Symbol
Compatible nnvm symbol
params : dict of str to tvm.ndarray
Dict of converted parameters stored in tvm.ndarray format
"""
Expand Down
2 changes: 1 addition & 1 deletion nnvm/src/compiler/compile_engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ class CompileEngine {
gf->inputs = inputs;
gf->outputs = outputs;
static const PackedFunc& flower = GetPackedFunc("nnvm.compiler.lower");
gf->funcs = flower(sch, all_args, gf->func_name);
gf->funcs = flower(sch, all_args, gf->func_name, graph);
return GraphFunc(gf);
}

Expand Down

0 comments on commit 9037fd1

Please sign in to comment.