scheduling_utils.py 1.26 KB
Newer Older
Patrick von Platen's avatar
up  
Patrick von Platen committed
1
2
3
4
5
6
7
8
9
10
11
12
13
# Copyright 2022 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
14
from dataclasses import dataclass
Patrick von Platen's avatar
Patrick von Platen committed
15

Patrick von Platen's avatar
up  
Patrick von Platen committed
16
17
import torch

Anton Lozhkov's avatar
Anton Lozhkov committed
18
from ..utils import BaseOutput
19

Patrick von Platen's avatar
up  
Patrick von Platen committed
20

Patrick von Platen's avatar
Patrick von Platen committed
21
22
23
SCHEDULER_CONFIG_NAME = "scheduler_config.json"


24
25
26
27
28
29
30
31
32
33
34
35
36
37
@dataclass
class SchedulerOutput(BaseOutput):
    """
    Base class for the scheduler's step function output.

    Args:
        prev_sample (`torch.FloatTensor` of shape `(batch_size, num_channels, height, width)` for images):
            Computed sample (x_{t-1}) of previous timestep. `prev_sample` should be used as next model input in the
            denoising loop.
    """

    prev_sample: torch.FloatTensor


Patrick von Platen's avatar
Patrick von Platen committed
38
class SchedulerMixin:
39
40
41
    """
    Mixin containing common functions for the schedulers.
    """
Patrick von Platen's avatar
Patrick von Platen committed
42
43

    config_name = SCHEDULER_CONFIG_NAME