espnet2.asr.transducer.rnnt_multi_blank.utils.rnnt_helper.copy_data_1d
Less than 1 minute
espnet2.asr.transducer.rnnt_multi_blank.utils.rnnt_helper.copy_data_1d
espnet2.asr.transducer.rnnt_multi_blank.utils.rnnt_helper.copy_data_1d(source: Tensor, dest: Tensor, idx: int)
Copies a single element from a source tensor to a destination tensor at the specified index.
This function is intended for use in CUDA kernels to facilitate data manipulation between tensors. It assumes that both source and dest are 1-dimensional tensors and that the provided index is within the bounds of these tensors.
- Parameters:
- source (torch.Tensor) – The source tensor from which to copy data. It must be a 1-dimensional tensor.
- dest (torch.Tensor) – The destination tensor where data will be copied. It must also be a 1-dimensional tensor.
- idx (int) – The index at which to copy the data from the source tensor to the destination tensor.
Examples
>>> import torch
>>> source_tensor = torch.tensor([1.0, 2.0, 3.0])
>>> dest_tensor = torch.zeros(3)
>>> copy_data_1d(source_tensor, dest_tensor, 1)
>>> print(dest_tensor) # Output: tensor([0.0, 2.0, 0.0])
NOTE
This function should be called within a CUDA kernel and is not intended for direct invocation in Python code.