Skip to content

Commit 2aba697

Browse files
committed
Simplifies boolean mask negation logic
Replaces `== False` comparison with the more idiomatic `~` operator for boolean negation, improving code readability and following Python best practices.
1 parent b238dd0 commit 2aba697

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

flash_dmattn/integrations/modeling_flash_dynamic_mask_attention_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def _flash_dynamic_mask_attention_forward(
101101
)
102102
attention_mask = torch.zeros_like(attention_bias, dtype=torch.bool, device=attention_bias.device)
103103
attention_mask = attention_mask.scatter(-1, topk_indices, topk_values != min_dtype)
104-
attention_bias = attention_bias.masked_fill(attention_mask == False, min_dtype)
104+
attention_bias = attention_bias.masked_fill(~attention_mask, min_dtype)
105105

106106
out = flash_fn(
107107
query_states, key_states, value_states, attn_mask=attention_mask, attn_bias=attention_bias, scale=softmax_scale, is_causal=is_causal

0 commit comments

Comments
 (0)