TPOW¶
Tile Operation Diagram¶
Introduction¶
Elementwise power operation: computes base raised to the power of exp for each element.
Math Interpretation¶
For each element (i, j) in the valid region:
\[ \mathrm{dst}_{i,j} = \mathrm{base}_{i,j}^{\mathrm{exp}_{i,j}} \]
For floating-point types, the computation follows: dst = exp(ln(|base|) * exp) with special case handling for negative base values and integer exponents.
Assembly Syntax¶
PTO-AS form: see PTO-AS Specification.
Synchronous form:
%dst = tpow %base, %exp, %tmp : !pto.tile<...>
AS Level 1 (SSA)¶
%dst = pto.tpow %base, %exp, %tmp : (!pto.tile<...>, !pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
AS Level 2 (DPS)¶
pto.tpow ins(%base, %exp, %tmp : !pto.tile_buf<...>, !pto.tile_buf<...>, !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
C++ Intrinsic¶
Declared in include/pto/common/pto_instr.hpp:
template <auto PrecisionType = PowAlgorithm::DEFAULT, typename DstTile, typename BaseTile, typename ExpTile,
typename TmpTile, typename... WaitEvents>
PTO_INTERNAL RecordEvent TPOW(DstTile &dst, BaseTile &base, ExpTile &exp, TmpTile &tmp, WaitEvents &... events);
PrecisionType has the following values available:
PowAlgorithm::DEFAULT: Normal algorithm, faster but with lower precision.PowAlgorithm::HIGH_PRECISION: High precision algorithm, but slower.
Constraints¶
General Constraints¶
dst,base, andexpmust all beTileType::Vec.- All tiles must use row-major layout (
TileData::isRowMajor). dst,base, andexpmust have the same element type.- Static valid bounds:
TileData::ValidRow <= TileData::RowsandTileData::ValidCol <= TileData::Cols. - Runtime valid region checks:
dst.GetValidRow() == base.GetValidRow()dst.GetValidCol() == base.GetValidCol()dst.GetValidRow() == exp.GetValidRow()dst.GetValidCol() == exp.GetValidCol()
- The intrinsic signature requires an explicit
tmpoperand.
A2A3 Implementation Checks¶
- Supported element types:
int32_t,int16_t,int8_t,uint32_t,uint16_t,uint8_t,float. HIGH_PRECISIONalgorithm is not supported on A2A3;PrecisionTypeoption is ignored.- Additional runtime valid region checks for
tmp:dst.GetValidRow() == tmp.GetValidRow()dst.GetValidCol() == tmp.GetValidCol()
A5 Implementation Checks¶
- For
DEFAULTalgorithm: supported element types areuint8_t,int8_t,uint16_t,int16_t,uint32_t,int32_t,half,float,bfloat16_t. - For
HIGH_PRECISIONalgorithm: supported element types arehalf,float,bfloat16_t(floating-point only). - Integer types use a separate integer power computation path.
Examples¶
Auto¶
#include <pto/pto-inst.hpp>
using namespace pto;
void example_auto() {
using TileT = Tile<TileType::Vec, float, 16, 16>;
TileT base, exp, dst, tmp;
TPOW(dst, base, exp, tmp);
TPOW<PowAlgorithm::HIGH_PRECISION>(dst, base, exp, tmp);
}
Manual¶
#include <pto/pto-inst.hpp>
using namespace pto;
void example_manual() {
using TileT = Tile<TileType::Vec, float, 16, 16>;
TileT base, exp, dst, tmp;
TASSIGN(base, 0x1000);
TASSIGN(exp, 0x2000);
TASSIGN(dst, 0x3000);
TASSIGN(tmp, 0x4000);
TPOW(dst, base, exp, tmp);
}
ASM Form Examples¶
Auto Mode¶
# Auto mode: compiler/runtime-managed placement and scheduling.
%dst = pto.tpow %base, %exp, %tmp : (!pto.tile<...>, !pto.tile<...>, !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)
# pto.tassign %arg2, @tile(0x3000)
%dst = pto.tpow %base, %exp, %tmp : (!pto.tile<...>, !pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
PTO Assembly Form¶
%dst = tpow %base, %exp, %tmp : !pto.tile<...>
# AS Level 2 (DPS)
pto.tpow ins(%base, %exp, %tmp : !pto.tile_buf<...>, !pto.tile_buf<...>, !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)