pub struct Tensor<T> {
pub shape: Vec<usize>,
pub data: Vec<T>,
}Expand description
Contiguous tensor with row-major layout (no stride stored)
Binary format: [t][dim_count][type][shape...][data...]
- Always row-major, contiguous in memory
- No stride information stored (implicitly computed)
- 95% of use cases (normal arrays, images, ML tensors)
- Dynamic dimensionality (1D, 2D, 3D, 4D, or more)
§Examples
use vsf::Tensor;
// 2D image: 1920×1080 u16 pixels
let img = Tensor::new(
vec![1920, 1080],
vec![0u16; 1920 * 1080]
);
// 3D tensor: 100×200×3 RGB
let rgb = Tensor::new(
vec![100, 200, 3],
vec![0u8; 100 * 200 * 3]
);Fields§
§shape: Vec<usize>§data: Vec<T>Implementations§
Trait Implementations§
impl<T> StructuralPartialEq for Tensor<T>
Auto Trait Implementations§
impl<T> Freeze for Tensor<T>
impl<T> RefUnwindSafe for Tensor<T>where
T: RefUnwindSafe,
impl<T> Send for Tensor<T>where
T: Send,
impl<T> Sync for Tensor<T>where
T: Sync,
impl<T> Unpin for Tensor<T>where
T: Unpin,
impl<T> UnsafeUnpin for Tensor<T>
impl<T> UnwindSafe for Tensor<T>where
T: UnwindSafe,
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