replaces tf.round with hlo.RoundToNearestEven
PiperOrigin-RevId: 466779182
diff --git a/tensorflow/compiler/xla/client/lib/math.cc b/tensorflow/compiler/xla/client/lib/math.cc
index bd1a173..d18395d 100644
--- a/tensorflow/compiler/xla/client/lib/math.cc
+++ b/tensorflow/compiler/xla/client/lib/math.cc
@@ -1123,16 +1123,7 @@
// just ask for that explicitly.)
TF_RETURN_IF_ERROR(EnsureOperandIsRealFp("RoundToEven", x));
- auto half = ScalarLike(x, 0.5);
- auto one = ScalarLike(x, 1.0);
- auto two = ScalarLike(x, 2.0);
-
- auto round_val = Floor(x);
- auto fraction = x - round_val;
- auto nearest_even_int = round_val - two * Floor(half * x);
- auto is_odd = Eq(nearest_even_int, one);
- return Select(Or(Gt(fraction, half), And(Eq(fraction, half), is_odd)),
- round_val + one, round_val);
+ return RoundNearestEven(x);
});
}