You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by "eaten-cake (via GitHub)" <gi...@apache.org> on 2025/05/19 07:19:40 UTC
[I] [Bug][Relax][Frontend] Extra unused tensor after torch.unbind conversion via from_exported_program [tvm]
eaten-cake opened a new issue, #17989:
URL: https://github.com/apache/tvm/issues/17989
After converting the torch.unbind operation using tvm.relax.frontend.torch.from_exported_program, the result, which should have been split into two tensors, was instead split into three. Furthermore, one of these resulting tensors has a dimension of size 0. This led to an error when running on CUDA. The specific Python code is as follows:
```python
import tvm
from tvm import dlight as dl
from tvm.relax.frontend.torch import from_exported_program
import torch
class Unbind(torch.nn.Module):
def forward(self, x):
return torch.unbind(x, dim=0)
model = Unbind()
x = torch.randn(2, 3, 4)
exported_program = torch.export.export(model, (x,))
mod = from_exported_program(exported_program)
dev = tvm.cuda(0)
target = tvm.target.Target.from_device(dev)
with target:
mod = tvm.relax.transform.LegalizeOps()(mod)
mod = dl.ApplyDefaultSchedule(
dl.gpu.Fallback(),
)(mod)
mod.show()
ex = tvm.relax.build(mod, target)
x_tvm = tvm.nd.from_dlpack(x)
vm = tvm.relax.VirtualMachine(ex, dev)
out = vm["main"](x_tvm)
print(out)
```
The TIR generated in this way has the following structure:
```python
for ax0_ax1_ax2_fused_0 in T.thread_binding(T.int64(0), thread="blockIdx.x"):
for ax0_ax1_ax2_fused_1 in T.thread_binding(T.int64(1024), thread="threadIdx.x"):
```
--
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-unsubscribe@tvm.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Bug][Relax][Frontend] Extra unused tensor after torch.unbind conversion via from_exported_program [tvm]
Posted by "eaten-cake (via GitHub)" <gi...@apache.org>.
eaten-cake commented on issue #17989:
URL: https://github.com/apache/tvm/issues/17989#issuecomment-2889903708
Sorry, the reproduction code above is incorrect. Here's the corrected one:
```python
import tvm
from tvm import dlight as dl
from tvm.relax.frontend.torch import from_exported_program
import torch
class Unbind(torch.nn.Module):
def forward(self, x):
return torch.unbind(x, dim=0)
model = Unbind()
x = torch.randn(2, 3, 4)
exported_program = torch.export.export(model, (x,))
mod = from_exported_program(exported_program)
dev = tvm.cuda(0)
target = tvm.target.Target.from_device(dev)
with target:
mod = tvm.relax.transform.LegalizeOps()(mod)
mod = dl.ApplyDefaultSchedule(
dl.gpu.Fallback(),
)(mod)
mod.show()
ex = tvm.relax.build(mod, target)
x_tvm = tvm.nd.from_dlpack(x)
x_tvm = x_tvm.copyto(dev)
vm = tvm.relax.VirtualMachine(ex, dev)
out = vm["main"](x_tvm)
print(out)
```
--
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-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Bug][Relax][Frontend] Extra unused tensor after torch.unbind conversion via from_exported_program [tvm]
Posted by "yongwww (via GitHub)" <gi...@apache.org>.
yongwww commented on issue #17989:
URL: https://github.com/apache/tvm/issues/17989#issuecomment-2892686549
closed as [#17990](https://github.com/apache/tvm/pull/17990) was landed
--
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-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Bug][Relax][Frontend] Extra unused tensor after torch.unbind conversion via from_exported_program [tvm]
Posted by "yongwww (via GitHub)" <gi...@apache.org>.
yongwww closed issue #17989: [Bug][Relax][Frontend] Extra unused tensor after torch.unbind conversion via from_exported_program
URL: https://github.com/apache/tvm/issues/17989
--
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-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org