espnet2.asr_transducer.encoder.modules.multi_blocks.MultiBlocks
espnet2.asr_transducer.encoder.modules.multi_blocks.MultiBlocks
class espnet2.asr_transducer.encoder.modules.multi_blocks.MultiBlocks(block_list: ~typing.List[~torch.nn.modules.module.Module], output_size: int, norm_class: ~torch.nn.modules.module.Module = <class 'torch.nn.modules.normalization.LayerNorm'>, norm_args: ~typing.Dict | None = None, blockdrop_rate: int = 0.0)
Bases: Module
MultiBlocks definition.
- Parameters:
- block_list – Individual blocks of the encoder architecture.
- output_size – Architecture output size.
- norm_class – Normalization module class.
- norm_args – Normalization module arguments.
- blockdrop_rate – Probability threshold of dropping out each block.
Construct a MultiBlocks object.
chunk_forward(x: Tensor, pos_enc: Tensor, mask: Tensor, left_context: int = 0) → Tensor
Forward each block of the encoder architecture.
- Parameters:
- x – MultiBlocks input sequences. (B, T, D_block_1)
- pos_enc – Positional embedding sequences. (B, 2 * (T - 1), D_att)
- mask – Source mask. (B, T_2)
- left_context – Number of previous frames the attention module can see in current chunk (used by Conformer and Branchformer block).
- Returns: MultiBlocks output sequences. (B, T, D_block_N)
- Return type: x
forward(x: Tensor, pos_enc: Tensor, mask: Tensor, chunk_mask: Tensor | None = None) → Tensor
Forward each block of the encoder architecture.
- Parameters:
- x – MultiBlocks input sequences. (B, T, D_block_1)
- pos_enc – Positional embedding sequences.
- mask – Source mask. (B, T)
- chunk_mask – Chunk mask. (T_2, T_2)
- Returns: Output sequences. (B, T, D_block_N)
- Return type: x
reset_streaming_cache(left_context: int, device: device) → None
Initialize/Reset encoder streaming cache.
- Parameters:
- left_context – Number of previous frames the attention module can see in current chunk (used by Conformer and Branchformer block).
- device – Device to use for cache tensor.