Skip to content

feat: Add tprint and treshape tilelib tile ops#994

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

feat: Add tprint and treshape tilelib tile ops#994
Crystal-wzy wants to merge 1 commit into
hw-native-sys:mainfrom
Crystal-wzy:main

Conversation

@Crystal-wzy

Copy link
Copy Markdown
Collaborator

Add the pto.tprint debug-print tile op and an A5 template for the existing pto.treshape op to the PTODSL TileLib for the A5 target, with frontend API, templates, catalog entries, an ExpandTileOp lowering fix, system tests, and user-guide documentation. Both ops are native (ExpandTileOp skips them and PTOToEmitC lowers them to TPRINT/TRESHAPE directly), so their templates exist for catalog completeness only.

Summary

  • Add pto.tprint (device-side debug print of a tile: the A5 CCE TPRINT_IMPL Vec path, cce::printf over the tile; a pure side effect with no numeric result, so the call returns None and the op is not fusible) DSL op in _ops.py, and expose it as pto.tprint / pto.tile.print. A Unified-Buffer (vec) tile prints directly; an accumulator tile may pass a scratch GlobalTensor tmp to stage the copy to GM. The CCE printFormat template argument is not exposed (the installed MLIR build lacks a PTO_PrintFormatAttr builder), so the default format is used
  • Add A5 TileLib templates template_tprint (ports A5 CCE TPRINT_IMPL: cce::printf with no vector compute and no dst, non-fusible) and template_treshape (ports A5 CCE TRESHAPE_IMPL: zero-copy __cce_alias storage alias, gated by a byte-size-equal constraint)
  • Register both templates in the a5 catalog and add catalog entries, plus a test_tprint_and_treshape_native_catalog_entries test. Since the ops are native, selection (not vector render) is the right coverage
  • Fix ExpandTileOp.cpp to also skip TPrintOp (alongside the existing TReshapeOp skip) in the tile-op walk, because both are lowered natively by PTOToEmitC (TPRINT / TRESHAPE) with no vector decomposition
  • Add system tests under test/tilelib-st/a5/{tprint, treshape}: tprint is run-only (no golden) across f32/i32/i8 at 1x8, 1x32, and 2x8 -- coverage mirroring the pto-isa C++ TPRINT ST cases; treshape is golden-output for byte-equal rank-2 reshapes (f32 2x16->1x32, 16x16->1x256, 16x16->32x8)
  • Document pto.tile.print in 04-type-system-and-buffer.md (section 4.11 Tile Debug Print)

Testing

  • All tests pass (fill in total count after running the suite)
  • Code review completed
  • Pre-commit hooks pass (clang-format, cpplint, ruff, pyright, markdownlint)

Add the pto.tprint debug-print tile op and an A5 template for the
existing pto.treshape op to the PTODSL TileLib for the A5 target, with
frontend API, templates, catalog entries, an ExpandTileOp lowering fix,
system tests, and user-guide documentation. Both ops are native
(ExpandTileOp skips them and PTOToEmitC lowers them to TPRINT/TRESHAPE
directly), so their templates exist for catalog completeness only.

## Summary
- Add pto.tprint (device-side debug print of a tile: the A5 CCE
  TPRINT_IMPL Vec path, cce::printf over the tile; a pure side effect
  with no numeric result, so the call returns None and the op is not
  fusible) DSL op in _ops.py, and expose it as pto.tprint /
  pto.tile.print. A Unified-Buffer (vec) tile prints directly; an
  accumulator tile may pass a scratch GlobalTensor tmp to stage the
  copy to GM. The CCE printFormat template argument is not exposed
  (the installed MLIR build lacks a PTO_PrintFormatAttr builder), so
  the default format is used
- Add A5 TileLib templates template_tprint (ports A5 CCE TPRINT_IMPL:
  cce::printf with no vector compute and no dst, non-fusible) and
  template_treshape (ports A5 CCE TRESHAPE_IMPL: zero-copy
  __cce_alias storage alias, gated by a byte-size-equal constraint)
- Register both templates in the a5 catalog and add catalog entries,
  plus a test_tprint_and_treshape_native_catalog_entries test. Since
  the ops are native, selection (not vector render) is the right
  coverage
- Fix ExpandTileOp.cpp to also skip TPrintOp (alongside the existing
  TReshapeOp skip) in the tile-op walk, because both are lowered
  natively by PTOToEmitC (TPRINT / TRESHAPE) with no vector
  decomposition
- Add system tests under test/tilelib-st/a5/{tprint, treshape}:
  tprint is run-only (no golden) across f32/i32/i8 at 1x8, 1x32, and
  2x8 -- coverage mirroring the pto-isa C++ TPRINT ST cases; treshape
  is golden-output for byte-equal rank-2 reshapes (f32 2x16->1x32,
  16x16->1x256, 16x16->32x8)
- Document pto.tile.print in 04-type-system-and-buffer.md (section
  4.11 Tile Debug Print)

## Testing
- [x] All tests pass (fill in total count after running the suite)
- [x] Code review completed
- [x] Pre-commit hooks pass (clang-format, cpplint, ruff, pyright,
      markdownlint)
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.

1 participant