Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,6 @@ def eager_attention_forward(
# seem a bit unusual, but is taken from the original Transformer paper.
attn_weights = nn.functional.dropout(attn_weights, p=dropout, training=module.training)

# Mask heads if we want to
if attention_mask is not None:
attn_weights = attn_weights * attention_mask

attn_output = torch.matmul(attn_weights, value)
attn_output = attn_output.transpose(1, 2).contiguous()

Expand Down
4 changes: 0 additions & 4 deletions src/transformers/models/deit/modeling_deit.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,6 @@ def eager_attention_forward(
# seem a bit unusual, but is taken from the original Transformer paper.
attn_weights = nn.functional.dropout(attn_weights, p=dropout, training=module.training)

# Mask heads if we want to
if attention_mask is not None:
attn_weights = attn_weights * attention_mask

attn_output = torch.matmul(attn_weights, value)
attn_output = attn_output.transpose(1, 2).contiguous()

Expand Down
4 changes: 0 additions & 4 deletions src/transformers/models/dinov2/modeling_dinov2.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,6 @@ def eager_attention_forward(
# seem a bit unusual, but is taken from the original Transformer paper.
attn_weights = nn.functional.dropout(attn_weights, p=dropout, training=module.training)

# Mask heads if we want to
if attention_mask is not None:
attn_weights = attn_weights * attention_mask

attn_output = torch.matmul(attn_weights, value)
attn_output = attn_output.transpose(1, 2).contiguous()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,6 @@ def eager_attention_forward(
# seem a bit unusual, but is taken from the original Transformer paper.
attn_weights = nn.functional.dropout(attn_weights, p=dropout, training=module.training)

# Mask heads if we want to
if attention_mask is not None:
attn_weights = attn_weights * attention_mask

attn_output = torch.matmul(attn_weights, value)
attn_output = attn_output.transpose(1, 2).contiguous()

Expand Down
4 changes: 0 additions & 4 deletions src/transformers/models/dinov3_vit/modeling_dinov3_vit.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,6 @@ def eager_attention_forward(
# seem a bit unusual, but is taken from the original Transformer paper.
attn_weights = nn.functional.dropout(attn_weights, p=dropout, training=module.training)

# Mask heads if we want to
if attention_mask is not None:
attn_weights = attn_weights * attention_mask

attn_output = torch.matmul(attn_weights, value)
attn_output = attn_output.transpose(1, 2).contiguous()

Expand Down
4 changes: 0 additions & 4 deletions src/transformers/models/dpt/modeling_dpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,10 +288,6 @@ def eager_attention_forward(
# seem a bit unusual, but is taken from the original Transformer paper.
attn_weights = nn.functional.dropout(attn_weights, p=dropout, training=module.training)

# Mask heads if we want to
if attention_mask is not None:
attn_weights = attn_weights * attention_mask

attn_output = torch.matmul(attn_weights, value)
attn_output = attn_output.transpose(1, 2).contiguous()

Expand Down
4 changes: 0 additions & 4 deletions src/transformers/models/ijepa/modeling_ijepa.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,6 @@ def eager_attention_forward(
# seem a bit unusual, but is taken from the original Transformer paper.
attn_weights = nn.functional.dropout(attn_weights, p=dropout, training=module.training)

# Mask heads if we want to
if attention_mask is not None:
attn_weights = attn_weights * attention_mask

attn_output = torch.matmul(attn_weights, value)
attn_output = attn_output.transpose(1, 2).contiguous()

Expand Down
4 changes: 0 additions & 4 deletions src/transformers/models/videomae/modeling_videomae.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,6 @@ def eager_attention_forward(
# seem a bit unusual, but is taken from the original Transformer paper.
attn_weights = nn.functional.dropout(attn_weights, p=dropout, training=module.training)

# Mask heads if we want to
if attention_mask is not None:
attn_weights = attn_weights * attention_mask

attn_output = torch.matmul(attn_weights, value)
attn_output = attn_output.transpose(1, 2).contiguous()

Expand Down
4 changes: 0 additions & 4 deletions src/transformers/models/vit/modeling_vit.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,6 @@ def eager_attention_forward(
# seem a bit unusual, but is taken from the original Transformer paper.
attn_weights = nn.functional.dropout(attn_weights, p=dropout, training=module.training)

# Mask heads if we want to
if attention_mask is not None:
attn_weights = attn_weights * attention_mask

attn_output = torch.matmul(attn_weights, value)
attn_output = attn_output.transpose(1, 2).contiguous()

Expand Down
4 changes: 0 additions & 4 deletions src/transformers/models/vit_mae/modeling_vit_mae.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,10 +347,6 @@ def eager_attention_forward(
# seem a bit unusual, but is taken from the original Transformer paper.
attn_weights = nn.functional.dropout(attn_weights, p=dropout, training=module.training)

# Mask heads if we want to
if attention_mask is not None:
attn_weights = attn_weights * attention_mask

attn_output = torch.matmul(attn_weights, value)
attn_output = attn_output.transpose(1, 2).contiguous()

Expand Down
4 changes: 0 additions & 4 deletions src/transformers/models/vit_msn/modeling_vit_msn.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,6 @@ def eager_attention_forward(
# seem a bit unusual, but is taken from the original Transformer paper.
attn_weights = nn.functional.dropout(attn_weights, p=dropout, training=module.training)

# Mask heads if we want to
if attention_mask is not None:
attn_weights = attn_weights * attention_mask

attn_output = torch.matmul(attn_weights, value)
attn_output = attn_output.transpose(1, 2).contiguous()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,6 @@ def eager_attention_forward(
# seem a bit unusual, but is taken from the original Transformer paper.
attn_weights = nn.functional.dropout(attn_weights, p=dropout, training=module.training)

# Mask heads if we want to
if attention_mask is not None:
attn_weights = attn_weights * attention_mask

attn_output = torch.matmul(attn_weights, value)
attn_output = attn_output.transpose(1, 2).contiguous()

Expand Down
4 changes: 0 additions & 4 deletions src/transformers/models/vivit/modeling_vivit.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,6 @@ def eager_attention_forward(
# seem a bit unusual, but is taken from the original Transformer paper.
attn_weights = nn.functional.dropout(attn_weights, p=dropout, training=module.training)

# Mask heads if we want to
if attention_mask is not None:
attn_weights = attn_weights * attention_mask

attn_output = torch.matmul(attn_weights, value)
attn_output = attn_output.transpose(1, 2).contiguous()

Expand Down
4 changes: 0 additions & 4 deletions src/transformers/models/vjepa2/modeling_vjepa2.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,6 @@ def eager_attention_forward(
# seem a bit unusual, but is taken from the original Transformer paper.
attn_weights = nn.functional.dropout(attn_weights, p=dropout, training=module.training)

# Mask heads if we want to
if attention_mask is not None:
attn_weights = attn_weights * attention_mask

attn_output = torch.matmul(attn_weights, value)
attn_output = attn_output.transpose(1, 2).contiguous()

Expand Down
4 changes: 0 additions & 4 deletions src/transformers/models/yolos/modeling_yolos.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,6 @@ def eager_attention_forward(
# seem a bit unusual, but is taken from the original Transformer paper.
attn_weights = nn.functional.dropout(attn_weights, p=dropout, training=module.training)

# Mask heads if we want to
if attention_mask is not None:
attn_weights = attn_weights * attention_mask

attn_output = torch.matmul(attn_weights, value)
attn_output = attn_output.transpose(1, 2).contiguous()

Expand Down