TEXPANDS¶
Tile Operation Diagram¶
Introduction¶
Broadcast a scalar into a destination tile.
Math Interpretation¶
For each element (i, j) in the valid region:
\[ \mathrm{dst}_{i,j} = \mathrm{scalar} \]
Assembly Syntax¶
PTO-AS form: see PTO-AS Specification.
Synchronous form:
%dst = texpands %scalar : f32, !pto.tile<...>
IR Level 1 (SSA)¶
%dst = pto.texpands %scalar : dtype -> !pto.tile<...>
IR Level 2 (DPS)¶
pto.texpands ins(%scalar : dtype) outs(%dst : !pto.tile_buf<...>)
C++ Intrinsic¶
Declared in include/pto/common/pto_instr.hpp:
template <typename TileData, typename... WaitEvents>
PTO_INST RecordEvent TEXPANDS(TileData& dst, typename TileData::DType scalar, WaitEvents&... events);
Constraints¶
- Implementation checks (A2A3):
- For
TileType::Vec:TileData::DTypemust be one of:int32_t,int16_t,half,float.- Tile layout must be row-major (
TileData::isRowMajor). - Static valid bounds:
TileData::ValidRow <= TileData::RowsandTileData::ValidCol <= TileData::Cols.
- For
TileType::Mat:TileData::DTypemust be one of:uint8_t,int8_t,uint16_t,int16_t,uint32_t,int32_t,half,float.- Static valid bounds:
The range of TileData::Rows * TileData::Cols * sizeof(T) / 32 is [1, 32767].
- Implementation checks (A5):
- For
TileType::Vec:TileData::DTypemust be one of:uint8_t,int8_t,uint16_t,int16_t,uint32_t,int32_t,half,float.- Tile layout must be row-major (
TileData::isRowMajor). - Static valid bounds:
TileData::ValidRow <= TileData::RowsandTileData::ValidCol <= TileData::Cols.
- For
TileType::Mat:TileData::DTypemust be one of:uint8_t,int8_t,uint16_t,int16_t,uint32_t,int32_t,half,float.- For
TileDataDst::layout == pto::Layout::NC1HWC0 || TileDataDst::layout == pto::Layout::FRACTAL_Z: The range of convtile's (shape0 * shape1 * shape2 * shape3) is [1, 32767].- For
TileDataDst::layout == pto::Layout::NDC1HWC0 || TileDataDst::layout == pto::Layout::FRACTAL_Z_3D: The range of convtile's (shape0 * shape1 * shape2 * shape3 * shape4) is [1, 32767].
- Valid region:
- For
TileType::Vec:- The op fills
dstoverdst.GetValidRow()/dst.GetValidCol().
- The op fills
- For
TileType::Mat:- For Tile : The op fills
dstoverTileData::Rows/TileData::Cols. - For ConvTile : The op fills
dstoverConvTileData's shape.
- For Tile : The op fills
Examples¶
Auto¶
#include <pto/pto-inst.hpp>
using namespace pto;
void example_auto() {
using TileT = Tile<TileType::Vec, float, 16, 16>;
TileT dst;
TEXPANDS(dst, 0.0f);
}
Manual¶
#include <pto/pto-inst.hpp>
using namespace pto;
void example_manual() {
using TileT = Tile<TileType::Vec, float, 16, 16>;
TileT dst;
TASSIGN(dst, 0x1000);
TEXPANDS(dst, 0.0f);
}
ASM Form Examples¶
Auto Mode¶
# Auto mode: compiler/runtime-managed placement and scheduling.
%dst = pto.texpands %scalar : dtype -> !pto.tile<...>
Manual Mode¶
# Manual mode: bind resources explicitly before issuing the instruction.
# Optional for tile operands:
# pto.tassign %arg0, @tile(0x1000)
# pto.tassign %arg1, @tile(0x2000)
%dst = pto.texpands %scalar : dtype -> !pto.tile<...>
PTO Assembly Form¶
%dst = texpands %scalar : f32, !pto.tile<...>
# IR Level 2 (DPS)
pto.texpands ins(%scalar : dtype) outs(%dst : !pto.tile_buf<...>)