ArchAttr

TT Arch

Syntax:

#tt.arch<
  ::mlir::tt::Arch   # value
>

Enum cases:

  • grayskull (Grayskull)
  • wormhole_b0 (WormholeB0)
  • blackhole (Blackhole)

Parameters:

ParameterC++ typeDescription
value::mlir::tt::Archan enum of type Arch

ArgumentAllocationAttr

Argument allocation attribute in TT dialect

Syntax:

#tt.arg_alloc<
  uint64_t,   # address
  uint64_t,   # size
  MemorySpace   # memorySpace
>

Holds the metadata for the allocation of an function argument i.e. for graph inputs.

Parameters:

ParameterC++ typeDescription
addressuint64_t
sizeuint64_t
memorySpaceMemorySpace

BufferAccessAttr

TT Buffer Access

Syntax:

#tt.buffer_access<
  ::mlir::tt::BufferAccess   # value
>

Enum cases:

  • alias (Alias)
  • stream (Stream)

Parameters:

ParameterC++ typeDescription
value::mlir::tt::BufferAccessan enum of type BufferAccess

BufferAttr

Buffer attribute in TT dialect

Syntax:

#tt.buffer<
  MemRefType,   # memref
  BufferAccess   # buffer_access
>

Describes the physical footprint and layout of a buffer in L1. Its memref must also have a shape with rank equal to DeviceAttr grid. It also carries a buffer access attribute which can be one of:

  • Alias: This buffer aliases a persistent Tensor L1 allocation directly. Implies that no datamovement occurs and the compute kernel just accesses the local allocation directly.
  • Stream: This buffer is a temporary destination as a means to get remote data for local computation. Remote data is most likely a a tensor that is allocated in dram, but could also be data from a remote core.

Parameters:

ParameterC++ typeDescription
memrefMemRefTypeA memref that describes the physical footprint and layout of the buffer. It must also have a shape with rank equal to DeviceAttr grid.
buffer_accessBufferAccessHow data is accessed through this buffer, alias or stream.

ChipChannelAttr

TT chip_channel attribute

Syntax:

#tt.chip_channel<
  unsigned,   # deviceId0
  ::llvm::ArrayRef<int64_t>,   # ethernetCoreCoord0
  unsigned,   # deviceId1
  ::llvm::ArrayRef<int64_t>   # ethernetCoreCoord1
>

TT chip_channel attribute

Parameters:

ParameterC++ typeDescription
deviceId0unsigned
ethernetCoreCoord0::llvm::ArrayRef<int64_t>
deviceId1unsigned
ethernetCoreCoord1::llvm::ArrayRef<int64_t>

ChipCoordAttr

TT chip_coord attribute

Syntax:

#tt.chip_coord<
  unsigned,   # rack
  unsigned,   # shelf
  unsigned,   # y
  unsigned   # x
>

TT chip_coord attribute

Parameters:

ParameterC++ typeDescription
rackunsigned
shelfunsigned
yunsigned
xunsigned

ChipDescAttr

TT chip_desc attribute

Syntax:

#tt.chip_desc<
  ArchAttr,   # arch
  ::llvm::ArrayRef<int64_t>,   # grid
  unsigned,   # l1Size
  unsigned,   # numDramChannels
  unsigned,   # dramChannelSize
  unsigned,   # nocL1AddressAlignBytes
  unsigned,   # pcieAddressAlignBytes
  unsigned,   # nocDRAMAddressAlignBytes
  unsigned,   # l1UnreservedBase
  unsigned,   # eriscL1UnreservedBase
  unsigned,   # dramUnreservedBase
  unsigned,   # dramUnreservedEnd
  ChipPhysicalCoresAttr,   # chipPhysicalCores
  ::llvm::ArrayRef<DataTypeAttr>,   # supportedDataTypes
  ::llvm::ArrayRef<TileSizeAttr>   # supportedTileSizes
>

TT chip_desc attribute

Parameters:

ParameterC++ typeDescription
archArchAttr
grid::llvm::ArrayRef<int64_t>
l1Sizeunsigned
numDramChannelsunsigned
dramChannelSizeunsigned
nocL1AddressAlignBytesunsigned
pcieAddressAlignBytesunsigned
nocDRAMAddressAlignBytesunsigned
l1UnreservedBaseunsigned
eriscL1UnreservedBaseunsigned
dramUnreservedBaseunsigned
dramUnreservedEndunsigned
chipPhysicalCoresChipPhysicalCoresAttr
supportedDataTypes::llvm::ArrayRef<DataTypeAttr>
supportedTileSizes::llvm::ArrayRef<TileSizeAttr>

ChipPhysicalCoresAttr

TT chip_physical_cores attribute

Syntax:

#tt.chip_physical_cores<
  ::llvm::ArrayRef<CoreCoordAttr>,   # worker
  ::llvm::ArrayRef<CoreCoordAttr>,   # dram
  ::llvm::ArrayRef<CoreCoordAttr>,   # eth
  ::llvm::ArrayRef<CoreCoordAttr>   # eth_inactive
