pub struct Tensor<T, A: Backend = CpuBackend> {
pub storage: Buffer<T, A>,
pub dimensions: Dimensions,
}Fields§
§storage: Buffer<T, A>§dimensions: DimensionsImplementations§
Source§impl<T, A: Backend> Tensor<T, A>
impl<T, A: Backend> Tensor<T, A>
pub fn with_sizes_in(sizes: impl AsRef<[usize]>, allocator: A) -> Self
pub fn zeros_in(sizes: impl AsRef<[usize]>, allocator: A) -> Self
pub fn zeros_in_with_total_capacity( sizes: impl AsRef<[usize]>, allocator: A, ) -> Self
pub fn try_with_sizes_in( sizes: impl AsRef<[usize]>, allocator: A, ) -> Result<Self, TryReserveError>
pub fn reshape_in_place(&mut self, sizes: impl AsRef<[usize]>)
pub fn reshape(self, sizes: impl AsRef<[usize]>) -> Self
Sourcepub unsafe fn reshape_unchecked(self, dimensions: Dimensions)
pub unsafe fn reshape_unchecked(self, dimensions: Dimensions)
§Safety
The caller must ensure that the new dimensions are compatible with the existing dimensions.
pub fn flatten_in_place(&mut self)
pub fn flatten(self) -> Self
pub fn into_buffer(self) -> Buffer<T, A>
pub fn as_buffer(&self) -> &Buffer<T, A>
pub fn as_mut_buffer(&mut self) -> &mut Buffer<T, A>
pub fn backend(&self) -> &A
pub fn shape(&self) -> &Dimensions
pub fn strides(&self) -> &[usize]
pub fn as_ptr(&self) -> *const T
Sourcepub unsafe fn owned_unchecked(&self) -> ManuallyDrop<Self>
pub unsafe fn owned_unchecked(&self) -> ManuallyDrop<Self>
§Safety
This function is unsafe because it enables bypassing the lifetime of the tensor.
Sourcepub unsafe fn owned_unchecked_in(
&self,
storage_allocator: A,
) -> ManuallyDrop<Self>
pub unsafe fn owned_unchecked_in( &self, storage_allocator: A, ) -> ManuallyDrop<Self>
§Safety
This function is unsafe because it enables bypassing the lifetime of the tensor.
pub fn total_len(&self) -> usize
pub fn as_mut_ptr(&mut self) -> *mut T
pub fn as_view(&self) -> TensorView<'_, T, A>
pub fn as_view_mut(&mut self) -> TensorViewMut<'_, T, A>
pub fn get(&self, index: usize) -> Option<TensorView<'_, T, A>>
pub fn get_mut(&mut self, index: usize) -> Option<TensorViewMut<'_, T, A>>
pub fn split(&self) -> impl Iterator<Item = TensorView<'_, T, A>>
pub fn split_mut(&mut self) -> impl Iterator<Item = TensorViewMut<'_, T, A>>
Sourcepub unsafe fn assume_init(&mut self)
pub unsafe fn assume_init(&mut self)
§Safety
pub fn flatten_to_base<F: Field>(self) -> Tensor<F, A>where
T: ExtensionField<F>,
pub fn into_extension<ET: ExtensionField<T>>(self) -> Tensor<ET, A>where
T: Field,
Source§impl<T> Tensor<T, CpuBackend>
impl<T> Tensor<T, CpuBackend>
Source§impl<T: Field> Tensor<T, CpuBackend>
impl<T: Field> Tensor<T, CpuBackend>
Sourcepub fn sum(&self, dim: usize) -> Tensor<T, CpuBackend>
pub fn sum(&self, dim: usize) -> Tensor<T, CpuBackend>
Computes the sum of the tensor along a dimension.
Trait Implementations§
Source§impl<T> Default for Tensor<T, CpuBackend>
impl<T> Default for Tensor<T, CpuBackend>
Source§impl<'de, T: Deserialize<'de>> Deserialize<'de> for Tensor<T>
impl<'de, T: Deserialize<'de>> Deserialize<'de> for Tensor<T>
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
Source§impl<T: Clone + Send + Sync> From<DenseMatrix<T>> for Tensor<T, CpuBackend>
impl<T: Clone + Send + Sync> From<DenseMatrix<T>> for Tensor<T, CpuBackend>
Source§fn from(value: RowMajorMatrix<T>) -> Self
fn from(value: RowMajorMatrix<T>) -> Self
Converts to this type from the input type.
Source§impl<T> FromIterator<T> for Tensor<T, CpuBackend>
impl<T> FromIterator<T> for Tensor<T, CpuBackend>
Source§fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
Creates a value from an iterator. Read more
Source§impl<T, A: Backend> HasBackend for Tensor<T, A>
impl<T, A: Backend> HasBackend for Tensor<T, A>
impl<T, A: Backend> Eq for Tensor<T, A>
Auto Trait Implementations§
impl<T, A> Freeze for Tensor<T, A>where
A: Freeze,
impl<T, A> RefUnwindSafe for Tensor<T, A>where
A: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, A> Send for Tensor<T, A>
impl<T, A> Sync for Tensor<T, A>
impl<T, A> Unpin for Tensor<T, A>
impl<T, A> UnsafeUnpin for Tensor<T, A>where
A: UnsafeUnpin,
impl<T, A> UnwindSafe for Tensor<T, A>where
A: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, A> CopyIntoBackend<A, A> for T
impl<T, A> CopyIntoBackend<A, A> for T
Source§impl<T, A> CopyToBackend<A, A> for T
impl<T, A> CopyToBackend<A, A> for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more