pub enum TensorValue {
Tensor(Arc<Tensor>),
View(TensorOwnedView),
}Expand description
Owned tensor value that can be compact or a lazy view.
TensorValue is the owned counterpart to TensorRead. It is suitable for
storing eager results that should remain lazy until an operation actually
requires compact materialized storage.
Variants§
Tensor(Arc<Tensor>)
View(TensorOwnedView)
Implementations§
Source§impl TensorValue
impl TensorValue
pub fn from_tensor(tensor: Tensor) -> Self
pub fn from_tensor_arc(tensor: Arc<Tensor>) -> Self
pub fn as_tensor_arc(&self) -> Option<&Arc<Tensor>>
pub fn dtype(&self) -> DType
pub fn shape(&self) -> &[usize]
pub fn tensor_read(&self) -> TensorRead<'_>
Sourcepub fn to_tensor(&self) -> Result<Tensor>
pub fn to_tensor(&self) -> Result<Tensor>
Materialize this tensor value into an owned compact tensor.
Compact tensor values are cloned. Lazy host views are materialized. Backend-backed views return an explicit error instead of panicking.
§Examples
use tenferro_tensor::{Tensor, TensorValue};
let value = TensorValue::from_tensor(Tensor::from_vec_col_major(
vec![2],
vec![1.0_f64, 2.0],
).unwrap());
let tensor = value.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 TensorValue
impl Clone for TensorValue
Source§fn clone(&self) -> TensorValue
fn clone(&self) -> TensorValue
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 TensorValue
impl !RefUnwindSafe for TensorValue
impl Send for TensorValue
impl Sync for TensorValue
impl Unpin for TensorValue
impl UnsafeUnpin for TensorValue
impl !UnwindSafe for TensorValue
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