Make cross-attention check more robust (#1560) · informaticacba/diffusers@5e03692 · GitHub
Skip to content

Commit 5e03692

Browse files
authored
Make cross-attention check more robust (huggingface#1560)
* Make cross-attention check more robust. * Fix copies.
1 parent bea7eb4 commit 5e03692

3 files changed

Lines changed: 10 additions & 4 deletions

File tree

‎src/diffusers/models/unet_2d_blocks.py‎

Lines changed: 3 additions & 0 deletions

‎src/diffusers/models/unet_2d_condition.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ def forward(
377377
# 3. down
378378
down_block_res_samples = (sample,)
379379
for downsample_block in self.down_blocks:
380-
if hasattr(downsample_block, "attentions") and downsample_block.attentions is not None:
380+
if hasattr(downsample_block, "has_cross_attention") and downsample_block.has_cross_attention:
381381
sample, res_samples = downsample_block(
382382
hidden_states=sample,
383383
temb=emb,
@@ -403,7 +403,7 @@ def forward(
403403
if not is_final_block and forward_upsample_size:
404404
upsample_size = down_block_res_samples[-1].shape[2:]
405405

406-
if hasattr(upsample_block, "attentions") and upsample_block.attentions is not None:
406+
if hasattr(upsample_block, "has_cross_attention") and upsample_block.has_cross_attention:
407407
sample = upsample_block(
408408
hidden_states=sample,
409409
temb=emb,

‎src/diffusers/pipelines/versatile_diffusion/modeling_text_unet.py‎

Lines changed: 5 additions & 2 deletions

0 commit comments

Comments
 (0)