Skip to content
Closed
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
12 changes: 3 additions & 9 deletions src/transformers/models/univnet/modeling_univnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

from ...modeling_outputs import ModelOutput
from ...modeling_utils import PreTrainedModel
from ...utils import auto_docstring, logging
from ...utils import auto_docstring, can_return_tuple, logging
from .configuration_univnet import UnivNetConfig


Expand Down Expand Up @@ -467,16 +467,16 @@ def __init__(self, config: UnivNetConfig):
# Initialize weights and apply final processing
self.post_init()

@can_return_tuple
@auto_docstring
def forward(
self,
input_features: torch.FloatTensor,
noise_sequence: torch.FloatTensor | None = None,
padding_mask: torch.FloatTensor | None = None,
generator: torch.Generator | None = None,
return_dict: bool | None = None,
**kwargs,
) -> tuple[torch.FloatTensor] | UnivNetModelOutput:
) -> UnivNetModelOutput:
r"""
noise_sequence (`torch.FloatTensor`, *optional*):
Tensor containing a noise sequence of standard Gaussian noise. Can be batched and of shape `(batch_size,
Expand Down Expand Up @@ -516,8 +516,6 @@ def forward(
[1, 140288]
```
"""
return_dict = return_dict if return_dict is not None else self.config.use_return_dict

# Resolve batch sizes for noise_sequence and spectrogram
spectrogram_batched = input_features.dim() == 3
if not spectrogram_batched:
Expand Down Expand Up @@ -582,10 +580,6 @@ def forward(
# Padding is always contiguous and added on the right
waveform_lengths = torch.sum(padding_mask, dim=1)

if not return_dict:
outputs = (waveform, waveform_lengths)
return outputs

return UnivNetModelOutput(
waveforms=waveform,
waveform_lengths=waveform_lengths,
Expand Down