[XLA] Fix bugs and incomplete comment in reduce_precision_test.cc.
We want a bitwise or, not bitwise and, to add in the sign bit. This was previously just creating zeros instead of negative test values.
PiperOrigin-RevId: 161473273
diff --git a/tensorflow/compiler/xla/tests/reduce_precision_test.cc b/tensorflow/compiler/xla/tests/reduce_precision_test.cc
index a66c9b4..48212dc 100644
--- a/tensorflow/compiler/xla/tests/reduce_precision_test.cc
+++ b/tensorflow/compiler/xla/tests/reduce_precision_test.cc
@@ -214,11 +214,12 @@
// Add positive values.
input_values.push_back(tensorflow::bit_cast<float>(test_value[0]));
expected_values.push_back(tensorflow::bit_cast<float>(test_value[index]));
- // Add negative values. We do this in the
+ // Add negative values. We do this in the bitwise representation so as to
+ // avoid problems with NaN handling.
input_values.push_back(
- tensorflow::bit_cast<float>(test_value[0] & sign_bit));
+ tensorflow::bit_cast<float>(test_value[0] ^ sign_bit));
expected_values.push_back(
- tensorflow::bit_cast<float>(test_value[index] & sign_bit));
+ tensorflow::bit_cast<float>(test_value[index] ^ sign_bit));
}
// This is required for proper handling of NaN values.