huggingface / transformers

🤗 Transformers: State-of-the-art Machine Learning for Pytorch, TensorFlow, and JAX.
https://huggingface.co/transformers
Apache License 2.0
135.05k stars 27.02k forks source link

Update modeling_longformer.py so it can be converted to onnx format using Pytorch. #33694

Open xiaowuhu opened 1 month ago

xiaowuhu commented 1 month ago

What does this PR do?

In longformer model, the original 'is_global_attn=None' can works, but when using torch.onnx.export() it will be failed when meet the below line if is_global_attn: So I need to change it to explicitly checking like 'if is_global_attn == True:', also set the default value as False in signature 'is_global_attn=False'.

Before submitting

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag members/contributors who may be interested in your PR.