@@ -173,34 +173,6 @@ def test_step_shape(self):
173173 self .assertEqual (output_0 .shape , sample .shape )
174174 self .assertEqual (output_0 .shape , output_1 .shape )
175175
176- # def test_pytorch_equal_numpy(self):
177- # kwargs = dict(self.forward_default_kwargs)
178-
179- # num_inference_steps = kwargs.pop("num_inference_steps", None)
180-
181- # for scheduler_class in self.scheduler_classes:
182- # sample_pt = self.dummy_sample
183- # residual_pt = 0.1 * sample_pt
184-
185- # sample = sample_pt.numpy()
186- # residual = 0.1 * sample
187-
188- # scheduler_config = self.get_scheduler_config()
189- # scheduler = scheduler_class(tensor_format="np", **scheduler_config)
190-
191- # scheduler_pt = scheduler_class(tensor_format="pt", **scheduler_config)
192-
193- # if num_inference_steps is not None and hasattr(scheduler, "set_timesteps"):
194- # scheduler.set_timesteps(num_inference_steps)
195- # scheduler_pt.set_timesteps(num_inference_steps)
196- # elif num_inference_steps is not None and not hasattr(scheduler, "set_timesteps"):
197- # kwargs["num_inference_steps"] = num_inference_steps
198-
199- # output = scheduler.step(residual, 1, sample, **kwargs).prev_sample
200- # output_pt = scheduler_pt.step(residual_pt, 1, sample_pt, **kwargs).prev_sample
201-
202- # assert np.sum(np.abs(output - output_pt.numpy())) < 1e-4, "Scheduler outputs are not identical"
203-
204176 def test_scheduler_outputs_equivalence (self ):
205177 def set_nan_tensor_to_zero (t ):
206178 t [t != t ] = 0
@@ -304,10 +276,6 @@ def test_variance(self):
304276 assert torch .sum (torch .abs (scheduler ._get_variance (487 ) - 0.00979 )) < 1e-5
305277 assert torch .sum (torch .abs (scheduler ._get_variance (999 ) - 0.02 )) < 1e-5
306278
307- # TODO Make DDPM Numpy compatible
308- def test_pytorch_equal_numpy (self ):
309- pass
310-
311279 def test_full_loop_no_noise (self ):
312280 scheduler_class = self .scheduler_classes [0 ]
313281 scheduler_config = self .get_scheduler_config ()
@@ -555,72 +523,6 @@ def full_loop(self, **config):
555523
556524 return sample
557525
558- # def test_pytorch_equal_numpy(self):
559- # kwargs = dict(self.forward_default_kwargs)
560- # num_inference_steps = kwargs.pop("num_inference_steps", None)
561-
562- # for scheduler_class in self.scheduler_classes:
563- # sample_pt = self.dummy_sample
564- # residual_pt = 0.1 * sample_pt
565- # dummy_past_residuals_pt = [residual_pt + 0.2, residual_pt + 0.15, residual_pt + 0.1, residual_pt + 0.05]
566-
567- # sample = sample_pt.numpy()
568- # residual = 0.1 * sample
569- # dummy_past_residuals = [residual + 0.2, residual + 0.15, residual + 0.1, residual + 0.05]
570-
571- # scheduler_config = self.get_scheduler_config()
572- # scheduler = scheduler_class(tensor_format="np", **scheduler_config)
573-
574- # scheduler_pt = scheduler_class(tensor_format="pt", **scheduler_config)
575-
576- # if num_inference_steps is not None and hasattr(scheduler, "set_timesteps"):
577- # scheduler.set_timesteps(num_inference_steps)
578- # scheduler_pt.set_timesteps(num_inference_steps)
579- # elif num_inference_steps is not None and not hasattr(scheduler, "set_timesteps"):
580- # kwargs["num_inference_steps"] = num_inference_steps
581-
582- # # copy over dummy past residuals (must be done after set_timesteps)
583- # scheduler.ets = dummy_past_residuals[:]
584- # scheduler_pt.ets = dummy_past_residuals_pt[:]
585-
586- # output = scheduler.step_prk(residual, 1, sample, **kwargs).prev_sample
587- # output_pt = scheduler_pt.step_prk(residual_pt, 1, sample_pt, **kwargs).prev_sample
588- # assert np.sum(np.abs(output - output_pt.numpy())) < 1e-4, "Scheduler outputs are not identical"
589-
590- # output = scheduler.step_plms(residual, 1, sample, **kwargs).prev_sample
591- # output_pt = scheduler_pt.step_plms(residual_pt, 1, sample_pt, **kwargs).prev_sample
592-
593- # assert np.sum(np.abs(output - output_pt.numpy())) < 1e-4, "Scheduler outputs are not identical"
594-
595- # def test_set_format(self):
596- # kwargs = dict(self.forward_default_kwargs)
597- # num_inference_steps = kwargs.pop("num_inference_steps", None)
598-
599- # for scheduler_class in self.scheduler_classes:
600- # scheduler_config = self.get_scheduler_config()
601- # scheduler = scheduler_class(tensor_format="np", **scheduler_config)
602- # scheduler_pt = scheduler_class(tensor_format="pt", **scheduler_config)
603-
604- # if num_inference_steps is not None and hasattr(scheduler, "set_timesteps"):
605- # scheduler.set_timesteps(num_inference_steps)
606- # scheduler_pt.set_timesteps(num_inference_steps)
607-
608- # for key, value in vars(scheduler).items():
609- # # we only allow `ets` attr to be a list
610- # assert not isinstance(value, list) or key in [
611- # "ets"
612- # ], f"Scheduler is not correctly set to np format, the attribute {key} is {type(value)}"
613-
614- # # check if `scheduler.set_format` does convert correctly attrs to pt format
615- # for key, value in vars(scheduler_pt).items():
616- # # we only allow `ets` attr to be a list
617- # assert not isinstance(value, list) or key in [
618- # "ets"
619- # ], f"Scheduler is not correctly set to pt format, the attribute {key} is {type(value)}"
620- # assert not isinstance(
621- # value, np.ndarray
622- # ), f"Scheduler is not correctly set to pt format, the attribute {key} is {type(value)}"
623-
624526 def test_step_shape (self ):
625527 kwargs = dict (self .forward_default_kwargs )
626528
@@ -953,28 +855,6 @@ def test_time_indices(self):
953855 for t in [0 , 500 , 800 ]:
954856 self .check_over_forward (time_step = t )
955857
956- # def test_pytorch_equal_numpy(self):
957- # for scheduler_class in self.scheduler_classes:
958- # sample_pt = self.dummy_sample
959- # residual_pt = 0.1 * sample_pt
960-
961- # sample = sample_pt.numpy()
962- # residual = 0.1 * sample
963-
964- # scheduler_config = self.get_scheduler_config()
965- # scheduler_config["tensor_format"] = "np"
966- # scheduler = scheduler_class(**scheduler_config)
967-
968- # scheduler_config["tensor_format"] = "pt"
969- # scheduler_pt = scheduler_class(**scheduler_config)
970-
971- # scheduler.set_timesteps(self.num_inference_steps)
972- # scheduler_pt.set_timesteps(self.num_inference_steps)
973-
974- # output = scheduler.step(residual, 1, sample).prev_sample
975- # output_pt = scheduler_pt.step(residual_pt, 1, sample_pt).prev_sample
976- # assert np.sum(np.abs(output - output_pt.numpy())) < 1e-4, "Scheduler outputs are not identical"
977-
978858 def test_full_loop_no_noise (self ):
979859 scheduler_class = self .scheduler_classes [0 ]
980860 scheduler_config = self .get_scheduler_config ()
0 commit comments