Struct Transaction
pub struct Transaction<B>where
B: Backend,{ /* private fields */ }
Expand description
A transaction can read multiple tensors at once with a single operation improving compute utilization with optimized laziness.
§Example
ⓘ
let [output_data, loss_data, targets_data] = Transaction::default()
.register(output)
.register(loss)
.register(targets)
.execute()
.try_into()
.expect("Correct amount of tensor data");
Implementations§
§impl<B> Transaction<B>where
B: Backend,
impl<B> Transaction<B>where
B: Backend,
pub fn register<const D: usize, K>(
self,
tensor: Tensor<B, D, K>,
) -> Transaction<B>where
K: BasicOps<B>,
pub fn register<const D: usize, K>(
self,
tensor: Tensor<B, D, K>,
) -> Transaction<B>where
K: BasicOps<B>,
Add a tensor to the transaction to be read.
pub fn execute(self) -> Vec<TensorData>
pub fn execute(self) -> Vec<TensorData>
Executes the transaction synchronously and returns the data in the same order in which they were registered.
pub fn execute_async(self) -> impl Future<Output = Vec<TensorData>>
pub fn execute_async(self) -> impl Future<Output = Vec<TensorData>>
Executes the transaction asynchronously and returns the data in the same order in which they were registered.
Trait Implementations§
§impl<B> Default for Transaction<B>
impl<B> Default for Transaction<B>
§fn default() -> Transaction<B>
fn default() -> Transaction<B>
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl<B> Freeze for Transaction<B>
impl<B> RefUnwindSafe for Transaction<B>where
<B as Backend>::FloatTensorPrimitive: RefUnwindSafe,
<B as Backend>::QuantizedTensorPrimitive: RefUnwindSafe,
<B as Backend>::IntTensorPrimitive: RefUnwindSafe,
<B as Backend>::BoolTensorPrimitive: RefUnwindSafe,
impl<B> Send for Transaction<B>
impl<B> Sync for Transaction<B>
impl<B> Unpin for Transaction<B>where
<B as Backend>::FloatTensorPrimitive: Unpin,
<B as Backend>::QuantizedTensorPrimitive: Unpin,
<B as Backend>::IntTensorPrimitive: Unpin,
<B as Backend>::BoolTensorPrimitive: Unpin,
impl<B> UnwindSafe for Transaction<B>where
<B as Backend>::FloatTensorPrimitive: UnwindSafe,
<B as Backend>::QuantizedTensorPrimitive: UnwindSafe,
<B as Backend>::IntTensorPrimitive: UnwindSafe,
<B as Backend>::BoolTensorPrimitive: UnwindSafe,
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
Mutably borrows from an owned value. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
Converts
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>
Converts
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§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian()
.