pto.trelu¶
pto.trelu is part of the Elementwise Tile Tile instruction set.
Summary¶
Elementwise ReLU of a tile.
Mechanism¶
Elementwise ReLU of a tile.
For each element (i, j) in the valid region:
\[ \mathrm{dst}_{i,j} = \max(\mathrm{src}_{i,j}, 0) \]
Syntax¶
Textual spelling is defined by the PTO ISA syntax-and-operands pages.
Synchronous form:
%dst = trelu %src : !pto.tile<...>
AS Level 1 (SSA)¶
%dst = pto.trelu %src : !pto.tile<...> -> !pto.tile<...>
AS Level 2 (DPS)¶
pto.trelu ins(%src : !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
C++ Intrinsic¶
Declared in include/pto/common/pto_instr.hpp:
template <typename TileDataDst, typename TileDataSrc, typename... WaitEvents>
PTO_INST RecordEvent TRELU(TileDataDst &dst, TileDataSrc &src, WaitEvents &... events);
Inputs¶
| Operand | Role | Description |
|---|---|---|
%src |
Source tile | Source tile; read at (i, j) for each (i, j) in dst valid region |
%dst |
Destination tile | Destination tile receiving the result |
WaitEvents... |
Optional synchronisation | RecordEvent tokens to wait on before issuing the operation |
Expected Outputs¶
| Result | Type | Description |
|---|---|---|
%dst |
!pto.tile<...> |
Destination tile; all (i, j) in its valid region contain max(src[i,j], 0) after the operation |
Side Effects¶
No architectural side effects beyond producing the destination tile. Does not implicitly fence unrelated traffic.
Constraints¶
Constraints
- Valid region:
- The op uses
dst.GetValidRow()/dst.GetValidCol()as the iteration domain;src/dstare assumed to be compatible (not validated by explicit runtime checks in this op).
- The op uses
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
-
Implementation checks (A2A3):
TileData::DTypemust be one of:half,float,int32_t.- Tile layout must be row-major (
TileData::isRowMajor). - Tile location must be vector (
TileData::Loc == TileType::Vec). - Static valid bounds:
TileData::ValidRow <= TileData::RowsandTileData::ValidCol <= TileData::Cols. - Runtime:
srcanddsttiles should have the samevalidRow/validCol.
-
Implementation checks (A5):
TileData::DTypemust be one of:half,float,int32_t.- Tile layout must be row-major (
TileData::isRowMajor). - Tile location must be vector (
TileData::Loc == TileType::Vec). - Static valid bounds:
TileData::ValidRow <= TileData::RowsandTileData::ValidCol <= TileData::Cols. - Runtime:
srcanddsttiles should have the samevalidRow/validCol.
Performance¶
A2/A3 Throughput¶
TRELU compiles to CCE vector instructions via the TUnaryOp.hpp performance model:
| Metric | Value |
|---|---|
| Startup latency | 13 |
| Completion latency | 26 (FP transcendental) |
| Per-repeat throughput | 1 |
| Pipeline interval | 18 |
Examples¶
#include <pto/pto-inst.hpp>
using namespace pto;
void example() {
using TileT = Tile<TileType::Vec, float, 16, 16>;
TileT x, out;
TRELU(out, x);
}
Auto Mode¶
# Auto mode: compiler/runtime-managed placement and scheduling.
%dst = pto.trelu %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.trelu %src : !pto.tile<...> -> !pto.tile<...>
PTO Assembly Form¶
%dst = trelu %src : !pto.tile<...>
# AS Level 2 (DPS)
pto.trelu ins(%src : !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
Related Ops / Instruction Set Links¶
- Instruction set overview: Elementwise Tile Tile
- Previous op in instruction set: pto.tnot
- Next op in instruction set: pto.tneg