pub struct Tape { /* private fields */ }Implementations§
Source§impl Tape
impl Tape
pub fn new() -> Tape
Sourcepub fn leaf(&mut self, t: Tensor) -> TVar
pub fn leaf(&mut self, t: Tensor) -> TVar
Register a leaf (parameter or input); its gradient is what
backward reports.
pub fn add(&mut self, a: &TVar, b: &TVar) -> Result<TVar>
Sourcepub fn matmul(
&mut self,
a: &TVar,
b: &TVar,
bias: Option<&TVar>,
spec: MatmulSpec,
) -> Result<TVar>
pub fn matmul( &mut self, a: &TVar, b: &TVar, bias: Option<&TVar>, spec: MatmulSpec, ) -> Result<TVar>
Matmul with the specs the training forward uses: trans_a == false,
b_rows == None, operands of equal rank (2x2 or batched 3x3).
pub fn gelu(&mut self, x: &TVar) -> Result<TVar>
pub fn layernorm( &mut self, x: &TVar, gamma: &TVar, beta: &TVar, eps: f32, ) -> Result<TVar>
Sourcepub fn softmax(&mut self, x: &TVar, causal: bool, off: usize) -> Result<TVar>
pub fn softmax(&mut self, x: &TVar, causal: bool, off: usize) -> Result<TVar>
Softmax over the last dim (optionally causal). Saves the output for backward; the causal mask needs no bookkeeping there because masked outputs are exact zeros.
pub fn split_heads( &mut self, qkv: &TVar, n_head: usize, ) -> Result<(TVar, TVar, TVar)>
pub fn merge_heads(&mut self, x: &TVar) -> Result<TVar>
Sourcepub fn embedding(
&mut self,
ids: &Tensor,
wte: &TVar,
wpe: &TVar,
pos: usize,
) -> Result<TVar>
pub fn embedding( &mut self, ids: &Tensor, wte: &TVar, wpe: &TVar, pos: usize, ) -> Result<TVar>
Fused token + positional embedding over a single-chunk wte.
dwte comes from scatter-add over the token ids; dwpe is the upstream
gradient placed at rows pos..pos+t.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Tape
impl !Send for Tape
impl !Sync for Tape
impl !UnwindSafe for Tape
impl Freeze for Tape
impl Unpin for Tape
impl UnsafeUnpin for Tape
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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