raindrops-0199 opened a new issue, #19922:
URL: https://github.com/apache/tvm/issues/19922
### Expected behavior
`tvm.compile` should compile a Relax module containing a `reshape` whose
result has a
0-sized dimension (e.g. reshaping an empty intermediate tensor to `(-1,
10)`, which yields
shape `(0, 10)`). A 0-sized dimension is a legal empty-tensor shape: eager
PyTorch,
`torch.export`, and the `from_exported_program` frontend all accept this
model, and eager
returns a valid `(0, 10)` tensor.
### Actual behavior
`tvm.compile` aborts at compile time with:
```
tvm.error.InternalError: Check failed: pb->value != 0 (0 vs. 0) : Divide by
zero
File ".../src/tirx/op/op.cc", line 623, in tvm::floormod(tvm::PrimExpr,
tvm::PrimExpr, tvm::Span)
if (auto ret = arith::TryConstFold<tirx::FloorMod>(a, b)) return
ret.value();
File ".../src/arith/const_fold.h", line 322, in
tvm::arith::TryConstFold(...) [Op = tvm::tirx::FloorMod]
TVM_FFI_ICHECK_NE(pb->value, 0) << "Divide by zero";
```
### Environment
- TVM: 0.25.dev0 (commit `6b4b866d6`)
- PyTorch: 2.12.0+cu130
- Python: 3.12
- OS: Ubuntu x86_64
- Target: `llvm` (CPU)
- Frontend: `tvm.relax.frontend.torch.from_exported_program`
### Steps to reproduce
```python
import torch
import tvm
from tvm import relax
from tvm.relax.frontend.torch import from_exported_program
class M(torch.nn.Module):
def forward(self, x):
return x.reshape(-1)[: x.numel() // 10 * 10].reshape(-1, 10)
m = M()
x = torch.randn(3)
# eager mode
out = m(x)
print("shape:", tuple(out.shape))
# compile mode
ep = torch.export.export(m, (x,))
mod = from_exported_program(ep, keep_params_as_input=True,
unwrap_unit_return_tuple=True)
mod, _ = relax.frontend.detach_params(mod)
tvm.compile(mod, target=tvm.target.Target("llvm"))
```
### Triage
* needs-triage
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]