TEXPANDS

Tile Operation Diagram

TEXPANDS tile operation

Introduction

Broadcast a scalar into a destination tile.

Math Interpretation

For each element (i, j) in the valid region:

\[ \mathrm{dst}_{i,j} = \mathrm{scalar} \]

Assembly Syntax

PTO-AS form: see PTO-AS Specification.

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<...>)

IR Level 1 (SSA)

%dst = pto.texpands %scalar : dtype -> !pto.tile<...>

IR Level 2 (DPS)

pto.texpands ins(%scalar : dtype) outs(%dst : !pto.tile_buf<...>)

C++ Intrinsic

Declared in include/pto/common/pto_instr.hpp:

template <typename TileData, typename... WaitEvents>
PTO_INST RecordEvent TEXPANDS(TileData &dst, typename TileData::DType scalar, WaitEvents &... events);

Constraints

  • Implementation checks (A2A3):
  • For TileType::Vec:
    • TileData::DType must be one of: uint8_t, int8_t, uint16_t, int16_t, uint32_t, int32_t, half, bfloat16_t, float.
    • Row-major and col-major vector tiles are both supported.
    • Static valid bounds: TileData::ValidRow <= TileData::Rows and TileData::ValidCol <= TileData::Cols.
  • For TileType::Mat:
    • TileData::DType must be one of: uint8_t, int8_t, uint16_t, int16_t, uint32_t, int32_t, half, bfloat16_t, float.
    • Static valid bounds: TileData::Rows * TileData::Cols * sizeof(T) / 32 must be in [1, 32767].
  • Implementation checks (A5):
  • For TileType::Vec:
    • TileData::DType must be one of: uint8_t, int8_t, uint16_t, int16_t, uint32_t, int32_t, half, bfloat16_t, float.
    • Row-major and col-major vector tiles are both supported.
    • Static valid bounds: TileData::ValidRow <= TileData::Rows and TileData::ValidCol <= TileData::Cols.
  • For TileType::Mat:
    • TileData::DType must be one of: 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:
    • shape0 * shape1 * shape2 * shape3 must be in [1, 32767].
    • For TileData::layout == pto::Layout::NDC1HWC0 || TileData::layout == pto::Layout::FRACTAL_Z_3D:
    • shape0 * shape1 * shape2 * shape3 * shape4 must be in [1, 32767].
  • Valid region:
  • For TileType::Vec:
    • The op fills dst over dst.GetValidRow() / dst.GetValidCol().
  • For TileType::Mat:
    • For tile operands, the op fills dst over TileData::Rows / TileData::Cols.
    • For conv tiles, the op fills dst over the conv-tile shape.

Examples

Auto

#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 Form Examples

Auto Mode

# Auto mode: compiler/runtime-managed placement and scheduling.
%dst = pto.texpands %scalar : dtype -> !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.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<...>)