pub enum Message {
Hello,
WorkerInfo(WorkerInfo),
SingleOp {
layer_name: String,
x: RawTensor,
index_pos: usize,
block_idx: usize,
},
Batch {
x: RawTensor,
batch: Vec<(String, usize, usize)>,
},
Tensor(RawTensor),
Goodbye,
LayerAssignment {
layers: Vec<String>,
model_hash: String,
},
LayerAssignmentAck {
needs_data: bool,
},
ModelDataChunk {
filename: String,
offset: u64,
total_size: u64,
data: Vec<u8>,
},
ModelDataDone,
WorkerReady,
WorkerError {
message: String,
},
}Expand description
A Cake protocol message.
Variants§
Hello
First message sent.
WorkerInfo(WorkerInfo)
Message that the worker sends when a master connects with runtime information.
SingleOp
Single inference operation for a given layer.
Batch
Batched inference operations over a Tensor.
Tensor(RawTensor)
A message to transmit tensors.
Goodbye
Last message sent.
LayerAssignment
Master tells worker which layers to serve.
LayerAssignmentAck
Worker tells master whether it needs model data.
ModelDataChunk
Chunk of model file data from master to worker.
ModelDataDone
All model files have been sent.
WorkerReady
Worker has loaded all assigned layers and is ready for inference.
WorkerError
Worker encountered an error during inference.
Implementations§
Source§impl Message
impl Message
Sourcepub fn single_op(
layer_name: &str,
x: &Tensor,
index_pos: usize,
block_idx: usize,
) -> Self
pub fn single_op( layer_name: &str, x: &Tensor, index_pos: usize, block_idx: usize, ) -> Self
Create a Message::SingleOp message.
Sourcepub fn from_tensor(x: &Tensor) -> Self
pub fn from_tensor(x: &Tensor) -> Self
Create a Message::Tensor message.
Sourcepub fn from_batch(x: &Tensor, batch: Vec<(String, usize, usize)>) -> Self
pub fn from_batch(x: &Tensor, batch: Vec<(String, usize, usize)>) -> Self
Create a Message::Batch message.
Sourcepub async fn from_reader<R>(reader: &mut R) -> Result<(usize, Self)>where
R: AsyncReadExt + Unpin,
pub async fn from_reader<R>(reader: &mut R) -> Result<(usize, Self)>where
R: AsyncReadExt + Unpin,
Read a Message with the provided reader.
Sourcepub async fn from_reader_buf<R>(
reader: &mut R,
buf: &mut Vec<u8>,
) -> Result<(usize, Self)>where
R: AsyncReadExt + Unpin,
pub async fn from_reader_buf<R>(
reader: &mut R,
buf: &mut Vec<u8>,
) -> Result<(usize, Self)>where
R: AsyncReadExt + Unpin,
Read a Message, reusing buf to avoid per-message heap allocation.
Sourcepub async fn to_writer<W>(&self, writer: &mut W) -> Result<usize>where
W: AsyncWriteExt + Unpin,
pub async fn to_writer<W>(&self, writer: &mut W) -> Result<usize>where
W: AsyncWriteExt + Unpin,
Write a Message with the provided writer.
Sourcepub async fn to_writer_buf<W>(
&self,
writer: &mut W,
buf: &mut Vec<u8>,
) -> Result<usize>where
W: AsyncWriteExt + Unpin,
pub async fn to_writer_buf<W>(
&self,
writer: &mut W,
buf: &mut Vec<u8>,
) -> Result<usize>where
W: AsyncWriteExt + Unpin,
Write a Message, reusing buf to avoid per-message heap allocation.
Trait Implementations§
Source§impl<'a_, C_: Context> Readable<'a_, C_> for Message
impl<'a_, C_: Context> Readable<'a_, C_> for Message
fn read_from<R_: Reader<'a_, C_>>(_reader_: &mut R_) -> Result<Self, C_::Error>
fn minimum_bytes_needed() -> usize
Source§fn read_from_buffer(buffer: &'a [u8]) -> Result<Self, <C as Context>::Error>where
Self: DefaultContext<Context = C>,
C: Default,
fn read_from_buffer(buffer: &'a [u8]) -> Result<Self, <C as Context>::Error>where
Self: DefaultContext<Context = C>,
C: Default,
Source§fn read_with_length_from_buffer(
buffer: &'a [u8],
) -> (Result<Self, <C as Context>::Error>, usize)where
Self: DefaultContext<Context = C>,
C: Default,
fn read_with_length_from_buffer(
buffer: &'a [u8],
) -> (Result<Self, <C as Context>::Error>, usize)where
Self: DefaultContext<Context = C>,
C: Default,
Source§fn read_from_buffer_copying_data(
buffer: &[u8],
) -> Result<Self, <C as Context>::Error>where
Self: DefaultContext<Context = C>,
C: Default,
fn read_from_buffer_copying_data(
buffer: &[u8],
) -> Result<Self, <C as Context>::Error>where
Self: DefaultContext<Context = C>,
C: Default,
Source§fn read_with_length_from_buffer_copying_data(
buffer: &[u8],
) -> (Result<Self, <C as Context>::Error>, usize)where
Self: DefaultContext<Context = C>,
C: Default,
fn read_with_length_from_buffer_copying_data(
buffer: &[u8],
) -> (Result<Self, <C as Context>::Error>, usize)where
Self: DefaultContext<Context = C>,
C: Default,
Source§fn read_from_stream_unbuffered(
stream: impl Read,
) -> Result<Self, <C as Context>::Error>where
Self: DefaultContext<Context = C>,
C: Default,
fn read_from_stream_unbuffered(
stream: impl Read,
) -> Result<Self, <C as Context>::Error>where
Self: DefaultContext<Context = C>,
C: Default,
Source§fn read_from_stream_buffered(
stream: impl Read,
) -> Result<Self, <C as Context>::Error>where
Self: DefaultContext<Context = C>,
C: Default,
fn read_from_stream_buffered(
stream: impl Read,
) -> Result<Self, <C as Context>::Error>where
Self: DefaultContext<Context = C>,
C: Default,
fn read_from_file(path: impl AsRef<Path>) -> Result<Self, <C as Context>::Error>where
Self: DefaultContext<Context = C>,
C: Default,
fn read_from_buffer_with_ctx( context: C, buffer: &'a [u8], ) -> Result<Self, <C as Context>::Error>
fn read_with_length_from_buffer_with_ctx( context: C, buffer: &'a [u8], ) -> (Result<Self, <C as Context>::Error>, usize)
fn read_from_buffer_copying_data_with_ctx( context: C, buffer: &[u8], ) -> Result<Self, <C as Context>::Error>
fn read_with_length_from_buffer_copying_data_with_ctx( context: C, buffer: &[u8], ) -> (Result<Self, <C as Context>::Error>, usize)
fn read_with_length_from_buffer_copying_data_with_ctx_mut( context: &mut C, buffer: &[u8], ) -> (Result<Self, <C as Context>::Error>, usize)
fn read_from_stream_unbuffered_with_ctx<S>(
context: C,
stream: S,
) -> Result<Self, <C as Context>::Error>where
S: Read,
fn read_from_stream_buffered_with_ctx<S>(
context: C,
stream: S,
) -> Result<Self, <C as Context>::Error>where
S: Read,
fn read_from_file_with_ctx( context: C, path: impl AsRef<Path>, ) -> Result<Self, <C as Context>::Error>
Source§impl<C_: Context> Writable<C_> for Message
impl<C_: Context> Writable<C_> for Message
fn write_to<T_: ?Sized + Writer<C_>>( &self, _writer_: &mut T_, ) -> Result<(), C_::Error>
fn write_to_buffer(
&self,
buffer: &mut [u8],
) -> Result<(), <C as Context>::Error>where
Self: DefaultContext<Context = C>,
C: Default,
fn write_to_vec(&self) -> Result<Vec<u8>, <C as Context>::Error>where
Self: DefaultContext<Context = C>,
C: Default,
fn write_to_stream<S>(&self, stream: S) -> Result<(), <C as Context>::Error>
fn write_to_file(
&self,
path: impl AsRef<Path>,
) -> Result<(), <C as Context>::Error>where
Self: DefaultContext<Context = C>,
C: Default,
fn write_to_buffer_with_ctx( &self, context: C, buffer: &mut [u8], ) -> Result<(), <C as Context>::Error>
fn write_to_buffer_with_ctx_mut( &self, context: &mut C, buffer: &mut [u8], ) -> Result<(), <C as Context>::Error>
fn write_to_vec_with_ctx( &self, context: C, ) -> Result<Vec<u8>, <C as Context>::Error>
fn write_to_vec_with_ctx_mut( &self, context: &mut C, ) -> Result<Vec<u8>, <C as Context>::Error>
fn write_to_stream_with_ctx<S>(
&self,
context: C,
stream: S,
) -> Result<(), <C as Context>::Error>where
S: Write,
fn write_to_file_with_ctx( &self, context: C, path: impl AsRef<Path>, ) -> Result<(), <C as Context>::Error>
fn bytes_needed(&self) -> Result<usize, <C as Context>::Error>
Auto Trait Implementations§
impl Freeze for Message
impl RefUnwindSafe for Message
impl Send for Message
impl Sync for Message
impl Unpin for Message
impl UnsafeUnpin for Message
impl UnwindSafe for Message
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more