Skip to content

[Enh] Add rounding-mode control for float-to-float casts - #916

Merged
coderfeli merged 2 commits into
mainfrom
pr/enh-cast-rounding-mode
Jul 28, 2026
Merged

coderfeli merged 2 commits into
mainfrom
pr/enh-cast-rounding-mode

Conversation

@sjfeng1999

Copy link
Copy Markdown
Collaborator

Motivation

Technical Details

Test Plan

Test Result

Submission Checklist

Copilot AI 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.

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 to Numeric.to(...) and Vector.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 through f32 and (b) attach the MLIR roundingmode attribute on narrowing arith.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.

Comment thread tests/language/test_arithmetic_types.py Resolved
Comment thread python/flydsl/expr/typing.py Resolved
Comment thread python/flydsl/expr/numeric.py Resolved
@coderfeli
coderfeli merged commit 9a5c08e into main Jul 28, 2026
15 checks passed
@coderfeli
coderfeli deleted the pr/enh-cast-rounding-mode branch July 28, 2026 16:04
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.

3 participants