Feature/assert tensor dump - #1479
Open
kuri780 wants to merge 2 commits into
Open
Conversation
Adds pto.assert %cond {message = "..."} : i1, the conditional form of
pto.trap, for issue hw-native-sys#1386.
- ODS: AssertOp with MicroOp/SimtOp interfaces and MemWrite effect so
the check is never CSE'd or DCE'd; no verifier (i1 enforced by ODS)
- VPTO lowering (beta1 + CANN900): negate the condition and guard a
call to the existing llvm.hivm.TRAP via scf.if; the declaration is
injected through the existing PlannedDecl/materializeDecls machinery.
The message attribute is ignored on this path: the VPTO backend has
no device printf channel.
- EmitC lowering: DEBUG_CHECK(cond, "msg") from pto/common/debug.h
(include injected only when an assert is present); message defaults
to "pto.assert failed" and is escaped like pto.print's format string
- PTODSL: pto.assert_(cond, message=None) with i1 coercion
- Docs: PTO_IR_manual 4.20 and ptodsl user guide 10.8 (doc-test fixture)
- Tests: vpto LLVM IR emission (default + CANN 9.0.0) and EmitC output
Co-Authored-By: Claude Code <noreply@anthropic.com>
Adds pto.tdump ins(%tile) outs(%gm_view), a VPTO-only debug op that writes a self-describing dump of a UB tile into a host-passed GM buffer, for issue hw-native-sys#1386. Dump layout: a 64-byte little-endian header (magic "PTD0", version, element size/type, ndim, shape, valid_shape, data offset, reserved) followed by the raw row-major tile data. The host can decode the dump without knowing the tensor shape up front. - ODS: PTO_TOp with OpPipeInterface (PIPE_MTE3) so tile-level sync insertion works like pto.tstore; verifier restricts v1 to vec-space tiles with dumpable element types (f16/bf16/f32/i8/i16/i32/i64) - Lowering (LowerPTOToUBufOps, runs on every arch before the A2/A3 phases): header written with 16 scalar GM stores (pto.stg, wrapped in a 1x1x1 pto.section.simt that PTOOutlineSIMTSections turns into a blocking simt_launch), then the data is copied with the same mte_ub_gm chain as tstore (llvm.hivm.MOV.UB.TO.OUT.*) - Defensive exclusions: TileOpExpansionUtils and both emitter catch-alls reject a stray pto.tdump instead of leaking to LLVM - PTODSL: pto.tile.dump(src, dst) with a vpto-backend gate; EmitC is documented as unsupported (no pto-isa changes) - Docs: PTO_IR_manual 4.20 (header layout table) and ptodsl user guide 8.1 (doc-test fixture) - Tests: vpto LLVM IR emission (a3, default + CANN 9.0.0), verifier negative test, and an end-to-end simulator case (test/vpto/cases/kernels/tdump-vec) whose compare.py decodes the header and checks the payload against the golden data Co-Authored-By: Claude Code <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
实现 issue #1386 中"条件 assert 和持久化 tensor dump"待办项:新增 pto.assert(条件 abort)与 pto.tdump(带元数据头的持久化 tensor dump),并明确与现有 pto.print / pto.tprint / pto.trap的边界。
pto.assert
pto.trap增加 message 接口 #1215(trap message)铺路pto.tdump(VPTO only)
测试