l1nkr opened a new pull request, #13537:
URL: https://github.com/apache/tvm/pull/13537
Increase the speed of graph converted.
When converting each operator, you need to get convert_map again, which will
affect the performance
The same problem also appears in other frameworks. If you think this is
correct, I will repair the same problems in other frameworks.
test script
```python
from time import time
import onnx
import tvm.relay as relay
import tvm
import time
import numpy as np
from tvm.contrib.download import download_testdata
from PIL import Image
def get_img():
img_url = "https://s3.amazonaws.com/model-server/inputs/kitten.jpg"
img_path = download_testdata(img_url, "imagenet_cat.png", module="data")
# Resize it to 224x224
resized_image = Image.open(img_path).resize((224, 224))
img_data = np.asarray(resized_image).astype("float32")
# Our input image is in HWC layout while ONNX expects CHW input, so
convert the array
img_data = np.transpose(img_data, (2, 0, 1))
# Normalize according to the ImageNet input specification
imagenet_mean = np.array([0.485, 0.456, 0.406]).reshape((3, 1, 1))
imagenet_stddev = np.array([0.229, 0.224, 0.225]).reshape((3, 1, 1))
norm_img_data = (img_data / 255 - imagenet_mean) / imagenet_stddev
# Add the batch dimension, as we are expecting 4-dimensional input: NCHW.
img_data = np.expand_dims(norm_img_data, axis=0)
return img_data
onnx_model = onnx.load("resnet50-v2-7.onnx")
np.random.seed(0)
img_data = get_img()
target = "llvm"
input_name = "data"
shape_dict = {input_name: img_data.shape}
start = time.time()
relay.frontend.from_onnx(onnx_model, shape_dict)
end = time.time()
print(end-start)
```
result
```
before
3.96
```
```
now
3.58
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]