fix(vpto): support signless i8*i8->i32 mad lowering (https://github.com/mouliangyu/PTOAS/issues/381)#389
Closed
TelGome wants to merge 1 commit into
Closed
Conversation
Collaborator
|
Included in PR #413 |
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.
Fix issue: #381
Problem:
issue #381 的核心问题出在 VPTO LLVM lowering 的 MAD callee 分发上。tmatmul 展开后会生成 pto.mad_raw,其中 int8 case 的实际类型是 signless i8 * i8 -> i32,不是 si8 * si8 -> si32,可以在 test/tilelang_st/npu/a5/src/st/testcase/tmatmul/tmatmul.pto:106 对应的 matmul case 里看到。但 lib/PTO/Transforms/VPTOLLVMEmitter.cpp:235 原来的 MAD 类型分发只把 signed integer 当成 s4/s8/s32 处理:
结果是 i8/i8/i32 这组类型拿不到合法的 intrinsic 名称,pto.mad_raw 在 LowerVPTOOpsPass 中无法完成 lowering,最终以 illegal op 形式报错:failed to legalize operation 'pto.mad_raw' that was explicitly marked illegal
Fix:
修复思路是把 PTO IR 中的 signless integer 语义和 MAD lowering 对齐。PTO IR 默认大量使用 signless integer,因此这里不应该只接受 si8/si32,而应该把 i8/si8 统一映射为 s8,把 i32/si32 统一映射为 s32。
具体改动在 lib/PTO/Transforms/VPTOLLVMEmitter.cpp:229: