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

Replace _expand_mask with _prepare_4d_attention_mask #604

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lavis/models/blip_diffusion_models/modeling_ctx_clip.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
from transformers.models.clip.modeling_clip import (
CLIPEncoder,
CLIPPreTrainedModel,
_expand_mask,
)
from transformers.modeling_attn_mask_utils import _prepare_4d_attention_mask


class CtxCLIPTextModel(CLIPPreTrainedModel):
Expand Down Expand Up @@ -136,7 +136,7 @@ def forward(
# expand attention_mask
if attention_mask is not None:
# [bsz, seq_len] -> [bsz, 1, tgt_seq_len, src_seq_len]
attention_mask = _expand_mask(attention_mask, hidden_states.dtype)
attention_mask = _prepare_4d_attention_mask(attention_mask, hidden_states.dtype)

encoder_outputs = self.encoder(
inputs_embeds=hidden_states,
Expand Down