pub struct TensorOwnedView { /* private fields */ }Expand description
Owned lazy tensor view over a shared base tensor.
This stores only ownership of the base allocation plus logical layout
metadata. Borrow it as TensorRead for kernels that understand strides,
or materialize it explicitly with TensorOwnedView::to_tensor.
Implementations§
Source§impl TensorOwnedView
impl TensorOwnedView
Sourcepub fn from_tensor(base: Arc<Tensor>) -> Self
pub fn from_tensor(base: Arc<Tensor>) -> Self
Create an owned view preserving the base tensor’s current layout.
Sourcepub fn from_parts(
base: Arc<Tensor>,
shape: Vec<usize>,
strides: Vec<isize>,
offset: isize,
) -> Result<Self>
pub fn from_parts( base: Arc<Tensor>, shape: Vec<usize>, strides: Vec<isize>, offset: isize, ) -> Result<Self>
Create an owned view with explicit layout metadata.
pub fn dtype(&self) -> DType
pub fn shape(&self) -> &[usize]
pub fn strides(&self) -> &[isize]
pub fn offset(&self) -> isize
pub fn tensor_view(&self) -> TensorView<'_>
pub fn tensor_read(&self) -> TensorRead<'_>
Sourcepub fn to_tensor(&self) -> Result<Tensor>
pub fn to_tensor(&self) -> Result<Tensor>
Materialize this owned view into an owned compact tensor.
This returns an explicit error for backend-backed views because no backend context is available for an implicit download.
§Examples
use std::sync::Arc;
use tenferro_tensor::{Tensor, TensorOwnedView};
let base = Arc::new(Tensor::from_vec_col_major(vec![2], vec![1.0_f64, 2.0]).unwrap());
let view = TensorOwnedView::from_tensor(base);
let tensor = view.to_tensor()?;
assert_eq!(tensor.shape(), &[2]);pub fn transpose_view(&self, axes: impl AsRef<[usize]>) -> Result<Self>
pub fn reshape_view(&self, shape: &[usize]) -> Result<Self>
pub fn slice_view(&self, config: &SliceConfig) -> Result<Self>
pub fn broadcast_in_dim_view( &self, shape: &[usize], dims: &[usize], ) -> Result<Self>
Trait Implementations§
Source§impl Clone for TensorOwnedView
impl Clone for TensorOwnedView
Source§fn clone(&self) -> TensorOwnedView
fn clone(&self) -> TensorOwnedView
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for TensorOwnedView
impl !RefUnwindSafe for TensorOwnedView
impl Send for TensorOwnedView
impl Sync for TensorOwnedView
impl Unpin for TensorOwnedView
impl UnsafeUnpin for TensorOwnedView
impl !UnwindSafe for TensorOwnedView
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more