Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion examples/scaffolded_scheduler/scheduling_ddpm_lite.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ def set_timesteps(self, num_inference_steps: int, device: Union[str, torch.devic
"""
self.num_inference_steps = num_inference_steps
step = self.config.num_train_timesteps // num_inference_steps
timesteps = (torch.arange(0, num_inference_steps) * step).round()[::-1].clone()
timesteps = (torch.arange(0, num_inference_steps) * step).round().long()
timesteps = torch.flip(timesteps, dims=[0]) # torch has no [::-1]
self.timesteps = timesteps.to(device) if device is not None else timesteps

def step(
Expand Down
3 changes: 2 additions & 1 deletion src/diffusers/schedulers/scheduling_euler_lite.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ def set_timesteps(self, num_inference_steps: int, device: Union[str, torch.devic
"""
self.num_inference_steps = num_inference_steps
step = self.config.num_train_timesteps // num_inference_steps
timesteps = (torch.arange(0, num_inference_steps) * step).round()[::-1].clone()
timesteps = (torch.arange(0, num_inference_steps) * step).round().long()
timesteps = torch.flip(timesteps, dims=[0]) # torch has no [::-1]
self.timesteps = timesteps.to(device) if device is not None else timesteps

def step(
Expand Down
3 changes: 2 additions & 1 deletion templates/scheduler/scheduling_TEMPLATE.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ def set_timesteps(self, num_inference_steps: int, device: Union[str, torch.devic
"""
self.num_inference_steps = num_inference_steps
step = self.config.num_train_timesteps // num_inference_steps
timesteps = (torch.arange(0, num_inference_steps) * step).round()[::-1].clone()
timesteps = (torch.arange(0, num_inference_steps) * step).round().long()
timesteps = torch.flip(timesteps, dims=[0]) # torch has no [::-1]
self.timesteps = timesteps.to(device) if device is not None else timesteps

def step(
Expand Down
1 change: 1 addition & 0 deletions tests/schedulers/test_scheduling_euler_lite.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ def test_output_type(self):
out = s.step(torch.ones_like(sample), 1, sample, generator=torch.Generator().manual_seed(0))
self.assertTrue(hasattr(out, "prev_sample"))
self.assertEqual(out.prev_sample.shape, sample.shape)
self.assertEqual(out.prev_sample.dtype, sample.dtype)

def test_same_seed_same_output(self):
import torch
Expand Down
Loading