Skip to main content

FloatMeta

Struct FloatMeta 

Source
pub struct FloatMeta<D: Device> {
    pub op: Option<Op<D>>,
    pub requires_grad: RwLock<bool>,
}

Fields§

§op: Option<Op<D>>§requires_grad: RwLock<bool>

Implementations§

Source§

impl<D: Device> FloatMeta<D>

Source

pub fn var() -> Self

A leaf variable that accumulates gradients.

Source

pub fn val() -> Self

A constant value that does not track gradients.

Source

pub fn from_op(op: Op<D>) -> Self

A non-leaf node produced by op.

Source

pub fn op(&self) -> Option<&Op<D>>

Source

pub fn requires_grad(&self) -> bool

Source

pub fn set_requires_grad(&self, mode: bool)

Source

pub fn is_leaf(&self) -> bool

A tensor is a leaf when it requires grad but was not produced by an op.

Source§

impl<D: Device> FloatMeta<D>

Records an op into a FloatMeta iff grad is globally enabled and record is true (i.e. some input requires grad). Otherwise produces a plain value meta.

Source

pub fn on_binary( lhs: &Tensor<D, Float>, rhs: &Tensor<D, Float>, op: BinaryOp, ) -> Self

Source

pub fn on_binary_scalar(lhs: &Tensor<D, Float>, rhs: f64, op: BinaryOp) -> Self

Source

pub fn on_unary(t: &Tensor<D, Float>, op: UnaryOp<f64>) -> Self

Source

pub fn on_float_unary(t: &Tensor<D, Float>, op: FloatUnaryOp) -> Self

Source

pub fn on_broadcast(t: &Tensor<D, Float>) -> Self

Source

pub fn on_reduce(t: &Tensor<D, Float>, dims: &[usize], op: ReduceOp) -> Self

Source

pub fn on_matmul(lhs: &Tensor<D, Float>, rhs: &Tensor<D, Float>) -> Self

Source

pub fn on_narrow( t: &Tensor<D, Float>, dim: usize, start: usize, len: usize, ) -> Self

Source

pub fn on_slice( t: &Tensor<D, Float>, dim: usize, start: usize, end: usize, step: usize, ) -> Self

Source

pub fn on_reshape(t: &Tensor<D, Float>) -> Self

Source

pub fn on_transpose(t: &Tensor<D, Float>, dim1: usize, dim2: usize) -> Self

Source

pub fn on_permute(t: &Tensor<D, Float>, dims: Vec<usize>) -> Self

Source

pub fn on_cat<A: AsRef<Tensor<D, Float>>>(args: &[A], dim: usize) -> Self

Source

pub fn on_copy(t: &Tensor<D, Float>) -> Self

Source

pub fn on_cast(t: &Tensor<D, Float>) -> Self

Source

pub fn on_pick( mask: &Tensor<D, Bool>, tv: Option<&Tensor<D, Float>>, fv: Option<&Tensor<D, Float>>, ) -> Self

Source

pub fn on_index_select( t: &Tensor<D, Float>, idx: &Tensor<D, Int>, dim: usize, ) -> Self

Source

pub fn on_index_add( init: &Tensor<D, Float>, idx: &Tensor<D, Int>, src: &Tensor<D, Float>, dim: usize, ) -> Self

Source

pub fn on_scatter_add( init: &Tensor<D, Float>, idx: &Tensor<D, Int>, src: &Tensor<D, Float>, dim: usize, ) -> Self

Source

pub fn on_gather( src: &Tensor<D, Float>, idx: &Tensor<D, Int>, dim: usize, ) -> Self

Source

pub fn on_rms_norm( input: &Tensor<D, Float>, weight: &Tensor<D, Float>, eps: f64, ) -> Self

Source

pub fn on_softmax(input: &Tensor<D, Float>, dim: usize) -> Self

Trait Implementations§

Source§

impl<D: Device> Default for FloatMeta<D>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<D: Device> TensorMeta<D, Float> for FloatMeta<D>

Source§

fn on_binary( lhs: &Tensor<D, Float>, rhs: &Tensor<D, Float>, op: BinaryOp, ) -> Self

Source§

fn on_binary_scalar(lhs: &Tensor<D, Float>, rhs: f64, op: BinaryOp) -> Self

Source§

fn on_unary(t: &Tensor<D, Float>, op: UnaryOp<f64>) -> Self

Source§

fn on_float_unary(t: &Tensor<D, Float>, op: FloatUnaryOp) -> Self

Source§

fn on_reduce(t: &Tensor<D, Float>, dims: &[usize], op: ReduceOp) -> Self

Source§

fn on_matmul(lhs: &Tensor<D, Float>, rhs: &Tensor<D, Float>) -> Self

Source§

fn on_broadcast(t: &Tensor<D, Float>) -> Self

Source§

fn on_narrow(t: &Tensor<D, Float>, dim: usize, start: usize, len: usize) -> Self

Source§

fn on_slice( t: &Tensor<D, Float>, dim: usize, start: usize, end: usize, step: usize, ) -> Self

Source§

fn on_reshape(t: &Tensor<D, Float>) -> Self

Source§

fn on_transpose(t: &Tensor<D, Float>, dim1: usize, dim2: usize) -> Self

Source§

fn on_permute(t: &Tensor<D, Float>, dims: Vec<usize>) -> Self

Source§

fn on_cat<A: AsRef<Tensor<D, Float>>>(args: &[A], dim: usize) -> Self

Source§

fn on_copy(t: &Tensor<D, Float>) -> Self

Source§

fn on_cast(t: &Tensor<D, Float>) -> Self

Source§

fn on_index_select( t: &Tensor<D, Float>, idx: &Tensor<D, Int>, dim: usize, ) -> Self

Source§

fn on_gather(src: &Tensor<D, Float>, idx: &Tensor<D, Int>, dim: usize) -> Self

Source§

fn on_index_add( init: &Tensor<D, Float>, idx: &Tensor<D, Int>, src: &Tensor<D, Float>, dim: usize, ) -> Self

Source§

fn on_scatter_add( init: &Tensor<D, Float>, idx: &Tensor<D, Int>, src: &Tensor<D, Float>, dim: usize, ) -> Self

Source§

fn on_pick( mask: &Tensor<D, Bool>, tv: Option<&Tensor<D, Float>>, fv: Option<&Tensor<D, Float>>, ) -> Self

Source§

fn on_rms_norm( input: &Tensor<D, Float>, weight: &Tensor<D, Float>, eps: f64, ) -> Self

Source§

fn on_softmax(input: &Tensor<D, Float>, dim: usize) -> Self

Auto Trait Implementations§

§

impl<D> !Freeze for FloatMeta<D>

§

impl<D> RefUnwindSafe for FloatMeta<D>
where Option<Op<D>>: RefUnwindSafe,

§

impl<D> Send for FloatMeta<D>
where Option<Op<D>>: Send,

§

impl<D> Sync for FloatMeta<D>
where Option<Op<D>>: Sync,

§

impl<D> Unpin for FloatMeta<D>
where Option<Op<D>>: Unpin,

§

impl<D> UnsafeUnpin for FloatMeta<D>
where Option<Op<D>>: UnsafeUnpin,

§

impl<D> UnwindSafe for FloatMeta<D>
where Option<Op<D>>: UnwindSafe,

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
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

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

Source§

type Error = !

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>,

Source§

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V