select_batch
- Tensor.select_batch(batch: List[int])
Selects a batch of elements along the batch dimension from the original
Tensorobject, and returns a newTensorobject that shares the underlying memory with the originalTensorobject.Both the returned tensor and the original tensor reference the same memory address.
Note
The returned tensor becomes invalid if the original tensor is destroyed. Accessing the returned tensor after the original tensor has been destroyed may result in undefined behavior due to a dangling pointer.
- Parameters:
batch (List[int]) -- A list of batch indices specifying the batch elements to select.
- Returns:
A new object that referencing the selected batch of elements form the original tensor.
- Return type:
- Raises:
RuntimeError -- If the batch selection operation fails.