pto.tcolsum¶
pto.tcolsum is part of the Reduce And Expand instruction set.
Summary¶
Reduce each column by summing across rows.
Mechanism¶
Reduce each column by summing across rows.
Let R = src.GetValidRow() and C = src.GetValidCol(). For 0 <= j < C:
isBinary selects the implementation path (binary-tree accumulation vs. sequential accumulation).
Syntax¶
Textual spelling is defined by the PTO ISA syntax-and-operands pages.
Synchronous form:
%dst = tcolsum %src {isBinary = false} : !pto.tile<...> -> !pto.tile<...>
Lowering may introduce internal scratch tiles; the C++ intrinsic requires an explicit tmp operand.
AS Level 1 (SSA)¶
%dst = pto.tcolsum %src : !pto.tile<...> -> !pto.tile<...>
%dst = pto.tcolsum %src, %tmp {isBinary = false} : (!pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
AS Level 2 (DPS)¶
pto.tcolsum ins(%src : !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
pto.tcolsum ins(%src, %tmp {isBinary = false} : !pto.tile_buf<...>, !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
C++ Intrinsic¶
Declared in include/pto/common/pto_instr.hpp:
template <typename TileDataOut, typename TileDataIn, typename... WaitEvents>
PTO_INST RecordEvent TCOLSUM(TileDataOut &dst, TileDataIn &src, WaitEvents &... events);
template <typename TileDataOut, typename TileDataIn, typename TileDataTmp, typename... WaitEvents>
PTO_INST RecordEvent TCOLSUM(TileDataOut &dst, TileDataIn &src, TileDataTmp &tmp, bool isBinary, WaitEvents &... events);
Inputs¶
srcis the source tile.dstnames the destination tile. The operation iterates over dst's valid region.isBinary(bool): selects the implementation path—binary-tree accumulation (true) or sequential accumulation (false).
Expected Outputs¶
dst holds the column-wise sum: for each column j, dst[0,j] = sum of all elements in column j of src.
Side Effects¶
No architectural side effects beyond producing the destination tile. Does not implicitly fence unrelated traffic.
Constraints¶
Constraints
General constraints / checks¶
-
dstandsrcmust beTileType::Vec. -
dstandsrcmust use standard ND layout: row-major and non-fractal (BLayout::RowMajor,SLayout::NoneBox). -
dstandsrcmust use the same element type. -
Runtime checks:
src.GetValidCol() == dst.GetValidCol()src.GetValidRow() != 0src.GetValidCol() != 0-
src.GetValidCol() <= tmprow stride measured insrcelements -
Supported element types:
half,float,int16_t,int32_t. -
tmpmust beTileType::Vecand use standard ND layout: row-major and non-fractal (BLayout::RowMajor,SLayout::NoneBox). -
tmpmust use the same element type assrcanddst.
Exceptions¶
Exceptions
- Illegal operand tuples, unsupported types, invalid layout combinations, or unsupported target-profile modes are rejected by the verifier or by the selected backend instruction set.
- Programs must not rely on behavior outside the documented legal domain of this operation, even if one backend currently accepts it.
Target-Profile Restrictions¶
Target-Profile Restrictions
isBinaryselects the checked backend path:true: binary-tree accumulation usingtmpfalse: sequential accumulation intodst
- If
src.GetValidRow() == 0orsrc.GetValidCol() == 0, the implementation returns early.
-
Shared A5 column-reduce checks allow
half,float,int8_t,uint8_t,int16_t,uint16_t,int32_t,uint32_t,bfloat16_t. -
The checked A5
TCOLSUMpath still takestmponly for the binary accumulation path; no extra compile-timetmptype/layout assertions are explicitly enforced inTCOLSUM_IMPL.
Examples¶
Auto¶
#include <pto/pto-inst.hpp>
using namespace pto;
void example_auto() {
using SrcT = Tile<TileType::Vec, float, 16, 16>;
using DstT = Tile<TileType::Vec, float, 1, 16>;
using TmpT = Tile<TileType::Vec, float, 16, 16>;
SrcT src;
DstT dst;
TmpT tmp;
TCOLSUM(dst, src, tmp, /*isBinary=*/false);
}
Manual¶
#include <pto/pto-inst.hpp>
using namespace pto;
void example_manual() {
using SrcT = Tile<TileType::Vec, float, 16, 16>;
using DstT = Tile<TileType::Vec, float, 1, 16>;
using TmpT = Tile<TileType::Vec, float, 16, 16>;
SrcT src;
DstT dst;
TmpT tmp;
TASSIGN(src, 0x1000);
TASSIGN(dst, 0x2000);
TASSIGN(tmp, 0x3000);
TCOLSUM(dst, src, tmp, /*isBinary=*/false);
}
Auto Mode¶
# Auto mode: compiler/runtime-managed placement and scheduling.
%dst = pto.tcolsum %src : !pto.tile<...> -> !pto.tile<...>
Manual Mode¶
# Manual mode: bind resources explicitly before issuing the instruction.
# Optional for tile operands:
# pto.tassign %arg0, @tile(0x1000)
# pto.tassign %arg1, @tile(0x2000)
%dst = pto.tcolsum %src : !pto.tile<...> -> !pto.tile<...>
PTO Assembly Form¶
%dst = tcolsum %src {isBinary = false} : !pto.tile<...> -> !pto.tile<...>
# AS Level 2 (DPS)
pto.tcolsum ins(%src : !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
Related Ops / Instruction Set Links¶
- Instruction set overview: Reduce And Expand
- Previous op in instruction set: pto.trowsum
- Next op in instruction set: pto.tcolprod