diff options
author | Jonas Harsch <jonas_harsch@web.de> | 2021-07-02 20:33:52 +0000 |
---|---|---|
committer | Antonio Sánchez <cantonios@google.com> | 2021-07-02 20:33:52 +0000 |
commit | aab747021be5ed1a1e9667243d884eb72003599d (patch) | |
tree | 13d56e54624d49e4141661fc4ea04b6c5324160d /unsupported/Eigen/CXX11/src/Tensor/TensorShuffling.h | |
parent | bbfc4d54cd863676b3ae874e25dbe150fb6d575c (diff) |
Don't crash when attempting to shuffle an empty tensor.
Diffstat (limited to 'unsupported/Eigen/CXX11/src/Tensor/TensorShuffling.h')
-rw-r--r-- | unsupported/Eigen/CXX11/src/Tensor/TensorShuffling.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorShuffling.h b/unsupported/Eigen/CXX11/src/Tensor/TensorShuffling.h index 0999815d7..e5e5efdee 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorShuffling.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorShuffling.h @@ -142,7 +142,8 @@ struct TensorEvaluator<const TensorShufflingOp<Shuffle, ArgType>, Device> m_unshuffledInputStrides[i] = m_unshuffledInputStrides[i - 1] * input_dims[i - 1]; m_outputStrides[i] = m_outputStrides[i - 1] * m_dimensions[i - 1]; - m_fastOutputStrides[i] = internal::TensorIntDivisor<Index>(m_outputStrides[i]); + m_fastOutputStrides[i] = internal::TensorIntDivisor<Index>( + m_outputStrides[i] > 0 ? m_outputStrides[i] : Index(1)); } } else { m_unshuffledInputStrides[NumDims - 1] = 1; @@ -151,7 +152,8 @@ struct TensorEvaluator<const TensorShufflingOp<Shuffle, ArgType>, Device> m_unshuffledInputStrides[i] = m_unshuffledInputStrides[i + 1] * input_dims[i + 1]; m_outputStrides[i] = m_outputStrides[i + 1] * m_dimensions[i + 1]; - m_fastOutputStrides[i] = internal::TensorIntDivisor<Index>(m_outputStrides[i]); + m_fastOutputStrides[i] = internal::TensorIntDivisor<Index>( + m_outputStrides[i] > 0 ? m_outputStrides[i] : Index(1)); } } |