pub struct Transaction { /* 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§
Source§impl Transaction
impl Transaction
Sourcepub fn register<const D: usize, K: Transaction>(
self,
tensor: Tensor<D, K>,
) -> Self
pub fn register<const D: usize, K: Transaction>( self, tensor: Tensor<D, K>, ) -> Self
Add a tensor to the transaction to be read.
Sourcepub 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.
Sourcepub fn try_execute(self) -> Result<Vec<TensorData>, ExecutionError>
pub fn try_execute(self) -> Result<Vec<TensorData>, ExecutionError>
Executes the transaction synchronously and returns the data in the same order in which they were registered.
§Returns
Any error that might have occurred since the last time the device was synchronized.
Sourcepub async fn execute_async(self) -> Result<Vec<TensorData>, ExecutionError>
pub async fn execute_async(self) -> Result<Vec<TensorData>, ExecutionError>
Executes the transaction asynchronously and returns the data in the same order in which they were registered.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Transaction
impl RefUnwindSafe for Transaction
impl Send for Transaction
impl Sync for Transaction
impl Unpin for Transaction
impl UnsafeUnpin for Transaction
impl UnwindSafe for Transaction
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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