Struct melior::dialect::ods::sparse_tensor::PackOperation
source · pub struct PackOperation<'c> { /* private fields */ }
Expand description
A pack
operation. Returns a sparse tensor from the given values, levels.
Packs the values and per-level coordinate or postion arrays into a sparse tensor. The order and types of provided levels must be consistent with the actual storage layout of the returned sparse tensor described below.
values : tensor<? x V>
supplies the value for each stored element in the sparse tensor.levels: [tensor<? x iType>, ...]
each supplies the sparse tensor coordinates scheme in the sparse tensor for the corresponding level as specifed bysparse_tensor::StorageLayout
.
This operation can be used to materialize a sparse tensor from external sources; e.g., when passing two numpy arrays from Python.
Disclaimer: This is the user’s responsibility to provide input that can be correctly interpreted by the sparse compiler, which does not perform any sanity test during runtime to verify data integrity.
TODO: The returned tensor is allowed (in principle) to have non-identity dimOrdering/higherOrdering mappings. However, the current implementation does not yet support them.
Example:
%values = arith.constant dense<[ 1.1, 2.2, 3.3 ]> : tensor<3xf64>
%coordinates = arith.constant dense<[[0,0], [1,2], [1,3]]> : tensor<3x2xindex>
%st = sparse_tensor.pack %values, %coordinates
: tensor<3xf64>, tensor<3x2xindex> to tensor<3x4xf64, #COO>
// yields COO format |1.1, 0.0, 0.0, 0.0|
// of 3x4 matrix |0.0, 0.0, 2.2, 3.3|
// |0.0, 0.0, 0.0, 0.0|
Implementations§
source§impl<'c> PackOperation<'c>
impl<'c> PackOperation<'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>
) -> PackOperationBuilder<'c, Unset, Unset, Unset>
pub fn builder( context: &'c Context, location: Location<'c> ) -> PackOperationBuilder<'c, Unset, Unset, Unset>
Creates a builder.