use cubecl_common::{ExecutionMode, future::DynFut, profile::ProfileDuration};
use crate::{
logging::ServerLogger,
server::{
Binding, BindingWithMeta, Bindings, ComputeServer, CubeCount, Handle, ProfileError,
ProfilingToken,
},
storage::{BindingResource, ComputeStorage},
};
use alloc::sync::Arc;
use alloc::vec::Vec;
pub trait ComputeChannel<Server: ComputeServer>: Clone + core::fmt::Debug + Send + Sync {
fn read(&self, bindings: Vec<Binding>) -> DynFut<Vec<Vec<u8>>>;
fn read_tensor(&self, bindings: Vec<BindingWithMeta>) -> DynFut<Vec<Vec<u8>>>;
fn sync(&self) -> DynFut<()>;
fn get_resource(
&self,
binding: Binding,
) -> BindingResource<<Server::Storage as ComputeStorage>::Resource>;
fn create(&self, data: &[u8]) -> Handle;
fn create_tensors(
&self,
data: Vec<&[u8]>,
shape: Vec<&[usize]>,
elem_size: Vec<usize>,
) -> Vec<(Handle, Vec<usize>)>;
fn empty(&self, size: usize) -> Handle;
fn empty_tensors(
&self,
shape: Vec<&[usize]>,
elem_size: Vec<usize>,
) -> Vec<(Handle, Vec<usize>)>;
unsafe fn execute(
&self,
kernel: Server::Kernel,
count: CubeCount,
bindings: Bindings,
mode: ExecutionMode,
logger: Arc<ServerLogger>,
);
fn flush(&self);
fn memory_usage(&self) -> crate::memory_management::MemoryUsage;
fn memory_cleanup(&self);
fn start_profile(&self) -> ProfilingToken;
fn end_profile(&self, token: ProfilingToken) -> Result<ProfileDuration, ProfileError>;
}