10 #ifndef EIGEN_CXX11_TENSOR_TENSOR_LAYOUT_SWAP_H
11 #define EIGEN_CXX11_TENSOR_TENSOR_LAYOUT_SWAP_H
13 #include "./InternalHeaderCheck.h"
40 template<
typename XprType>
41 struct traits<TensorLayoutSwapOp<XprType> > :
public traits<XprType>
43 typedef typename XprType::Scalar Scalar;
44 typedef traits<XprType> XprTraits;
45 typedef typename XprTraits::StorageKind StorageKind;
46 typedef typename XprTraits::Index
Index;
47 typedef typename XprType::Nested Nested;
48 typedef std::remove_reference_t<Nested> Nested_;
49 static constexpr
int NumDimensions = traits<XprType>::NumDimensions;
51 typedef typename XprTraits::PointerType PointerType;
54 template<
typename XprType>
55 struct eval<TensorLayoutSwapOp<XprType>,
Eigen::Dense>
57 typedef const TensorLayoutSwapOp<XprType>& type;
60 template<
typename XprType>
61 struct nested<TensorLayoutSwapOp<XprType>, 1, typename eval<TensorLayoutSwapOp<XprType> >::type>
63 typedef TensorLayoutSwapOp<XprType> type;
70 template<
typename XprType>
71 class TensorLayoutSwapOp :
public TensorBase<TensorLayoutSwapOp<XprType>, WriteAccessors>
74 typedef TensorBase<TensorLayoutSwapOp<XprType>,
WriteAccessors> Base;
75 typedef typename Eigen::internal::traits<TensorLayoutSwapOp>::Scalar Scalar;
77 typedef std::remove_const_t<typename XprType::CoeffReturnType> CoeffReturnType;
78 typedef typename Eigen::internal::nested<TensorLayoutSwapOp>::type Nested;
79 typedef typename Eigen::internal::traits<TensorLayoutSwapOp>::StorageKind StorageKind;
80 typedef typename Eigen::internal::traits<TensorLayoutSwapOp>::Index
Index;
82 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorLayoutSwapOp(
const XprType& expr)
86 const internal::remove_all_t<typename XprType::Nested>&
87 expression()
const {
return m_xpr; }
89 EIGEN_TENSOR_INHERIT_ASSIGNMENT_OPERATORS(TensorLayoutSwapOp)
91 typename XprType::Nested m_xpr;
96 template<
typename ArgType,
typename Device>
97 struct TensorEvaluator<const TensorLayoutSwapOp<ArgType>, Device>
99 typedef TensorLayoutSwapOp<ArgType> XprType;
100 typedef typename XprType::Index Index;
101 static constexpr
int NumDims = internal::array_size<typename TensorEvaluator<ArgType, Device>::Dimensions>::value;
102 typedef DSizes<Index, NumDims> Dimensions;
104 static constexpr
int Layout = (TensorEvaluator<ArgType, Device>::Layout ==
static_cast<int>(
ColMajor)) ?
RowMajor :
ColMajor;
106 IsAligned = TensorEvaluator<ArgType, Device>::IsAligned,
107 PacketAccess = TensorEvaluator<ArgType, Device>::PacketAccess,
109 PreferBlockAccess = TensorEvaluator<ArgType, Device>::PreferBlockAccess,
111 RawAccess = TensorEvaluator<ArgType, Device>::RawAccess
115 typedef internal::TensorBlockNotImplemented TensorBlock;
118 EIGEN_STRONG_INLINE TensorEvaluator(
const XprType& op,
const Device& device)
119 : m_impl(op.expression(), device)
121 for(
int i = 0; i < NumDims; ++i) {
122 m_dimensions[i] = m_impl.dimensions()[NumDims-1-i];
126 #ifdef EIGEN_USE_SYCL
128 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void bind(cl::sycl::handler &cgh)
const {
133 typedef typename XprType::Scalar Scalar;
134 typedef typename XprType::CoeffReturnType CoeffReturnType;
135 typedef typename PacketType<CoeffReturnType, Device>::type PacketReturnType;
136 typedef StorageMemory<CoeffReturnType, Device> Storage;
137 typedef typename Storage::Type EvaluatorPointerType;
139 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
const Dimensions& dimensions()
const {
return m_dimensions; }
141 EIGEN_STRONG_INLINE
bool evalSubExprsIfNeeded(EvaluatorPointerType data) {
142 return m_impl.evalSubExprsIfNeeded(data);
144 EIGEN_STRONG_INLINE
void cleanup() {
148 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index)
const
150 return m_impl.coeff(index);
153 template<
int LoadMode>
154 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketReturnType packet(Index index)
const
156 return m_impl.template packet<LoadMode>(index);
159 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorOpCost costPerCoeff(
bool vectorized)
const {
160 return m_impl.costPerCoeff(vectorized);
163 EIGEN_DEVICE_FUNC
typename Storage::Type data()
const {
164 return constCast(m_impl.data());
167 const TensorEvaluator<ArgType, Device>& impl()
const {
return m_impl; }
170 TensorEvaluator<ArgType, Device> m_impl;
171 Dimensions m_dimensions;
176 template<
typename ArgType,
typename Device>
177 struct TensorEvaluator<TensorLayoutSwapOp<ArgType>, Device>
178 :
public TensorEvaluator<const TensorLayoutSwapOp<ArgType>, Device>
180 typedef TensorEvaluator<const TensorLayoutSwapOp<ArgType>, Device> Base;
181 typedef TensorLayoutSwapOp<ArgType> XprType;
183 static constexpr
int Layout = (TensorEvaluator<ArgType, Device>::Layout ==
static_cast<int>(
ColMajor)) ?
RowMajor :
ColMajor;
185 IsAligned = TensorEvaluator<ArgType, Device>::IsAligned,
186 PacketAccess = TensorEvaluator<ArgType, Device>::PacketAccess,
188 PreferBlockAccess = TensorEvaluator<ArgType, Device>::PreferBlockAccess,
193 typedef internal::TensorBlockNotImplemented TensorBlock;
196 EIGEN_STRONG_INLINE TensorEvaluator(
const XprType& op,
const Device& device)
200 typedef typename XprType::Index
Index;
201 typedef typename XprType::Scalar Scalar;
202 typedef typename XprType::CoeffReturnType CoeffReturnType;
203 typedef typename PacketType<CoeffReturnType, Device>::type PacketReturnType;
205 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType& coeffRef(Index index)
207 return this->m_impl.coeffRef(index);
209 template <
int StoreMode> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
210 void writePacket(Index index,
const PacketReturnType& x)
212 this->m_impl.template writePacket<StoreMode>(index, x);
Namespace containing all symbols from the Eigen library.
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index