burn_compute/channel/base.rs
1use crate::server::{ComputeServer, Handle};
2use alloc::vec::Vec;
3use burn_common::reader::Reader;
4
5/// The ComputeChannel trait links the ComputeClient to the ComputeServer
6/// while ensuring thread-safety
7pub trait ComputeChannel<Server: ComputeServer>: Clone + core::fmt::Debug + Send + Sync {
8 /// Given a handle, returns owned resource as bytes
9 fn read(&self, handle: &Handle<Server>) -> Reader<Vec<u8>>;
10
11 /// Given a resource as bytes, stores it and returns the resource handle
12 fn create(&self, data: &[u8]) -> Handle<Server>;
13
14 /// Reserves `size` bytes in the storage, and returns a handle over them
15 fn empty(&self, size: usize) -> Handle<Server>;
16
17 /// Executes the `kernel` over the given `handles`.
18 fn execute(&self, kernel: Server::Kernel, handles: &[&Handle<Server>]);
19
20 /// Wait for the completion of every task in the server.
21 fn sync(&self);
22}