[GitHub] [tvm] Hzfengsy commented on a diff in pull request #13906: [tir] fix buffer_decl buffer allocation

2023-02-02 Thread via GitHub


Hzfengsy commented on code in PR #13906:
URL: https://github.com/apache/tvm/pull/13906#discussion_r1094699143


##
tests/python/unittest/test_tir_transform_plan_update_buffer_allocation_location.py:
##
@@ -416,5 +416,26 @@ def test_allocate_const_after_tensorize():
 _ = seq(sch.mod)
 
 
+def test_buffer_decl_allocation():
+"""
+Confirm a fix to
+`src/tir/transforms/plan_update_buffer_allocation_location.cc`
+in which a declared buffer was erroneously duplicated, resulting in a
+TIR-compilation failure.
+"""
+
+@tvm.script.ir_module
+class IRMod:
+@T.prim_func
+def func(a: T.Ptr[T.float32]):
+T.func_attr({"global_symbol": "main", "tir.noalias": True})
+A = T.buffer_decl(1, "float32", data=a)
+for i in range(1):
+A[i] = 0
+
+ir_mod = IRMod
+built_mod = tvm.build(ir_mod)

Review Comment:
   It would be great to make the test "unit" enough, i.e., only test the 
related pass instead of a whole build workflow.
   
   One of the common practices is to test the IRModule before and after the 
pass. Please see the test case `test_1D_cascade_op_rolling_buffer()` in the 
same file. 



-- 
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-unsubscr...@tvm.apache.org

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



[GitHub] [tvm] Hzfengsy commented on a diff in pull request #13906: [tir] fix buffer_decl buffer allocation

2023-02-02 Thread via GitHub


Hzfengsy commented on code in PR #13906:
URL: https://github.com/apache/tvm/pull/13906#discussion_r1094665278


##
src/tir/transforms/plan_update_buffer_allocation_location.cc:
##
@@ -111,6 +112,12 @@ class BufferAllocationLocator : public StmtExprMutator {
 collector(func->body);
 unmanaged_allocations_ = collector.unmanaged_allocations;
 
+for (Var param : func->params) {

Review Comment:
   ```suggestion
   for (const Var& param : func->params) {
   ```



##
tests/python/unittest/test_buffer_decl.py:
##
@@ -0,0 +1,44 @@
+# 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

Review Comment:
   Could you please add a testcase in 
`tests/python/unittest/test_tir_transform_plan_update_buffer_allocation_location.py`
 as the code changes are in the related file?



-- 
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-unsubscr...@tvm.apache.org

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