espnet2.asr.transducer.rnnt_multi_blank.utils.cpu_utils.cpu_rnnt.CpuRNNT_index
espnet2.asr.transducer.rnnt_multi_blank.utils.cpu_utils.cpu_rnnt.CpuRNNT_index
class espnet2.asr.transducer.rnnt_multi_blank.utils.cpu_utils.cpu_rnnt.CpuRNNT_index(U: int, maxU: int, minibatch: int, alphabet_size: int, batch_first: bool)
Bases: object
Class to compute the CPU-based index for RNNT (Recurrent Neural Network Transducer) operations, mimicking pointer indexing as done in CUDA kernels.
This class facilitates the mapping of target samples to flattened tensors, allowing for efficient access to indices based on the current target sample, the maximum padded target sample length, and the vocabulary size.
U
Length of the current target sample (without padding).
- Type: int
maxU
Maximum length of the padded target samples.
- Type: int
minibatch
Minibatch index.
- Type: int
alphabet_size
Size of the vocabulary including RNNT blank (V + 1).
- Type: int
batch_first
Flag determining if batch index is first or third.
Type: bool
Parameters:
- U (int) – Length of the current target sample (without padding).
- maxU (int) – Max length of the padded target samples.
- minibatch (int) – Minibatch index.
- alphabet_size (int) – Size of the vocabulary including RNNT blank (V + 1).
- batch_first (bool) – Flag to indicate if batch dimension is first (True) or third (False).
__call__(t
int, u: int, v: Optional[int] = None) -> int: Returns the computed index for the given parameters.
Examples
>>> index = CpuRNNT_index(U=10, maxU=15, minibatch=2, alphabet_size=30,
... batch_first=True)
>>> idx = index(t=3, u=5)
>>> print(idx)
53 # Example output based on given parameters
NOTE
The index computation is designed to emulate the memory access patterns of CUDA kernels on the CPU, which is essential for performance in RNNT training and inference.
A placeholder Index computation class that emits the resolved index in a
flattened tensor, mimicing pointer indexing in CUDA kernels on the CPU.
- Parameters:
- U – Length of the current target sample (without padding).
- maxU – Max Length of the padded target samples.
- minibatch – Minibatch index
- alphabet_size – Size of the vocabulary including RNNT blank - V+1.
- batch_first – Bool flag determining if batch index is first or third.