10#ifndef EIGEN_CXX11_TENSOR_TENSOR_LAYOUT_SWAP_H
11#define EIGEN_CXX11_TENSOR_TENSOR_LAYOUT_SWAP_H
38template<
typename XprType>
39struct traits<TensorLayoutSwapOp<XprType> > :
public traits<XprType>
41 typedef typename XprType::Scalar Scalar;
42 typedef traits<XprType> XprTraits;
43 typedef typename XprTraits::StorageKind StorageKind;
44 typedef typename XprTraits::Index
Index;
45 typedef typename XprType::Nested Nested;
46 typedef typename remove_reference<Nested>::type _Nested;
47 static const int NumDimensions = traits<XprType>::NumDimensions;
48 static const int Layout = (traits<XprType>::Layout ==
ColMajor) ? RowMajor : ColMajor;
49 typedef typename XprTraits::PointerType PointerType;
52template<
typename XprType>
53struct eval<TensorLayoutSwapOp<XprType>,
Eigen::Dense>
55 typedef const TensorLayoutSwapOp<XprType>& type;
58template<
typename XprType>
59struct nested<TensorLayoutSwapOp<XprType>, 1, typename eval<TensorLayoutSwapOp<XprType> >::type>
61 typedef TensorLayoutSwapOp<XprType> type;
68template<
typename XprType>
69class TensorLayoutSwapOp :
public TensorBase<TensorLayoutSwapOp<XprType>, WriteAccessors>
72 typedef TensorBase<TensorLayoutSwapOp<XprType>,
WriteAccessors> Base;
73 typedef typename Eigen::internal::traits<TensorLayoutSwapOp>::Scalar Scalar;
75 typedef typename internal::remove_const<typename XprType::CoeffReturnType>::type CoeffReturnType;
76 typedef typename Eigen::internal::nested<TensorLayoutSwapOp>::type Nested;
77 typedef typename Eigen::internal::traits<TensorLayoutSwapOp>::StorageKind StorageKind;
78 typedef typename Eigen::internal::traits<TensorLayoutSwapOp>::Index
Index;
80 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorLayoutSwapOp(
const XprType& expr)
84 const typename internal::remove_all<typename XprType::Nested>::type&
85 expression()
const {
return m_xpr; }
87 EIGEN_TENSOR_INHERIT_ASSIGNMENT_OPERATORS(TensorLayoutSwapOp)
89 typename XprType::Nested m_xpr;
94template<
typename ArgType,
typename Device>
95struct TensorEvaluator<const TensorLayoutSwapOp<ArgType>, Device>
97 typedef TensorLayoutSwapOp<ArgType> XprType;
98 typedef typename XprType::Index Index;
99 static const int NumDims = internal::array_size<typename TensorEvaluator<ArgType, Device>::Dimensions>::value;
100 typedef DSizes<Index, NumDims> Dimensions;
103 IsAligned = TensorEvaluator<ArgType, Device>::IsAligned,
104 PacketAccess = TensorEvaluator<ArgType, Device>::PacketAccess,
106 PreferBlockAccess = TensorEvaluator<ArgType, Device>::PreferBlockAccess,
107 Layout = (
static_cast<int>(TensorEvaluator<ArgType, Device>::Layout) ==
static_cast<int>(
ColMajor)) ?
RowMajor :
ColMajor,
109 RawAccess = TensorEvaluator<ArgType, Device>::RawAccess
113 typedef internal::TensorBlockNotImplemented TensorBlock;
116 EIGEN_STRONG_INLINE TensorEvaluator(
const XprType& op,
const Device& device)
117 : m_impl(op.expression(), device)
119 for(
int i = 0; i < NumDims; ++i) {
120 m_dimensions[i] = m_impl.dimensions()[NumDims-1-i];
126 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void bind(cl::sycl::handler &cgh)
const {
131 typedef typename XprType::Scalar Scalar;
132 typedef typename XprType::CoeffReturnType CoeffReturnType;
133 typedef typename PacketType<CoeffReturnType, Device>::type PacketReturnType;
134 typedef StorageMemory<CoeffReturnType, Device> Storage;
135 typedef typename Storage::Type EvaluatorPointerType;
137 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
const Dimensions& dimensions()
const {
return m_dimensions; }
139 EIGEN_STRONG_INLINE
bool evalSubExprsIfNeeded(EvaluatorPointerType data) {
140 return m_impl.evalSubExprsIfNeeded(data);
142 EIGEN_STRONG_INLINE
void cleanup() {
146 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index)
const
148 return m_impl.coeff(index);
151 template<
int LoadMode>
152 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketReturnType packet(Index index)
const
154 return m_impl.template packet<LoadMode>(index);
157 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorOpCost costPerCoeff(
bool vectorized)
const {
158 return m_impl.costPerCoeff(vectorized);
161 EIGEN_DEVICE_FUNC
typename Storage::Type data()
const {
162 return constCast(m_impl.data());
165 const TensorEvaluator<ArgType, Device>& impl()
const {
return m_impl; }
168 TensorEvaluator<ArgType, Device> m_impl;
169 Dimensions m_dimensions;
174template<
typename ArgType,
typename Device>
175 struct TensorEvaluator<TensorLayoutSwapOp<ArgType>, Device>
176 :
public TensorEvaluator<const TensorLayoutSwapOp<ArgType>, Device>
178 typedef TensorEvaluator<const TensorLayoutSwapOp<ArgType>, Device> Base;
179 typedef TensorLayoutSwapOp<ArgType> XprType;
182 IsAligned = TensorEvaluator<ArgType, Device>::IsAligned,
183 PacketAccess = TensorEvaluator<ArgType, Device>::PacketAccess,
185 PreferBlockAccess = TensorEvaluator<ArgType, Device>::PreferBlockAccess,
186 Layout = (
static_cast<int>(TensorEvaluator<ArgType, Device>::Layout) ==
static_cast<int>(
ColMajor)) ?
RowMajor :
ColMajor,
191 typedef internal::TensorBlockNotImplemented TensorBlock;
194 EIGEN_STRONG_INLINE TensorEvaluator(
const XprType& op,
const Device& device)
198 typedef typename XprType::Index
Index;
199 typedef typename XprType::Scalar Scalar;
200 typedef typename XprType::CoeffReturnType CoeffReturnType;
201 typedef typename PacketType<CoeffReturnType, Device>::type PacketReturnType;
203 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType& coeffRef(Index index)
205 return this->m_impl.coeffRef(index);
207 template <
int StoreMode> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
208 void writePacket(Index index,
const PacketReturnType& x)
210 this->m_impl.template writePacket<StoreMode>(index, x);
Namespace containing all symbols from the Eigen library.
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index