I’m using tvm on Windows x64. Running the original codes to check the installation:
import tvm
from tvm import relay
import numpy as np
from tvm.contrib.download import download_testdata
# PyTorch imports
import torch
import torchvision
import time
model_name = "resnet18"
model = getattr(torchvision.models, model_name)(pretrained=True)
model = model.eval()
# We grab the TorchScripted model via tracing
input_shape = [1, 3, 224, 224]
input_data = torch.randn(input_shape)
scripted_model = torch.jit.trace(model, input_data).eval()
from PIL import Image
img_url = "https://github.com/dmlc/mxnet.js/blob/main/data/cat.png?raw=true"
img_path = download_testdata(img_url, "cat.png", module="data")
img = Image.open(img_path).resize((224, 224))
# Preprocess the image and convert to tensor
from torchvision import transforms
my_preprocess = transforms.Compose(
[
transforms.Resize(256),
transforms.CenterCrop(224),
transforms.ToTensor(),
transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),
]
)
img = my_preprocess(img)
img = np.expand_dims(img, 0)
input_name = "input0"
shape_list = [(input_name, img.shape)]
func, params = relay.frontend.from_pytorch(scripted_model, shape_list)
When running to the final statement, func, params = relay.frontend.from_pytorch(scripted_model, shape_list), an error accurs:
file:1:1: parse error: expected text format semantic version, found a Token(span=Span(SourceName(D:\myTVM\venv\lib\site-packages\tvm\relay\std/prelude.rly, 000002E9033840F0), 1, 1, 1, 2), token_type=EndOfFile, data=(nullptr))you can annotate it as #[version = "0.0.5"]
What does this mean, how to slove the error?