[Bug] InternalError: Check failed: (!block_stack_.empty()) is false in StaticPlanBlockMemory with Dataflow
- Dominant language
- Python
- Stars
- 13.7k
- Forks
- 4k
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 111
Description
The code defines a relax function that allocates a tensor using R.builtin.alloc_tensor inside a dataflow block. When applying the StaticPlanBlockMemory transformation, it results in an internal error with the message: `Check failed: (!block_stack_.empty()) is false`. However, if the dataflow block is removed, the transformation completes without error.
### Expected behavior
The `StaticPlanBlockMemory` transformation should handle functions with dataflow blocks correctly, allowing the memory planning without causing internal errors.
### Actual behavior
```
File "/software/tvm/src/relax/transform/static_plan_block_memory.cc", line 597
InternalError: Check failed: (!block_stack_.empty()) is false:
```
### Steps to reproduce
```python
import tvm
from tvm import relax
from tvm.script import ir as I
from tvm.script import relax as R
@I.ir_module
class Module:
@R.function
def main() -> R.Tensor((10,), dtype="float32"):
with R.dataflow():
gv: R.Tensor((10,), dtype="float32") = R.builtin.alloc_tensor(
R.shape([10]), R.dtype("float32"), R.prim_value(0), R.str("global")
)
R.output(gv)
return gv
mod = Module
mod_seq = tvm.transform.Sequential([relax.transform.StaticPlanBlockMemory()])(mod)
```
This issue may indicate a problem with how dataflow blocks are processed within the StaticPlanBlockMemory pass. Any guidance or fixes to resolve this would be appreciated.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the reproducer in the issue and inspect relax/transform/static_plan_block_memory.cc around line 597, where the empty block stack is checked. Run the supplied StaticPlanBlockMemory transformation with and without the R.dataflow block to trace the differing state. Done means the dataflow version completes without the reported InternalError and existing relevant tests continue to pass.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, python
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100