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


   @masahi 
   There are some problems with the type/shape inference when converting the 
PyTorch model.
   
   Sample code to reproduce.
   ```
   import numpy as np
   import torch
   import tvm
   from tvm import relay
   import tvm.contrib.graph_runtime as runtime
   
   def fn(x):
       x /= x.shape[-1]
       return x
   
   jit = torch.jit.trace(fn, (torch.ones(4, 5, dtype=torch.int64),))
   
   inputs = torch.randint(low=0, high=10, size=(4, 5), dtype=torch.float32)
   print(jit(inputs))
   
   
   shape_list = [('input', [4, 5])]
   
   mod, params = relay.frontend.pytorch.from_pytorch(jit,
                                                     shape_list,
                                                     default_dtype="float32")
   
   with tvm.transform.PassContext(opt_level=3):
       json, lib, params = relay.build(mod, target="llvm", params=params)
   
   ctx = tvm.cpu(0)
   inputs = tvm.nd.array(inputs.cpu().numpy().astype(np.int64), ctx)
   runtime = tvm.contrib.graph_runtime.create(json, lib, ctx)
   runtime.set_input(**params)
   runtime.set_input('input', inputs)
   runtime.run()
   tvm_result = runtime.get_output(0).asnumpy()
   print(tvm_result)
   ```


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