Skip to main content

Op

Enum Op 

Source
pub enum Op {
    Embed {
        table: W,
        out: Val,
    },
    LayerNorm {
        x: Val,
        w: W,
        b: Option<W>,
        eps: f64,
        out: Val,
    },
    Gemm {
        a: Val,
        w: W,
        b: Option<W>,
        epilogue: Epilogue,
        out: Val,
    },
    Rope {
        qkv: Val,
        theta: f64,
    },
    Attention {
        qkv: Val,
        window: Option<usize>,
        out: Val,
    },
    GeGlu {
        x: Val,
        out: Val,
    },
    AddType {
        h: Val,
        table: W,
    },
    GatherMarkers {
        h: Val,
        out: Val,
    },
    ActFeatures {
        h: Val,
        logits: Val,
        out: Val,
    },
}
Expand description

One step of a graph. Every op runs on the rows the batch has, not the bucket’s padded count.

Variants§

§

Embed

out[i] = table[ids[i]], token rows.

Fields

§table: W

[vocab, width].

§out: Val

Token rows.

§

LayerNorm

LayerNorm over each row, statistics in f64.

Fields

§x: Val

Input.

§w: W

Scale.

§b: Option<W>

Shift, if the norm has one.

§eps: f64

Epsilon.

§out: Val

Output, the same shape as x.

§

Gemm

out = epilogue(a wᵀ + b) with w as [n, k].

Fields

§a: Val

Input, k wide.

§w: W

[n, k].

§b: Option<W>

[n], if there is one.

§epilogue: Epilogue

What happens to each result.

§out: Val

Output, n wide, with as many rows as a.

§

Rope

Rotary embedding applied in place to the q and k parts of fused [q | k | v] rows, with positions counted from the start of each sequence.

Fields

§qkv: Val

Token rows, 3 heads 64 wide.

§theta: f64

The base.

§

Attention

Self attention within each sequence over fused [q | k | v] rows.

Fields

§qkv: Val

Token rows, 3 heads 64 wide.

§window: Option<usize>

Keys at most this far away on either side, or all of them.

§out: Val

Token rows, heads 64 wide.

§

GeGlu

out = gelu(x[:, ..n]) * x[:, n..] with x twice as wide as out.

Fields

§x: Val

Input.

§out: Val

Output.

§

AddType

Adds table[qtype[s]] to every row of sequence s, in place.

Fields

§h: Val

Token rows.

§table: W

[types, width].

§

GatherMarkers

The row of each marker.

Fields

§h: Val

Token rows.

§out: Val

Marker rows.

§

ActFeatures

Per sequence, its first row followed by [top1, top1 - top2, entropy / ln k, k / 255] over the softmax of its markers’ logits, Laya’s act head input.

Fields

§h: Val

Token rows.

§logits: Val

Marker rows, one wide.

§out: Val

Sequence rows, h width plus four.

Implementations§

Source§

impl Op

Source

pub fn uses(&self) -> (Vec<Val>, Vec<Val>)

Values the op reads, then values it writes. An in place op lists the value in both.

Trait Implementations§

Source§

impl Clone for Op

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Op

Source§

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

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

impl PartialEq for Op

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Op

Auto Trait Implementations§

§

impl Freeze for Op

§

impl RefUnwindSafe for Op

§

impl Send for Op

§

impl Sync for Op

§

impl Unpin for Op

§

impl UnsafeUnpin for Op

§

impl UnwindSafe for Op

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

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

Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.