TLOG¶
Tile Operation Diagram¶
Introduction¶
Elementwise natural logarithm of a tile.
Math Interpretation¶
For each element (i, j) in the valid region:
\[ \mathrm{dst}_{i,j} = \log(\mathrm{src}_{i,j}) \]
Assembly Syntax¶
PTO-AS form: see PTO-AS Specification.
Synchronous form:
%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<...>)
C++ Intrinsic¶
Declared in include/pto/common/pto_instr.hpp:
template <auto PrecisionType = LogAlgorithm::DEFAULT, typename TileDataDst, typename TileDataSrc,
typename... WaitEvents>
PTO_INST RecordEvent TLOG(TileDataDst &dst, TileDataSrc &src, WaitEvents &... events);
PrecisionType has the following values available:
LogAlgorithm::DEFAULT: Normal algorithm, faster but with lower precision.LogAlgorithm::HIGH_PRECISION: High precision algorithm, but slower.
Constraints¶
- Implementation checks (NPU):
TileData::DTypemust be one of:floatorhalf;- Tile location must be vector (
TileData::Loc == TileType::Vec); - Static valid bounds:
TileData::ValidRow <= TileData::RowsandTileData::ValidCol <= TileData::Cols; - Runtime:
src.GetValidRow() == dst.GetValidRow()andsrc.GetValidCol() == dst.GetValidCol(); - Tile layout must be row-major (
TileData::isRowMajor).
- Valid region:
- The op uses
dst.GetValidRow()/dst.GetValidCol()as the iteration domain.
- The op uses
- Domain / NaN:
- Domain behavior (e.g.,
log(<=0)) is target-defined.
- Domain behavior (e.g.,
- High Precision Algorithm
- Only available on A5,
PrecisionTypeoption is ignored on A3.
- Only available on A5,
Examples¶
#include <pto/pto-inst.hpp>
using namespace pto;
void example() {
using TileT = Tile<TileType::Vec, float, 16, 16>;
TileT x, out;
TLOG(out, x);
TLOG<LogAlgorithm::HIGH_PRECISION>(out, x); // A5 Only
}
ASM Form Examples¶
Auto Mode¶
# Auto mode: compiler/runtime-managed placement and scheduling.
%dst = pto.tlog %src : !pto.tile<...> -> !pto.tile<...>
Manual Mode¶
# Manual mode: resources must be bound explicitly before issuing the instruction.
# Optional for tile operands:
# pto.tassign %arg0, @tile(0x1000)
# pto.tassign %arg1, @tile(0x2000)
%dst = pto.tlog %src : !pto.tile<...> -> !pto.tile<...>
PTO Assembly Form¶
%dst = tlog %src : !pto.tile<...>
# AS Level 2 (DPS)
pto.tlog ins(%src : !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)