[TIRx] Add a dedicated boolean buffer lowering pass#19873
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a dedicated LowerBoolBuffer pass to replace boolean buffers with an int8 backing array, moving this logic out of FlattenBuffer and LayoutApplier. The new pass is integrated into the compilation pipelines to run after buffer flattening and before loop vectorization. Feedback on the changes suggests handling SBlockNode within the BoolBufferLegalizer to properly remap boolean buffers referenced or allocated inside blocks. Additionally, it is recommended to use new_buf->dtype instead of hardcoding DataType::Int(8) during load and store casts to improve code robustness.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
actually i am not sure if bool to int8 lowering is still needed given we migrated into DLPack bool recently and now bool is native bool(8bit), cc @tlopex |
8da0ec3 to
e6a6bcd
Compare
|
Thanks @tqchen for catching this. Just confirmed it's dead code. With native DLPack bool(8-bit), LLVM lowers bool to byte-addressable i1 and CUDA emits native bool, so the int8 backing isn't needed. Verified end-to-end on LLVM CPU and CUDA L4: bool alloc buffers + load/store + compare/select all pass with the conversion removed. I have updated this PR to just delete the bool→int8 lowering instead of adding the pass. |
e6a6bcd to
315cc5f
Compare
|
|
||
| // Bool tensors are backed by int8 so vectorized accesses lower to real loads/stores | ||
| // (ld1b/st1b) instead of the i1 predicate registers that an i1 type would force. | ||
| PrimType BoolStorageType(const PrimType& dtype) { |
There was a problem hiding this comment.
The name sounds it only works for Bool, instead, i think it is betetr to say BufferAccessType
and comment as the underlying access type for Buffer
There was a problem hiding this comment.
Thanks for the great suggestion and I just updated.
Signed-off-by: Guan-Ming (Wesley) Chiu <105915352+guan404ming@users.noreply.github.com>
Signed-off-by: Guan-Ming (Wesley) Chiu <105915352+guan404ming@users.noreply.github.com>
315cc5f to
2136eb5
Compare
Why
The bool→int8 backing-array conversion was duplicated inline across
FlattenBufferandLowerTIRxCleanup.How
LowerBoolBufferpass that rewritesboolbuffers toint8and inserts load/store casts.FlattenBufferandLowerTIRxCleanup.