>

TT chip_physical_cores attribute containing arrays of physical cores by core type in order of logical cores.

Parameters:

ParameterC++ typeDescription
worker::llvm::ArrayRef<CoreCoordAttr>
dram::llvm::ArrayRef<CoreCoordAttr>
eth::llvm::ArrayRef<CoreCoordAttr>
eth_inactive::llvm::ArrayRef<CoreCoordAttr>

CoreCoordAttr

TT core_coord attribute

Syntax:

#tt.core_coord<
  int64_t,   # y
  int64_t   # x
>

TT core_coord attribute containing a single physical core coordinate.

Parameters:

ParameterC++ typeDescription
yint64_t
xint64_t

DataTypeAttr

TT DataTypes

Syntax:

#tt.supportedDataTypes<
  ::mlir::tt::DataType   # value
>

Enum cases:

  • f32 (Float32)
  • f16 (Float16)
  • bf16 (BFloat16)
  • bfp_f8 (BFP_Float8)
  • bfp_bf8 (BFP_BFloat8)
  • bfp_f4 (BFP_Float4)
  • bfp_bf4 (BFP_BFloat4)
  • bfp_f2 (BFP_Float2)
  • bfp_bf2 (BFP_BFloat2)
  • u32 (UInt32)
  • u16 (UInt16)
  • u8 (UInt8)

Parameters:

ParameterC++ typeDescription
value::mlir::tt::DataTypean enum of type DataType

DeviceAttr

Device attribute in TT dialect.

Syntax:

#tt.device<
  ::mlir::tt::GridAttr,   # workerGrid
  AffineMap,   # l1Map
  AffineMap,   # dramMap
  ::llvm::ArrayRef<int64_t>,   # meshShape
  ::llvm::ArrayRef<unsigned>   # chipIds
>

Describes the physical layout of a device in the system and is made up of a few components:

  • A grid attribute that describes the device's compute grid shape. It not only describes the shape of the compute grid, but also carries an affine map that describes how the logical grid maps to the physical grid.
  • Two affine maps that describe how a tensor layout's linear attribute maps to the L1 and DRAM memory spaces.
  • A mesh shape that describes the virtual layout of the chips with respect to each other. Note that in a multi-chip system, this grid encapsulates the entire system's grid shape, e.g. 8x16 grid could be made up of a 1x2 mesh of chips side-by-side. The mesh attribute configures how the above grid/map attributes are created such that they implement this mesh topology.
  • An array of chip ids that this device is made up of. This array's length must match the volume of the mesh shape and should be interpreted in row-major order.

Parameters:

ParameterC++ typeDescription
workerGrid::mlir::tt::GridAttrTT grid attribute
l1MapAffineMap
dramMapAffineMap
meshShape::llvm::ArrayRef<int64_t>
chipIds::llvm::ArrayRef<unsigned>

GridAttr

TT grid attribute

Syntax:

#tt.grid<
  ::llvm::ArrayRef<int64_t>,   # shape
  AffineMap   # mapping
>

TT grid attribute

Parameters:

ParameterC++ typeDescription
shape::llvm::ArrayRef<int64_t>
mappingAffineMap

IteratorTypeAttr

TT IteratorType

Syntax:

#tt.iterator_type<
  ::mlir::tt::IteratorType   # value
>

Enum cases:

  • parallel (Parallel)
  • systolic (Systolic)
  • broadcast (Broadcast)

Parameters:

ParameterC++ typeDescription
value::mlir::tt::IteratorTypean enum of type IteratorType

LayoutAttr

Tensor layout attribute

Syntax:

#tt.layout<
  AffineMap,   # linear
  OOBVal,   # oob_val
  GridAttr,   # grid
  MemRefType,   # memref
  TensorMemoryLayout   # mem_layout
>

The tensor layout attribute captures how tensor data is sharded across a grid of devices, cores, and is laid out in memory.

Some high level goals

  • Logical shapes: Keep the original tensor shape and rank intact and agnostic to underlying storage layout. Keeping the logical shapes not only makes some graph transformations vastly simpler, in particular convs, but it makes the lowered IR much easier to read and reason about. The original tensor shapes leave breadcrumbs that make it much easier to map back to the input representation.
  • Flexible sharding: Enable flexibility in choosing grid shape, to get better parallelization and avoid resharding. This is particularly important in cases where tensor shapes are not clean powers of two and would otherwise force our hand in choosing non-optimal grid shapes.
  • Logical-Physical Isomorphism: Encode this information with just a few attributes to enable derived conversions from logical to physical layout and back.
  • Explicit: A single source of truth.
  • Enable a direct way to query padded regions.

Please refer to the Tensor Layout Spec for more in depth documentation.

Examples:

