File size: 831 Bytes
f233443 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | #!/usr/bin/env fbpython
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import torch
from torchmultimodal.diffusion_labs.transforms.diffusion_transform import (
RandomDiffusionSteps,
)
class DummySchedule:
def sample_steps(self, x):
return x
def sample_noise(self, x):
return x
def q_sample(self, x, noise, t):
return x
def __call__(self, var_name, t, shape):
return torch.ones(shape)
def test_random_diffusion_steps():
transform = RandomDiffusionSteps(DummySchedule())
actual = len(transform({"x": torch.ones(1)}))
expected = 4
assert actual == expected, "Transform not returning correct keys"
|