TFILLPAD¶
指令示意图¶
简介¶
复制 Tile 并在有效区域外使用编译时填充值进行填充。
Copy a source tile into a destination tile and fill the remaining (padded) elements with a compile-time pad value
selected by TileDataDst::PadVal (e.g., PadValue::Min/PadValue::Max).
This is commonly used to materialize deterministic values outside the runtime valid region so that subsequent ops can operate on a full static tile shape.
数学语义¶
Let VR = src.GetValidRow() and VC = src.GetValidCol(). 对每个 destination element (i, j):
pad is determined by TileDataDst::PadVal and the element type (e.g., +inf/-inf for floating types when available,
otherwise std::numeric_limits<T>::max()/min()).
汇编语法¶
PTO-AS 形式:参见 PTO-AS Specification.
Synchronous form (conceptual):
%dst = tfillpad %src : !pto.tile<...> -> !pto.tile<...>
AS Level 1 (SSA)¶
%dst = pto.tfillpad %src : !pto.tile<...> -> !pto.tile<...>
AS Level 2 (DPS)¶
pto.tfillpad ins(%src : !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
AS Level 1(SSA)¶
%dst = pto.tfillpad %src : !pto.tile<...> -> !pto.tile<...>
AS Level 2(DPS)¶
pto.tfillpad ins(%src : !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
C++ 内建接口¶
Implemented in the backend headers pulled in by include/pto/common/pto_instr_impl.hpp:
template <typename TileData, PadValue PadVal = PadValue::Zero, typename... WaitEvents>
PTO_INST RecordEvent TFILLPAD(TileData &dst, TileData &src, WaitEvents &... events);
template <typename DstTileData, typename SrcTileData, typename... WaitEvents>
PTO_INST RecordEvent TFILLPAD(DstTileData &dst, SrcTileData &src, WaitEvents &... events);
约束¶
TileDataDst::PadVal != PadValue::Null.sizeof(TileDataDst::DType) == sizeof(TileDataSrc::DType)and element size must be1,2, or4bytes.TFILLPAD:TileDataDst::Rows/Colsmust matchTileDataSrc::Rows/Cols.TFILLPAD_EXPAND:TileDataDst::Rows >= TileDataSrc::RowsandTileDataDst::Cols >= TileDataSrc::Cols.TFILLPAD(TileData &dst, TileData &src):if TileData::TileType is Mat, layout only support (!TileData::isRowMajor && TileData::Slayout::RowMajor), and PadVal only support PadValue::Zero
示例¶
#include <pto/pto-inst.hpp>
using namespace pto;
void example1() {
using SrcT = Tile<TileType::Vec, float, 16, 16>;
using DstT = Tile<TileType::Vec, float, 16, 16, BLayout::RowMajor, 16, 16, SLayout::NoneBox, TileConfig::fractalABSize, PadValue::Min>;
SrcT src;
DstT dst;
TFILLPAD(dst, src);
}
void example2() {
using TileMatData = Tile<TileType::Mat, float, 16, 256, BLayout::ColMajor, 1, 224, SLayout::RowMajor, 512>;
TileMatData matTile;
TFILLPAD(matTile, matTile);
}