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 by sparse_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>

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> ) -> PackOperationBuilder<'c, Unset, Unset, Unset>

Creates a builder.

source

pub fn result(&self) -> Result<OperationResult<'c, '_>, Error>

source

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

source

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

Trait Implementations§

source§

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

source§

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

Converts to this type from the input type.
source§

impl<'c> TryFrom<Operation<'c>> for PackOperation<'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 PackOperation<'c>

§

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

§

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

§

impl<'c> Unpin for PackOperation<'c>

§

impl<'c> UnwindSafe for PackOperation<'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.