10#ifndef EIGEN_CXX11_TENSOR_TENSOR_EVAL_TO_H
11#define EIGEN_CXX11_TENSOR_TENSOR_EVAL_TO_H
16template<
typename XprType,
template <
class>
class MakePointer_>
17struct traits<TensorEvalToOp<XprType, MakePointer_> >
20 typedef typename XprType::Scalar Scalar;
21 typedef traits<XprType> XprTraits;
22 typedef typename XprTraits::StorageKind StorageKind;
23 typedef typename XprTraits::Index
Index;
24 typedef typename XprType::Nested Nested;
25 typedef typename remove_reference<Nested>::type _Nested;
26 static const int NumDimensions = XprTraits::NumDimensions;
27 static const int Layout = XprTraits::Layout;
35 typedef MakePointer_<T> MakePointerT;
36 typedef typename MakePointerT::Type Type;
40template<
typename XprType,
template <
class>
class MakePointer_>
41struct eval<TensorEvalToOp<XprType, MakePointer_>, Eigen::Dense>
43 typedef const TensorEvalToOp<XprType, MakePointer_>& type;
46template<
typename XprType,
template <
class>
class MakePointer_>
47struct nested<TensorEvalToOp<XprType, MakePointer_>, 1, typename eval<TensorEvalToOp<XprType, MakePointer_> >::type>
49 typedef TensorEvalToOp<XprType, MakePointer_> type;
57template<
typename XprType,
template <
class>
class MakePointer_>
58class TensorEvalToOp :
public TensorBase<TensorEvalToOp<XprType, MakePointer_>, ReadOnlyAccessors>
61 typedef typename Eigen::internal::traits<TensorEvalToOp>::Scalar Scalar;
62 typedef typename Eigen::NumTraits<Scalar>::Real RealScalar;
63 typedef typename internal::remove_const<typename XprType::CoeffReturnType>::type CoeffReturnType;
64 typedef typename MakePointer_<CoeffReturnType>::Type PointerType;
65 typedef typename Eigen::internal::nested<TensorEvalToOp>::type Nested;
66 typedef typename Eigen::internal::traits<TensorEvalToOp>::StorageKind StorageKind;
67 typedef typename Eigen::internal::traits<TensorEvalToOp>::Index Index;
69 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorEvalToOp(PointerType buffer,
const XprType& expr)
70 : m_xpr(expr), m_buffer(buffer) {}
73 const typename internal::remove_all<typename XprType::Nested>::type&
74 expression()
const {
return m_xpr; }
76 EIGEN_DEVICE_FUNC PointerType buffer()
const {
return m_buffer; }
79 typename XprType::Nested m_xpr;
85template<
typename ArgType,
typename Device,
template <
class>
class MakePointer_>
86struct TensorEvaluator<const TensorEvalToOp<ArgType, MakePointer_>, Device>
88 typedef TensorEvalToOp<ArgType, MakePointer_> XprType;
89 typedef typename ArgType::Scalar Scalar;
90 typedef typename TensorEvaluator<ArgType, Device>::Dimensions Dimensions;
91 typedef typename XprType::Index Index;
92 typedef typename internal::remove_const<typename XprType::CoeffReturnType>::type CoeffReturnType;
93 typedef typename PacketType<CoeffReturnType, Device>::type PacketReturnType;
94 static const int PacketSize = internal::unpacket_traits<PacketReturnType>::size;
97 IsAligned = TensorEvaluator<ArgType, Device>::IsAligned,
98 PacketAccess = TensorEvaluator<ArgType, Device>::PacketAccess,
99 Layout = TensorEvaluator<ArgType, Device>::Layout,
104 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorEvaluator(
const XprType& op,
const Device&
device)
106 m_buffer(op.buffer()), m_op(op), m_expression(op.expression())
110 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
const XprType& op()
const {
114 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ~TensorEvaluator() {
117 typedef typename internal::traits<const TensorEvalToOp<ArgType, MakePointer_> >::template MakePointer<CoeffReturnType>::Type DevicePointer;
118 EIGEN_DEVICE_FUNC
const Dimensions& dimensions()
const {
return m_impl.dimensions(); }
120 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
bool evalSubExprsIfNeeded(DevicePointer scalar) {
121 EIGEN_UNUSED_VARIABLE(scalar);
122 eigen_assert(scalar == NULL);
123 return m_impl.evalSubExprsIfNeeded(m_buffer);
126 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void evalScalar(Index i) {
127 m_buffer[i] = m_impl.coeff(i);
129 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void evalPacket(Index i) {
130 internal::pstoret<CoeffReturnType, PacketReturnType, Aligned>(m_buffer + i, m_impl.template packet<TensorEvaluator<ArgType, Device>::IsAligned ?
Aligned :
Unaligned>(i));
133 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void cleanup() {
137 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index)
const
139 return m_buffer[index];
142 template<
int LoadMode>
143 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketReturnType packet(Index index)
const
145 return internal::ploadt<PacketReturnType, LoadMode>(m_buffer + index);
148 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorOpCost costPerCoeff(
bool vectorized)
const {
151 return m_impl.costPerCoeff(vectorized) +
152 TensorOpCost(0,
sizeof(CoeffReturnType), 0, vectorized, PacketSize);
155 EIGEN_DEVICE_FUNC DevicePointer data()
const {
return m_buffer; }
156 ArgType expression()
const {
return m_expression; }
159 const TensorEvaluator<ArgType, Device>& impl()
const {
return m_impl; }
161 const Device&
device()
const{
return m_device;}
164 TensorEvaluator<ArgType, Device> m_impl;
165 const Device& m_device;
166 DevicePointer m_buffer;
168 const ArgType m_expression;
The tensor base class.
Definition TensorForwardDeclarations.h:29
Namespace containing all symbols from the Eigen library.
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The tensor evaluator class.
Definition TensorEvaluator.h:27
const Device & device() const
required by sycl in order to construct sycl buffer from raw pointer
Definition TensorEvaluator.h:112