pub struct PreparedDiagonalPlan { /* private fields */ }Expand description
Caller-owned, device-bound indices for repeated-axis diagonal extraction.
Axis ids represent the input side of an einsum equation: equal ids are the
repeated labels whose diagonal is retained, and first occurrence order
determines the output axes. Preparing once avoids rebuilding and uploading
the same u32 index tensor for repeated calls with the same shape.
Implementations§
Source§impl PreparedDiagonalPlan
impl PreparedDiagonalPlan
Sourcepub fn new(
input_shape: &[usize],
axis_ids: &[usize],
device: &Device,
) -> Result<Self>
pub fn new( input_shape: &[usize], axis_ids: &[usize], device: &Device, ) -> Result<Self>
Prepares reusable diagonal indices for one exact shape and device.
Sourcepub fn repeated(
extent: usize,
multiplicity: usize,
device: &Device,
) -> Result<Self>
pub fn repeated( extent: usize, multiplicity: usize, device: &Device, ) -> Result<Self>
Convenience constructor for i i ... -> i extraction.
Sourcepub fn interleaved(
first_extent: usize,
second_extent: usize,
device: &Device,
) -> Result<Self>
pub fn interleaved( first_extent: usize, second_extent: usize, device: &Device, ) -> Result<Self>
Convenience constructor for i j i j -> i j extraction.
Sourcepub fn execute(&self, input: &Tensor) -> Result<Tensor>
pub fn execute(&self, input: &Tensor) -> Result<Tensor>
Extracts the prepared diagonal from one contiguous tensor.
Sourcepub fn input_shape(&self) -> &[usize]
pub fn input_shape(&self) -> &[usize]
Exact input shape captured by this plan.
Sourcepub fn output_shape(&self) -> &[usize]
pub fn output_shape(&self) -> &[usize]
Unique-axis output shape in first-occurrence order.
Sourcepub const fn index_dtype(&self) -> DType
pub const fn index_dtype(&self) -> DType
Device index representation used by the prepared gather.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for PreparedDiagonalPlan
impl !UnwindSafe for PreparedDiagonalPlan
impl Freeze for PreparedDiagonalPlan
impl Send for PreparedDiagonalPlan
impl Sync for PreparedDiagonalPlan
impl Unpin for PreparedDiagonalPlan
impl UnsafeUnpin for PreparedDiagonalPlan
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
impl<T> ErasedDestructor for Twhere
T: 'static,
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