Fix out-of bounds access in TensorArgMax.h.

This commit is contained in:
Rasmus Munk Larsen 2018-10-08 16:41:36 -07:00
parent 1a737e1d6a
commit d16634c4d4

View File

@ -235,7 +235,6 @@ struct TensorEvaluator<const TensorTupleReducerOp<ReduceOp, Dims, ArgType>, Devi
,m_device(device) ,m_device(device)
#endif #endif
{ {
gen_strides(m_orig_impl.dimensions(), m_strides); gen_strides(m_orig_impl.dimensions(), m_strides);
if (Layout == static_cast<int>(ColMajor)) { if (Layout == static_cast<int>(ColMajor)) {
const Index total_size = internal::array_prod(m_orig_impl.dimensions()); const Index total_size = internal::array_prod(m_orig_impl.dimensions());
@ -244,7 +243,7 @@ struct TensorEvaluator<const TensorTupleReducerOp<ReduceOp, Dims, ArgType>, Devi
const Index total_size = internal::array_prod(m_orig_impl.dimensions()); const Index total_size = internal::array_prod(m_orig_impl.dimensions());
m_stride_mod = (m_return_dim > 0) ? m_strides[m_return_dim - 1] : total_size; m_stride_mod = (m_return_dim > 0) ? m_strides[m_return_dim - 1] : total_size;
} }
m_stride_div = m_strides[m_return_dim]; m_stride_div = (m_return_dim >= 0) ? m_strides[m_return_dim] : 1;
} }
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Dimensions& dimensions() const { EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Dimensions& dimensions() const {