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

A pack operation. Tensor pack operation.

The pack operation converts an input tensor to a higher-dimensional tensor with a tiled and packed layout. The mandatory inner_dims_pos attribute specifies a permutation for the original dimensions, while inner_tiles is the tiling factor for each dimension. The optional attribute outer_dims_perm specifies the order for the tiled data dimension, while the attribute padding_value specifies a padding value at the boundary on non-perfectly divisible dimensions. Padding is optional:

  • If absent, it is UB if the tile does not perfectly divide the dimension.
  • If present, it will pad along high dimensions (high-padding) to make the tile complete.

Example NC_to_NCnc:

%0 = tensor.pack %source inner_dims_pos = [0, 1]
  inner_tiles = [8, 32] into %dest : tensor<128x256xf32> -> tensor<16x8x8x32xf32>

Example CK to KCck

%0 = tensor.pack %source outer_dims_perm = [1, 0] inner_dims_pos = [0, 1]
  inner_tiles = [8, 32] into %dest : tensor<128x256xf32> -> tensor<8x16x8x32xf32>

In all cases, dimension at position 0 in the input tensor (128) is tiled with a factor of 8, while dimension at position 1 (256) is tiled with a factor of 32. In the second example, the outer data dimensions are interchanged according to outer_dims_perm.

Example NC_to_NCnc with padding:

%0 = tensor.pack %arg padding_value(%pad : f32) inner_dims_pos = [0, 1]
  inner_tiles = [8, 2] into %arg1 : tensor<13x15xf32> -> tensor<2x8x8x2xf32>

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, Unset, Unset, Unset>

Creates a builder.

source

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

source

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

source

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

source

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

source

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

source

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

source

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

source

pub fn remove_outer_dims_perm(&mut self) -> Result<(), Error>

source

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

source

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

source

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

source

pub fn set_static_inner_tiles(&mut self, value: Attribute<'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.