Use the proper index type in the padding code

This commit is contained in:
Benoit Steiner 2014-10-30 18:15:05 -07:00
parent bc99c5f7db
commit d62bfe73a9

View File

@ -98,7 +98,6 @@ struct TensorEvaluator<const TensorPaddingOp<PaddingDimensions, ArgType>, Device
for (int i = 0; i < NumDims; ++i) { for (int i = 0; i < NumDims; ++i) {
m_dimensions[i] += m_padding[i].first + m_padding[i].second; m_dimensions[i] += m_padding[i].first + m_padding[i].second;
} }
const typename TensorEvaluator<ArgType, Device>::Dimensions& input_dims = m_impl.dimensions(); const typename TensorEvaluator<ArgType, Device>::Dimensions& input_dims = m_impl.dimensions();
m_inputStrides[0] = 1; m_inputStrides[0] = 1;
m_outputStrides[0] = 1; m_outputStrides[0] = 1;
@ -125,6 +124,7 @@ struct TensorEvaluator<const TensorPaddingOp<PaddingDimensions, ArgType>, Device
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index) const EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index) const
{ {
eigen_assert(index < dimensions().TotalSize());
Index inputIndex = 0; Index inputIndex = 0;
for (int i = NumDims - 1; i > 0; --i) { for (int i = NumDims - 1; i > 0; --i) {
const Index idx = index / m_outputStrides[i]; const Index idx = index / m_outputStrides[i];
@ -151,11 +151,11 @@ struct TensorEvaluator<const TensorPaddingOp<PaddingDimensions, ArgType>, Device
const Index initialIndex = index; const Index initialIndex = index;
Index inputIndex = 0; Index inputIndex = 0;
for (int i = NumDims - 1; i > 0; --i) { for (int i = NumDims - 1; i > 0; --i) {
const int first = index; const Index first = index;
const int last = index + packetSize - 1; const Index last = index + packetSize - 1;
const int lastPaddedLeft = m_padding[i].first * m_outputStrides[i]; const Index lastPaddedLeft = m_padding[i].first * m_outputStrides[i];
const int firstPaddedRight = (m_dimensions[i] - m_padding[i].second) * m_outputStrides[i]; const Index firstPaddedRight = (m_dimensions[i] - m_padding[i].second) * m_outputStrides[i];
const int lastPaddedRight = m_outputStrides[i+1]; const Index lastPaddedRight = m_outputStrides[i+1];
if (last < lastPaddedLeft) { if (last < lastPaddedLeft) {
// all the coefficient are in the padding zone. // all the coefficient are in the padding zone.
@ -179,9 +179,9 @@ struct TensorEvaluator<const TensorPaddingOp<PaddingDimensions, ArgType>, Device
const Index last = index + packetSize - 1; const Index last = index + packetSize - 1;
const Index first = index; const Index first = index;
const int lastPaddedLeft = m_padding[0].first; const Index lastPaddedLeft = m_padding[0].first;
const int firstPaddedRight = (m_dimensions[0] - m_padding[0].second); const Index firstPaddedRight = (m_dimensions[0] - m_padding[0].second);
const int lastPaddedRight = m_outputStrides[1]; const Index lastPaddedRight = m_outputStrides[1];
if (last < lastPaddedLeft) { if (last < lastPaddedLeft) {
// all the coefficient are in the padding zone. // all the coefficient are in the padding zone.