Skip to main content

Forwarder

Trait Forwarder 

Source
pub trait Forwarder:
    Debug
    + Send
    + Sync
    + Display {
    // Required methods
    fn load(name: String, ctx: &Context) -> Result<Box<Self>>
       where Self: Sized;
    fn forward<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        x: &'life1 Tensor,
        index_pos: usize,
        block_idx: usize,
        ctx: &'life2 mut Context,
    ) -> Pin<Box<dyn Future<Output = Result<Tensor>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn forward_mut<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 mut self,
        x: &'life1 Tensor,
        index_pos: usize,
        block_idx: usize,
        ctx: &'life2 mut Context,
    ) -> Pin<Box<dyn Future<Output = Result<Tensor>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn layer_name(&self) -> &str;

    // Provided methods
    fn forward_batch<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 mut self,
        _x: &'life1 Tensor,
        _batch: Vec<(String, usize, usize)>,
        _ctx: &'life2 mut Context,
    ) -> Pin<Box<dyn Future<Output = Result<Tensor>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait { ... }
    fn goodbye<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn ident(&self) -> &str { ... }
}
Expand description

This is the trait that a shardable object must implement.

Required Methods§

Source

fn load(name: String, ctx: &Context) -> Result<Box<Self>>
where Self: Sized,

Create an instance of this object loading the specified layer(s) from a VarBuilder.

Source

fn forward<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, x: &'life1 Tensor, index_pos: usize, block_idx: usize, ctx: &'life2 mut Context, ) -> Pin<Box<dyn Future<Output = Result<Tensor>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Applies a forward operation to the input tensor, does not require mutability.

Source

fn forward_mut<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, x: &'life1 Tensor, index_pos: usize, block_idx: usize, ctx: &'life2 mut Context, ) -> Pin<Box<dyn Future<Output = Result<Tensor>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Applies a forward operation to the input tensor, requires mutability.

Source

fn layer_name(&self) -> &str

Return the layer name.

Provided Methods§

Source

fn forward_batch<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, _x: &'life1 Tensor, _batch: Vec<(String, usize, usize)>, _ctx: &'life2 mut Context, ) -> Pin<Box<dyn Future<Output = Result<Tensor>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Applies a batch of forward operations to the input tensor.

Source

fn goodbye<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source

fn ident(&self) -> &str

Return the unique identity or local.

Implementors§