Skip to content

Commit

Permalink
chore: remove obsolete code for torch<2
Browse files Browse the repository at this point in the history
Minimum torch version is 2.1 now.
  • Loading branch information
eginhard committed May 8, 2024
1 parent 865a481 commit 6d563af
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 9 deletions.
6 changes: 1 addition & 5 deletions TTS/tts/layers/glow_tts/glow.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import torch
from packaging.version import Version
from torch import nn
from torch.nn import functional as F

Expand Down Expand Up @@ -90,10 +89,7 @@ def __init__(self, channels, num_splits=4, no_jacobian=False, **kwargs): # pyli
self.no_jacobian = no_jacobian
self.weight_inv = None

if Version(torch.__version__) < Version("1.9"):
w_init = torch.qr(torch.FloatTensor(self.num_splits, self.num_splits).normal_())[0]
else:
w_init = torch.linalg.qr(torch.FloatTensor(self.num_splits, self.num_splits).normal_(), "complete")[0]
w_init = torch.linalg.qr(torch.FloatTensor(self.num_splits, self.num_splits).normal_(), "complete")[0]

if torch.det(w_init) < 0:
w_init[:, 0] = -1 * w_init[:, 0]
Expand Down
4 changes: 0 additions & 4 deletions TTS/tts/layers/xtts/perceiver_encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import torch.nn.functional as F
from einops import rearrange, repeat
from einops.layers.torch import Rearrange
from packaging import version
from torch import einsum, nn


Expand Down Expand Up @@ -44,9 +43,6 @@ def __init__(self, dropout=0.0, causal=False, use_flash=False):
self.register_buffer("mask", None, persistent=False)

self.use_flash = use_flash
assert not (
use_flash and version.parse(torch.__version__) < version.parse("2.0.0")
), "in order to use flash attention, you must be using pytorch 2.0 or above"

# determine efficient attention configs for cuda and cpu
self.config = namedtuple("EfficientAttentionConfig", ["enable_flash", "enable_math", "enable_mem_efficient"])
Expand Down

0 comments on commit 6d563af

Please sign in to comment.