TFILLPAD
Instruction Diagram
Introduction
Copies a tile and fills the elements outside the valid region with a compile-time fill value.
Copies the source tile into the destination tile and fills the remaining (padding) elements with a compile-time fill value selected by TileDataDst::PadVal (such as PadValue::Min/PadValue::Max).
This operation is commonly used to deterministically materialize a specific value outside the runtime valid region, allowing subsequent operations to compute on the complete static tile shape.
Mathematical Semantics
Assume VR = src.GetValidRow() and VC = src.GetValidCol(). For each destination element (i, j):
pad is determined by TileDataDst::PadVal and the element type (for example, +inf/-inf when supported by the floating-point type, otherwise std::numeric_limits<T>::max()/min()).
Assembly Syntax
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<...>)C++ Built-in APIs
Implemented in the backend header file introduced 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);Constraints
TileDataDst::PadVal != PadValue::Null(Vec type overload).sizeof(TileDataDst::DType) == sizeof(TileDataSrc::DType)and the 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)(Mat type overload): whenTileData::TileTypeisMat, the layout must satisfy!TileData::isRowMajor && TileData::SLayout::RowMajor, andPadValmust bePadValue::ZeroorPadValue::Null. This Mat overload and the first Vec overload (PadVal != PadValue::Null) belong to different SFINAE overloads and do not conflict.
Examples
#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);
}ASM Examples
Automatic Mode
# Automatic mode: the compiler/runtime is responsible for resource placement and scheduling.
%dst = pto.tfillpad %src : !pto.tile<...> -> !pto.tile<...>Manual Mode
# Manual mode: explicitly bind resources first, then issue the instruction.
# Optional (when the instruction contains tile operands):
# pto.tassign %arg0, @tile(0x1000)
# pto.tassign %arg1, @tile(0x2000)
%dst = pto.tfillpad %src : !pto.tile<...> -> !pto.tile<...>PTO Assembly Form
%dst = pto.tfillpad %src : !pto.tile<...> -> !pto.tile<...>
# AS Level 2 (DPS)
pto.tfillpad ins(%src : !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)