Skip to content

Adapt conv tile. - #13

Open
and0d0 wants to merge 1 commit into
set_opfrom
set_op_conv
Open

Adapt conv tile.#13
and0d0 wants to merge 1 commit into
set_opfrom
set_op_conv

Conversation

@and0d0

@and0d0 and0d0 commented Aug 27, 2026

Copy link
Copy Markdown
Owner

ConvTile:
独立 ConvTileType
复用地址、地址空间、内存规划框架
复用 AllocTileOp、TASSIGN、TLOAD 的操作壳
在 EmitC 中生成 PTO-ISA ConvTile 类型
暂时只承诺 EmitC 后端支持

项目 原有 Tile 新增 ConvTile
PTOAS IR 类型 TileBufType ConvTileType
MLIR 类型语法 !pto.tile_buf<...> !pto.conv_tile<...>
主要用途 普通二维 Tile buffer 卷积相关硬件 Tile buffer
逻辑 shape 固定二维,例如 32x32 卷积维度,可为 1 到 6 维
存储容量计算 shape[0] * shape[1] * sizeof(dtype) bufferSize * sizeof(dtype)
layout 表达 BLayout + SLayout 独立的 ConvLayoutAttr
valid shape 有 valid_row、valid_col 当前不使用普通 Tile 的 valid shape
地址空间 vec、mat、left、right、acc 等 复用相同的 PTO address space
内存规划 已有成熟路径 已接入,按照 bufferSize 计算
AllocTileOp 原有支持 已支持
TLOAD 普通 PartitionTensorView -> TileBuf 当前支持 PartitionTensorView -> ConvTile
TASSIGN 已支持 已支持
TLOAD EmitC 生成 TLOAD(tile, global_tensor) 同样生成 TLOAD(conv_tile, global_tensor)
EmitC 类型 PTO-ISA Tile<...> PTO-ISA ConvTile<...>
VPTO 后端 已有原有 Tile 路径 当前没有完整 ConvTile VPTO lowering
卷积配置 op 不适用 SETFMATRIX 等还未实现

Comment thread include/PTO/IR/PTOOps.td
AnyTypeOf<[AnyRankedTensor, TensorViewType, TileBufType],
"TensorView, TileBuf, or Tensor">;
AnyTypeOf<[AnyRankedTensor, TensorViewType, TileBufType, ConvTileType],
"TensorView, TileBuf, ConvTile, or Tensor">;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PTOPipeEntryType仅涉及到TPush Tpop等mix kernel op, 这些op应该不支持convtile吧,确认是否需要,不需要的话这个不能添加ConvTile

Comment thread include/PTO/IR/PTOOps.td
def PTODpsType :
AnyTypeOf<[AnyRankedTensor, PartitionTensorViewType, TileBufType]>;
AnyTypeOf<[AnyRankedTensor, PartitionTensorViewType, TileBufType,
ConvTileType]>;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PTODpsType涉及到很多不支持convtile的op, 加在这里相当于很多op的输入输出都支持convtile,有需要的话单独定义个type, 不要动这个类型

Comment thread include/PTO/IR/PTOOps.td
AnyTypeOf<[AnyRankedTensor, TensorViewType, PartitionTensorViewType,
TileBufType], "TensorView, PartitionTensorView, TileBuf, or Tensor">;
TileBufType, ConvTileType],
"TensorView, PartitionTensorView, TileBuf, ConvTile, or Tensor">;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同上

Comment thread include/PTO/IR/PTOOps.td

let results = (outs TileBufType:$result);
let results = (outs AnyTypeOf<[TileBufType, ConvTileType]>:$result);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alloc_tile 结果现在可能是 ConvTile,但基线里至少有多处对 alloc/tile 结果无条件 castpto::TileBufType,本 PR 只适配了 EmitC alloc pattern 和
Utils.cpp::resolveSemanticRange,以下 pass 未适配:

  • lib/PTO/Transforms/LowerPTOToUBufOps.cpp:263,272
  • lib/PTO/Transforms/PTOA5NormalizeTMovPass.cpp:211-212
  • lib/PTO/Transforms/FoldTileBufIntrinsics.cpp:732
  • lib/PTO/IR/PTO.cpp:10416

只要 ConvTile 流经任一路径就是 cast<> 断言崩溃。PR 声称"仅 EmitC",但类型系统并不阻止 ConvTile 进入这些 pass。建议:要么在这些 pass 入口对 ConvTile 做
notifyMatchFailure/早退,要么加一个 pipeline 前置校验"ConvTile 只允许出现在 EmitC 路径",把"仅 EmitC"从口头约定变成可验证的约束

printer << "x";
}
printTileBufDim(printer, dim);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ConvTileType 有 hasDynamicShape() helper,printer(printTileBufDim)大概会打印 ?,但 parser 用 parseDimensionList(allowDynamic=false),且各 verifier dim <= 0
会拒绝 kDynamic。即动态维度构造得出来却读不回、过不了校验——hasDynamicShape() 实际是死代码。要么明确不支持动态并删掉该 helper,要么打通。当前语义下建议前者

@github-actions

Copy link
Copy Markdown

Warning: @and0d0, ci-sim exceeded its soft runtime budget.

  • vpto-sim-validation runtime: 24h 0m 1s
  • Soft budget: 1h 30m
  • Job conclusion: cancelled
  • Workflow run

This warning is advisory only and does not affect required checks. Please inspect the step timings for an unexpected regression.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants