PR #122826
tensorflow/tensorflow · Grappler · Merged · 4 files changed
Corrected Grappler ArgMax/ArgMin graph rewrites on saturated float32 boundaries where non-strict monotonicity altered winning indices.
Checkout Pull Request
Inspect the full commit history and diff locally from upstream tensorflow/tensorflow.
$gh pr checkout 122826 --repo tensorflow/tensorflowCorrected Grappler ArgMax/ArgMin graph rewrites on saturated float32 boundaries where non-strict monotonicity altered winning indices.
File-by-File Modification Breakdown (4)
- +36 / -0
tensorflow/core/grappler/op_types.cc
Grappler C++ graph optimizer pass and algebraic rewrite rules
- +1 / -0
tensorflow/core/grappler/op_types.h
Grappler C++ graph optimizer pass and algebraic rewrite rules
- +10 / -0
tensorflow/core/grappler/optimizers/arithmetic_optimizer.cc
Grappler C++ graph optimizer pass and algebraic rewrite rules
- +216 / -0
tensorflow/core/grappler/optimizers/arithmetic_optimizer_test.cc
C++ unit and regression test suite verifying the fix
Changed Files (4)
1. Introduction & Motivation
Grappler simplifies ArgMax(f(x)) to ArgMax(x) when is an order-preserving transformation, saving compute on large logits tensors. However, near float32 saturation limits, finite-precision clamping collapses distinct inputs onto the same boundary value and flips tie-breaking outcomes [1].
2. Strict Monotonicity Condition
An argmax-preserving rewrite is sound if and only if is strictly increasing over the entire representable float32 domain:
When saturation causes , Equation (1) fails and the rewrite returns a different winning index than the unoptimized graph.
3. References
- D. Goldberg, What Every Computer Scientist Should Know About Floating-Point Arithmetic, ACM Computing Surveys, 1991.