TRESHAPE
Tile Operation Diagram
Introduction
Reinterpret a tile as another tile type/shape while preserving the underlying bytes.
This is a bitwise reshape: it does not change values, it only changes how the same byte buffer is viewed.
Assembly Syntax
%dst = treshape %src : !pto.tile<...>
AS Level 1 (SSA)
%dst = pto.treshape %src : !pto.tile<...> -> !pto.tile<...>
AS Level 2 (DPS)
pto.treshape ins(%src : !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 TRESHAPE(TileDataOut &dst, TileDataIn &src, WaitEvents &... events);
Constraints
Enforced by TRESHAPE_IMPL:
- Tile type must match:
TileDataIn::Loc == TileDataOut::Loc. - Total byte size must match:
sizeof(InElem) * InNumel == sizeof(OutElem) * OutNumel. - No boxed/non-boxed conversion:
- cannot reshape between
SLayout::NoneBoxand boxed layouts.
- cannot reshape between
Notes
- CPU simulation: implemented as a byte-for-byte copy into
dst. - A2/A3: implemented as an alias (
TASSIGN_IMPL(dst, src.data())), sodstandsrcrefer to the same underlying storage.
Examples
#include <pto/pto-inst.hpp>
using namespace pto;
void example() {
using Src = Tile<TileType::Vec, float, 16, 16>;
using Dst = Tile<TileType::Vec, float, 8, 32>;
static_assert(Src::Numel == Dst::Numel);
Src src;
Dst dst;
TRESHAPE(dst, src);
}
Math Interpretation
Unless otherwise specified, semantics are defined over the valid region and target-dependent behavior is marked as implementation-defined.
ASM Form Examples
Auto Mode
# Auto mode: compiler/runtime-managed placement and scheduling.
%dst = pto.treshape %src : !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)
%dst = pto.treshape %src : !pto.tile<...> -> !pto.tile<...>
PTO Assembly Form
%dst = pto.treshape %src : !pto.tile<...> -> !pto.tile<...>
# AS Level 2 (DPS)
pto.treshape ins(%src : !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)