pub trait Backend: Send + Sync {
type Weights: Send + Sync;
type Plan: Send;
// Required methods
fn caps(&self) -> Caps;
fn upload(
&self,
tensors: &[HostTensor<'_>],
graph: &Graph,
) -> Result<Self::Weights>;
fn lower(
&self,
w: &Self::Weights,
graph: &Graph,
bucket: Bucket,
) -> Result<Self::Plan>;
fn run(
&self,
plan: &mut Self::Plan,
batch: &Batch<'_>,
out: &mut Outputs,
) -> Result<()>;
// Provided methods
fn weight_bytes(&self, _w: &Self::Weights) -> usize { ... }
fn plan_bytes(&self, _p: &Self::Plan) -> usize { ... }
}Expand description
A device that runs graphs. The engine is generic over it, so the path through it is monomorphized and there is no dynamic dispatch per op.
Required Associated Types§
Required Methods§
Sourcefn upload(
&self,
tensors: &[HostTensor<'_>],
graph: &Graph,
) -> Result<Self::Weights>
fn upload( &self, tensors: &[HostTensor<'_>], graph: &Graph, ) -> Result<Self::Weights>
Converts a checkpoint’s tensors, indexed as the graph’s weights are.
§Errors
When a tensor cannot be converted.
Provided Methods§
Sourcefn weight_bytes(&self, _w: &Self::Weights) -> usize
fn weight_bytes(&self, _w: &Self::Weights) -> usize
Bytes the weights take on the device.
Sourcefn plan_bytes(&self, _p: &Self::Plan) -> usize
fn plan_bytes(&self, _p: &Self::Plan) -> usize
Bytes a plan takes on the device, its arena and staging buffers.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".