Trait SliceAccess
pub trait SliceAccess: Sized + Clone {
// Required methods
fn zeros_like(sample: &Self, capacity: usize, device: &Device) -> Self;
fn select(self, dim: usize, indices: Tensor<1, Int>) -> Self;
fn slice_assign_inplace(&mut self, index: usize, value: Self);
}Expand description
Trait for types that support tensor-like slice operations,
enabling storage in a TransitionBuffer.
Implement this trait for any type that wraps tensors and can be stored in a replay buffer. The buffer uses these operations for:
- Pre-allocating storage (
zeros_like) - Writing transitions (
slice_assign_inplace) - Sampling batches (
select)
Required Methods§
fn zeros_like(sample: &Self, capacity: usize, device: &Device) -> Self
fn zeros_like(sample: &Self, capacity: usize, device: &Device) -> Self
Create zeroed storage matching the shape of sample but with capacity rows
along the first dimension.
fn select(self, dim: usize, indices: Tensor<1, Int>) -> Self
fn select(self, dim: usize, indices: Tensor<1, Int>) -> Self
Select rows at the given indices along the specified dimension.
fn slice_assign_inplace(&mut self, index: usize, value: Self)
fn slice_assign_inplace(&mut self, index: usize, value: Self)
Assign value at row index along the first dimension, in place.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".