Skip to content

Add merge-axis TileLang element-wise templates#456

Open
liuzidi wants to merge 1 commit into
feature-vpto-backendfrom
tilelang-dsl-merge-axis
Open

Add merge-axis TileLang element-wise templates#456
liuzidi wants to merge 1 commit into
feature-vpto-backendfrom
tilelang-dsl-merge-axis

Conversation

@liuzidi

@liuzidi liuzidi commented May 29, 2026

Copy link
Copy Markdown
Collaborator

标题

TileLang element-wise OP 增加满轴合轴版本并补齐 ST 覆盖

描述

本次主要为 lib/TileOps 中的 element-wise 类 OP 增加“合轴/满轴”版本实现,并同步补齐对应的 TileLang ST 用例。

修改内容

新增 lib/TileOps/merge_axis.py,抽出满轴场景的公共约束与合轴遍历辅助逻辑。
为 element-wise OP 增加 merge_axis 版本模板,满轴时优先选择 1D 合轴实现,非满轴仍保持原有 2D 实现兜底。
更新 test/tilelang_st 下相关 testcase,补充合轴场景 .pto、cases.py、launch.cpp、main.cpp。
调整 run_ptoas_to_file.cmake,确保 ST 编译时使用当前仓库内的 TileOps / tilelang-dsl 实现,避免误用外部安装版本。
修正部分合轴 case 的 shape / valid_shape / stride 配置,使其满足满轴展开条件。

验证

已通过 test/tilelang_st 相关 element-wise 合轴 ST 回归。

total_elems = valid_rows * valid_cols
lanes = pto.get_lanes(dtype)

with pto.strict_vecscope(dst, src0, src1, total_elems, 0, total_elems, lanes) as (

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

PTOAS后端会自动推导vecscope,这里不需要显式写

priority=100,
advanced=True,
)
def template_tabs_merge_axis(src: pto.Tile, dst: pto.Tile):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

binary op能否共用1个模板,看一下手册里有template的写法

op="pto.tabs",
constraints=[full_axis_constraint],
priority=100,
advanced=True,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

跟ptr无关的op不需要advanced模式



// Merge-axis case: f32 full-axis 16x72 (1152 elements)
func.func @TABS_f32_merge_axis_16x72(%a_ptr: !pto.ptr<f32>, %b_ptr: !pto.ptr<f32>) attributes {pto.aicore} {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

测试用例现在推荐用PTODSL写,放到test/dsl-st目录下面

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants