TEXPANDS
Instruction Diagram
Introduction
Broadcasts the scalar to the destination tile.
Mathematical Semantics
For each element (i, j) in the valid region:
Assembly Syntax
Synchronous form:
%dst = texpands %scalar : f32, !pto.tile<...>AS Level 1 (SSA)
%dst = pto.texpands %scalar : dtype -> !pto.tile<...>AS Level 2 (DPS)
pto.texpands ins(%scalar : dtype) 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... WaitEvents>
PTO_INST RecordEvent TEXPANDS(TileData &dst, typename TileData::DType scalar, WaitEvents &... events);Constraints
- Implementation check (Atlas A2/A3 training products/Atlas A2/A3 inference products):
- For a tile whose location is a vector (
TileData::Loc == TileType::Vec): TileData::DTypemust be one of the following:int8_t,uint8_t,int16_t,uint16_t,int32_t,uint32_t,half,bfloat16_t,float.- Static valid bounds:
TileData::ValidRow <= TileData::RowsandTileData::ValidCol <= TileData::Cols. - For a tile whose location is a Mat (
TileData::Loc == TileType::Mat): TileData::DTypemust be one of the following:int8_t,uint8_t,int16_t,uint16_t,int32_t,uint32_t,half,bfloat16_t,float.- Valid bounds:
TileData::Rows * TileData::Cols * sizeof(TileData::DType) / 32must be within the range[1, 32767].
- For a tile whose location is a vector (
- Implementation check (Ascend 950PR/Ascend 950DT):
- For a tile whose location is a vector (
TileData::Loc == TileType::Vec): - Static valid bounds:
TileData::ValidRow <= TileData::RowsandTileData::ValidCol <= TileData::Cols. TileData::DTypemust be one of the following:uint8_t,int8_t,uint16_t,int16_t,uint32_t,int32_t,half,bfloat16_t,float.- For a tile whose location is Mat (
TileData::Loc == TileType::Mat): TileData::DTypemust be one of the following:uint8_t,int8_t,uint16_t,int16_t,uint32_t,int32_t,half,bfloat16_t,float.- For
TileData::layout == pto::Layout::NC1HWC0 || TileData::layout == pto::Layout::FRACTAL_Z:TileData::shape0 * TileData::shape1 * TileData::shape2 * TileData::shape3must be within the range[1, 32767].
- For
TileData::layout == pto::Layout::NDC1HWC0 || TileData::layout == pto::Layout::FRACTAL_Z_3D:TileData::shape0 * TileData::shape1 * TileData::shape2 * TileData::shape3 * TileData::shape4must be within the range[1, 32767].
- For a tile whose location is a vector (
- Valid region:
- For a tile whose location is a vector (
TileData::Loc == TileType::Vec): - The operation fills
dstondst.GetValidRow()/dst.GetValidCol(). - For a tile whose location is Mat (
TileData::Loc == TileType::Mat): - For a tile, the operation fills
dstonTileData::Rows/TileData::Cols. - For a convTile, the operation fills
dstwithin theshapeofConvTileData.
- For a tile whose location is a vector (
Examples
Automatic
#include <pto/pto-inst.hpp>
using namespace pto;
void example_auto() {
using TileT = Tile<TileType::Vec, float, 16, 16>;
TileT dst;
TEXPANDS(dst, 0.0f);
}Manual
#include <pto/pto-inst.hpp>
using namespace pto;
void example_manual() {
using TileT = Tile<TileType::Vec, float, 16, 16>;
TileT dst;
TASSIGN(dst, 0x1000);
TEXPANDS(dst, 0.0f);
}ASM Examples
Automatic Mode
# Automatic mode: the compiler/runtime handles resource placement and scheduling.
%dst = pto.texpands %scalar : dtype -> !pto.tile<...>Manual Mode
# Manual mode: explicitly bind resources first, then issue the instruction.
%dst = pto.texpands %scalar : dtype -> !pto.tile<...>PTO Assembly Form
%dst = texpands %scalar : f32, !pto.tile<...>
# AS Level 2 (DPS)
pto.texpands ins(%scalar : dtype) outs(%dst : !pto.tile_buf<...>)