You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by "Lunderberg (via GitHub)" <gi...@apache.org> on 2023/05/19 21:09:54 UTC

[GitHub] [tvm] Lunderberg opened a new pull request, #14892: [TIR] Expand unit tests for ConvertSSA

Lunderberg opened a new pull request, #14892:
URL: https://github.com/apache/tvm/pull/14892

   Prior to this PR, there was a single test which invoked ConvertSSA and checked that no error was thrown.  This PR adds additional test cases for nested variable definition, and for variables de-duplicated across separate function calls in an `IRModule`.
   
   Of the additional tests, the behavior tested by `TestDedupAutoBroadcastBuffer` and `TestReusedBufferParameter` fails on main, and is resolved by this PR.


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


[GitHub] [tvm] tqchen commented on a diff in pull request #14892: [TIR] Expand unit tests for ConvertSSA

Posted by "tqchen (via GitHub)" <gi...@apache.org>.
tqchen commented on code in PR #14892:
URL: https://github.com/apache/tvm/pull/14892#discussion_r1199661886


##########
tests/python/unittest/test_tir_transform_convert_ssa.py:
##########
@@ -0,0 +1,255 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import tvm
+import tvm.testing
+from tvm.script import tir as T, ir as I
+
+
+class BaseBeforeAfter(tvm.testing.CompareBeforeAfter):
+    transform = tvm.tir.transform.ConvertSSA()
+
+
+class TestReuseInSequentialLetStmt(BaseBeforeAfter):
+    """De-dup sequential variable bindings"""
+
+    def before(self):
+        @T.prim_func
+        def func():
+            i1 = T.handle("int32")
+            with T.LetStmt(i1, var=i1):
+                T.evaluate(0)
+            with T.LetStmt(i1, var=i1):

Review Comment:
   I am not sure if TVMScript support creation of non-SSA form, since  future parsers could choose to do renaming, or not support such case. 
   
   It would be safer to do things with ir builder



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


[GitHub] [tvm] masahi merged pull request #14892: [TIR] Expand unit tests for ConvertSSA

Posted by "masahi (via GitHub)" <gi...@apache.org>.
masahi merged PR #14892:
URL: https://github.com/apache/tvm/pull/14892


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


[GitHub] [tvm] Lunderberg commented on a diff in pull request #14892: [TIR] Expand unit tests for ConvertSSA

Posted by "Lunderberg (via GitHub)" <gi...@apache.org>.
Lunderberg commented on code in PR #14892:
URL: https://github.com/apache/tvm/pull/14892#discussion_r1199689299


##########
tests/python/unittest/test_tir_transform_convert_ssa.py:
##########
@@ -0,0 +1,255 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import tvm
+import tvm.testing
+from tvm.script import tir as T, ir as I
+
+
+class BaseBeforeAfter(tvm.testing.CompareBeforeAfter):
+    transform = tvm.tir.transform.ConvertSSA()
+
+
+class TestReuseInSequentialLetStmt(BaseBeforeAfter):
+    """De-dup sequential variable bindings"""
+
+    def before(self):
+        @T.prim_func
+        def func():
+            i1 = T.handle("int32")
+            with T.LetStmt(i1, var=i1):
+                T.evaluate(0)
+            with T.LetStmt(i1, var=i1):

Review Comment:
   Good point, especially since all the before cases are malformed in some way.  The IRModule-wide checks should be safe, since the duplication is introduced after parsing, but both `TestReuseInSequentialLetStmt` and `TestReuseInNestedLetStmt` should be updated to prevent future improvements to the parser from fixing them before the test runs.



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


[GitHub] [tvm] Lunderberg commented on a diff in pull request #14892: [TIR] Expand unit tests for ConvertSSA

Posted by "Lunderberg (via GitHub)" <gi...@apache.org>.
Lunderberg commented on code in PR #14892:
URL: https://github.com/apache/tvm/pull/14892#discussion_r1199769037


##########
tests/python/unittest/test_tir_transform_convert_ssa.py:
##########
@@ -0,0 +1,255 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import tvm
+import tvm.testing
+from tvm.script import tir as T, ir as I
+
+
+class BaseBeforeAfter(tvm.testing.CompareBeforeAfter):
+    transform = tvm.tir.transform.ConvertSSA()
+
+
+class TestReuseInSequentialLetStmt(BaseBeforeAfter):
+    """De-dup sequential variable bindings"""
+
+    def before(self):
+        @T.prim_func
+        def func():
+            i1 = T.handle("int32")
+            with T.LetStmt(i1, var=i1):
+                T.evaluate(0)
+            with T.LetStmt(i1, var=i1):

Review Comment:
   Unit tests are now updated so that all SSA violations are introduced outside of TVMScript.



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


[GitHub] [tvm] Lunderberg commented on pull request #14892: [TIR] Expand unit tests for ConvertSSA

Posted by "Lunderberg (via GitHub)" <gi...@apache.org>.
Lunderberg commented on PR #14892:
URL: https://github.com/apache/tvm/pull/14892#issuecomment-1555253773

   This PR is a subset of the functionality in https://github.com/apache/tvm/pull/14862.  As that PR has grown to a difficult-to-review size, I'm carving off independent chunks of it into separate PRs, after which #14862 can be rebased to a more manageable size.


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


[GitHub] [tvm] tvm-bot commented on pull request #14892: [TIR] Expand unit tests for ConvertSSA

Posted by "tvm-bot (via GitHub)" <gi...@apache.org>.
tvm-bot commented on PR #14892:
URL: https://github.com/apache/tvm/pull/14892#issuecomment-1555253744

   <!---bot-comment-->
   
   Thanks for contributing to TVM! Please refer to the contributing guidelines https://tvm.apache.org/docs/contribute/ for useful information and tips. Please request code reviews from [Reviewers](https://github.com/apache/incubator-tvm/blob/master/CONTRIBUTORS.md#reviewers) by @-ing them in a comment.
   
   <!--bot-comment-ccs-start-->
    * cc @Hzfengsy, @junrushao, @quic-sanirudh, @shingjan <sub>See [#10317](https://github.com/apache/tvm/issues/10317) for details</sub><!--bot-comment-ccs-end-->
   
   <sub>Generated by [tvm-bot](https://github.com/apache/tvm/blob/main/ci/README.md#github-actions)</sub>


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