Skip to content

feat(ptodsl): Add tile debug print support - #994

Open
Crystal-wzy wants to merge 1 commit into
hw-native-sys:mainfrom
Crystal-wzy:main
Open

feat(ptodsl): Add tile debug print support#994
Crystal-wzy wants to merge 1 commit into
hw-native-sys:mainfrom
Crystal-wzy:main

Conversation

@Crystal-wzy

@Crystal-wzy Crystal-wzy commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

Add PTODSL support for the native pto.tprint debug-print operation and
expose it through pto.tile.print. The operation is modeled as a device-side
side effect, emits no numeric result, and is routed through the native EmitC
TPRINT lowering path.

Summary

  • Add _ops.tprint(src, *, tmp=None) and export it through pto.tile.print
    for tile debug printing, including the optional scratch tmp operand
  • Reject pto.tile.print on the VPTO backend with an explicit unsupported
    diagnostic, while allowing EmitC modules to keep the native pto.tprint
    operation
  • Treat TPrintOp as a native operation in tile expansion and template
    metadata insertion, so it is not expanded through TileLib templates
  • Add JIT compile coverage for EmitC pto.tile.print lowering and the VPTO
    unsupported-backend diagnostic
  • Add an A5 TileLib ST case for pto.tile.print using an EmitC kernel and a
    GM -> tile -> print -> GM round trip
  • Add a VPTO lit negative case that checks the explicit unsupported diagnostic
  • Document pto.tile.print in the PTODSL user guide, including side-effect
    behavior, tmp handling, dtype coverage, backend support, and A5 constraints

Testing

  • ptodsl/tests/test_jit_compile.py adds EmitC lowering and VPTO
    unsupported-backend checks for pto.tile.print
  • test/lit/vpto/tprint_vpto_unsupported.pto covers the VPTO unsupported
    diagnostic for pto.tprint
  • test/tilelib-st/a5/tprint/case.py covers the A5 EmitC
    pto.tile.print path with an f32 round trip

@Crystal-wzy
Crystal-wzy force-pushed the main branch 2 times, most recently from 646d4a3 to 0afdbd3 Compare July 25, 2026 03:47
Comment thread ptodsl/ptodsl/tilelib/templates/a5/tprint.py Outdated
Comment thread lib/PTO/Transforms/ExpandTileOp.cpp Outdated
func.walk([&](Operation *op) {
if (isa<pto::TReshapeOp>(op))
// TReshapeOp (zero-copy alias) and TPrintOp (cce::printf side effect) are
// lowered natively by PTOToEmitC (TRESHAPE / TPRINT) with no vector

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.

tprint只能在emitc后端用吗?vpto后端的实现方案是什么?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

目前 tprint 只支持 EmitC。EmitC 已有 PTOPrintToTPRINT lowering,能直接生成 pto-isa TPRINT 调用;VPTO 侧目前没有 TPrintOp/TPRINT 的 emission/runtime debug print 实现。因此这版不做 TileLib 模板展开,并在 VPTO backend下遇到 pto.tprint 时显式报 unsupported,避免静默走错路径。后续 VPTO 支持需要先补 VPTO lowering/runtime 的 print side-effect 方案。

Comment thread ptodsl/ptodsl/tilelib/templates/a5/treshape.py Outdated
Comment thread ptodsl/tests/test_tilelib_catalog.py Outdated
@Crystal-wzy Crystal-wzy changed the title feat: Add tprint and treshape tilelib tile ops feat: Add pto.tile.print debug tile op Jul 27, 2026
@Crystal-wzy
Crystal-wzy force-pushed the main branch 7 times, most recently from 2c3b929 to 79e7d4c Compare July 28, 2026 02:59
Comment thread lib/PTO/Transforms/ExpandTileOp.cpp Outdated
Comment thread ptodsl/docs/user_guide/04-type-system-and-buffer.md Outdated
Comment thread ptodsl/ptodsl/_ops.py
@Crystal-wzy Crystal-wzy changed the title feat: Add pto.tile.print debug tile op feat(ptodsl): Add tile debug print support Jul 28, 2026
@Crystal-wzy
Crystal-wzy force-pushed the main branch 2 times, most recently from acc8e00 to 71e7649 Compare July 29, 2026 03:11
Add PTODSL support for the native `pto.tprint` debug-print operation and
expose it through `pto.tile.print`. The operation is modeled as a device-side
side effect, emits no numeric result, and is routed through the native EmitC
TPRINT lowering path.

## Summary

- Add `_ops.tprint(src, *, tmp=None)` and export it through `pto.tile.print`
  for tile debug printing, including the optional scratch `tmp` operand
- Reject `pto.tile.print` on the VPTO backend with an explicit unsupported
  diagnostic, while allowing EmitC modules to keep the native `pto.tprint`
  operation
- Treat `TPrintOp` as a native operation in tile expansion and template
  metadata insertion, so it is not expanded through TileLib templates
- Add JIT compile coverage for EmitC `pto.tile.print` lowering and the VPTO
  unsupported-backend diagnostic
- Add an A5 TileLib ST case for `pto.tile.print` using an EmitC kernel and a
  tile fill -> print sequence
- Add a VPTO lit negative case that checks the explicit unsupported diagnostic
- Document `pto.tile.print` in the PTODSL user guide, including side-effect
  behavior, `tmp` handling, dtype coverage, backend support, and A5 constraints

## Testing

- [x] `ptodsl/tests/test_jit_compile.py` adds EmitC lowering and VPTO
  unsupported-backend checks for `pto.tile.print`
- [x] `test/lit/vpto/tprint_vpto_unsupported.pto` covers the VPTO unsupported
  diagnostic for `pto.tprint`
- [x] `test/tilelib-st/a5/tprint/case.py` covers the A5 EmitC
  `pto.tile.print` path with an f32 tile fill and device-side print
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