Codegen: Optional Expression Rewriter#385
Open
eugenebokhan wants to merge 9 commits intomainfrom
Open
Conversation
CC-Yeh
reviewed
May 5, 2026
Comment on lines
+34
to
+38
| Err(_) => return format!("static_cast<bool>({condition})"), | ||
| }; | ||
| match emit_metal_expr(&parsed, self) { | ||
| Ok(body) => format!("static_cast<bool>({body})"), | ||
| Err(_) => format!("static_cast<bool>({condition})"), |
Contributor
There was a problem hiding this comment.
Should we let it fail earlier instead of getting cryptic metal compile error?
|
|
||
| namespace uzu::quantization_method { | ||
| enum class QuantizationMethod : uint32_t { | ||
| MLX = 0, |
Contributor
There was a problem hiding this comment.
How about ZeroPoint and Bias?
| .enumerate() | ||
| .map(|(i, a)| { | ||
| let c_type = a.c_type.trim_start_matches("const "); | ||
| let c_type = specialize_constant_type(&a.c_type); |
Contributor
There was a problem hiding this comment.
Curious why we use #define/#undef here instead of having rewrite_for_metal substitute bare specialize names with their prefixed counterparts, wouldn't that keep all name resolution in one place?
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.
What changed
OPTIONAL(...)conditions likeOPTIONAL(quant_method == QuantizationMethod::AWQ)now are available to use.use_zero_points/use_mlx_quantbool pair inQmv,QmvFast,QmmTransposedkernels with singlequant_method: QuantizationMethodenum.Bindgen decoupling
Each kernel argument is parsed once into a typed variant; each emission stream is one
iter().filter_map()pass:Replaced a
.multiunzip()over a 7-tuple ofVec<Option<TokenStream>>and threemutaccumulators (arg_count,indirect_flag,referenced_variants) with typed fields and aVariantPathRewriterconsumed via.finish().mod.rsorchestrator —parse → emit → assemble: