-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
[Relay] Start porting pass to the pass manager #3191
Conversation
@MarisaKirisame Thank you for the effort. For registration this is okay to me. But there are still some problems we probably want to discuss:
|
@zhiics I dont think it should be able to take function. Everything will work Module -> Module inside the pass manager, and if you want function to function, you can use the old api which will still be open. |
@MarisaKirisame Yes, you are right everything is |
@zhiics I see. |
@MarisaKirisame I am okay with either way. I updated inplace because we usually cannot run multiple function level opts in parallel. |
@zhiics I see. I think leaving the old module intact is better because it allow one to debug by just looking at the intermediate Modules. |
|
@MarisaKirisame I don't think we need to change the API to pass in a |
@zhiics yes, but some pass might need to additionally take a module, to work on a function (to handle globalvar). |
@MarisaKirisame Yes, I understand. As I mentioned in the RFC, it seems every pass will need EDIT: I was thinking if it is necessary to encode into to |
@zhiics it is definitely possible, whetthrt we should or not is another issue. What was the design intent of PassContext? |
@MarisaKirisame Let's bring @jroesch in discussion. |
include/tvm/relay/pass.h
Outdated
/*! \brief Aggressive constant propagation/constant folding/inlining. | ||
* It will do as much computation in compile time as possible. | ||
* It has two benefit: remove runtime overhead, and allow more optimization (typically fusion). | ||
* As a side effect, code size will explode. | ||
*/ | ||
Expr PartialEval(const Expr& e); | ||
|
||
inline pass::Pass PartialEvalPass() { |
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.
do not use inline function and put all implementation in the corresponding pass file.
@tqchen I address your comments. can you give another round of review? |
@MarisaKirisame This looks good to me now. Do we have more passes to register? |
@zhiics yes. for example, simplify inference is not exposed in the C++ side. |
@MarisaKirisame Yes, that's totally fine to me. Thank you. Another thing we need to keep in mind or probably add to the RFC is that we should add PassContext to the passes so that they can take internal thing like error reporting. |
include/tvm/relay/pass.h
Outdated
@@ -271,13 +272,17 @@ TVM_DLL tvm::Array<TypeVar> AllTypeVars(const Type& t, const Module& mod); | |||
*/ | |||
TVM_DLL Expr DeadCodeElimination(const Expr& e); | |||
|
|||
transform::Pass DeadCodeEliminationPass(); |
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.
given that transform namespace has been merged in. Please move them to transform.h . Under the same name
Pass DeadCodeElimination();
src/relay/pass/pass.cc
Outdated
using namespace runtime; | ||
using std::function; | ||
|
||
Pass DeadCodeEliminationPass() { |
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.
Instead of putting these in pass.cc , directly move it to dead_code.cc Note that we might remove the original DeadCodeElimination function and only keep this one
include/tvm/relay/transform.h
Outdated
int opt_level, | ||
const std::string& name, | ||
const tvm::Array<tvm::Expr>& required); | ||
|
||
Pass DeadCodeElimination(); |
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.
document each function using the doxygen format
include/tvm/relay/pass.h
Outdated
* | ||
* Implements structural hashing of a Relay type. | ||
* | ||
* \param type the type to hash. |
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.
seems the location of StructualHash does not have to change
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.
I wanna move the big one down, and have the small one together, so it is easier to read.
include/tvm/relay/transform.h
Outdated
int opt_level, | ||
const std::string& name, | ||
const tvm::Array<tvm::Expr>& required); | ||
|
||
Pass DeadCodeElimination(); |
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.
Mark the declaration with prefix TVM_DLL so that it is exposed in the dynamic library.
include/tvm/relay/transform.h
Outdated
* | ||
* \return The pass. | ||
*/ | ||
TVM_DLL Pass FuseOps(int fuse_opt_level); |
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.
Let us allow fuse_opt_level=-1 (automatic mode) which allows the op_level to equal PassContext::Current()->opt_level
Thanks, @MarisaKirisame , this is merged |
@zhiics @jroesch is this fine? If so, I will convert the rest in the same manner.