pub enum TensorRef<'a> {
Tensor(&'a Tensor),
View(TensorView<'a>),
}Expand description
Core-neutral tensor input reference.
§Examples
use tenferro_tensor_core::{Tensor, TensorRef};
let tensor = Tensor::from_vec_col_major(vec![1], vec![1.0_f32])?;
let reference = TensorRef::Tensor(&tensor);
assert_eq!(reference.shape(), &[1]);Variants§
Tensor(&'a Tensor)
View(TensorView<'a>)
Implementations§
Source§impl<'a> TensorRef<'a>
impl<'a> TensorRef<'a>
Sourcepub fn dtype(&self) -> DType
pub fn dtype(&self) -> DType
Return the referenced dtype.
§Examples
use tenferro_tensor_core::{DType, Tensor, TensorRef};
let tensor = Tensor::from_vec_col_major(vec![1], vec![1_i64])?;
assert_eq!(TensorRef::Tensor(&tensor).dtype(), DType::I64);Sourcepub fn shape(&self) -> &[usize]
pub fn shape(&self) -> &[usize]
Borrow the referenced shape.
§Examples
use tenferro_tensor_core::{Tensor, TensorRef};
let tensor = Tensor::from_vec_col_major(vec![1], vec![1_i64])?;
assert_eq!(TensorRef::Tensor(&tensor).shape(), &[1]);Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for TensorRef<'a>
impl<'a> RefUnwindSafe for TensorRef<'a>
impl<'a> Send for TensorRef<'a>
impl<'a> Sync for TensorRef<'a>
impl<'a> Unpin for TensorRef<'a>
impl<'a> UnsafeUnpin for TensorRef<'a>
impl<'a> UnwindSafe for TensorRef<'a>
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