syang-ng opened a new issue #9401:
URL: https://github.com/apache/tvm/issues/9401


   It seems that the name of a buffer can be invalid after applying pass 
`PlanAndUpdateBufferAllocationLocation` and `CompactBufferAllocation`.
   
   ### Expected behavior
   
   The TVM can normally report the exception message.
   
   ### Actual behavior
   
   After applying pass `PlanAndUpdateBufferAllocationLocation` and 
`CompactBufferAllocation`,  there will be a crash if we continue to use pass 
`LowerMatchBuffer`.
   
   I used gdb to trace this bug:
   
![image](https://user-images.githubusercontent.com/25731241/139542985-a3284f2b-7301-421f-8c48-a5c1ccab3255.png)
   
   According to the source code, it seems that the name of the buffer will be 
invalid after applying these two passes for the module.
   
   
![image](https://user-images.githubusercontent.com/25731241/139543012-37a45d75-184b-4e48-b24c-588df9f4137c.png)
   
   
   ### Environment
   
   Ubuntu18.04, cmake 3.18.2, llvm 12, tested on latest git 4087e72
   
   ### Steps to reproduce
   
   Here is the script to reproduce the bug:
   
   ```python
   import tvm
   from tvm import tir
   
   var = tir.Var(name='v', dtype='int32')
   buf = tir.decl_buffer((1,), name='buf')
   zero = tir.const(0)
   buf_load = tir.expr.BufferLoad(buffer=buf, indices=[zero])
   then_case = tir.Store(buffer_var=var,value=buf_load,index=zero)
   for_stmt = tir.For(loop_var=var, min_val=0, extent=0, kind=1,body=then_case)
   y = 
tir.IfThenElse(then_case=then_case,else_case=for_stmt,condition=tir.Cast('bool',
 zero))
   f=tir.PrimFunc(body=y,params=[var])
   
   mod = tvm.IRModule({'main':f})
   mod = tir.transform.PlanAndUpdateBufferAllocationLocation()(mod)
   mod = tir.transform.CompactBufferAllocation()(mod)
   mod = tir.transform.LowerMatchBuffer()(mod)
   ```
   
   
   


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