Skip to content

Commit

Permalink
Remove Longformers from ONNX-supported models (#15273)
Browse files Browse the repository at this point in the history
  • Loading branch information
lewtun authored Feb 7, 2022
1 parent 7a1412e commit 6775b21
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 32 deletions.
3 changes: 1 addition & 2 deletions docs/source/serialization.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ and are designed to be easily extendable to other architectures.

Ready-made configurations include the following architectures:

<!--This table is automatically generated by make style, do not fill manually!-->
<!--This table is automatically generated by `make fix-copies`, do not fill manually!-->

- ALBERT
- BART
Expand All @@ -53,7 +53,6 @@ Ready-made configurations include the following architectures:
- GPT Neo
- I-BERT
- LayoutLM
- Longformer
- Marian
- mBART
- OpenAI GPT-2
Expand Down
19 changes: 1 addition & 18 deletions src/transformers/models/longformer/configuration_longformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
""" Longformer configuration"""
from collections import OrderedDict
from typing import List, Mapping, Union
from typing import List, Union

from ...onnx import OnnxConfig
from ...utils import logging
from ..roberta.configuration_roberta import RobertaConfig

Expand Down Expand Up @@ -69,18 +67,3 @@ class LongformerConfig(RobertaConfig):
def __init__(self, attention_window: Union[List[int], int] = 512, sep_token_id: int = 2, **kwargs):
super().__init__(sep_token_id=sep_token_id, **kwargs)
self.attention_window = attention_window


class LongformerOnnxConfig(OnnxConfig):
@property
def inputs(self) -> Mapping[str, Mapping[int, str]]:
return OrderedDict(
[
("input_ids", {0: "batch", 1: "sequence"}),
("attention_mask", {0: "batch", 1: "sequence"}),
]
)

@property
def outputs(self) -> Mapping[str, Mapping[int, str]]:
return OrderedDict([("last_hidden_state", {0: "batch", 1: "sequence"}), ("pooler_output", {0: "batch"})])
10 changes: 0 additions & 10 deletions src/transformers/onnx/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from ..models.gpt_neo import GPTNeoOnnxConfig
from ..models.ibert import IBertOnnxConfig
from ..models.layoutlm import LayoutLMOnnxConfig
from ..models.longformer import LongformerOnnxConfig
from ..models.marian import MarianOnnxConfig
from ..models.mbart import MBartOnnxConfig
from ..models.roberta import RobertaOnnxConfig
Expand Down Expand Up @@ -154,15 +153,6 @@ class FeaturesManager:
"question-answering",
onnx_config_cls=DistilBertOnnxConfig,
),
"longformer": supported_features_mapping(
"default",
"masked-lm",
"sequence-classification",
# "multiple-choice",
"token-classification",
"question-answering",
onnx_config_cls=LongformerOnnxConfig,
),
"marian": supported_features_mapping(
"default",
"default-with-past",
Expand Down
1 change: 0 additions & 1 deletion tests/test_onnx_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ def test_values_override(self):
("ibert", "kssteven/ibert-roberta-base"),
("camembert", "camembert-base"),
("distilbert", "distilbert-base-cased"),
# ("longFormer", "longformer-base-4096"),
("roberta", "roberta-base"),
("xlm-roberta", "xlm-roberta-base"),
("layoutlm", "microsoft/layoutlm-base-uncased"),
Expand Down
2 changes: 1 addition & 1 deletion utils/check_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def check_onnx_model_list(overwrite=False):
"""Check the model list in the serialization.mdx is consistent with the state of the lib and maybe `overwrite`."""
current_list, start_index, end_index, lines = _find_text_in_file(
filename=os.path.join(PATH_TO_DOCS, "serialization.mdx"),
start_prompt="<!--This table is automatically generated by make style, do not fill manually!-->",
start_prompt="<!--This table is automatically generated by `make fix-copies`, do not fill manually!-->",
end_prompt="The ONNX conversion is supported for the PyTorch versions of the models.",
)
new_list = get_onnx_model_list()
Expand Down

0 comments on commit 6775b21

Please sign in to comment.