aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Eugene Zhulenev <ezhulenev@google.com>2019-05-17 14:02:25 -0700
committerGravatar Eugene Zhulenev <ezhulenev@google.com>2019-05-17 14:02:25 -0700
commit01654d97fac5ad5be7d215981e81a606b4878447 (patch)
tree630cb85c21eada404def66ed850a2a323b354a08
parent78d3015722e9af436a0cf1d62810e18387a28638 (diff)
Prevent potential division by zero in TensorExecutor
-rw-r--r--unsupported/Eigen/CXX11/src/Tensor/TensorExecutor.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorExecutor.h b/unsupported/Eigen/CXX11/src/Tensor/TensorExecutor.h
index d57203ad9..7b5842571 100644
--- a/unsupported/Eigen/CXX11/src/Tensor/TensorExecutor.h
+++ b/unsupported/Eigen/CXX11/src/Tensor/TensorExecutor.h
@@ -333,9 +333,9 @@ class TensorExecutor<Expression, ThreadPoolDevice, Vectorizable, /*Tileable*/ tr
typename TensorBlockMapper::Dimensions(evaluator.dimensions()),
block_shape, block_size);
block_size = block_mapper.block_dims_total_size();
+ const size_t align = numext::maxi(EIGEN_MAX_ALIGN_BYTES, 1);
const size_t aligned_blocksize =
- EIGEN_MAX_ALIGN_BYTES *
- divup<size_t>(block_size * sizeof(Scalar), EIGEN_MAX_ALIGN_BYTES);
+ align * divup<size_t>(block_size * sizeof(Scalar), align);
void* buf = device.allocate((num_threads + 1) * aligned_blocksize);
device.parallelFor(
block_mapper.total_block_count(), cost * block_size,