smoothieAI commited on
Commit
e89d2cd
·
verified ·
1 Parent(s): e5616d3

Update pipeline.py

Browse files
Files changed (1) hide show
  1. pipeline.py +6 -6
pipeline.py CHANGED
@@ -1528,13 +1528,13 @@ class AnimateDiffPipeline(DiffusionPipeline, TextualInversionLoaderMixin, IPAdap
1528
  torch.cuda.synchronize() # Synchronize GPU before batch addition
1529
  time_batch_addition_start = time.time()
1530
 
1531
- for z, context_index in enumerate(current_context_indexes):
1532
- # Perform batch addition
1533
- noise_pred_uncond_sum[..., context_index, :, :] += noise_pred_uncond[:, :, z, :, :]
1534
- noise_pred_text_sum[..., context_index, :, :] += noise_pred_text[:, :, z, :, :]
1535
 
1536
- # Batch increment for latent_counter
1537
- latent_counter[context_index] += 1
1538
 
1539
  torch.cuda.synchronize() # Synchronize GPU after batch addition
1540
  time_batch_addition_end = time.time()
 
1528
  torch.cuda.synchronize() # Synchronize GPU before batch addition
1529
  time_batch_addition_start = time.time()
1530
 
1531
+ current_context_tensor = torch.tensor(current_context_indexes, device=latent_counter.device)
1532
+ # Perform batch addition
1533
+ noise_pred_uncond_sum[..., current_context_tensor, :, :] += noise_pred_uncond.transpose(1, 2)
1534
+ noise_pred_text_sum[..., current_context_tensor, :, :] += noise_pred_text.transpose(1, 2)
1535
 
1536
+ # Batch increment for latent_counter
1537
+ latent_counter[current_context_tensor] += 1
1538
 
1539
  torch.cuda.synchronize() # Synchronize GPU after batch addition
1540
  time_batch_addition_end = time.time()