TROWEXPAND¶
指令示意图¶
简介¶
将每个源行的第一个元素广播到目标行中。
数学语义¶
Let R = dst.GetValidRow() and C = dst.GetValidCol(). For 0 <= i < R and 0 <= j < C:
\[ \mathrm{dst}_{i,j} = \mathrm{src}_{i,0} \]
汇编语法¶
PTO-AS 形式:参见 PTO-AS Specification.
同步形式:
%dst = trowexpand %src : !pto.tile<...> -> !pto.tile<...>
AS Level 1 (SSA)¶
%dst = pto.trowexpand %src : !pto.tile<...> -> !pto.tile<...>
AS Level 2 (DPS)¶
pto.trowexpand ins(%src : !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
AS Level 1(SSA)¶
%dst = pto.trowexpand %src : !pto.tile<...> -> !pto.tile<...>
AS Level 2(DPS)¶
pto.trowexpand ins(%src : !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
C++ 内建接口¶
声明于 include/pto/common/pto_instr.hpp:
template <typename TileDataDst, typename TileDataSrc, typename... WaitEvents>
PTO_INST RecordEvent TROWEXPAND(TileDataDst &dst, TileDataSrc &src, WaitEvents &... events);
约束¶
实现检查 (NPU):
- Tile Type:
dstandsrcmust beTileType::Vec. - Tile 布局: ND fractal (
isRowMajorandSLayout::NoneBox) for bothsrcanddst. - Data type: A2A3/A5 element types must be one of:
int8_toruint8_torint16_toruint16_torint32_toruint32_torhalforbfloat16_torfloat. - 运行期有效区域检查:
- A2A3: returns early if any of
dstValidRow,dstValidCol,srcValidRow,srcValidColis zero. - A5: asserts
srcValidRow == dstValidRowand assertssrcValidRow != 0 && srcValidCol != 0.
- A2A3: returns early if any of
示例¶
自动(Auto)¶
#include <pto/pto-inst.hpp>
using namespace pto;
void example_auto() {
using SrcT = Tile<TileType::Vec, float, 16, 16>;
using DstT = Tile<TileType::Vec, float, 16, 16>;
SrcT src;
DstT dst;
TROWEXPAND(dst, src);
}
手动(Manual)¶
#include <pto/pto-inst.hpp>
using namespace pto;
void example_manual() {
using SrcT = Tile<TileType::Vec, float, 16, 16>;
using DstT = Tile<TileType::Vec, float, 16, 16>;
SrcT src;
DstT dst;
TASSIGN(src, 0x1000);
TASSIGN(dst, 0x2000);
TROWEXPAND(dst, src);
}