TLOG

指令示意图

TLOG tile operation

简介

Tile 的逐元素自然对数。

数学语义

对每个元素 (i, j) 在有效区域内:

\[ \mathrm{dst}_{i,j} = \log(\mathrm{src}_{i,j}) \]

汇编语法

PTO-AS 形式:参见 PTO-AS Specification.

同步形式:

%dst = tlog %src : !pto.tile<...>

AS Level 1 (SSA)

%dst = pto.tlog %src : !pto.tile<...> -> !pto.tile<...>

AS Level 2 (DPS)

pto.tlog ins(%src : !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)

AS Level 1(SSA)

%dst = pto.tlog %src : !pto.tile<...> -> !pto.tile<...>

AS Level 2(DPS)

pto.tlog 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 TLOG(TileDataDst &dst, TileDataSrc &src, WaitEvents &... events);

约束

  • 实现检查 (NPU):
    • TileData::DType must be one of: float or half;
    • Tile location must be vector (TileData::Loc == TileType::Vec);
    • Static valid bounds: TileData::ValidRow <= TileData::Rows and TileData::ValidCol <= TileData::Cols;
    • Runtime: src.GetValidRow() == dst.GetValidRow() and src.GetValidCol() == dst.GetValidCol();
    • Tile 布局 must be row-major (TileData::isRowMajor).
  • 有效区域:
    • The op uses dst.GetValidRow() / dst.GetValidCol() as the iteration domain.
  • Domain / NaN:
    • Domain behavior (e.g., log(<=0)) is target-defined.

示例

#include <pto/pto-inst.hpp>

using namespace pto;

void example() {
  using TileT = Tile<TileType::Vec, float, 16, 16>;
  TileT x, out;
  TLOG(out, x);
}