# Motivation

Working and discussing with @MarisaKirisame , we ran into a reoccurring issue 
when developing Relay passes: it is unclear whether a failed pass is at fault 
or an earlier pass which may have corrupted the AST. This makes errors in Relay 
passes harder to locate, especially when complexity grows as more passes are 
developed within the community.

Thus, if a pass fails, we want a way to check whether the input AST was bad or 
the pass itself is wrong based on the specific pass.

Currently, there is no design for pass-dependent checks. Ex. quantization does 
not support control flow. This RFC proposes to add a method for Relay pass 
developers/maintainers to specify pre/post conditions that can be called by 
Relay's Pass Manager to provide more detailed debugging whenever the pass fails.

# Proposed Design

Our main concern is creating a design that can be easily used by Relay pass 
developers/maintainers since these are the folks who have enough in-depth 
knowledge about the specific pass to write code checking the preconditions and 
postconditions. Thus, I propose to add `check` function within the Pass object. 
By default, it will have the weakest specification so that passes that haven't 
implemented check will still work, but developers will be able to override this 
function such that pass-specific checks can be used by the PassManager.

# Unsolved Problem:

- How should this function be passed into 
`CreateFunctionPass`/`CreateModulePass`/`CreateSequentialPass`

I'm fairly new to the TVM codebase, so any critical feedback is much 
appreciated.
@tqchen @zhiics @jroesch @MarisaKirisame @slyubomirsky 

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/apache/incubator-tvm/issues/5096

Reply via email to