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§
Sourcefn load(name: String, ctx: &Context) -> Result<Box<Self>>where
Self: Sized,
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.
Sourcefn 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<'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.
Sourcefn 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 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.
Sourcefn layer_name(&self) -> &str
fn layer_name(&self) -> &str
Return the layer name.
Provided Methods§
Sourcefn 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 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.