Skip to content

Conversation

@jroesch
Copy link
Member

@jroesch jroesch commented Dec 26, 2018

This pull request adds the ability to generate descriptive errors for Relay. An error can be reported on a tam::relay::Span which 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


mutable ErrorReporter err_reporter;

mutable GlobalVar entry_func;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra space

});



Copy link
Contributor

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 `"
Copy link
Contributor

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(";");
Copy link
Contributor

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())
Copy link
Contributor

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.

@jroesch
Copy link
Member Author

jroesch commented Jan 10, 2019

Closing in favor of #2408, will revive span based errors in a follow-up PR.

@jroesch jroesch closed this Jan 10, 2019
@jroesch jroesch deleted the relay-errors branch February 4, 2021 04:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants