Repository navigation
[Enh] Add rounding-mode control for float-to-float casts - #916
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds user-facing rounding-mode control for narrowing float-to-float casts in the FlyDSL expression layer, wiring the requested rounding mode through to MLIR arith.truncf and documenting/testing the new behavior.
Changes:
- Add
rounding_mode=keyword parameter toNumeric.to(...)andVector.to(...), with validation and rejection of non-float casts / compile-time constants. - Extend
fp_to_fp(...)to (a) route same-width sub-32-bit float casts throughf32and (b) attach the MLIRroundingmodeattribute on narrowingarith.truncf. - Update language spec docs and add conformance tests for rounding-mode behavior.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/language/test_arithmetic_types.py | Adds IR-level tests for same-width float casts via f32 and for rounding_mode= propagation/rejection. |
| python/flydsl/expr/utils/arith.py | Plumbs rounding_mode into float-to-float lowering and adds f32 detour for same-width sub-32-bit casts. |
| python/flydsl/expr/typing.py | Extends Vector.to(...) API to accept/validate rounding_mode= for float-to-float casts. |
| python/flydsl/expr/numeric.py | Extends Numeric.to(...) API to accept/validate rounding_mode= and enforce runtime-only narrowing semantics. |
| python/flydsl/expr/arith.py | Re-exports RoundingMode in the public arith API surface. |
| docs/language/arithmetic_types.md | Documents the new rounding_mode= keyword and rounding-mode semantics. |
| docs/index.rst | Renames the toctree caption for the language docs section. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Motivation
Technical Details
Test Plan
Test Result
Submission Checklist