pub struct Tensor<S: Storage, Dim: Dimension> { /* private fields */ }
Expand description
A multidimensional data structure not unlike ndarray::ArrayBase
.
Implementations§
Source§impl<S: Storage> Tensor<S, [usize; 2]>
impl<S: Storage> Tensor<S, [usize; 2]>
Sourcepub fn dot(
&self,
rhs: Vector<&ViewOf<S>>,
) -> Vector<DefaultVec<S::T, S::Device>>where
S::Device: DefaultDeviceAllocator + DefaultBLASContext,
S::T: Zero + One + BLAS<<S::Device as DefaultBLASContext>::Context>,
pub fn dot(
&self,
rhs: Vector<&ViewOf<S>>,
) -> Vector<DefaultVec<S::T, S::Device>>where
S::Device: DefaultDeviceAllocator + DefaultBLASContext,
S::T: Zero + One + BLAS<<S::Device as DefaultBLASContext>::Context>,
Matrix-vector multiplication
Sourcepub fn dot_using<C: BLASContext<Device = S::Device>>(
&self,
rhs: Vector<&ViewOf<S>>,
ctx: C,
) -> Vector<DefaultVec<S::T, S::Device>>
pub fn dot_using<C: BLASContext<Device = S::Device>>( &self, rhs: Vector<&ViewOf<S>>, ctx: C, ) -> Vector<DefaultVec<S::T, S::Device>>
Matrix-vector multiplication, using the specified BLASContext
Sourcepub fn dot_into<C: BLASContext<Device = S::Device>, A: DeviceAllocator<Device = S::Device>>(
&self,
rhs: Vector<&ViewOf<S>>,
ctx: C,
alloc: A,
) -> Vector<Vec<S::T, A>>
pub fn dot_into<C: BLASContext<Device = S::Device>, A: DeviceAllocator<Device = S::Device>>( &self, rhs: Vector<&ViewOf<S>>, ctx: C, alloc: A, ) -> Vector<Vec<S::T, A>>
Matrix-vector multiplication, using the provided DeviceAllocator
, using the specified BLASContext
Source§impl<S: Storage> Tensor<S, [usize; 2]>
impl<S: Storage> Tensor<S, [usize; 2]>
Sourcepub fn matmul(
&self,
rhs: Matrix<&ViewOf<S>>,
) -> Matrix<DefaultVec<S::T, S::Device>>where
S::Device: DefaultDeviceAllocator + DefaultBLASContext,
S::T: Zero + One + BLAS<<S::Device as DefaultBLASContext>::Context>,
pub fn matmul(
&self,
rhs: Matrix<&ViewOf<S>>,
) -> Matrix<DefaultVec<S::T, S::Device>>where
S::Device: DefaultDeviceAllocator + DefaultBLASContext,
S::T: Zero + One + BLAS<<S::Device as DefaultBLASContext>::Context>,
Multiply two matricies together.
Sourcepub fn matmul_using<C: BLASContext<Device = S::Device>>(
&self,
rhs: Matrix<&ViewOf<S>>,
ctx: C,
) -> Matrix<DefaultVec<S::T, S::Device>>
pub fn matmul_using<C: BLASContext<Device = S::Device>>( &self, rhs: Matrix<&ViewOf<S>>, ctx: C, ) -> Matrix<DefaultVec<S::T, S::Device>>
Multiply two matricies together, using the specified BLASContext
Sourcepub fn matmul_into<C: BLASContext<Device = S::Device>, A: DeviceAllocator<Device = S::Device>>(
&self,
rhs: Matrix<&ViewOf<S>>,
ctx: C,
alloc: A,
) -> Matrix<Vec<S::T, A>>
pub fn matmul_into<C: BLASContext<Device = S::Device>, A: DeviceAllocator<Device = S::Device>>( &self, rhs: Matrix<&ViewOf<S>>, ctx: C, alloc: A, ) -> Matrix<Vec<S::T, A>>
Multiply two matricies together, using the provided DeviceAllocator
, using the specified BLASContext
Source§impl<S: Storage> Tensor<S, [usize; 1]>
impl<S: Storage> Tensor<S, [usize; 1]>
Source§impl<S: StorageMut> Tensor<S, [usize; 1]>
impl<S: StorageMut> Tensor<S, [usize; 1]>
Sourcepub fn scale_using<C: BLASContext<Device = S::Device>>(
&mut self,
alpha: S::T,
ctx: C,
)
pub fn scale_using<C: BLASContext<Device = S::Device>>( &mut self, alpha: S::T, ctx: C, )
Vector scaling, using the specified BLASContext
Source§impl<S: Storage, Dim: Dimension> Tensor<S, Dim>
impl<S: Storage, Dim: Dimension> Tensor<S, Dim>
Sourcepub fn from_shape(shape: Dim, data: S) -> Self
pub fn from_shape(shape: Dim, data: S) -> Self
Creates a new tensor using the shape and the raw data.
§Panics
The length of the data structure must match the size of the dimensions
Sourcepub fn into_inner(self) -> S
pub fn into_inner(self) -> S
Consumes the tensor, returning the underlying data
Sourcepub fn reverse_axes(&mut self)
pub fn reverse_axes(&mut self)
Reverses the axes of the tensor. An inplace transpose
pub fn swap_axes(&mut self, i: usize, j: usize)
Sourcepub fn t(&self) -> Tensor<&ViewOf<S>, Dim>
pub fn t(&self) -> Tensor<&ViewOf<S>, Dim>
Returns a view of the tensor with the contents transposed. This operation happens without mutating or cloning any data
Sourcepub fn into_owned(self) -> Tensor<S::Owned, Dim>
pub fn into_owned(self) -> Tensor<S::Owned, Dim>
Creates a new owned version of the tensor. Will only clone the contents if needed
Source§impl<'a, T, D: Device, Dim: Dimension> Tensor<&'a mut Ref<[MaybeUninit<T>], D>, Dim>
impl<'a, T, D: Device, Dim: Dimension> Tensor<&'a mut Ref<[MaybeUninit<T>], D>, Dim>
Sourcepub unsafe fn assume_init(self) -> TensorViewMut<'a, T, D, Dim>
pub unsafe fn assume_init(self) -> TensorViewMut<'a, T, D, Dim>
§Safety
Contents must be initialised
Source§impl<'a, T, D: Device, Dim: Dimension> Tensor<&'a Ref<[MaybeUninit<T>], D>, Dim>
impl<'a, T, D: Device, Dim: Dimension> Tensor<&'a Ref<[MaybeUninit<T>], D>, Dim>
Sourcepub unsafe fn assume_init(self) -> TensorView<'a, T, D, Dim>
pub unsafe fn assume_init(self) -> TensorView<'a, T, D, Dim>
§Safety
Contents must be initialised