You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by "lhutton1 (via GitHub)" <gi...@apache.org> on 2024/01/05 17:26:45 UTC

Re: [PR] [TVMC] Add tvmc flag to print ir before and print ir after named pass [tvm]

lhutton1 commented on code in PR #16261:
URL: https://github.com/apache/tvm/pull/16261#discussion_r1443145010


##########
python/tvm/ir/instrument.py:
##########
@@ -255,3 +255,18 @@ def render():
                 profiles = timing_inst.render()
         """
         return _ffi_instrument_api.RenderTimePassProfiles()
+
+
+@pass_instrument
+class PassPrintingInstrument:
+    def __init__(self, print_before_pass_name, print_after_pass_name):
+        self.print_before_pass_name = print_before_pass_name
+        self.print_after_pass_name = print_after_pass_name
+
+    def run_before_pass(self, mod, pass_info):
+        if pass_info.name in self.print_before_pass_name:
+            print(f"Print IR before:\n{pass_info.name}\n{mod}\n\n")

Review Comment:
   nit: I feel it's slightly easier to read if "Print IR before: pass-name" is on the same line. Happy either way though



##########
python/tvm/ir/instrument.py:
##########
@@ -255,3 +255,18 @@ def render():
                 profiles = timing_inst.render()
         """
         return _ffi_instrument_api.RenderTimePassProfiles()
+
+
+@pass_instrument
+class PassPrintingInstrument:
+    def __init__(self, print_before_pass_name, print_after_pass_name):

Review Comment:
   ```suggestion
       def __init__(self, print_before_pass_names, print_after_pass_names):
   ```



-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org