From 3055e3a7c213e7f1337cdc43d5b1953acd013897 Mon Sep 17 00:00:00 2001 From: Mehdi Goli Date: Wed, 8 Aug 2018 11:19:02 +0100 Subject: [PATCH] Creating a pointer type in TensorCustomOp.h --- .../Eigen/CXX11/src/Tensor/TensorCustomOp.h | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorCustomOp.h b/unsupported/Eigen/CXX11/src/Tensor/TensorCustomOp.h index 47b5a5a5e..87d84a311 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorCustomOp.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorCustomOp.h @@ -88,6 +88,7 @@ struct TensorEvaluator, Devi typedef typename internal::remove_const::type CoeffReturnType; typedef typename PacketType::type PacketReturnType; static const int PacketSize = PacketType::size; + typedef typename internal::remove_all::PointerType>::type * PointerType; enum { IsAligned = false, @@ -106,7 +107,7 @@ struct TensorEvaluator, Devi EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Dimensions& dimensions() const { return m_dimensions; } - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE bool evalSubExprsIfNeeded(CoeffReturnType* data) { + EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE bool evalSubExprsIfNeeded(PointerType data) { if (data) { evalTo(data); return false; @@ -139,23 +140,22 @@ struct TensorEvaluator, Devi return TensorOpCost(sizeof(CoeffReturnType), 0, 0, vectorized, PacketSize); } - EIGEN_DEVICE_FUNC typename Eigen::internal::traits::PointerType data() const { return m_result; } + EIGEN_DEVICE_FUNC PointerType data() const { return m_result; } #ifdef EIGEN_USE_SYCL EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Device& device() const { return m_device; } #endif protected: - EIGEN_DEVICE_FUNC void evalTo(Scalar* data) { - TensorMap > result( - data, m_dimensions); + EIGEN_DEVICE_FUNC void evalTo(PointerType data) { + TensorMap > result(data, m_dimensions); m_op.func().eval(m_op.expression(), result, m_device); } Dimensions m_dimensions; const ArgType m_op; const Device& m_device; - CoeffReturnType* m_result; + PointerType m_result; }; @@ -250,6 +250,7 @@ struct TensorEvaluator::type CoeffReturnType; typedef typename PacketType::type PacketReturnType; static const int PacketSize = PacketType::size; + typedef typename internal::remove_all::PointerType>::type * PointerType; enum { IsAligned = false, @@ -268,12 +269,12 @@ struct TensorEvaluator(m_device.allocate_temp(dimensions().TotalSize() * sizeof(Scalar))); + m_result = static_cast(m_device.allocate_temp(dimensions().TotalSize() * sizeof(CoeffReturnType))); evalTo(m_result); return true; } @@ -300,22 +301,22 @@ struct TensorEvaluator::PointerType data() const { return m_result; } + EIGEN_DEVICE_FUNC PointerType data() const { return m_result; } #ifdef EIGEN_USE_SYCL EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Device& device() const { return m_device; } #endif protected: - EIGEN_DEVICE_FUNC void evalTo(Scalar* data) { - TensorMap > result(data, m_dimensions); + EIGEN_DEVICE_FUNC void evalTo(PointerType data) { + TensorMap > result(data, m_dimensions); m_op.func().eval(m_op.lhsExpression(), m_op.rhsExpression(), result, m_device); } Dimensions m_dimensions; const XprType m_op; const Device& m_device; - CoeffReturnType* m_result; + PointerType m_result; };