Commit cff62bdb by Zhi Committed by Yizhi Liu

[tutorial] Relay pass infra tutorial (#4083)

* Add pass manager tutorial

* fix some examples

* retrigger ci

* Update tutorials/dev/relay_pass_infra.py

Co-Authored-By: 雾雨魔理沙 <lolisa@marisa.moe>

* Add ToANormalForm link
parent 1d243664
...@@ -567,9 +567,11 @@ TVM_DLL Pass EtaExpand(); ...@@ -567,9 +567,11 @@ TVM_DLL Pass EtaExpand();
/*! /*!
* \brief Print the IR for a module to help debugging. * \brief Print the IR for a module to help debugging.
* *
* \param show_meta_data The flag to control if meta data needs to be printed.
*
* \return the pass. * \return the pass.
*/ */
TVM_DLL Pass PrintIR(); TVM_DLL Pass PrintIR(bool show_meta_data = true);
} // namespace transform } // namespace transform
......
...@@ -594,16 +594,21 @@ def LambdaLift(): ...@@ -594,16 +594,21 @@ def LambdaLift():
return _transform.LambdaLift() return _transform.LambdaLift()
def PrintIR(): def PrintIR(show_meta_data=True):
""" """
Print the IR for a module to help debugging. Print the IR for a module to help debugging.
Parameters
----------
show_meta_data : bool
A boolean flag to indicate if meta data should be printed.
Returns Returns
------- -------
ret : tvm.relay.Pass ret : tvm.relay.Pass
The registered pass that prints the module IR. The registered pass that prints the module IR.
""" """
return _transform.PrintIR() return _transform.PrintIR(show_meta_data)
def gradient(expr, mod=None, mode='higher_order'): def gradient(expr, mod=None, mode='higher_order'):
......
...@@ -32,10 +32,10 @@ namespace relay { ...@@ -32,10 +32,10 @@ namespace relay {
namespace transform { namespace transform {
Pass PrintIR() { Pass PrintIR(bool show_meta_data) {
runtime::TypedPackedFunc<Module(Module, PassContext)> pass_func = runtime::TypedPackedFunc<Module(Module, PassContext)> pass_func =
[=](Module m, PassContext pc) { [=](Module m, PassContext pc) {
LOG(INFO) << "Dumping the module IR: " << std::endl << AsText(m); LOG(INFO) << "Dumping the module IR: " << std::endl << AsText(m, show_meta_data);
return m; return m;
}; };
return CreateModulePass(pass_func, 0, "PrintIR", {}); return CreateModulePass(pass_func, 0, "PrintIR", {});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment