Skip to content

Commit 1beb12d

Browse files
committed
Avoid negative strides for tensors
1 parent f1484b8 commit 1beb12d

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_img2img.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,10 @@ def __call__(
284284

285285
# Some schedulers like PNDM have timesteps as arrays
286286
# It's more optimzed to move all timesteps to correct device beforehand
287-
timesteps_tensor = torch.tensor(self.scheduler.timesteps[t_start:], device=self.device)
287+
if torch.is_tensor(self.scheduler.timesteps):
288+
timesteps_tensor = torch.tensor(self.scheduler.timesteps[t_start:], device=self.device)
289+
else:
290+
timesteps_tensor = torch.tensor(self.scheduler.timesteps.copy()[t_start:], device=self.device)
288291

289292
for i, t in enumerate(self.progress_bar(timesteps_tensor)):
290293
t_index = t_start + i

src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_inpaint.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,10 @@ def __call__(
318318

319319
# Some schedulers like PNDM have timesteps as arrays
320320
# It's more optimzed to move all timesteps to correct device beforehand
321-
timesteps_tensor = torch.tensor(self.scheduler.timesteps[t_start:], device=self.device)
321+
if torch.is_tensor(self.scheduler.timesteps):
322+
timesteps_tensor = torch.tensor(self.scheduler.timesteps[t_start:], device=self.device)
323+
else:
324+
timesteps_tensor = torch.tensor(self.scheduler.timesteps.copy()[t_start:], device=self.device)
322325

323326
for i, t in tqdm(enumerate(timesteps_tensor)):
324327
t_index = t_start + i

0 commit comments

Comments
 (0)