背景
在当前 native-fold-tile-view-intrinsics 语义下,FoldTileBufIntrinsics 只接受原生 pto.make_tensor_view / pto.partition_view 生产的 tensor-view descriptor,不再接受桥接式 builtin.unrealized_conversion_cast。
但 test/basic/tlrelu/tlrelu.pto 走 VPTO backend 时仍会失败,原因不是源 IR 直接使用 memref bridge,而是 TileLang DSL helper / ExpandTileOp 调用适配过程中把静态 shape 的原生 partition_tensor_view 宽化成了动态 shape 的 partition_tensor_view<?x?...>,并插入了 builtin.unrealized_conversion_cast。
复现
命令:
build/tools/ptoas/ptoas --pto-arch=a5 --pto-backend=vpto --emit-vpto test/basic/tlrelu/tlrelu.pto -o -
报错:
loc("-":40:18): error: FoldTileBufIntrinsics: unsupported tensor_view cast producer builtin.unrealized_conversion_cast; expected native pto.make_tensor_view / pto.partition_view
Error: backend lowering pass execution failed.
lit 里的失败表现是 FileCheck 读到空 stdout,因为测试当前把 stderr 重定向到了 /dev/null:
PTOAS_BUILD_DIR=$PWD/build LLVM_BUILD_DIR=$PWD/../llvm-project/build-shared \
~/.local/bin/llvm-lit -sv test/basic/tlrelu/tlrelu.pto
关键现象
在 pto-fold-tile-buf-intrinsics 之前的 IR 里可以看到:
%2 = pto.partition_view %0, offsets = [...], sizes = [...]
: !pto.tensor_view<1x1x1x32x64xf32>
%6 = builtin.unrealized_conversion_cast %2
: !pto.partition_tensor_view<1x1x1x32x64xf32>
to !pto.partition_tensor_view<?x?x?x?x?xf32>
%7 = pto.get_tensor_view_dim %6, %c0 ...
%12 = pto.get_tensor_view_stride %6, %c0 ...
%29 = pto.tensor_view_addr %6 ...
也就是:
- 调用点原本持有的是原生静态
partition_tensor_view<...>
- 进入 DSL helper / expand call 前后,被适配成动态
partition_tensor_view<?...>
- 适配方式是
builtin.unrealized_conversion_cast
FoldTileBufIntrinsics 现已将这种 producer 视为非法输入
疑似根因
ExpandTileOp 当前在 helper-call 适配时,只要 operand.getType() != fnArgTypes[i] 就会插 builtin.unrealized_conversion_cast。
问题在于这里不只会桥接旧的 memref -> tensor_view/partition_tensor_view,也会桥接:
!pto.partition_tensor_view<static-shape> -> !pto.partition_tensor_view<dynamic-shape>
!pto.tensor_view<static-shape> -> !pto.tensor_view<dynamic-shape>
这导致 DSL/helper 侧只要把 view 参数声明得更动态,就会在 VPTO pipeline 中重新引入目前已被收紧 contract 禁止的桥接形状。
期望
更理想的 contract 应该是二选一:
- DSL/helper 不应把静态 shape 的原生 tensor_view/partition_tensor_view 宽化成动态 shape 参数;或者
- Expand/helper-call 适配不应通过
builtin.unrealized_conversion_cast 为 native view -> native view 的 shape widening 建桥。
至少对 test/basic/tlrelu/tlrelu.pto 这类正常 TileLang case,不应因为 helper 参数更动态而在 FoldTileBufIntrinsics 前引入非法 tensor-view cast。
影响范围
目前在 tlrelu.pto 的多个 case 上都能复现,例如:
TLRELU_f32_32x64_dst128
TLRELU_f16_63x64_dst128
TLRELU_f32_7x448_dst512
TLRELU_f32_256x16_dst32
看起来这不是单个算子模板的问题,而是 DSL/helper view 参数与调用点类型对齐策略的共性问题。
背景
在当前
native-fold-tile-view-intrinsics语义下,FoldTileBufIntrinsics只接受原生pto.make_tensor_view/pto.partition_view生产的 tensor-view descriptor,不再接受桥接式builtin.unrealized_conversion_cast。但
test/basic/tlrelu/tlrelu.pto走 VPTO backend 时仍会失败,原因不是源 IR 直接使用 memref bridge,而是 TileLang DSL helper /ExpandTileOp调用适配过程中把静态 shape 的原生partition_tensor_view宽化成了动态 shape 的partition_tensor_view<?x?...>,并插入了builtin.unrealized_conversion_cast。复现
命令:
报错:
lit里的失败表现是FileCheck读到空 stdout,因为测试当前把 stderr 重定向到了/dev/null:关键现象
在
pto-fold-tile-buf-intrinsics之前的 IR 里可以看到:也就是:
partition_tensor_view<...>partition_tensor_view<?...>builtin.unrealized_conversion_castFoldTileBufIntrinsics现已将这种 producer 视为非法输入疑似根因
ExpandTileOp当前在 helper-call 适配时,只要operand.getType() != fnArgTypes[i]就会插builtin.unrealized_conversion_cast。问题在于这里不只会桥接旧的
memref -> tensor_view/partition_tensor_view,也会桥接:!pto.partition_tensor_view<static-shape>->!pto.partition_tensor_view<dynamic-shape>!pto.tensor_view<static-shape>->!pto.tensor_view<dynamic-shape>这导致 DSL/helper 侧只要把 view 参数声明得更动态,就会在 VPTO pipeline 中重新引入目前已被收紧 contract 禁止的桥接形状。
期望
更理想的 contract 应该是二选一:
builtin.unrealized_conversion_cast为 native view -> native view 的 shape widening 建桥。至少对
test/basic/tlrelu/tlrelu.pto这类正常 TileLang case,不应因为 helper 参数更动态而在FoldTileBufIntrinsics前引入非法 tensor-view cast。影响范围
目前在
tlrelu.pto的多个 case 上都能复现,例如:TLRELU_f32_32x64_dst128TLRELU_f16_63x64_dst128TLRELU_f32_7x448_dst512TLRELU_f32_256x16_dst32看起来这不是单个算子模板的问题,而是 DSL/helper view 参数与调用点类型对齐策略的共性问题。