10#ifndef EIGEN_CXX11_TENSOR_TENSOR_LAYOUT_SWAP_H
11#define EIGEN_CXX11_TENSOR_TENSOR_LAYOUT_SWAP_H
16template<
typename XprType>
17struct traits<TensorLayoutSwapOp<XprType> > :
public traits<XprType>
19 typedef typename XprType::Scalar Scalar;
20 typedef traits<XprType> XprTraits;
21 typedef typename XprTraits::StorageKind StorageKind;
22 typedef typename XprTraits::Index
Index;
23 typedef typename XprType::Nested Nested;
24 typedef typename remove_reference<Nested>::type _Nested;
25 static const int NumDimensions = traits<XprType>::NumDimensions;
26 static const int Layout = (traits<XprType>::Layout ==
ColMajor) ? RowMajor :
ColMajor;
27 typedef typename XprTraits::PointerType PointerType;
30template<
typename XprType>
31struct eval<TensorLayoutSwapOp<XprType>, Eigen::Dense>
33 typedef const TensorLayoutSwapOp<XprType>& type;
36template<
typename XprType>
37struct nested<TensorLayoutSwapOp<XprType>, 1, typename eval<TensorLayoutSwapOp<XprType> >::type>
39 typedef TensorLayoutSwapOp<XprType> type;
66template <
typename XprType>
67class TensorLayoutSwapOp :
public TensorBase<TensorLayoutSwapOp<XprType>, WriteAccessors> {
69 typedef TensorBase<TensorLayoutSwapOp<XprType>,
WriteAccessors> Base;
70 typedef typename Eigen::internal::traits<TensorLayoutSwapOp>::Scalar Scalar;
71 typedef typename Eigen::NumTraits<Scalar>::Real RealScalar;
72 typedef typename internal::remove_const<typename XprType::CoeffReturnType>::type CoeffReturnType;
73 typedef typename Eigen::internal::nested<TensorLayoutSwapOp>::type Nested;
74 typedef typename Eigen::internal::traits<TensorLayoutSwapOp>::StorageKind StorageKind;
75 typedef typename Eigen::internal::traits<TensorLayoutSwapOp>::Index Index;
77 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorLayoutSwapOp(
const XprType& expr)
81 const typename internal::remove_all<typename XprType::Nested>::type&
82 expression()
const {
return m_xpr; }
84 EIGEN_TENSOR_INHERIT_ASSIGNMENT_OPERATORS(TensorLayoutSwapOp)
86 typename XprType::Nested m_xpr;
91template<
typename ArgType,
typename Device>
94 typedef TensorLayoutSwapOp<ArgType> XprType;
95 typedef typename XprType::Index Index;
96 static const int NumDims = internal::array_size<typename TensorEvaluator<ArgType, Device>::Dimensions>::value;
97 typedef DSizes<Index, NumDims> Dimensions;
100 IsAligned = TensorEvaluator<ArgType, Device>::IsAligned,
101 PacketAccess = TensorEvaluator<ArgType, Device>::PacketAccess,
103 PreferBlockAccess = TensorEvaluator<ArgType, Device>::PreferBlockAccess,
104 Layout = (
static_cast<int>(TensorEvaluator<ArgType, Device>::Layout) ==
static_cast<int>(
ColMajor)) ?
RowMajor :
ColMajor,
106 RawAccess = TensorEvaluator<ArgType, Device>::RawAccess
110 typedef internal::TensorBlockNotImplemented TensorBlock;
113 EIGEN_STRONG_INLINE TensorEvaluator(
const XprType& op,
const Device& device)
114 : m_impl(op.expression(), device)
116 for(
int i = 0; i < NumDims; ++i) {
117 m_dimensions[i] = m_impl.dimensions()[NumDims-1-i];
123 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void bind(cl::sycl::handler &cgh)
const {
128 typedef typename XprType::Scalar Scalar;
129 typedef typename XprType::CoeffReturnType CoeffReturnType;
130 typedef typename PacketType<CoeffReturnType, Device>::type PacketReturnType;
131 typedef StorageMemory<CoeffReturnType, Device> Storage;
132 typedef typename Storage::Type EvaluatorPointerType;
134 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
const Dimensions& dimensions()
const {
return m_dimensions; }
136 EIGEN_STRONG_INLINE
bool evalSubExprsIfNeeded(EvaluatorPointerType data) {
137 return m_impl.evalSubExprsIfNeeded(data);
139 EIGEN_STRONG_INLINE
void cleanup() {
143 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index)
const
145 return m_impl.coeff(index);
148 template<
int LoadMode>
149 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketReturnType packet(Index index)
const
151 return m_impl.template packet<LoadMode>(index);
154 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorOpCost costPerCoeff(
bool vectorized)
const {
155 return m_impl.costPerCoeff(vectorized);
158 EIGEN_DEVICE_FUNC
typename Storage::Type data()
const {
159 return constCast(m_impl.data());
162 const TensorEvaluator<ArgType, Device>& impl()
const {
return m_impl; }
165 TensorEvaluator<ArgType, Device> m_impl;
166 Dimensions m_dimensions;
171template<
typename ArgType,
typename Device>
172 struct TensorEvaluator<TensorLayoutSwapOp<ArgType>, Device>
173 :
public TensorEvaluator<const TensorLayoutSwapOp<ArgType>, Device>
175 typedef TensorEvaluator<const TensorLayoutSwapOp<ArgType>, Device> Base;
176 typedef TensorLayoutSwapOp<ArgType> XprType;
179 IsAligned = TensorEvaluator<ArgType, Device>::IsAligned,
180 PacketAccess = TensorEvaluator<ArgType, Device>::PacketAccess,
182 PreferBlockAccess = TensorEvaluator<ArgType, Device>::PreferBlockAccess,
183 Layout = (
static_cast<int>(TensorEvaluator<ArgType, Device>::Layout) ==
static_cast<int>(
ColMajor)) ?
RowMajor :
ColMajor,
188 typedef internal::TensorBlockNotImplemented TensorBlock;
191 EIGEN_STRONG_INLINE TensorEvaluator(
const XprType& op,
const Device& device)
195 typedef typename XprType::Index
Index;
196 typedef typename XprType::Scalar Scalar;
197 typedef typename XprType::CoeffReturnType CoeffReturnType;
198 typedef typename PacketType<CoeffReturnType, Device>::type PacketReturnType;
200 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType& coeffRef(Index index)
202 return this->m_impl.coeffRef(index);
204 template <
int StoreMode> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
205 void writePacket(Index index,
const PacketReturnType& x)
207 this->m_impl.template writePacket<StoreMode>(index, x);
The tensor base class.
Definition TensorForwardDeclarations.h:56
Namespace containing all symbols from the Eigen library.
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The tensor evaluator class.
Definition TensorEvaluator.h:27