Mousius commented on code in PR #13136:
URL: https://github.com/apache/tvm/pull/13136#discussion_r999601671


##########
tests/python/driver/tvmc/test_compiler.py:
##########
@@ -697,5 +697,36 @@ def test_compile_check_workspace_pools(mock_pkg, mock_fe, 
mock_relay):
     assert mock_relay.call_args_list[0][1]["workspace_memory_pools"] == 
memory_pools
 
 
+def test_compile_check_pass_instrument(keras_resnet50):
+    pytest.importorskip("tensorflow")
+
+    @tvm.instrument.pass_instrument
+    class PassesCounter:
+        def __init__(self):
+            self.run_before_count = 0
+            self.run_after_count = 0
+
+        def __clear(self):
+            self.run_before_count = 0
+            self.run_after_count = 0
+
+        def enter_pass_ctx(self):
+            self.__clear()
+
+        def exit_pass_ctx(self):
+            self.__clear()
+
+        def run_before_pass(self, mod, info):
+            self.run_before_count = self.run_before_count + 1
+
+        def run_after_pass(self, mod, info):
+            self.run_after_count = self.run_after_count + 1
+
+    passes_counter = PassesCounter()
+    tvmc_model = tvmc.load(keras_resnet50)
+    tvmc.compile(tvmc_model, target="llvm", instruments=[passes_counter])
+    assert passes_counter.run_after_count == passes_counter.run_before_count

Review Comment:
   Given `run_before_count` and `run_after_count` both start as `0`, wouldn't 
that mean that if we never used these instruments this assertion would still 
pass? Potentially worth asserting the actual number as well or that it's at `> 
0` ?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to