Skip to content

Commit 794a942

Browse files
author
mirco
committed
fixed some warning with pytorch 1.9
1 parent c8de97c commit 794a942

5 files changed

Lines changed: 18 additions & 14 deletions

File tree

speechbrain/decoders/seq2seq.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,9 @@ def _update_hyp_and_scores(
486486
for index in eos_indices:
487487
# convert to int
488488
index = index.item()
489-
batch_id = index // self.beam_size
489+
batch_id = torch.div(
490+
index, self.beam_size, rounding_mode="floor"
491+
)
490492
if len(hyps_and_scores[batch_id]) == self.beam_size:
491493
continue
492494
hyp = alived_seq[index, :]
@@ -704,7 +706,7 @@ def forward(self, enc_states, wav_len): # noqa: C901
704706

705707
# The index of which beam the current top-K output came from in (t-1) timesteps.
706708
predecessors = (
707-
candidates // vocab_size
709+
torch.div(candidates, vocab_size, rounding_mode="floor")
708710
+ self.beam_offset.unsqueeze(1).expand_as(candidates)
709711
).view(batch_size * self.beam_size)
710712

speechbrain/nnet/CNN.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,14 +1047,14 @@ def get_padding_elem(L_in: int, stride: int, kernel_size: int, dilation: int):
10471047
dilation : int
10481048
"""
10491049
if stride > 1:
1050-
n_steps = math.ceil(((L_in - kernel_size * dilation) / stride) + 1)
1051-
L_out = stride * (n_steps - 1) + kernel_size * dilation
1052-
padding = [kernel_size // 2, kernel_size // 2]
1050+
half_kernel = torch.div(kernel_size, 2, rounding_mode="floor")
1051+
padding = [half_kernel, half_kernel]
10531052

10541053
else:
1055-
L_out = (L_in - dilation * (kernel_size - 1) - 1) // stride + 1
1054+
tot_padding = dilation * (kernel_size - 1)
1055+
half_padding = torch.div(tot_padding, 2, rounding_mode="floor")
10561056

1057-
padding = [(L_in - L_out) // 2, (L_in - L_out) // 2]
1057+
padding = [half_padding, half_padding]
10581058
return padding
10591059

10601060

speechbrain/processing/decomposition.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,15 @@ def gevd(a, b=None):
8686
bsh = f(b)
8787

8888
# Performing the Cholesky decomposition
89-
lsh = torch.cholesky(bsh)
89+
lsh = torch.linalg.cholesky(bsh)
9090
lsh_inv = torch.inverse(lsh)
9191
lsh_inv_T = torch.transpose(lsh_inv, D - 2, D - 1)
9292

9393
# Computing the matrix C
9494
csh = torch.matmul(lsh_inv, torch.matmul(ash, lsh_inv_T))
9595

9696
# Performing the eigenvalue decomposition
97-
es, ysh = torch.symeig(csh, eigenvectors=True)
97+
es, ysh = torch.linalg.eigh(csh, UPLO="U")
9898

9999
# Collecting the eigenvalues
100100
dsh = torch.zeros(
@@ -166,7 +166,7 @@ def svdl(a):
166166
ash_mm_ash_T = torch.matmul(ash, ash_T)
167167

168168
# Finding the eigenvectors and eigenvalues
169-
es, ush = torch.symeig(ash_mm_ash_T, eigenvectors=True)
169+
es, ush = torch.linalg.eigh(ash_mm_ash_T, UPLO="U")
170170

171171
# Collecting the eigenvalues
172172
dsh = torch.zeros(ush.shape, dtype=es.dtype, device=es.device)

speechbrain/processing/diarization.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,8 +357,8 @@ def _graph_connected_component(graph, node_id):
357357
if sparse.issparse(graph):
358358
# speed up row-wise access to boolean connection mask
359359
graph = graph.tocsr()
360-
connected_nodes = np.zeros(n_node, dtype=np.bool)
361-
nodes_to_explore = np.zeros(n_node, dtype=np.bool)
360+
connected_nodes = np.zeros(n_node, dtype=bool)
361+
nodes_to_explore = np.zeros(n_node, dtype=bool)
362362
nodes_to_explore[node_id] = True
363363
for _ in range(n_node):
364364
last_num_component = connected_nodes.sum()

speechbrain/processing/multi_mic.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,7 @@ def _extract_delays(xxs, tdoa_max=None):
768768

769769
# If no tdoa specified, cover the whole frame
770770
if tdoa_max is None:
771-
tdoa_max = n_fft // 2
771+
tdoa_max = torch.div(n_fft, 2, rounding_mode="floor")
772772

773773
# Splitting the GCC-PHAT values to search in the range
774774
slice_1 = xxs[..., 0:tdoa_max, :]
@@ -1496,7 +1496,9 @@ def sphere(levels_count=4):
14961496
(unique_scalar.shape[0], 2), dtype=unique_scalar.dtype
14971497
)
14981498

1499-
unique_values[:, 0] = torch.floor_divide(unique_scalar, index_max + 1)
1499+
unique_values[:, 0] = torch.div(
1500+
unique_scalar, index_max + 1, rounding_mode="floor"
1501+
)
15001502
unique_values[:, 1] = unique_scalar - unique_values[:, 0] * (
15011503
index_max + 1
15021504
)

0 commit comments

Comments
 (0)