Skip to content

Support creating specialized vector/matrix functions#3

Merged
miselin merged 14 commits intomainfrom
codex/shape-specialization-skeleton
Mar 31, 2026
Merged

Support creating specialized vector/matrix functions#3
miselin merged 14 commits intomainfrom
codex/shape-specialization-skeleton

Conversation

@miselin
Copy link
Copy Markdown
Owner

@miselin miselin commented Mar 31, 2026

fvecN and matMxN both exist as statically defined types when a programmer writes their Haven code. This is fine, but it made it difficult to imagine building custom libraries for future development work.

Consider something like ML code, where we might want to have tensors of varying lengths. The current approach requires the library implementor to either pre-specialize all the possible shapes or have some sort of code generation. Not great!

This PR instead adds specialization hole capability, where fvec? and mat? can be provided as parameters. These are specialized at compile time. There are a few compile-time constants (.dim on vectors, .cols/.rows on matrices) that present the "real" shape once automatically specialized. A compile-time assertion in the form of @assert now also gives implementors the ability to validate the input parameters statically.

Also, functions using specialization holes will infer their return types automatically.

⚠️ CI will no longer run the legacy C compiler after this change! This is a real syntax change that won't be backported to the C version, marking this the first backwards-incompatible change.

@miselin miselin force-pushed the codex/shape-specialization-skeleton branch from 158589b to 4c870f1 Compare March 31, 2026 04:21
@miselin miselin merged commit 671b439 into main Mar 31, 2026
6 checks passed
@miselin miselin added the ai-generated This PR/code was majority generated by AI and may require deeper review. label Apr 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-generated This PR/code was majority generated by AI and may require deeper review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant