You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2021/09/27 17:08:49 UTC

[GitHub] [tvm] tkonolige commented on a change in pull request #9115: [TVMScript] Script namespace changes

tkonolige commented on a change in pull request #9115:
URL: https://github.com/apache/tvm/pull/9115#discussion_r716862248



##########
File path: python/tvm/tir/function.py
##########
@@ -138,3 +138,18 @@ def mem_copy_16_16(a: ty.handle, b: ty.handle) -> None:
             The new function with parameter specialized
         """
         return _ffi_api.Specialize(self, param_map)  # type: ignore
+
+    def script(self, show_meta=False) -> str:
+        """Print PrimFunc into TVMScript
+
+        Parameters
+        ----------
+        show_meta : bool
+            Whether show meta

Review comment:
       ```suggestion
               Whether to show meta information
   ```

##########
File path: tests/python/unittest/test_tvmscript_spans.py
##########
@@ -18,26 +18,26 @@
 import inspect
 
 import tvm
-import tvm.script
-from tvm import tir
+from tvm.script import tir as T
 
 
+@T.prim_func
 def loops() -> None:
-    for i in tir.parallel(0, 2):
-        for j in tir.serial(0, 1):
-            for z in tir.vectorized(3, 4):
-                tir.evaluate(0)
+    for i in T.parallel(0, 2):
+        for j in T.serial(0, 1):
+            for z in T.vectorized(3, 4):
+                T.evaluate(0)
 
 
 def test_loops():
-    _, start_line = inspect.getsourcelines(loops)
-    parsed = tvm.script.tir(loops)
+    start_line = 25

Review comment:
       Using relative line numbers in the tests make it easier to reorganize the tests. Is there a reason that is not possible with any more?

##########
File path: python/tvm/script/parser.py
##########
@@ -895,16 +923,18 @@ def transform_TypeAttr(self, node):
         """Visitor for field access of the form `x.y` for types.
 
         We have two cases here:
-        1. If the type is of the form `ty.something`, we look up the type in
-           the `ty` namespace in this module.
+        1. If the type is of the form `tir.something`, we look up the type in
+           the `tir` namespace in this module.

Review comment:
       ```suggestion
           1. If the type is of the form `T.something`, we look up the type in
              the `tir` namespace in this module.
   ```

##########
File path: python/tvm/topi/arm_cpu/cortex_m7/micro_kernel/gemm.py
##########
@@ -75,7 +75,7 @@ def intrin_func(ins, outs):
         def _reduce_update():
             ib = tvm.tir.ir_builder.create()
             ib.emit(
-                tvm.tir.call_extern(
+                tvm.T.call_extern(

Review comment:
       This should be `tvm.tir.call_extern` (Same with below).

##########
File path: tests/python/unittest/test_aot_legalize_packed_call.py
##########
@@ -70,8 +71,8 @@ def tir_packed_call() -> None:
 
 
 def test_aot_packed_call():
-    mod = Module()
-    expected = Expected()
+    mod = Module
+    expected = Expected

Review comment:
       So we are changing the behavior of the decorators to directly return the IRModule instead of returning a callable that creates an IRModule? Do you know what it was done the latter way originally? My guess is that the callable approach lets you create multiple instances of the IRModule.




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