pub struct SortOperation<'c> { /* private fields */ }
Expand description

A sort operation. Sorts the arrays in xs and ys lexicographically on the integral values found in the xs list.

Lexicographically sort the first n values in xs along with the values in ys. Conceptually, the values being sorted are tuples produced by zip(zip(xs), zip(ys)). In particular, values in ys needed to be sorted along with values in xs, but values in ys don’t affect the lexicographical order. The order in which arrays appear in xs affects the sorting result. The operator updates xs and ys in place with the result of the sorting.

For example, assume x1=[4, 3], x2=[1, 2], y1=[10, 5], then the output of “sort 2, x1, x2 jointly y1” are x1=[3, 4], x2=[2, 1], y1=[5, 10] while the output of “sort 2, x2, x1, jointly y1” are x2=[1, 2], x1=[4, 3], y1=[10, 5].

Buffers in xs needs to have the same integral element type while buffers in ys can have different numeric element types. All buffers in xs and ys should have a dimension not less than n. The behavior of the operator is undefined if this condition is not met. The operator requires at least one buffer in xs while ys can be empty.

The enum attribute algorithm indicates the sorting algorithm used to implement the operator: hybrid_quick_sort, insertion_sort_stable, quick_sort, or heap_sort.

Note that this operation is “impure” in the sense that its behavior is solely defined by side-effects and not SSA values.

Example:

sparse_tensor.sort insertion_sort_stable %n, %x1, %x2 jointly y1, %y2
  : memref<?xindex>, memref<?xindex> jointly memref<?xindex>, memref<?xf32>
sparse_tensor.sort hybrid_quick_sort %n, %x1, %x2 jointly y1, %y2
  { alg=1 : index}
  : memref<?xindex>, memref<?xindex> jointly memref<?xindex>, memref<?xf32>

Implementations§

source§

impl<'c> SortOperation<'c>

source

pub fn name() -> &'static str

Returns a name.

source

pub fn as_operation(&self) -> &Operation<'c>

Returns a generic operation.

source

pub fn builder( context: &'c Context, location: Location<'c> ) -> SortOperationBuilder<'c, Unset, Unset, Unset, Unset>

Creates a builder.

source

pub fn n(&self) -> Result<Value<'c, '_>, Error>

source

pub fn xs(&self) -> Result<impl Iterator<Item = Value<'c, '_>>, Error>

source

pub fn ys(&self) -> Result<impl Iterator<Item = Value<'c, '_>>, Error>

source

pub fn algorithm(&self) -> Result<Attribute<'c>, Error>

source

pub fn set_algorithm(&mut self, value: Attribute<'c>)

Trait Implementations§

source§

impl<'c> From<SortOperation<'c>> for Operation<'c>

source§

fn from(operation: SortOperation<'c>) -> Self

Converts to this type from the input type.
source§

impl<'c> TryFrom<Operation<'c>> for SortOperation<'c>

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(operation: Operation<'c>) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

§

impl<'c> RefUnwindSafe for SortOperation<'c>

§

impl<'c> !Send for SortOperation<'c>

§

impl<'c> !Sync for SortOperation<'c>

§

impl<'c> Unpin for SortOperation<'c>

§

impl<'c> UnwindSafe for SortOperation<'c>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.