espnet2.asr.transducer.rnnt_multi_blank.utils.rnnt_helper.compute_costs_data
Less than 1 minute
espnet2.asr.transducer.rnnt_multi_blank.utils.rnnt_helper.compute_costs_data
espnet2.asr.transducer.rnnt_multi_blank.utils.rnnt_helper.compute_costs_data(source: Tensor, dest: Tensor, fastemit_lambda: float)
Compute the costs for the RNN Transducer model.
This CUDA kernel computes the costs for the RNN Transducer model by copying data from the source tensor to the destination tensor, modifying the destination values based on a given fastemit_lambda. The computed costs are the negative values of the source tensor scaled by the factor (1 + fastemit_lambda).
- Parameters:
- source (torch.Tensor) – The input tensor containing source values.
- dest (torch.Tensor) – The output tensor where computed costs will be stored.
- fastemit_lambda (float) – A scaling factor that influences the cost computation.
- Returns: This function modifies the dest tensor in place.
- Return type: None
Examples
>>> source_tensor = torch.tensor([1.0, 2.0, 3.0], device='cuda')
>>> dest_tensor = torch.empty_like(source_tensor)
>>> fastemit_lambda = 0.5
>>> compute_costs_data(source_tensor, dest_tensor, fastemit_lambda)
>>> print(dest_tensor) # Should output modified values based on source
NOTE
This function is designed to run on a CUDA device. Ensure that the input tensors are on the GPU.