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;
29template<
typename XprType>
30struct eval<TensorLayoutSwapOp<XprType>, Eigen::Dense>
32 typedef const TensorLayoutSwapOp<XprType>& type;
35template<
typename XprType>
36struct nested<TensorLayoutSwapOp<XprType>, 1, typename eval<TensorLayoutSwapOp<XprType> >::type>
38 typedef TensorLayoutSwapOp<XprType> type;
65template <
typename XprType>
66class TensorLayoutSwapOp :
public TensorBase<TensorLayoutSwapOp<XprType>, WriteAccessors> {
68 typedef typename Eigen::internal::traits<TensorLayoutSwapOp>::Scalar Scalar;
69 typedef typename Eigen::NumTraits<Scalar>::Real RealScalar;
70 typedef typename internal::remove_const<typename XprType::CoeffReturnType>::type CoeffReturnType;
71 typedef typename Eigen::internal::nested<TensorLayoutSwapOp>::type Nested;
72 typedef typename Eigen::internal::traits<TensorLayoutSwapOp>::StorageKind StorageKind;
73 typedef typename Eigen::internal::traits<TensorLayoutSwapOp>::Index Index;
75 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorLayoutSwapOp(
const XprType& expr)
79 const typename internal::remove_all<typename XprType::Nested>::type&
80 expression()
const {
return m_xpr; }
83 EIGEN_STRONG_INLINE TensorLayoutSwapOp& operator = (
const TensorLayoutSwapOp& other)
85 typedef TensorAssignOp<TensorLayoutSwapOp, const TensorLayoutSwapOp> Assign;
86 Assign assign(*
this, other);
87 internal::TensorExecutor<const Assign, DefaultDevice>::run(assign, DefaultDevice());
91 template<
typename OtherDerived>
93 EIGEN_STRONG_INLINE TensorLayoutSwapOp& operator = (
const OtherDerived& other)
95 typedef TensorAssignOp<TensorLayoutSwapOp, const OtherDerived> Assign;
96 Assign assign(*
this, other);
97 internal::TensorExecutor<const Assign, DefaultDevice>::run(assign, DefaultDevice());
102 typename XprType::Nested m_xpr;
107template<
typename ArgType,
typename Device>
110 typedef TensorLayoutSwapOp<ArgType> XprType;
111 typedef typename XprType::Index Index;
112 static const int NumDims = internal::array_size<typename TensorEvaluator<ArgType, Device>::Dimensions>::value;
113 typedef DSizes<Index, NumDims> Dimensions;
116 IsAligned = TensorEvaluator<ArgType, Device>::IsAligned,
117 PacketAccess = TensorEvaluator<ArgType, Device>::PacketAccess,
118 Layout = (
static_cast<int>(TensorEvaluator<ArgType, Device>::Layout) ==
static_cast<int>(
ColMajor)) ?
RowMajor :
ColMajor,
120 RawAccess = TensorEvaluator<ArgType, Device>::RawAccess
123 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorEvaluator(
const XprType& op,
const Device&
device)
124 : m_impl(op.expression(),
device)
126 for(
int i = 0; i < NumDims; ++i) {
127 m_dimensions[i] = m_impl.dimensions()[NumDims-1-i];
131 typedef typename XprType::Scalar Scalar;
132 typedef typename XprType::CoeffReturnType CoeffReturnType;
133 typedef typename PacketType<CoeffReturnType, Device>::type PacketReturnType;
135 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
const Dimensions& dimensions()
const {
return m_dimensions; }
137 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
bool evalSubExprsIfNeeded(CoeffReturnType* data) {
138 return m_impl.evalSubExprsIfNeeded(data);
140 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void cleanup() {
144 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index)
const
146 return m_impl.coeff(index);
149 template<
int LoadMode>
150 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketReturnType packet(Index index)
const
152 return m_impl.template packet<LoadMode>(index);
155 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorOpCost costPerCoeff(
bool vectorized)
const {
156 return m_impl.costPerCoeff(vectorized);
159 EIGEN_DEVICE_FUNC Scalar* data()
const {
return m_impl.data(); }
161 const TensorEvaluator<ArgType, Device>& impl()
const {
return m_impl; }
164 TensorEvaluator<ArgType, Device> m_impl;
165 Dimensions m_dimensions;
170template<
typename ArgType,
typename Device>
171 struct TensorEvaluator<TensorLayoutSwapOp<ArgType>, Device>
172 :
public TensorEvaluator<const TensorLayoutSwapOp<ArgType>, Device>
174 typedef TensorEvaluator<const TensorLayoutSwapOp<ArgType>, Device> Base;
175 typedef TensorLayoutSwapOp<ArgType> XprType;
178 IsAligned = TensorEvaluator<ArgType, Device>::IsAligned,
179 PacketAccess = TensorEvaluator<ArgType, Device>::PacketAccess,
180 Layout = (
static_cast<int>(TensorEvaluator<ArgType, Device>::Layout) ==
static_cast<int>(
ColMajor)) ?
RowMajor :
ColMajor,
184 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorEvaluator(
const XprType& op,
const Device&
device)
188 typedef typename XprType::Index
Index;
189 typedef typename XprType::Scalar Scalar;
190 typedef typename XprType::CoeffReturnType CoeffReturnType;
191 typedef typename PacketType<CoeffReturnType, Device>::type PacketReturnType;
193 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType& coeffRef(Index index)
195 return this->m_impl.coeffRef(index);
197 template <
int StoreMode> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
198 void writePacket(Index index,
const PacketReturnType& x)
200 this->m_impl.template writePacket<StoreMode>(index, x);
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