I try to import ResNet18 PyTorch model to Relax. The error occurs when executing relax.build and the error is:
File "/WORK/Dev/tvm/src/relax/backend/vm/codegen_vm.cc", line 169
TVMError: CodeGenVM cannot handle this intrinsic now:
Op(relax.nn.conv2d)
It hints relax.nn.conv2d cannot handle. But the unittest test_op_nn_convolution.py is passed. So I am puzzled.
Test code:
import numpy as np
import torch.fx as fx
import torchvision.models as models
from tvm.relax.frontend.torch import from_fx
import tvm
from tvm import relax, tir
if __name__ == "__main__":
torch_model = models.resnet18()
# Use FX tracer to trace the PyTorch model.
graph_module = fx.symbolic_trace(torch_model)
# symbolic dimensions
bs = tir.Var("bs", "int64")
input_info = [((bs, 3, 224, 224), "float32")]
# Use the importer to import the PyTorch model to Relax.
mod = from_fx(graph_module, input_info)
# Print out the imported model.
mod.show()
# build and create vm executor
target = tvm.target.Target("llvm", host="llvm")
ex = relax.build(mod, target)
vm = relax.VirtualMachine(ex, tvm.cpu())
# init parameters
params = tvm.relax.testing.nn.init_params(mod)
# run the mlp model on relax vm
data = tvm.nd.array(np.random.rand(1, 3, 224, 224).astype(np.float32))
res = vm["main"](data, *params)
print(res)
Environment
branch: unity
commit 854f2e9
Date: Tue Mar 28 19:28:32 2023 +0300
OS: Linux
I try to import ResNet18 PyTorch model to Relax. The error occurs when executing
relax.buildand the error is:It hints
relax.nn.conv2dcannot handle. But the unittest test_op_nn_convolution.py is passed. So I am puzzled.Test code:
Environment
branch: unity
commit 854f2e9
Date: Tue Mar 28 19:28:32 2023 +0300
OS: Linux