When would pegasus be able to be exported in ONNX format?
Author: phosfuldev
Pull request: no

It seems like it's not available now, I got this error:
`Error while converting the model: Unrecognized configuration class <class 'transformers.configuration_pegasus.PegasusConfig'> for this kind of AutoModel: AutoModel.
Model type should be one of RetriBertConfig, T5Config, DistilBertConfig, AlbertConfig, CamembertConfig, XLMRobertaConfig, BartConfig, LongformerConfig, RobertaConfig, LayoutLMConfig, SqueezeBertConfig, BertConfig, OpenAIGPTConfig, GPT2Config, MobileBertConfig, TransfoXLConfig, XLNetConfig, FlaubertConfig, FSMTConfig, XLMConfig, CTRLConfig, ElectraConfig, ReformerConfig, FunnelConfig, LxmertConfig, BertGenerationConfig, DebertaConfig, DPRConfig, XLMProphetNetConfig, ProphetNetConfig.`

Which is fair since pegasus is a new addition. Is it something the team plans to do soon? 

Or can someone point me some resources on if there are other ways to export a pre-trained model from huggingface? I'm pretty new to the machine learning thing :p

Thanks all!

Comments:
@patil-suraj has a partial solution that he just posted to the forums. he might be able to extend that to Pegasus/BART 

I'm on it! Will ping here once I get it working.

@phosfuldev, you can refer to this post to see how T5 is exported to onnx
https://discuss.huggingface.co/t/speeding-up-t5-inference/1841

@sshleifer @patil-suraj Thank you!!

Thank you so much @patil-suraj for taking the initiative to export `Pegasus` to onnx. Eagerly waiting for it :) 

Hi @patil-suraj 

Please let us know if you have any update on exporting Pegasus to Onnx format.

Apologies for bothering you. 

Thanks,
Karthik

I was about to open a new issue and then discovered this one. For reference, this is where I got stopped when trying to export a Pegasus model in ONNX format:


I am using a recent clone of the `transformers` repository, cloned on `feb 18 2021`

Unless I am doing something wrong, I think that the `convert_graph_to_onnx.py` script does not currently work with Pegasus models.

I tried it with both `pegasus_large`, and a model that I have fined-tuned, that is based, on `pegasus_large`, with a command like this....

command: `python3 -m transformers.convert_graph_to_onnx --framework pt --model ../models_foreign/pegasus_large  ./onnx/onnx_model.onnx`

and in both cases, I got this console output....

console output
```
====== Converting model to ONNX ======
ONNX opset version set to: 11
Loading pipeline (model: ../models_foreign/pegasus_large, tokenizer: ../models_foreign/pegasus_large)
Some weights of PegasusModel were not initialized from the model checkpoint at ../models_foreign/pegasus_large and are newly initialized: ['model.encoder.embed_positions.weight', 'model.decoder.embed_positions.weight']
You should probably TRAIN this model on a down-stream task to be able to use it for predictions and inference.
Using framework PyTorch: 1.8.0a0+1606899
Error while converting the model: You have to specify either decoder_input_ids or decoder_inputs_embeds
```


This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/master/CONTRIBUTING.md) are likely to be ignored.