apivovarov opened a new issue #7546:
URL: https://github.com/apache/tvm/issues/7546


   `torch.slice` works fine for fixed ranges (e.g. a[0:2]). If instead of 
particular number I use Var for Length (just for Length) (e.g. a[0, L] then 
`from_pytorch` fails.
   
   The code to reproduce the issue:
   ```
   import torch
   import tvm
   from tvm import relay
   import numpy as np
           
   class Net(torch.nn.Module):
       def __init__(self):
           super(Net, self).__init__()
       def forward(self, values, length):
           return values[0:length]
   
   
   net = Net()
   a = torch.tensor([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
   len = torch.tensor(2)
   net(a, len)
   
   traced_net = torch.jit.trace(net, (a, len))
   
   ctx = tvm.cpu(0)
   target = 'llvm'
   
   shape_list = [("input0", [3,3]),("input1", []),]
   mod, params = relay.frontend.from_pytorch(traced_net, shape_list)
   ```
   
   Error:
   ```
   >>> mod, params = relay.frontend.from_pytorch(traced_net, shape_list)
   Traceback (most recent call last):
     File "<stdin>", line 1, in <module>
     File "/Users/pivovaa/workspace/tvm/python/tvm/relay/frontend/pytorch.py", 
line 3180, in from_pytorch
       ret = converter.convert_operators(_get_operator_nodes(graph.nodes()), 
outputs, ret_name)[0]
     File "/Users/pivovaa/workspace/tvm/python/tvm/relay/frontend/pytorch.py", 
line 2601, in convert_operators
       relay_out = relay_op(
     File "/Users/pivovaa/workspace/tvm/python/tvm/relay/frontend/pytorch.py", 
line 403, in slice
       if target_begin == 0 and target_end >= index_size_limit and stride == 1:
     File "/Users/pivovaa/workspace/tvm/python/tvm/relay/expr.py", line 84, in 
__ge__
       raise TypeError('convert "%s" with `const` first' % str(other))
   TypeError: convert "9223372036854775807" with `const` first
   ```
   @masahi 


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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to