Skip to content

Commit

Permalink
Cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
comfyanonymous committed Feb 11, 2025
1 parent b124256 commit d9f0fcd
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions comfy/clip_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,7 @@ def forward(self, input_tokens, attention_mask=None, intermediate_output=None, f
mask = 1.0 - attention_mask.to(x.dtype).reshape((attention_mask.shape[0], 1, -1, attention_mask.shape[-1])).expand(attention_mask.shape[0], 1, attention_mask.shape[-1], attention_mask.shape[-1])
mask = mask.masked_fill(mask.to(torch.bool), -torch.finfo(x.dtype).max)

if comfy.model_management.is_directml_enabled():
causal_mask = torch.full((x.shape[1], x.shape[1]), -torch.finfo(x.dtype).max, dtype=x.dtype, device=x.device).triu_(1)
else:
causal_mask = torch.empty(x.shape[1], x.shape[1], dtype=x.dtype, device=x.device).fill_(float("-inf")).triu_(1)
causal_mask = torch.full((x.shape[1], x.shape[1]), -torch.finfo(x.dtype).max, dtype=x.dtype, device=x.device).triu_(1)

if mask is not None:
mask += causal_mask
Expand Down

0 comments on commit d9f0fcd

Please sign in to comment.