pub trait LayerwisePolicy<B, U>where
B: NeuralBackend,{
type Lease: DerefMut<Target = U>;
type Error;
// Required methods
fn begin(
&mut self,
initial: &B::Tensor,
context: &<B::Tensor as Tensor>::Context,
) -> Result<(), Self::Error>;
fn acquire<E, F>(
&mut self,
ordinal: usize,
address: ExecutionUnitAddress,
build: F,
context: &<B::Tensor as Tensor>::Context,
) -> Result<Self::Lease, LayerwiseAcquireError<E, Self::Error>>
where F: FnOnce(&<B::Tensor as Tensor>::Context) -> Result<U, E>;
fn complete<'a, StateValues, ContextValues>(
&mut self,
ordinal: usize,
address: ExecutionUnitAddress,
lease: Self::Lease,
output: &'a B::Tensor,
state_values: StateValues,
context_values: ContextValues,
context: &<B::Tensor as Tensor>::Context,
) -> Result<(), Self::Error>
where B::Tensor: 'a,
StateValues: Iterator<Item = &'a B::Tensor>,
ContextValues: Iterator<Item = &'a B::Tensor>;
fn finish(
&mut self,
output: &B::Tensor,
context: &<B::Tensor as Tensor>::Context,
) -> Result<(), Self::Error>;
// Provided method
fn abort(
&mut self,
active: Option<(usize, ExecutionUnitAddress, Self::Lease)>,
_context: &<B::Tensor as Tensor>::Context,
) { ... }
}Expand description
Policy controlling acquisition and exact release of one execution unit.
Required Associated Types§
Required Methods§
Sourcefn begin(
&mut self,
initial: &B::Tensor,
context: &<B::Tensor as Tensor>::Context,
) -> Result<(), Self::Error>
fn begin( &mut self, initial: &B::Tensor, context: &<B::Tensor as Tensor>::Context, ) -> Result<(), Self::Error>
Starts one forward after architecture input preparation.
Sourcefn acquire<E, F>(
&mut self,
ordinal: usize,
address: ExecutionUnitAddress,
build: F,
context: &<B::Tensor as Tensor>::Context,
) -> Result<Self::Lease, LayerwiseAcquireError<E, Self::Error>>
fn acquire<E, F>( &mut self, ordinal: usize, address: ExecutionUnitAddress, build: F, context: &<B::Tensor as Tensor>::Context, ) -> Result<Self::Lease, LayerwiseAcquireError<E, Self::Error>>
Acquires one populated unit for exclusive execution.
The flat ordinal addresses storage while address preserves the
architecture execution group and group-local unit index for scheduling.
Sourcefn complete<'a, StateValues, ContextValues>(
&mut self,
ordinal: usize,
address: ExecutionUnitAddress,
lease: Self::Lease,
output: &'a B::Tensor,
state_values: StateValues,
context_values: ContextValues,
context: &<B::Tensor as Tensor>::Context,
) -> Result<(), Self::Error>
fn complete<'a, StateValues, ContextValues>( &mut self, ordinal: usize, address: ExecutionUnitAddress, lease: Self::Lease, output: &'a B::Tensor, state_values: StateValues, context_values: ContextValues, context: &<B::Tensor as Tensor>::Context, ) -> Result<(), Self::Error>
Retains the unit and dependent native values through exact completion.
Provided Methods§
Sourcefn abort(
&mut self,
active: Option<(usize, ExecutionUnitAddress, Self::Lease)>,
_context: &<B::Tensor as Tensor>::Context,
)
fn abort( &mut self, active: Option<(usize, ExecutionUnitAddress, Self::Lease)>, _context: &<B::Tensor as Tensor>::Context, )
Aborts an incomplete forward and releases all policy-owned state.
active contains the unit lease when execution stopped after
acquisition but before exact completion. Implementations with no
forward-scoped state may rely on the default, which simply drops it.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".