Struct melior::dialect::ods::sparse_tensor::SortOperation
source · 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>
impl<'c> SortOperation<'c>
sourcepub fn as_operation(&self) -> &Operation<'c>
pub fn as_operation(&self) -> &Operation<'c>
Returns a generic operation.
sourcepub fn builder(
context: &'c Context,
location: Location<'c>
) -> SortOperationBuilder<'c, Unset, Unset, Unset, Unset>
pub fn builder( context: &'c Context, location: Location<'c> ) -> SortOperationBuilder<'c, Unset, Unset, Unset, Unset>
Creates a builder.