Hello TVM developers and community,
I am trying to convert the Transformer-like models such as BERT from different platforms (Tensorflow or PyTorch) to relay models.
For TensorFlow model, I was able to convert them into relay models successfully by referring to this tutorial: Deploy a Hugging Face Pruned Model on CPU — tvm 0.8.dev0 documentation (apache.org)
However, for some models like SqueezeBert. Huggingface only provides PyTorch implementation. I need to convert from pytorch to relay model.
Here are the codes I use (which is very similar to tensorflow tutorial):
model = transformers.SqueezeBertForSequenceClassification(config) shape_dict = {"input_1": (batch_size, s)} traced_script_module = torch.jit.trace(model, np_input, strict=False) mod, params = relay.frontend.from_pytorch(traced_script_module, input_infos=shape_dict)
However, “Error: The following operators are not implemented” would show up:
Traceback (most recent call last): File "TVMBertModel.py", line 187, in <module> mod, params, shape_dict, test_input = pytorch_get_tvm_model(BERT_type, config, sl, bs, np_input) File "TVMBertModel.py", line 85, in pytorch_get_tvm_model mod, params = relay.frontend.from_pytorch( File "/home/hungyangchang/.local/lib/python3.8/site-packages/tvm-0.9.dev32+gecd8a9ce3-py3.8-linux-x86_64.egg/tvm/relay/frontend/pytorch.py", line 3858, in from_pytorch converter.report_missing_conversion(op_names) File "/home/hungyangchang/.local/lib/python3.8/site-packages/tvm-0.9.dev32+gecd8a9ce3-py3.8-linux-x86_64.egg/tvm/relay/frontend/pytorch.py", line 3091, in report_missing_conversion raise NotImplementedError(msg) NotImplementedError: The following operators are not implemented: ['prim::DictConstruct'] free(): invalid pointer Aborted (core dumped)
More info: I have read similar question such as [Frontend][Pytorch] Convert RCNN model from Torch Vision Model - Apache TVM Discuss, but I still don’t know how to solve it.
Any thoughts are welcomed.