-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[RELAY][Errors][WIP] Add descriptive errors for Relay #2341
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
|
||
| mutable ErrorReporter err_reporter; | ||
|
|
||
| mutable GlobalVar entry_func; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extra space
| }); | ||
|
|
||
|
|
||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extra line
| Error err("failed to unify"); | ||
| err.sp = span; | ||
| FatalError(err); | ||
| // << "Error unifying `" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
put into err or delete the comment
| this->PrintCallAttrs(op->op, op->attrs, stream_); | ||
| stream_ << ")"; | ||
| this->PrintEndInst(""); | ||
| this->PrintEndInst(";"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refactor into two method
| auto e = TypeInferencer(mod).Infer(expr); | ||
| Expr InferType(const Expr& expr, const Module& m) { | ||
| Module mod = m; | ||
| if (!mod.defined()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are you sure we need this? I think tvm ffi will init this to a empty Module.
|
Closing in favor of #2408, will revive span based errors in a follow-up PR. |
This pull request adds the ability to generate descriptive errors for Relay. An error can be reported on a
tam::relay::Spanwhich corresponds to a source location in the original program.For programs which are built programmatically we recover a representation of the program which is useful for error reporting. We generate this representation using the text printer and then parse it to recover the span information.
Once we have done this we can precisely mark an error on the original program, for example report the operator invocation which has a type error.
My goal is that we will only need to do this once when inputting the program, and store the program fragment in a
tvm::relay::Module.This PR lays the initial groundwork to do this kind of error reporting.
I will do more experimentation and clean up work before this is ready to merge.
One large challenge is related to vars, due to vars appearing many times in the program, but only being allocated once we can not easily track the span information correctly for it using Relay's current representation. If we put the programs into ANF, we can provide very clear errors, but I think we will need to revisit how we track span information, but this will enable us to have informative errors in the mean time.
cc @joshpoll @MarisaKirisame @tqchen @ZihengJiang