Struct web_rwkv::tensor::Tensor

source ·
pub struct Tensor<D: Device, T: Scalar> {
    pub context: Context,
    /* private fields */
}

Fields§

§context: Context

Implementations§

source§

impl<D: Device, T: Scalar> Tensor<D, T>

source

pub fn len(&self) -> usize

source

pub fn is_empty(&self) -> bool

source

pub fn size(&self) -> usize

Size of the tensor in bytes.

source

pub fn offset(index: usize) -> usize

The offset in bytes for a linear index.

source

pub fn data(&self) -> &D::Data

source§

impl<T: Scalar, K: Kind> Tensor<Gpu<K>, T>

source

pub fn load(&self, host: &TensorCpu<'_, T>) -> Result<(), TensorError>

source

pub fn load_batch( &self, host: &TensorCpu<'_, T>, batch: usize ) -> Result<(), TensorError>

source

pub fn destroy(self)

source§

impl<'a, T: Scalar> Tensor<Cpu<'a, T>, T>

source

pub fn map<U: Scalar>(self, f: impl FnMut(&T) -> U) -> TensorCpu<'a, U>

source

pub fn repeat(self, axis: usize, repeat: usize) -> Self

Repeat the tensor along a given axis.

source

pub fn split(self, axis: usize) -> Result<Vec<Self>, TensorError>

Split the tensor along the highest plural axis.

source

pub fn stack(batches: Vec<Self>) -> Result<Self, TensorError>

Concat a batch of tensors.

source

pub fn slice( &self, x: impl TensorAxis, y: impl TensorAxis, z: impl TensorAxis, w: impl TensorAxis ) -> Result<TensorCpu<'a, T>, TensorError>

source

pub fn into_slice( self, x: impl TensorAxis, y: impl TensorAxis, z: impl TensorAxis, w: impl TensorAxis ) -> Result<Self, TensorError>

source§

impl<T: Scalar> Tensor<Gpu<ReadWrite>, T>

source

pub fn view( &self, x: impl TensorAxis, y: impl TensorAxis, z: impl TensorAxis, w: impl TensorAxis ) -> Result<TensorView<'_, T>, TensorError>

Trait Implementations§

source§

impl<D: Device, T: Scalar> Clone for Tensor<D, T>

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<D: Debug + Device, T: Debug + Scalar> Debug for Tensor<D, T>
where D::Data: Debug,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<D: Device, T: Scalar> Deref for Tensor<D, T>

§

type Target = <D as Device>::Data

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl<T: Scalar, K: Kind> From<Tensor<Cpu<'_, T>, T>> for TensorGpu<T, K>

source§

fn from(value: TensorCpu<'_, T>) -> Self

Converts to this type from the input type.
source§

impl<T: Scalar> From<Tensor<Cpu<'_, T>, T>> for Vec<T>

source§

fn from(value: TensorCpu<'_, T>) -> Self

Converts to this type from the input type.
source§

impl<T: Scalar> From<Tensor<Gpu<ReadBack>, T>> for TensorCpu<'_, T>

source§

fn from(value: TensorGpu<T, ReadBack>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<D, T> !RefUnwindSafe for Tensor<D, T>

§

impl<D, T> Send for Tensor<D, T>
where T: Send, <D as Device>::Data: Send,

§

impl<D, T> Sync for Tensor<D, T>
where T: Sync, <D as Device>::Data: Sync,

§

impl<D, T> Unpin for Tensor<D, T>
where T: Unpin, <D as Device>::Data: Unpin,

§

impl<D, T> !UnwindSafe for Tensor<D, T>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<T> WasmNotSend for T
where T: Send,

§

impl<T> WasmNotSync for T
where T: Sync,