Struct web_rwkv::tensor::ops::TensorOp

source ·
pub struct TensorOp<'a> {
    pub pipeline: &'a ComputePipeline,
    pub bindings: Vec<BindGroup>,
    pub dispatch: [u32; 3],
}

Fields§

§pipeline: &'a ComputePipeline§bindings: Vec<BindGroup>§dispatch: [u32; 3]

Implementations§

source§

impl<'a> TensorOp<'a>

source

pub fn softmax(x: &'a TensorGpu<f32, ReadWrite>) -> Result<Self, TensorError>

Softmax operator applied on x.

source

pub fn layer_norm( w: &'a TensorGpu<f16, ReadWrite>, b: &'a TensorGpu<f16, ReadWrite>, x: &'a TensorGpu<f32, ReadWrite> ) -> Result<Self, TensorError>

Layer normalization applied on x, with weight w and bias b.

  • x shape: [C, T, B].
  • w shape: [C, 1, 1].
  • b shape: [C, 1, 1].
source

pub fn group_norm( w: &'a TensorGpu<f16, ReadWrite>, b: &'a TensorGpu<f16, ReadWrite>, x: &'a TensorGpu<f32, ReadWrite> ) -> Result<Self, TensorError>

Group normalization applied on x, with weight w and bias b.

  • x shape: [S, H, A].
  • w shape: [S, H, 1].
  • b shape: [S, H, 1].
source

pub fn matmul_vec_fp16( matrix: &'a TensorGpu<f16, ReadWrite>, input: TensorView<'a, f32>, output: TensorView<'a, f32> ) -> Result<Self, TensorError>

Fp32 matrix-vector multiplication.

  • matrix shape: [C, R, 1].
  • input shape: [C, T, B].
  • output shape: [R, T, B].
source

pub fn matmul_vec_int8( matrix: &'a TensorGpu<u8, ReadWrite>, mx: &'a TensorGpu<f32, ReadWrite>, rx: &'a TensorGpu<f32, ReadWrite>, my: &'a TensorGpu<f32, ReadWrite>, ry: &'a TensorGpu<f32, ReadWrite>, input: TensorView<'a, f32>, output: TensorView<'a, f32> ) -> Result<Self, TensorError>

Int8 matrix-vector multiplication.

  • matrix shape: [C, R, 1].
  • mx and rx shape: [C, 1, 1].
  • my and ry shape: [R, 1, 1].
  • input shape: [C, T, B].
  • output shape: [R, T, B].
source

pub fn matmul_mat_fp16( matrix: TensorView<'a, f16>, input: TensorView<'a, f16>, output: TensorView<'a, f32> ) -> Result<Self, TensorError>

Fp16 matrix-matrix multiplication.

  • matrix shape: [K, M, B].
  • input shape: [K, N, B].
  • output shape: [M, N, B].
source

pub fn add( input: &'a TensorGpu<f32, ReadWrite>, output: &'a TensorGpu<f32, ReadWrite> ) -> Result<Self, TensorError>

Add input onto output.

source

pub fn token_shift( cursors: &'a TensorGpu<u32, ReadWrite>, time_mix: &'a TensorGpu<f16, ReadWrite>, x: &'a TensorGpu<f32, ReadWrite>, sx: TensorView<'_, f32>, output: &'a TensorGpu<f32, ReadWrite> ) -> Result<Self, TensorError>

source

pub fn time_mix( stack: &'a TensorGpu<u32, ReadWrite>, time_decay: &'a TensorGpu<f32, ReadWrite>, time_first: &'a TensorGpu<f32, ReadWrite>, k: &'a TensorGpu<f32, ReadWrite>, v: &'a TensorGpu<f32, ReadWrite>, r: &'a TensorGpu<f32, ReadWrite>, x: &'a TensorGpu<f32, ReadWrite>, state: TensorView<'_, f32> ) -> Result<Self, TensorError>

source

pub fn time_mix_v5( stack: &'a TensorGpu<u32, ReadWrite>, time_decay: &'a TensorGpu<f32, ReadWrite>, time_first: &'a TensorGpu<f32, ReadWrite>, k: &'a TensorGpu<f32, ReadWrite>, v: &'a TensorGpu<f32, ReadWrite>, r: &'a TensorGpu<f32, ReadWrite>, x: &'a TensorGpu<f32, ReadWrite>, state: TensorView<'_, f32> ) -> Result<Self, TensorError>

source

pub fn silu( input: &'a TensorGpu<f32, ReadWrite>, output: &'a TensorGpu<f32, ReadWrite> ) -> Result<Self, TensorError>

source

pub fn squared_relu( x: &'a TensorGpu<f32, ReadWrite> ) -> Result<Self, TensorError>

source

pub fn channel_mix( cursors: &'a TensorGpu<u32, ReadWrite>, r: &'a TensorGpu<f32, ReadWrite>, v: &'a TensorGpu<f32, ReadWrite>, x: &'a TensorGpu<f32, ReadWrite>, state: TensorView<'a, f32> ) -> Result<Self, TensorError>

source

pub fn blit( input: TensorView<'a, f32>, output: TensorView<'a, f32> ) -> Result<Self, TensorError>

Copy the content of input into output, given an offset.

source

pub fn blend( factor: &'a TensorGpu<f32, Uniform>, input: &'a TensorGpu<f32, ReadWrite>, output: &'a TensorGpu<f32, ReadWrite> ) -> Result<Self, TensorError>

source

pub fn quantize_mat_int8( input: &'a TensorGpu<f16, ReadWrite>, mx: &'a TensorGpu<f32, ReadWrite>, rx: &'a TensorGpu<f32, ReadWrite>, my: &'a TensorGpu<f32, ReadWrite>, ry: &'a TensorGpu<f32, ReadWrite>, output: &'a TensorGpu<u8, ReadWrite> ) -> Result<Vec<Self>, TensorError>

source

pub fn quantize_fp16( input: &'a TensorGpu<f32, ReadWrite>, output: &'a TensorGpu<f16, ReadWrite> ) -> Result<Self, TensorError>

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for TensorOp<'a>

§

impl<'a> Send for TensorOp<'a>

§

impl<'a> Sync for TensorOp<'a>

§

impl<'a> Unpin for TensorOp<'a>

§

impl<'a> !UnwindSafe for TensorOp<'a>

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