Uh oh!
There was an error while loading. Please reload this page.
[Relay] Add generic & informative Relay error reporting - #2408
Conversation
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
jroesch
commented
Jan 10, 2019
This is ready for review, could everyone check it out? |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
tqchen
commented
Jan 10, 2019
I will do it tomorrow evening |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
zhiics
commented
Jan 10, 2019
@jroesch I briefly went through. I will do another pass later. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| // it may be good to instead report it to std::cout. | ||
| LOG(FATAL) << annotated_prog.str() << std::endl; | ||
| exit(1); |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| * expression, we will default to throwing an exception with a textual representation | ||
| * of the error and no indication of where it occured in the original program. | ||
| * | ||
| * The latter mode is not ideal, and the goal of the new error reporting machinery is |
There was a problem hiding this comment.
I misread this doc comment initially, as only describing two modes. It should be "The final mode" here. My bad.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
2a3cc59 to
7a370eaCompare| @@ -0,0 +1 @@ | |||
| exclude_files=rang.h | |||
| * | ||
| * \returns The entry point function, (i.e. main). | ||
| */ | ||
| Expr EntryPoint(); |
There was a problem hiding this comment.
This name could still use more discussions.
Given that this is an one-liner module[module->entry_func], maybe we don't need this function
| #include <vector> | ||
| namespace tvm { | ||
| namespace relay { |
There was a problem hiding this comment.
can we put this into error.h? assuming this is part of error handling mechanism
There was a problem hiding this comment.
There was a cyclic dependency issue that I was trying to avoid by splitting the files, a few places use relay::Error which ErrorReporter depends on.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
tqchen
commented
Jan 18, 2019
zhiics
commented
Jan 18, 2019
@tqchen No problem. I will do one tonight. |
| struct Error : public dmlc::Error { | ||
| explicit Error(const std::string &msg) : dmlc::Error(msg) {} | ||
| Span sp; | ||
| explicit Error(const std::string &msg) : dmlc::Error(msg), sp() {} |
There was a problem hiding this comment.
| explicitError(conststd::string&msg) : dmlc::Error(msg), sp() {} | |
| explicitError(conststd::string&msg) : dmlc::Error(msg), sp() {} |
| // it may be good to instead report it to std::cout. | ||
| LOG(FATAL) << annotated_prog.str() << std::endl; | ||
| exit(1); |
There was a problem hiding this comment.
no need to have exit after LOG(FATAL)?
There was a problem hiding this comment.
LOG(FATAL) doesn't tell the compiler that it is [noreturn] causing a warning to be triggered. We can choose to omit these but in general marking unreachable code and code that doesn't return allows the compiler to better optimize.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
1add04c to
e1ec636Compare4e32721 to
c98bb22Comparetqchen
commented
Jan 25, 2019
Thank you, @jroesch@joshpoll@zhiics@MarisaKirisame ! this is now merged |
| } else { | ||
| return func->body; | ||
| } | ||
| } else { |
There was a problem hiding this comment.
@jroesch I guess we forgot to call TypeInferencer here...?
This PR adds the ability to generate informative error messages for Relay programs. This works irrespective of spans, and source programs.
The new error reporting works by collecting the set of errors generated by the program, then reporting them in two separate steps.
This design enables us to collect more than a single error when processing a program and report many at the same time. We can report errors on a module using the function
mod->ReportError(...).When can then choose to render the errors to the user as an error message using
mod->RenderErrors(...). This will use the reported errors to annotated the program using the text printer.The error messages will be marked in red on the line they occurred.
You can see an example of the error reporting in action below:
Currently I have only enabled this behavior in the type inferencer, but the machinery is generic and exposed by
relay::Moduleideally future passes can take advantage of it.I plan to propose and implement a generic pass & pass manager interface soon. The pass manager should make it easy to opt-in to error reporting without much work from pass authors.
I just got a basic version of this working and am still in the process of polishing the PR.
cc @ZihengJiang@MarisaKirisame@joshpoll@weberlo@tqchen@zhiics @icemelon9