Skip to content

'iree_encoding' Dialectlink

Tensor encoding attributes and ops.

A dialect defining IREE tensor encoding attributes and related ops, used to implement data-tiling.

Operationslink

iree_encoding.set_encoding (Encoding::SetEncodingOp)link

Perform pack and pad operation on source

Syntax:

operation ::= `iree_encoding.set_encoding` attr-dict $source `:` type($source) `->` type($result)

Operation to assign an encoding to a tensor. The operation does not change the rank or extent of a tensor. Instead it adds an encoding attribute to the tensor type to represent a change in layout.

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), ReifyRankedShapedTypeOpInterface

Effects: MemoryEffects::Effect{}

Operands:link
Operand Description
source ranked tensor of any type values
Results:link
Result Description
result ranked tensor of any type values

iree_encoding.unset_encoding (Encoding::UnsetEncodingOp)link

Perfom unpack and extract operation on source

Syntax:

operation ::= `iree_encoding.unset_encoding` attr-dict $source `:` type($source) `->` type($result)

Operation to convert an tensor with encoding that represents its data layout into a tensor with default layout (i.e. no encoding). For now in IREE the default layout is row-major.

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), ReifyRankedShapedTypeOpInterface

Effects: MemoryEffects::Effect{}

Operands:link
Operand Description
source ranked tensor of any type values
Results:link
Result Description
result ranked tensor of any type values

iree_encoding.upper_bound_tile_size (Encoding::UpperBoundTileSizeOp)link

Returns an upper bound on tile sizes

Syntax:

operation ::= `iree_encoding.upper_bound_tile_size` attr-dict $tensorType `->` type($results)

This returns the largest tile sizes that might result from materialization of the given encoding. This can be used outside of target-specific code, so there may be multiple targets, and this will return the maximum tile size from iterating over all of them. The evaluation happens in the MaterializeUpperBoundTileSize pass.

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Attributes:link
AttributeMLIR TypeDescription
tensorType::mlir::TypeAttrtype attribute of ranked tensor of any type values
Results:link
Result Description
results variadic of index

Attributeslink

EncodingAttrlink

information to decide how to data-tile a tensor

Syntax:

#iree_encoding.encoding<
  EncodingRoleAttr,   # role
  ArrayAttr,   # element_types
  TypeAttr,   # original_type
  IntegerAttr,   # matmul_narrow_M
  IntegerAttr,   # matmul_narrow_N
  ArrayAttr,   # user_indexing_maps
  DenseArrayAttr   # round_dims_to
>

This attribute describes the change in the layout for a given tensor to execute subsequent operations on the tiled layout. The encoding serves as a way to represent the change in the way the data is laid out in memory without changing the logical rank/extent of the tensor itself. When required, the encoding can be used to explicitly manifest the layout change through operations like pack/unpack.

Parameters:link
Parameter C++ type Description
role EncodingRoleAttr role of this tensor as an operand
element_types ArrayAttr element types of the user's operands
original_type TypeAttr type of the original tensor type before padding
matmul_narrow_M IntegerAttr optional M narrow dimension size (only for contraction op user_indexing_maps)
matmul_narrow_N IntegerAttr optional N narrow dimension size (only for contraction op user_indexing_maps)
user_indexing_maps ArrayAttr Indexing maps of the operation using this tensor
round_dims_to DenseArrayAttr Values for padding M,N,K dimensions

EncodingRoleAttrlink

Describes the role of the tensor as an operand or a result of an operation.

Syntax:

#iree_encoding.role<
  ::mlir::iree_compiler::IREE::Encoding::EncodingRole   # value
>

Enum cases: * LHS (LHS) * RHS (RHS) * RESULT (RESULT)

Parameters:link
Parameter C++ type Description
value ::mlir::iree_compiler::IREE::Encoding::EncodingRole an enum of type EncodingRole