Skip to content

Commit aa23952

Browse files
[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
1 parent 7624e8e commit aa23952

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

tensorflow/compiler/xla/tests/reduce_precision_test.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,11 +214,12 @@ XLA_TEST_P(ReducePrecisionTest, ReducePrecisionF32) {
214214
// Add positive values.
215215
input_values.push_back(tensorflow::bit_cast<float>(test_value[0]));
216216
expected_values.push_back(tensorflow::bit_cast<float>(test_value[index]));
217-
// Add negative values. We do this in the
217+
// Add negative values. We do this in the bitwise representation so as to
218+
// avoid problems with NaN handling.
218219
input_values.push_back(
219-
tensorflow::bit_cast<float>(test_value[0] & sign_bit));
220+
tensorflow::bit_cast<float>(test_value[0] ^ sign_bit));
220221
expected_values.push_back(
221-
tensorflow::bit_cast<float>(test_value[index] & sign_bit));
222+
tensorflow::bit_cast<float>(test_value[index] ^ sign_bit));
222223
}
223224

224225
// This is required for proper handling of NaN values.

0 commit comments

Comments
 (0)