chiwwang commented on a change in pull request #8220: URL: https://github.com/apache/tvm/pull/8220#discussion_r650802362
########## File path: docs/dev/pass_infra.rst ########## @@ -389,6 +397,51 @@ To allow other C++ modules to apply this pass, we declare a free function in TVM_DLL Pass FoldConstant(); +Pass Instrument +~~~~~~~~~~~~~~~ + +To instrument passes, four methods are introduced to ``PassContext``. + +.. code:: c++ + + TVM_DLL void InstrumentEnterPassContext(); + TVM_DLL void InstrumentExitPassContext(); + TVM_DLL bool InstrumentBeforePass(const IRModule& mod, const PassInfo& info) const; + TVM_DLL void InstrumentAfterPass(const IRModule& mod, const PassInfo& info) const; + +The first two methods are called respectively in entering/exiting context scope. The latter two are called while passes is being applied(`src/ir/transform.cc`_). + +Note that ``InstrumentBeforePass()`` return a boolean indicating this pass should +be run or not. + +``PassInstrument`` provides callbacks run by these methods. Multiple +``PassInstrument`` instances can be registed into a single ``PassContext``. +They are called sequentially in the order of ``instruments`` member. + Review comment: It's hard to introduce python frontend first because pass_infra.txt put a big section called "Python Frontend" downward. All python things are put there. If I don't follow this, pass_instra.txt become fragmented. (Although I agreed it is easier to introduce call-sequences and concepts with Python code...) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org