pig-pig-yang opened a new issue, #12469:
URL: https://github.com/apache/tvm/issues/12469

   I tried to convert Pytorch MobilenetV3 to Relay IR. But the converted Relay 
IR is wrong. I tried to convert to ONNX first and then convert to Relay, 
results are still wrong. 
   
   Original structure:
   
![image](https://user-images.githubusercontent.com/65580829/185101766-2d7eaee7-c3e8-4ee3-8ada-f3e5121ce8ff.png)
   
   Converted Relay IR structure:
   
![image](https://user-images.githubusercontent.com/65580829/185101669-40a60c11-414c-47cd-9062-d913053300a1.png)
   
   As shown above, the convolution weights are connected to Mul and the branch 
is connected to conv2D after conversion for every Mul->Conv Node.
   
   The codes are shown below:
   
   ```
   import tvm
   from tvm import te
   import tvm.relay as relay
   from tvm.contrib.download import download_testdata
   import numpy as np
   import os
   
   from tvm.relay.quantize.quantize import QConfig
   
   import torch
   import torchvision
   from torchvision import transforms
   
   from PIL import Image
   from matplotlib import pyplot as plt
   
   import netron
   import onnx
   
   model_name = "mobilenet_v3"
   model = torchvision.models.mobilenet_v3_large(pretrained=True)
   model = model.eval()
   
   x = torch.randn(1, 3, 224, 224)
   saved_path = "./mobilenet_v3.onnx"
   torch.onnx.export(model, x, saved_path)
   
   onnx_model = onnx.load(saved_path)
   
   input_name = "input.1"
   shape_list = {input_name: (1, 3, 224, 224)}
   
   mod, params = relay.frontend.from_onnx(onnx_model, shape_list)
   
   print(mod)
   ```
   Since I am not familiar with the frontend,  I don't know what causes the 
problem.  


-- 
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-unsubscr...@tvm.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to