Unverified Commit 60c9634a authored by Yuta Hayashibe's avatar Yuta Hayashibe Committed by GitHub
Browse files

Avoid negative strides for tensors (#717)

* Avoid negative strides for tensors

* Changed not to make torch.tensor

* Removed a needless copy
parent b9eea06e
......@@ -304,12 +304,9 @@ class StableDiffusionImg2ImgPipeline(DiffusionPipeline):
latents = init_latents
t_start = max(num_inference_steps - init_timestep + offset, 0)
timesteps = self.scheduler.timesteps[t_start:]
# Some schedulers like PNDM have timesteps as arrays
# It's more optimzed to move all timesteps to correct device beforehand
timesteps_tensor = torch.tensor(self.scheduler.timesteps[t_start:], device=self.device)
for i, t in enumerate(self.progress_bar(timesteps_tensor)):
for i, t in enumerate(self.progress_bar(timesteps)):
t_index = t_start + i
# expand the latents if we are doing classifier free guidance
......
......@@ -342,12 +342,9 @@ class StableDiffusionInpaintPipeline(DiffusionPipeline):
latents = init_latents
t_start = max(num_inference_steps - init_timestep + offset, 0)
timesteps = self.scheduler.timesteps[t_start:]
# Some schedulers like PNDM have timesteps as arrays
# It's more optimzed to move all timesteps to correct device beforehand
timesteps_tensor = torch.tensor(self.scheduler.timesteps[t_start:], device=self.device)
for i, t in tqdm(enumerate(timesteps_tensor)):
for i, t in tqdm(enumerate(timesteps)):
t_index = t_start + i
# expand the latents if we are doing classifier free guidance
latent_model_input = torch.cat([latents] * 2) if do_classifier_free_guidance else latents
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment