You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2021/09/13 16:46:25 UTC
[GitHub] [tvm] gilles-reservoir opened a new issue #8994: [Bug] relay.transform.AnnotateSpans does not work on modules imported from Pytorch
gilles-reservoir opened a new issue #8994:
URL: https://github.com/apache/tvm/issues/8994
### Expected behavior
AnnotateSpans should work on modules imported from Pytorch.
### Actual behavior
It fails, because the PyTorch importer creates variables with "." in their names. AnnotateSpans works by pretty-printing and then re-parsing a module. Unfortunately, the parser (tokenizer?) chokes on variables with "." in the name.
### Environment
Ubuntu LTS, latest TVM main, torch 1.8.0
### Steps to reproduce
```python
class Net(nn.Module):
def __init__(self):
super().__init__()
self.dense = nn.Linear(4, 13)
def forward(self, x):
return self.dense(x)
net = Net()
data = torch.randn(17, 4)
traced = torch.jit.trace(net, data).eval()
mod, params = relay.frontend.from_pytorch(traced, [('x', tuple(data.shape))])
print(mod['main'].astext())
mod = relay.transform.AnnotateSpans()(mod)
```
Output:
```
#[version = "0.0.5"]
fn (%x: Tensor[(17, 4), float32], %dense.weight: Tensor[(13, 4), float32], %dense.bias: Tensor[(13), float32]) {
%0 = transpose(%dense.weight, axes=[1, 0]);
%1 = transpose(%0, axes=[1, 0]);
%2 = nn.dense(%x, %1, units=13);
add(%2, %dense.bias)
}
error: expected a local variable found `.`
--> GeneratedSource:115:48
|
115 | def @main(%x: Tensor[(17, 4), float32], %dense.weight: Tensor[(13, 4), float32], %dense.bias: Tensor[(13), float32]) {
| ^
```
Unfortunately it's not totally trivial to fix this because tuples use "." for element access. Maybe the PyTorch importer / all variable creation should excise "."s from variable names, but I could see that breaking scripts that currently work.
--
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
[GitHub] [tvm] gilles-reservoir commented on issue #8994: [Bug] relay.transform.AnnotateSpans does not work on modules imported from Pytorch
Posted by GitBox <gi...@apache.org>.
gilles-reservoir commented on issue #8994:
URL: https://github.com/apache/tvm/issues/8994#issuecomment-920177473
Thanks so much!
--
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
[GitHub] [tvm] masahi commented on issue #8994: [Bug] relay.transform.AnnotateSpans does not work on modules imported from Pytorch
Posted by GitBox <gi...@apache.org>.
masahi commented on issue #8994:
URL: https://github.com/apache/tvm/issues/8994#issuecomment-918758861
Oh in PT models we can have a variable name like `%features.1.conv.1_bias`. We cannot distinguish '1' there with tuple access...
I'll write a pass to replace "." with "_" in a variable name, and let users optionally run it after PT model import.
--
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
[GitHub] [tvm] masahi commented on issue #8994: [Bug] relay.transform.AnnotateSpans does not work on modules imported from Pytorch
Posted by GitBox <gi...@apache.org>.
masahi commented on issue #8994:
URL: https://github.com/apache/tvm/issues/8994#issuecomment-918743876
There is a comment suggesting "x.y" should be parsed as an identifier ideally:
https://github.com/apache/tvm/blob/2c67d7131bc820481aaaca921f9e76f5709051b3/src/parser/parser.cc#L1547
So we should fix the tokenizer / parser
--
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
[GitHub] [tvm] masahi closed issue #8994: [Bug] relay.transform.AnnotateSpans does not work on modules imported from Pytorch
Posted by GitBox <gi...@apache.org>.
masahi closed issue #8994:
URL: https://github.com/apache/tvm/issues/8994
--
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
[GitHub] [tvm] masahi commented on issue #8994: [Bug] relay.transform.AnnotateSpans does not work on modules imported from Pytorch
Posted by GitBox <gi...@apache.org>.
masahi commented on issue #8994:
URL: https://github.com/apache/tvm/issues/8994#issuecomment-918600398
Thanks I'll take a look.
--
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