TROWEXPAND

指令示意图

TROWEXPAND tile operation

简介

将每个源行的第一个元素广播到目标行中。

数学语义

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: dst and src must be TileType::Vec.
  • Tile 布局: ND fractal (isRowMajor and SLayout::NoneBox) for both src and dst.
  • Data type: A2A3/A5 element types must be one of: int8_t or uint8_t or int16_t or uint16_t or int32_t or uint32_t or half or bfloat16_t or float.
  • 运行期有效区域检查:
    • A2A3: returns early if any of dstValidRow, dstValidCol, srcValidRow, srcValidCol is zero.
    • A5: asserts srcValidRow == dstValidRow and asserts srcValidRow != 0 && srcValidCol != 0.

示例

自动(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);
}