Skip to content

[TIRx] Add a dedicated boolean buffer lowering pass#19873

Open
guan404ming wants to merge 2 commits into
apache:mainfrom
guan404ming:tirx-lower-bool-buffer
Open

[TIRx] Add a dedicated boolean buffer lowering pass#19873
guan404ming wants to merge 2 commits into
apache:mainfrom
guan404ming:tirx-lower-bool-buffer

Conversation

@guan404ming

@guan404ming guan404ming commented Jun 23, 2026

Copy link
Copy Markdown
Member

Why

The bool→int8 backing-array conversion was duplicated inline across FlattenBuffer and LowerTIRxCleanup.

How

  • Add LowerBoolBuffer pass that rewrites bool buffers to int8 and inserts load/store casts.
  • Remove the duplicated bool handling from FlattenBuffer and LowerTIRxCleanup.
  • Run it after FlattenBuffer (before VectorizeLoop) in every pipeline, with structural and build-and-run tests.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Comment thread src/tirx/transform/lower_bool_buffer.cc
Comment thread src/tirx/transform/lower_bool_buffer.cc
Comment thread src/tirx/transform/lower_bool_buffer.cc
Signed-off-by: Guan-Ming (Wesley) Chiu <105915352+guan404ming@users.noreply.github.com>
@tqchen

tqchen commented Jun 23, 2026

Copy link
Copy Markdown
Member

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

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