Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix prune range for empty reference #1304

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
10 changes: 7 additions & 3 deletions k2/python/k2/rnnt_loss.py
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ def get_rnnt_prune_ranges(
)
s_range = S + 1

if is_regular:
if is_regular and S != 0:
assert (
s_range >= 2
), f"""Pruning range for standard RNN-T should be equal to or greater
Expand Down Expand Up @@ -1079,7 +1079,9 @@ def get_hat_logprobs_pruned(
rnnt_type != "modified" or T >= S
), f"Modified transducer requires T >= S, but got T={T} and S={S}"
assert rnnt_type in ["regular", "modified", "constrained"], rnnt_type
assert termination_symbol == 0, f"Termination symbol must be 0, but got {termination_symbol}"
assert (
termination_symbol == 0
), f"Termination symbol must be 0, but got {termination_symbol}"

# For blank symbol, log-prob is log-sigmoid of the score
logp_b = torch.nn.functional.logsigmoid(logits[..., 0])
Expand Down Expand Up @@ -1141,7 +1143,9 @@ def get_hat_logprobs_pruned(
px = torch.cat(
(
px,
torch.full((B, S, 1), float("-inf"), device=px.device, dtype=px.dtype),
torch.full(
(B, S, 1), float("-inf"), device=px.device, dtype=px.dtype
),
),
dim=2,
) # now: [B][S][T+1], index [:,:,T] has -inf..
Expand Down
Loading