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)](https://tvm.apache.org/docs/how_to/deploy_models/deploy_sparse.html)

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](https://discuss.tvm.apache.org/t/frontend-pytorch-convert-rcnn-model-from-torch-vision-model/7525),
 but I still don't know how to solve it.

Any thoughts are welcomed.





---
[Visit 
Topic](https://discuss.tvm.apache.org/t/issue-converting-model-from-pytorch-to-relay-model/11538/1)
 to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click 
here](https://discuss.tvm.apache.org/email/unsubscribe/ec1b881b6465db013cecaf5519a60314f575964d8d829073acde0786894b8d47).

Reply via email to