tensor<8x300xf32,
  #tt.layout<(d0, d1) -> (d0, d1),
    undef,
    <1x2>,
    memref<8x150xf32, #tt.memory_space<l1>>
  >
>

tensor<8x96x32xf32,
  #tt.layout<(d0, d1, d2) -> (d0 * 96 + d1, d2),
    undef,
    <2x1>,
    memref<384x32xf32, #tt.memory_space<l1>>
  >
>

tensor<8x96x32xf32,
  #tt.layout<(d0, d1, d2) -> (d0 * 96 + d1, d1, d2),
    undef,
    <2x1x2>,
    memref<384x96x16xf32, #tt.memory_space<l1>>
  >
>

tensor<5x3x2x2x7x32x32xf32,
  #tt.layout<
    (d0, d1, d2, d3, d4, d5, d6)
      -> (d0 * 2688 + d1 * 896 + d2 * 448 + d3 * 224 + d4 * 32 + d5, d4, d5, d6),
    undef,
    <3x2x2x2>,
    memref<4480x4x16x16xf32, #tt.memory_space<l1>>
  >
>

Parameters:

ParameterC++ typeDescription
linearAffineMapAn affine map that defines how the logical tensor dimensions map to a grid shape.
oob_valOOBValA tracked out of bounds value that fills padding space.
gridGridAttrThe grid shape that this tensor is divided onto.
memrefMemRefTypeA memref that describes the physical footprint allocation of the shard. It must also have a shape with rank equal to grid.
mem_layoutTensorMemoryLayoutThe layout of the tensor in memory.

MemorySpaceAttr

TT MemorySpace

Syntax:

#tt.memory_space<
  ::mlir::tt::MemorySpace   # value
>

Enum cases:

  • system (System)
  • mmio (SystemMMIO)
  • dram (DeviceDRAM)
  • l1 (DeviceL1)

Parameters:

ParameterC++ typeDescription
value::mlir::tt::MemorySpacean enum of type MemorySpace

OOBValAttr

TT OOBVal

Syntax:

#tt.oob_val<
  ::mlir::tt::OOBVal   # value
>

Enum cases:

  • undef (Undef)
  • zero (Zero)
  • one (One)
  • inf (Inf)
  • neginf (NegInf)

Parameters:

ParameterC++ typeDescription
value::mlir::tt::OOBValan enum of type OOBVal

OperandConstraintAttr

TT Operand Constraints

Syntax:

#tt.operand_constraint<
  ::mlir::tt::OperandConstraint   # value
>

Enum cases:

  • system (System)
  • dram (DRAM)
  • l1 (L1)
  • scalar (Scalar)
  • tile (Tile)
  • none (None)
  • interleaved (Interleaved)
  • single_bank (SingleBank)
  • height_sharded (HeightSharded)
  • width_sharded (WidthSharded)
  • block_sharded (BlockSharded)
  • any_layout (AnyLayout)
  • any (Any)
  • any_device (AnyDevice)
  • any_device_tile (AnyDeviceTile)
  • l1_block_sharded (L1BlockSharded)

Parameters:

ParameterC++ typeDescription
value::mlir::tt::OperandConstraintan enum of type OperandConstraint

SystemDescAttr

TT system_desc attribute

Syntax:

#tt.system_desc<
  ::llvm::ArrayRef<ChipDescAttr>,   # chipDescs
  ::llvm::ArrayRef<unsigned>,   # chipDescIndices
  ::llvm::ArrayRef<ChipCapabilityAttr>,   # chipCapabilities
  ::llvm::ArrayRef<ChipCoordAttr>,   # chipCoords
  ::llvm::ArrayRef<ChipChannelAttr>   # chipChannels
>

TT system_desc attribute

Parameters:

ParameterC++ typeDescription
chipDescs::llvm::ArrayRef<ChipDescAttr>
chipDescIndices::llvm::ArrayRef<unsigned>
chipCapabilities::llvm::ArrayRef<ChipCapabilityAttr>
chipCoords::llvm::ArrayRef<ChipCoordAttr>
chipChannels::llvm::ArrayRef<ChipChannelAttr>

TensorMemoryLayoutAttr

TT TensorMemoryLayout

Syntax:

#tt.tensor_memory_layout<
  ::mlir::tt::TensorMemoryLayout   # value
>

Enum cases:

  • none (None)
  • interleaved (Interleaved)
  • single_bank (SingleBank)
  • height_sharded (HeightSharded)
  • width_sharded (WidthSharded)
  • block_sharded (BlockSharded)

Parameters:

ParameterC++ typeDescription
value::mlir::tt::TensorMemoryLayoutan enum of type TensorMemoryLayout

TileSizeAttr

TT tile_size attribute

Syntax:

#tt.tile_size<
  int64_t,   # y
  int64_t   # x
>

TT tile_size attribute containing a supported Tensix tile shape.

Parameters:

ParameterC++ typeDescription
yint64_t
xint64_t