PR #123282
tensorflow/tensorflow · MLIR · Merged · 4 files changed
Removed the unsound TF_Involution trait from tf.Reciprocal in MLIR TableGen definitions so MLIR canonicalization never cancels nested 1/(1/x) pairs and silently alters IEEE 754 precision.
Checkout Pull Request
Inspect the full commit history and diff locally from upstream tensorflow/tensorflow.
$gh pr checkout 123282 --repo tensorflow/tensorflowRemoved the unsound TF_Involution trait from tf.Reciprocal in MLIR TableGen definitions so MLIR canonicalization never cancels nested 1/(1/x) pairs and silently alters IEEE 754 precision.
File-by-File Modification Breakdown (4)
- +0 / -24
tensorflow/compiler/mlir/tensorflow/ir/tf_generated_ops.td
MLIR TableGen operator trait and canonicalization definition
- +29 / -0
tensorflow/compiler/mlir/tensorflow/ir/tf_ops.td
MLIR TableGen operator trait and canonicalization definition
- +17 / -1
tensorflow/compiler/mlir/tensorflow/tests/canonicalize.mlir
Python/XLA regression test suite verifying edge-case behavior
- +21 / -3
tensorflow/compiler/mlir/tensorflow/tests/tf_trait_folds.mlir
Python/XLA regression test suite verifying edge-case behavior
Changed Files (4)
1. Introduction & Motivation
Compiler canonicalizers rely on algebraic traits declared in MLIR TableGen (.td) files to simplify redundant operator chains [1]. Because tf.Reciprocal carried the TF_Involution trait, MLIR treated as an exact identity and eliminated both ops, silently breaking numerical reproducibility on subnormals and rounding boundaries.
2. Finite-Precision Proof Against Involution
An operator is a true involution iff for every in its domain. In IEEE 754 binary32 with machine epsilon , each division incurs rounding with [2]:
Furthermore, for any subnormal with (such as ), overflows FLT_MAX to , yielding:
Input (float32) | Exact 1/(1/x) | Simplified x (Before) | Unfolded (After) |
|---|---|---|---|
| (subnormal) | (wrong) | (exact) | |
| Normal float | ULP drift | Preserves IEEE 754 |
3. References
- Lattner et al., MLIR: Scaling Compiler Infrastructure for Domain Specific Computation, CGO 2021.
- IEEE Computer Society, IEEE Std 754-2019, Binary Floating-Point Rounding & Subnormals.