Struct melior::dialect::ods::sparse_tensor::ExpandOperation
source · pub struct ExpandOperation<'c> { /* private fields */ }
Expand description
An expand
operation. Expands an access pattern for insertion.
Performs an access pattern expansion for the innermost levels of the given tensor. This operation is useful to implement kernels in which a sparse tensor appears as output. This technique is known under several different names and using several alternative implementations, for example, phase counter [Gustavson72], expanded or switch array [Pissanetzky84], in phase scan [Duff90], access pattern expansion [Bik96], and workspaces [Kjolstad19].
The values
and filled
arrays must have lengths equal to the
level-size of the innermost level (i.e., as if the innermost level
were dense). The added
array and count
are used to store new
level-coordinates when a false value is encountered in the filled
array. All arrays should be allocated before the loop (possibly even
shared between loops in a future optimization) so that their dense
initialization can be amortized over many iterations. Setting and
resetting the dense arrays in the loop nest itself is kept sparse
by only iterating over set elements through an indirection using
the added array, so that the operations are kept proportional to
the number of nonzeros.
Note that this operation is “impure” in the sense that even though the results are modeled through SSA values, the operation relies on a proper side-effecting context that sets and resets the expanded arrays.
Example:
%values, %filled, %added, %count = sparse_tensor.expand %tensor
: tensor<4x4xf64, #CSR> to memref<?xf64>, memref<?xi1>, memref<?xindex>
Implementations§
source§impl<'c> ExpandOperation<'c>
impl<'c> ExpandOperation<'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>
) -> ExpandOperationBuilder<'c, Unset, Unset, Unset, Unset, Unset>
pub fn builder( context: &'c Context, location: Location<'c> ) -> ExpandOperationBuilder<'c, Unset, Unset, Unset, Unset, Unset>
Creates a builder.