TCOLEXPANDEXPDIF

指令示意图

TCOLEXPANDEXPDIF tile operation

简介

列指数差运算:计算 exp(src0 - src1),其中 src1 为每列标量。

数学语义

R = dst.GetValidRow()C = dst.GetValidCol()。设 s_j 为从 src1 中获取的每列标量(每列一个值)。

对于 0 <= i < R0 <= j < C

\[ \mathrm{dst}_{i,j} = \exp(\mathrm{src0}_{i,j} - s_j) \]

汇编语法

PTO-AS 形式:参见 PTO-AS 规范

同步形式:

%dst = tcolexpandexpdif %src0, %src1 : !pto.tile<...>, !pto.tile<...> -> !pto.tile<...>

AS Level 1(SSA)

%dst = pto.tcolexpandexpdif %src0, %src1 : !pto.tile<...>, !pto.tile<...> -> !pto.tile<...>

AS Level 2(DPS)

pto.tcolexpandexpdif ins(%src0, %src1 : !pto.tile_buf<...>, !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)

C++ 内建接口

声明于 include/pto/common/pto_instr.hpp

template <typename TileDataDst, typename TileDataSrc1, typename... WaitEvents>
PTO_INST RecordEvent TCOLEXPANDEXPDIF(TileDataDst &dst, TileDataDst &src0, TileDataSrc1 &src1, WaitEvents &... events);

约束

  • TileDataDst::DTypeTileDataSrc1::DType 必须是以下之一:halffloat
  • Tile 形状/布局约束(编译时):TileDataDst::isRowMajor
  • src1 预期提供每列一个标量(即,其有效形状必须覆盖 C 个值)。
  • 确切的布局/分形约束是目标特定的;参见 include/pto/npu/*/TColExpand*.hpp 下的后端头文件。

示例

参见 docs/isa/docs/coding/tutorials/ 中的相关示例。

汇编示例(ASM)

自动模式

# 自动模式:由编译器/运行时负责资源放置与调度。
%dst = pto.tcolexpandexpdif %src0, %src1 : !pto.tile<...>, !pto.tile<...> -> !pto.tile<...>

手动模式

# 手动模式:先显式绑定资源,再发射指令。
# 可选(当该指令包含 tile 操作数时):
# pto.tassign %arg0, @tile(0x1000)
# pto.tassign %arg1, @tile(0x2000)
%dst = pto.tcolexpandexpdif %src0, %src1 : !pto.tile<...>, !pto.tile<...> -> !pto.tile<...>

PTO 汇编形式

%dst = tcolexpandexpdif %src0, %src1 : !pto.tile<...>, !pto.tile<...> -> !pto.tile<...>
# AS Level 2 (DPS)
pto.tcolexpandexpdif ins(%src0, %src1 : !pto.tile_buf<...>, !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)