Skip to content

Separate the language Type from the ABI halide_type_t#9205

Open
alexreinking wants to merge 7 commits into
mainfrom
alexreinking/type-exploration
Open

Separate the language Type from the ABI halide_type_t#9205
alexreinking wants to merge 7 commits into
mainfrom
alexreinking/type-exploration

Conversation

@alexreinking

@alexreinking alexreinking commented Jul 13, 2026

Copy link
Copy Markdown
Member
  • ABI halide_type_t drops lanes -> {code, bits, reserved} (still 4 bytes; halide_buffer_t layout unchanged). Halide::Type is decoupled and stores its own fields; must be explicitly erased with as_abi (asserts scalar), Trace event/packet carry their own lanes.
  • Halide::Type is reduced to 8 bytes: the handle_type pointer is replaced by a 4-byte index into a process-wide handle-type intern table.
  • The IR matcher / constant folder uses Halide::Type directly; This keeps handle C++-type metadata fidelity through matcher reconstruction.

One open problem remains for future work due to lack of testing:

  • d3d12 buffer element types treated as scalar (multi-channel texture format selection is a follow-up). @slomp maybe you know something about this? I don't think it's tested at all.

Fixes #9202
Fixes #9203

Breaking changes

The Type and halide_type_t arguments have been significantly reworked. This is both an ABI and an API break.

Checklist

  • Tests added or updated (not required for docs, CI config, or typo fixes)
  • Documentation updated (if public API changed)
  • Python bindings updated (if public API changed)
  • Benchmarks are included here if the change is intended to affect performance.
  • Commits include AI attribution where applicable (see Code of Conduct)

@alexreinking
alexreinking requested a review from abadams July 13, 2026 22:08
@alexreinking
alexreinking force-pushed the alexreinking/type-exploration branch 5 times, most recently from 0bd2e30 to 3f1f8c9 Compare July 13, 2026 22:46
Comment thread src/Type.cpp
@codecov

codecov Bot commented Jul 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.00000% with 72 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@5476bf3). Learn more about missing BASE report.

Files with missing lines Patch % Lines
src/IRMatch.h 87.23% 16 Missing and 2 partials ⚠️
src/Type.cpp 67.50% 5 Missing and 8 partials ⚠️
src/runtime/HalideRuntime.h 45.83% 9 Missing and 4 partials ⚠️
src/Type.h 81.39% 4 Missing and 4 partials ⚠️
src/Callable.h 64.28% 2 Missing and 3 partials ⚠️
src/CodeGen_LLVM.cpp 16.66% 2 Missing and 3 partials ⚠️
src/CodeGen_C.cpp 85.18% 1 Missing and 3 partials ⚠️
src/CPlusPlusMangle.cpp 92.00% 1 Missing and 1 partial ⚠️
src/WasmExecutor.cpp 83.33% 2 Missing ⚠️
src/Buffer.h 66.66% 1 Missing ⚠️
... and 1 more
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #9205   +/-   ##
=======================================
  Coverage        ?   70.32%           
=======================================
  Files           ?      255           
  Lines           ?    78928           
  Branches        ?    18879           
=======================================
  Hits            ?    55504           
  Misses          ?    17874           
  Partials        ?     5550           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@alexreinking
alexreinking force-pushed the alexreinking/type-exploration branch 4 times, most recently from 89ab379 to cd20a61 Compare July 14, 2026 13:46
@slomp

slomp commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

d3d12 buffer element types treated as scalar

IIRC, the no-scalar buffer formats would only be applicable in specific instances of vectorized inputs/outputs.
I do remember testing the behavior waaay back when, but I don't think actual tests were added to the repository.

@alexreinking

Copy link
Copy Markdown
Member Author

IIRC, the no-scalar buffer formats would only be applicable in specific instances of vectorized inputs/outputs.
I do remember testing the behavior waaay back when, but I don't think actual tests were added to the repository.

I wonder whether they actually work on main... In any case, we'll need a Type-driven (rather than halide_type_t-driven) way of communicating that information to D3D12.

Comment thread src/Type.h
alexreinking and others added 4 commits July 17, 2026 19:14
- ABI halide_type_t drops `lanes` -> {code, bits, reserved} (still 4 bytes;
  halide_buffer_t layout unchanged). Halide::Type is decoupled and stores
  its own fields; must be explicitly erased with `as_abi` (asserts scalar),
  Trace event/packet carry their own `lanes`.
- Halide::Type is reduced to 8 bytes: the handle_type pointer is replaced
  by a 4-byte index into a process-wide handle-type intern table.
- The IR matcher / constant folder uses Halide::Type directly; This keeps
  handle C++-type metadata fidelity through matcher reconstruction.
- CodeGen intrinsic tables (ARM/X86/Hexagon/PowerPC/WebAssembly) use
  Halide::Type.
- Added ostream operator<< support for halide_type_t directly.

Some open problems remain:

- d3d12 buffer element types treated as scalar (multi-channel texture format
  selection is a follow-up).
- A few instances call for invalid/uninitialized `Type`s, which goes against
  the overarching goal of making Type always coherent.

Fixes #9202
Fixes #9203

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@alexreinking
alexreinking force-pushed the alexreinking/type-exploration branch from 1c50698 to 13cfd19 Compare July 17, 2026 23:14
@alexreinking

Copy link
Copy Markdown
Member Author

Rebased and pushed to include #9108 in CI. The only other failure was a very mysterious case in HVX. It's complaining about an incorrect function signature for qurt_hvx_lock. This was first corrected in #7601 and then later reverted in #7614.

If it happens again, I'll investigate further.

@alexreinking alexreinking added the release_notes For changes that may warrant a note in README for official releases. label Jul 18, 2026
@alexreinking

alexreinking commented Jul 18, 2026

Copy link
Copy Markdown
Member Author

All green now.

edit: some filesystem issue on win-worker-3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release_notes For changes that may warrant a note in README for official releases.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IRMatch drops Handle metadata Runtime buffers' pointer/size arithmetic ignores type.lanes

3 participants