From 79b69b7444cfae2f7631e873e822cdca6f4e355f Mon Sep 17 00:00:00 2001 From: Benoit Steiner Date: Tue, 12 Jan 2016 15:21:09 -0800 Subject: [PATCH] Trigger the optimized matrix vector path more conservatively. --- unsupported/Eigen/CXX11/src/Tensor/TensorContraction.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorContraction.h b/unsupported/Eigen/CXX11/src/Tensor/TensorContraction.h index 63d0c6f68..72a378dfd 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorContraction.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorContraction.h @@ -145,7 +145,10 @@ class SimpleTensorContractionMapper { } EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE Index firstAligned(Index size) const { - return (Alignment == Aligned) ? 0 : size; + // Only claim alignment when we can compute the actual stride (ie when we're + // dealing with the lhs with inner_dim_contiguous. This is because the + // matrix-vector product relies on the stride when dealing with aligned inputs. + return (Alignment == Aligned) && (side == Lhs) && inner_dim_contiguous ? 0 : size; } EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE Index stride() const { return ((side == Lhs) && inner_dim_contiguous) ? m_contract_strides[0] : 1;