nolanliou commented on issue #6268:
URL: https://github.com/apache/incubator-tvm/issues/6268#issuecomment-675457643


   The above problem solved to modify the model code.
   However, another problem occurred when inferring the type of intermediate 
tensor and there is a `type cast` operator.
   
   sample code to reproduce the error.
   ```
   import torch
   import tvm
   from tvm import relay
   import tvm.contrib.graph_runtime as runtime
   
   def fn(x):
       y = (x != 0).long()
       y = y.to(dtype=torch.float32)
       y = y[:, 0]
       return y
   
   jit = torch.jit.trace(fn, (torch.ones(4, 5, dtype=torch.int64),))
   torch.jit.save(jit, "test.jit")
   
   jit = torch.jit.load("test.jit", map_location=torch.device('cpu'))
   jit.eval()
   
   print(jit(torch.ones(4, 5, dtype=torch.int64)))
   
   batch = 1
   seq_length = 43
   shape_list = [('input', [4, 5])]
   input_types = [('input', 'torch.int64')]
   
   print("==========relay=======")
   #print(jit.code)
   mod, params = relay.frontend.pytorch.from_pytorch(jit,
                                                     shape_list,
                                                     input_types=input_types,  
// Add input types, or input type only could be float32
                                                     default_dtype="float32")
   ```


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