pub struct Transaction<B: Backend> { /* private fields */ }Available on crate feature
api only.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<B: Backend> Transaction<B>
impl<B: Backend> Transaction<B>
Sourcepub fn register<const D: usize, K: TransactionOp<B> + BasicOps<B>>(
self,
tensor: Tensor<B, D, K>,
) -> Self
pub fn register<const D: usize, K: TransactionOp<B> + BasicOps<B>>( self, tensor: Tensor<B, 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<B> Freeze for Transaction<B>where
TransactionPrimitive<B>: Freeze,
impl<B> RefUnwindSafe for Transaction<B>where
TransactionPrimitive<B>: RefUnwindSafe,
impl<B> Send for Transaction<B>where
TransactionPrimitive<B>: Send,
impl<B> Sync for Transaction<B>where
TransactionPrimitive<B>: Sync,
impl<B> Unpin for Transaction<B>where
TransactionPrimitive<B>: Unpin,
impl<B> UnsafeUnpin for Transaction<B>where
TransactionPrimitive<B>: UnsafeUnpin,
impl<B> UnwindSafe for Transaction<B>where
TransactionPrimitive<B>: 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