select_roi
- Tensor.select_roi(roi_start: List[int], shape: List[int])
Selects a Region of Interest (ROI) from the current tensor and returns a new
Tensorobject that shares the underlying memory with the originalTensorobject.This method supports N-dimensional (ND) tensors. The
roi_startandshapeparameters define the region to be extracted.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:
roi_start (List[int]) -- A list of starting indices for the ROI in each dimension. The size must match the number of dimensions of the tensor.
shape (List[int]) -- A list of sizes for the ROI in each dimension. The size must match the number of dimensions of the tensor.
- Returns:
A new Tensor object containing the data from the selected ROI.
- Return type:
- Raises:
RuntimeError -- If the ROI selection operation fails (e.g., out of bounds).