The transferred onnx model is much bigger than the origin pytorch model
python -m transformers.onnx --model=facebook/bart-large /home/sysadmin/downlaod/onnx_models/bart-large

Pytorch version: 1.9.0
transformers version: 4.9.1
platform: centos 7
python version: 3.7

The original bart model is aroud 2GB, But the transferred bart-large model is more than 3gb. This could because some shared weights are are duplicated in the onnx model
Hi @leoozy, 

Thanks for bringing this to our attention.

I don't have all the details about the machinery ONNX/ORT are using to export the weights, but you're certainly right about some shared buffers being copied over at multiple places.

May be @tianleiwu from ORT would have some more insights about this specific behaviour? <|||||>@mfuntowicz @tianleiwu I checked the converted bart.onnx model. There is a huge weight called shared.weight, which is the weights of embeding layers (size: seq_length x vocabulary_size)。The encoding and decoding process shared the weights but the shape used in the two processes are different. When encoding, the shape is (vocabulary_size X seq_length). When decoding, the shape is (seq_length X vocabulary size). So, the onnx file saved it duplicatedly because of the different shapes. Models excess 2GB have a lot of limits while being optimized using onnxruntime. <|||||>@leoozy, please try do_constant_folding=False in torch.onnx.export to see whether it could reduce the onnx model size. 

Updated: I tried in my machine, onnx model file size is 1.5 GB, pytorch model is about 1.0 GB. I also verified that removing duplicated weights in onnx model won't help (result is still around 1.5GB).<|||||>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.