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

   # The bug
   Currently, the `compute_inline` function would report an error if we try to 
`compute_inline` a block where the buffer has a symbolic shape, below is a 
minimal reproduction:
   
   ```python
   import tvm
   import numpy as np
   from tvm.script import tir as T
   
   @T.prim_func
   def failed_compute_inline(a: T.handle, b: T.handle):
       N = T.int32()
       A = T.match_buffer(a, (N, 32), "float32")
       temp = T.alloc_buffer((N, 32), "float32", scope="local")
       B = T.match_buffer(b, (N, 32), "float32")
       for i in range(N):
           for j in range(32):
               with T.block("T"):
                   vi, vj = T.axis.remap("SS", [i, j])
                   temp[vi, vj] = A[vi, vj] + 1
           for j in range(32):
               with T.block("B"):
                   vi, vj = T.axis.remap("SS", [i, j])
                   B[vi, vj] = temp[vi, vj] * A[vi, vj]
   
   sch = tvm.tir.Schedule(failed_compute_inline)
   T = sch.get_block("T")
   B = sch.get_block("B")
   j = sch.get_loops(B)[-1]
   sch.compute_inline(T)
   ```
   
   The reason is that the validity check analysis would use `UndefinedVars` to 
find variables that appeared in the block being `compute_inline` 'd. However, 
the `UndefinedVars` would visit `Buffer` and counts variables in buffer 
shape/strides,  and actually, we only care about buffer access indices. 
   
   # Fix
   This PR fixes the issue by adding a `visit_buffer` argument in the 
`UndefinedVars` function so that we can exclude variables that appeared in 
buffer shape/strides.


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