aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/c
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <gardener@tensorflow.org>2018-08-20 17:18:25 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-08-20 17:23:19 -0700
commitf1ed43263ff034b029e1e197e1c83178646bde7a (patch)
tree6cf197ebd07a58e07dabe0b92676a9aa57c9e8d0 /tensorflow/c
parent9962eb5e84b15e309410071b06c2ed2d6148ed44 (diff)
EIGEN_MAX_ALIGN_BYTES can be zero when vectorization is disabled. In that case, checking for alignment boundaries breaks due to division by zero. But in these cases the check itself is redundant, so replace EIGEN_MAX_ALIGN_BYTES with std::max(1, EIGEN_MAX_ALIGN_BYTES).
PiperOrigin-RevId: 209513729
Diffstat (limited to 'tensorflow/c')
-rw-r--r--tensorflow/c/c_api.cc3
1 files changed, 2 insertions, 1 deletions
diff --git a/tensorflow/c/c_api.cc b/tensorflow/c/c_api.cc
index 19ccb6e71d..b8adf6c127 100644
--- a/tensorflow/c/c_api.cc
+++ b/tensorflow/c/c_api.cc
@@ -202,7 +202,8 @@ TF_Tensor* TF_NewTensor(TF_DataType dtype, const int64_t* dims, int num_dims,
buf->len_ = len;
if (dtype != TF_STRING && dtype != TF_RESOURCE &&
tensorflow::DataTypeCanUseMemcpy(static_cast<DataType>(dtype)) &&
- reinterpret_cast<intptr_t>(data) % EIGEN_MAX_ALIGN_BYTES != 0) {
+ reinterpret_cast<intptr_t>(data) % std::max(1, EIGEN_MAX_ALIGN_BYTES) !=
+ 0) {
// TF_STRING and TF_RESOURCE tensors have a different representation in
// TF_Tensor than they do in tensorflow::Tensor. So a copy here is a waste
// (any alignment requirements will be taken care of by TF_TensorToTensor