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>
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, Unset, Unset, Unset>
pub fn builder( context: &'c Context, location: Location<'c> ) -> PackOperationBuilder<'c, Unset, Unset, Unset, Unset, Unset, Unset>
Creates a builder.