TLOAD
Instruction Diagram
Introduction
Loads data from GlobalTensor (GM) to a tile.
Mathematical Semantics
The symbolic representation depends on the shape/stride of GlobalTensor and the layout of Tile. Conceptually (two-dimensional view, with base offsets r_0 and c_0):
Assembly Syntax
Synchronous form:
%t0 = tload %sv[%c0, %c0] : (!pto.memref<...>, index, index) -> !pto.tile<...>AS Level 1 (SSA)
%dst = pto.tload %mem : !pto.partition_tensor_view<MxNxdtype> ->
!pto.tile<loc, dtype, rows, cols, blayout, slayout, fractal, pad>AS Level 2 (DPS)
pto.tload ins(%mem : !pto.partition_tensor_view<MxNxdtype>) outs(%dst : !pto.tile_buf<...>)C++ Built-in APIs
Declared in include/pto/common/pto_instr.hpp:
The public include header is
<pto/pto-inst.hpp>, and the internal declaration is located inpto/common/pto_instr.hpp.
template <typename TileData, typename GlobalData, typename... WaitEvents>
PTO_INST RecordEvent TLOAD(TileData &dst, GlobalData &src, WaitEvents &... events);Constraints
Implementation check (Atlas A2/A3 training products/Atlas A2/A3 inference products):
TileData::DTypemust be one of the following:int8_t,uint8_t,int16_t,uint16_t,int32_t,uint32_t,int64_t,uint64_t,half,bfloat16_t,float.- The destination tile position must be
TileType::VecorTileType::Mat. sizeof(TileData::DType) == sizeof(GlobalData::DType).- Runtime: all
src.GetShape(dim)values anddst.GetValidRow()/GetValidCol()must be> 0. TileType::Vecloads support only matching layouts: ND->ND, DN->DN, NZ->NZ.TileType::Matloads support: ND->ND, DN->DN, NZ->NZ, as well as ND->NZ and DN->ZN.- For ND->NZ or DN->ZN:
GlobalData::staticShape[0..2] == 1andTileData::SFractalSize == 512. - For
int64_t/uint64_t, only ND->ND or DN->DN is supported. - Vec tile (UB path):
1 <= TileData::Rows <= 4095. - Mat tile (L1 path):
1 <= TileData::Rows <= 16384.
Implementation check (Ascend 950PR/Ascend 950DT):
sizeof(TileData::DType)must be1,2,4, or8bytes, and must matchsizeof(GlobalData::DType).- For
int64_t/uint64_t,TileData::PadValmust bePadValue::NullorPadValue::Zero. TileType::Vecloading requires one of the following layout pairs:- ND uses row-major +
SLayout::NoneBox(ND->ND), - DN uses column-major +
SLayout::NoneBox(DN->DN), - NZ uses
SLayout::RowMajor(NZ->NZ). - For row-major ND->ND with compile-time known shapes,
TileData::ValidColmust equalGlobalData::staticShape[4], andTileData::ValidRowmust equal the product ofGlobalData::staticShape[0..3]. TileType::Matloads are also subject toTLoadCubeCheckconstraints (for example, only specific ND/DN/NZ conversions and L1 size limits).TileType::Matloads also handle mx-format loads, includingMX_A_ZZ/MX_A_ND/MX_A_DNto ZZ (for scalarA) andMX_B_NN/MX_B_ND/MX_B_DNto NN (for scalarB).- For
MX_A_ZZ/MX_B_NN:(GlobalData::staticShape[3] == 16 || GlobalData::staticShape[3] == -1)and(GlobalData::staticShape[4] == 2 || GlobalData::staticShape[4] == -1). - For
MX_A_ND/MX_A_DN/MX_B_ND/MX_B_DN:(GlobalData::staticShape[0] == 1 || GlobalData::staticShape[0] == -1)and(GlobalData::staticShape[1] == 1 || GlobalData::staticShape[1] == -1)and(GlobalData::staticShape[4] == 2 || GlobalData::staticShape[4] == -1). - For scaleA,
dst.GetValidCol() % 2 == 0. - For scaleB,
dst.GetValidRow() % 2 == 0.
Valid region:
- The implementation uses
dst.GetValidRow()/dst.GetValidCol()as the transfer size.
- The implementation uses
Examples
Automatic
#include <pto/pto-inst.hpp>
using namespace pto;
template <typename T>
void example_auto(__gm__ T* in) {
using TileT = Tile<TileType::Vec, T, 16, 16>;
using GShape = Shape<1, 1, 1, 16, 16>;
using GStride = BaseShape2D<T, 16, 16, Layout::ND>;
using GTensor = GlobalTensor<T, GShape, GStride, Layout::ND>;
GTensor gin(in);
TileT t;
TLOAD(t, gin);
}Manual
#include <pto/pto-inst.hpp>
using namespace pto;
template <typename T>
void example_manual(__gm__ T* in) {
using TileT = Tile<TileType::Vec, T, 16, 16>;
using GShape = Shape<1, 1, 1, 16, 16>;
using GStride = BaseShape2D<T, 16, 16, Layout::ND>;
using GTensor = GlobalTensor<T, GShape, GStride, Layout::ND>;
GTensor gin(in);
TileT t;
TASSIGN(t, 0x1000);
TLOAD(t, gin);
}ASM Examples
Automatic Mode
# Automatic mode: the compiler/runtime handles resource placement and scheduling.
%dst = pto.tload %mem : !pto.partition_tensor_view<MxNxdtype> ->Manual Mode
# Manual mode: explicitly bind resources first, then issue the instruction.
# Optional (when the instruction contains a tile operand):
# pto.tassign %arg0, @tile(0x1000)
# pto.tassign %arg1, @tile(0x2000)
%dst = pto.tload %mem : !pto.partition_tensor_view<MxNxdtype> ->PTO Assembly Form
%t0 = tload %sv[%c0, %c0] : (!pto.memref<...>, index, index) -> !pto.tile<...>
# AS Level 2 (DPS)
pto.tload ins(%mem : !pto.partition_tensor_view<MxNxdtype>) outs(%dst : !pto.tile_buf<...>)