10 #ifndef EIGEN_CXX11_TENSOR_TENSOR_FORCED_EVAL_H 11 #define EIGEN_CXX11_TENSOR_TENSOR_FORCED_EVAL_H 23 template<
typename XprType>
31 typedef typename XprType::Nested
Nested;
33 static const int NumDimensions = XprTraits::NumDimensions;
34 static const int Layout = XprTraits::Layout;
42 template<
typename XprType>
48 template<
typename XprType>
58 template<
typename XprType>
81 template <
typename Device,
typename CoeffReturnType>
83 template <
typename StorageType>
87 for (
Index i = 0;
i < numValues; ++
i)
new (m_buffer +
i) CoeffReturnType();
95 template <
typename CoeffReturnType>
97 template <
typename StorageType>
103 template<
typename ArgType_,
typename Device>
122 PreferBlockAccess =
false,
139 : m_impl(op.expression(), device), m_op(op.expression()),
140 m_device(device), m_buffer(
NULL)
147 m_buffer = m_device.get((CoeffReturnType*)m_device.allocate_temp(numValues *
sizeof(CoeffReturnType)));
152 EvalTo evalToTmp(m_device.get(m_buffer), m_op);
158 run(evalToTmp, m_device);
163 #ifdef EIGEN_USE_THREADS 164 template <
typename EvalSubExprsCallback>
166 EvaluatorPointerType, EvalSubExprsCallback done) {
168 m_buffer = m_device.get((CoeffReturnType*)m_device.allocate_temp(
169 numValues *
sizeof(CoeffReturnType)));
172 EvalTo evalToTmp(m_device.get(m_buffer), m_op);
174 auto on_done = std::bind([](EvalSubExprsCallback done_) { done_(
true); },
181 runAsync(evalToTmp, m_device, std::move(on_done));
186 m_device.deallocate_temp(m_buffer);
192 return m_buffer[index];
195 template<
int LoadMode>
198 return internal::ploadt<PacketReturnType, LoadMode>(m_buffer + index);
207 block(TensorBlockDesc& desc, TensorBlockScratch& scratch,
208 bool =
false)
const {
209 assert(m_buffer !=
NULL);
210 return TensorBlock::materialize(m_buffer, m_impl.dimensions(), desc, scratch);
214 return TensorOpCost(
sizeof(CoeffReturnType), 0, 0, vectorized, PacketSize);
218 EvaluatorPointerType
data()
const {
return m_buffer; }
220 #ifdef EIGEN_USE_SYCL 237 #endif // EIGEN_CXX11_TENSOR_TENSOR_FORCED_EVAL_H internal::TensorBlockScratchAllocator< Device > TensorBlockScratch
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE std::ptrdiff_t array_prod(const Sizes< Indices... > &)
#define EIGEN_STRONG_INLINE
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index) const
Eigen::internal::traits< TensorForcedEvalOp >::Index Index
TensorEvaluator< ArgType, Device >::Dimensions Dimensions
internal::TensorBlockDescriptor< NumDims, Index > TensorBlockDesc
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketReturnType packet(Index index) const
const internal::remove_all< ArgType_ >::type ArgType
internal::TensorMaterializedBlock< CoeffReturnType, NumDims, Layout, Index > TensorBlock
Storage::Type EvaluatorPointerType
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorOpCost costPerCoeff(bool vectorized) const
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorForcedEvalOp(const XprType &expr)
remove_reference< Nested >::type _Nested
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EvaluatorPointerType data() const
EIGEN_DEVICE_FUNC const internal::remove_all< typename XprType::Nested >::type & expression() const
Namespace containing all symbols from the Eigen library.
A cost model used to limit the number of threads used for evaluating tensor expression.
Eigen::internal::traits< TensorForcedEvalOp >::Scalar Scalar
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void operator()(Index, StorageType)
TensorForcedEvalOp< XprType > type
traits< XprType >::StorageKind StorageKind
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE internal::TensorBlockResourceRequirements getResourceRequirements() const
Eigen::NumTraits< Scalar >::Real RealScalar
TensorEvaluator(const XprType &op, const Device &device)
const TensorForcedEvalOp< XprType > & type
const Device EIGEN_DEVICE_REF m_device
Generic expression where a coefficient-wise binary operator is applied to two expressions.
XprTraits::PointerType PointerType
EIGEN_STRONG_INLINE void cleanup()
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void operator()(Index numValues, StorageType m_buffer)
TensorForcedEvalOp< ArgType > XprType
Eigen::internal::nested< TensorForcedEvalOp >::type Nested
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
EvaluatorPointerType m_buffer
internal::remove_const< typename XprType::CoeffReturnType >::type CoeffReturnType
EIGEN_DEVICE_FUNC const Dimensions & dimensions() const
#define EIGEN_DEVICE_FUNC
traits< XprType > XprTraits
TensorEvaluator< ArgType, Device > m_impl
Eigen::internal::traits< TensorForcedEvalOp >::StorageKind StorageKind
EIGEN_STRONG_INLINE bool evalSubExprsIfNeeded(EvaluatorPointerType)
StorageMemory< CoeffReturnType, Device > Storage
Generic expression where a coefficient-wise unary operator is applied to an expression.
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorBlockResourceRequirements any()
traits< XprType >::Index Index
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorBlock block(TensorBlockDesc &desc, TensorBlockScratch &scratch, bool=false) const
XprType::CoeffReturnType CoeffReturnType
PacketType< CoeffReturnType, Device >::type PacketReturnType
Eigen::internal::traits< XprType >::PointerType TensorPointerType