Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding BetterTransformer support for ProphetNet #648

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
Added prophetnet mapping to __init__.py and resolved merge issue
adit299 committed Jan 5, 2023
commit daa425547cd9bb09242f0b8ebffc3747fe048bc1
1 change: 1 addition & 0 deletions optimum/bettertransformer/models/__init__.py
Original file line number Diff line number Diff line change
@@ -59,6 +59,7 @@ class BetterTransformerManager:
"whisper": ("WhisperEncoderLayer", WhisperEncoderLayerBetterTransformer),
"xlm-roberta": ("XLMRobertaLayer", BertLayerBetterTransformer),
"yolos": ("YolosLayer", ViTLayerBetterTransformer),
"prophetnet": ("ProphetNetEncoderLayer", ProphetNetEncoderLayerBetterTransformer)
}

EXCLUDE_FROM_TRANSFORM = {
2 changes: 0 additions & 2 deletions optimum/bettertransformer/models/encoder_models.py
Original file line number Diff line number Diff line change
@@ -1117,8 +1117,6 @@ def __init__(self, layer, config):
)

# Out proj layer

def forward(self, hidden_states, attention_mask, position_bias=None, *_, **__):
self.out_proj_weight = layer.self_attn.out_proj.weight
self.out_proj_bias = layer.self_attn.out_proj.bias