pub struct Tensor {
pub data: Vec<f64>,
pub integer_data: Option<IntegerStorage>,
pub shape: Vec<usize>,
pub rows: usize,
pub cols: usize,
pub dtype: NumericDType,
}Fields§
§data: Vec<f64>§integer_data: Option<IntegerStorage>Exact homogeneous integer backing storage during the integer-dtype migration. Floating tensors leave this unset.
shape: Vec<usize>§rows: usize§cols: usize§dtype: NumericDTypeLogical numeric class of this tensor; host storage remains f64.
Implementations§
Source§impl Tensor
impl Tensor
pub fn new(data: Vec<f64>, shape: Vec<usize>) -> Result<Self, String>
pub fn new_2d(data: Vec<f64>, rows: usize, cols: usize) -> Result<Self, String>
pub fn from_f32(data: Vec<f32>, shape: Vec<usize>) -> Result<Self, String>
pub fn from_f32_slice(data: &[f32], shape: &[usize]) -> Result<Self, String>
pub fn new_with_dtype( data: Vec<f64>, shape: Vec<usize>, dtype: NumericDType, ) -> Result<Self, String>
Sourcepub fn new_integer(
storage: IntegerStorage,
shape: Vec<usize>,
) -> Result<Self, String>
pub fn new_integer( storage: IntegerStorage, shape: Vec<usize>, ) -> Result<Self, String>
Construct a tensor backed by an exact homogeneous integer buffer.
The floating data member is retained only as a compatibility view for
legacy numeric consumers. Integer-aware code must use integer_data.
pub fn integer_storage(&self) -> Option<&IntegerStorage>
Sourcepub fn reshape(self, shape: Vec<usize>) -> Result<Self, String>
pub fn reshape(self, shape: Vec<usize>) -> Result<Self, String>
Change only shape metadata while retaining the underlying numeric storage.
pub fn zeros(shape: Vec<usize>) -> Self
pub fn ones(shape: Vec<usize>) -> Self
pub fn zeros2(rows: usize, cols: usize) -> Self
pub fn ones2(rows: usize, cols: usize) -> Self
pub fn rows(&self) -> usize
pub fn cols(&self) -> usize
pub fn get2(&self, row: usize, col: usize) -> Result<f64, String>
pub fn set2(&mut self, row: usize, col: usize, value: f64) -> Result<(), String>
pub fn scalar_to_tensor2(scalar: f64, rows: usize, cols: usize) -> Tensor
Trait Implementations§
impl StructuralPartialEq for Tensor
Auto Trait Implementations§
impl Freeze for Tensor
impl RefUnwindSafe for Tensor
impl Send for Tensor
impl Sync for Tensor
impl Unpin for Tensor
impl UnsafeUnpin for Tensor
impl UnwindSafe for Tensor
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