diff options
author | 2016-05-03 15:32:45 -0800 | |
---|---|---|
committer | 2016-05-03 16:41:35 -0700 | |
commit | 1ed0e764c8ca84d45823f2fd172dc8d40f89e3e2 (patch) | |
tree | 8b5ab4224bbaa27f5eb340cddee2931d2421333b /tensorflow/core/framework/types_test.cc | |
parent | 2863cc1361e061d36061368df66feda32c2790a8 (diff) |
Catch integer division by zero on CPU to avoid SIGFPE
We let it through on GPU since the behavior is bizarre but harmless.
On the CPU, we have to turn off packet math in Eigen and use a special binary
functor that sets an error bit on division by zero. Ideally we'd be able to
use packet math too; all it would take is a nice way for checking if a packet
contains a zero.
Fixes #2163.
Change: 121429857
Diffstat (limited to 'tensorflow/core/framework/types_test.cc')
-rw-r--r-- | tensorflow/core/framework/types_test.cc | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tensorflow/core/framework/types_test.cc b/tensorflow/core/framework/types_test.cc index 8b6c8493d9..d4f11eb02c 100644 --- a/tensorflow/core/framework/types_test.cc +++ b/tensorflow/core/framework/types_test.cc @@ -129,5 +129,15 @@ TEST(TypesTest, QuantizedTypes) { EXPECT_FALSE(DataTypeIsQuantized(DT_BFLOAT16)); } +TEST(TypesTest, IntegerTypes) { + for (auto dt : AllTypes()) { + const string name = DataTypeString(dt); + const StringPiece n = name; + EXPECT_EQ(DataTypeIsInteger(dt), + n.starts_with("int") || n.starts_with("uint")) + << "DataTypeInteger failed for " << name; + } +} + } // namespace } // namespace tensorflow |