10#ifndef EIGEN_CXX11_TENSOR_TENSOR_LAYOUT_SWAP_H
11#define EIGEN_CXX11_TENSOR_TENSOR_LAYOUT_SWAP_H
14#include "./InternalHeaderCheck.h"
19template <
typename XprType>
20struct traits<TensorLayoutSwapOp<XprType> > :
public traits<XprType> {
21 typedef typename XprType::Scalar Scalar;
22 typedef traits<XprType> XprTraits;
23 typedef typename XprTraits::StorageKind StorageKind;
24 typedef typename XprTraits::Index
Index;
25 typedef typename XprType::Nested Nested;
26 typedef std::remove_reference_t<Nested> Nested_;
27 static constexpr int NumDimensions = traits<XprType>::NumDimensions;
28 static constexpr int Layout = (traits<XprType>::Layout ==
ColMajor) ? RowMajor :
ColMajor;
29 typedef typename XprTraits::PointerType PointerType;
32template <
typename XprType>
33struct eval<TensorLayoutSwapOp<XprType>, Eigen::Dense> {
34 typedef const TensorLayoutSwapOp<XprType>& type;
37template <
typename XprType>
38struct 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 std::remove_const_t<typename XprType::CoeffReturnType> 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) : m_xpr(expr) {}
79 EIGEN_DEVICE_FUNC
const internal::remove_all_t<typename XprType::Nested>& expression()
const {
return m_xpr; }
81 EIGEN_TENSOR_INHERIT_ASSIGNMENT_OPERATORS(TensorLayoutSwapOp)
83 typename XprType::Nested m_xpr;
87template <
typename ArgType,
typename Device>
89 typedef TensorLayoutSwapOp<ArgType> XprType;
90 typedef typename XprType::Index Index;
91 static constexpr int NumDims = internal::array_size<typename TensorEvaluator<ArgType, Device>::Dimensions>::value;
92 typedef DSizes<Index, NumDims> Dimensions;
94 static constexpr int Layout =
97 IsAligned = TensorEvaluator<ArgType, Device>::IsAligned,
98 PacketAccess = TensorEvaluator<ArgType, Device>::PacketAccess,
100 PreferBlockAccess = TensorEvaluator<ArgType, Device>::PreferBlockAccess,
102 RawAccess = TensorEvaluator<ArgType, Device>::RawAccess
106 typedef internal::TensorBlockNotImplemented TensorBlock;
109 EIGEN_STRONG_INLINE TensorEvaluator(
const XprType& op,
const Device& device) : m_impl(op.expression(), device) {
110 for (
int i = 0; i < NumDims; ++i) {
111 m_dimensions[i] = m_impl.dimensions()[NumDims - 1 - i];
115 typedef typename XprType::Scalar Scalar;
116 typedef typename XprType::CoeffReturnType CoeffReturnType;
117 typedef typename PacketType<CoeffReturnType, Device>::type PacketReturnType;
118 typedef StorageMemory<CoeffReturnType, Device> Storage;
119 typedef typename Storage::Type EvaluatorPointerType;
121 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
const Dimensions& dimensions()
const {
return m_dimensions; }
123 EIGEN_STRONG_INLINE
bool evalSubExprsIfNeeded(EvaluatorPointerType data) {
return m_impl.evalSubExprsIfNeeded(data); }
124 EIGEN_STRONG_INLINE
void cleanup() { m_impl.cleanup(); }
126 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index)
const {
return m_impl.coeff(index); }
128 template <
int LoadMode>
129 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketReturnType packet(Index index)
const {
130 return m_impl.template packet<LoadMode>(index);
133 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorOpCost costPerCoeff(
bool vectorized)
const {
134 return m_impl.costPerCoeff(vectorized);
137 EIGEN_DEVICE_FUNC
typename Storage::Type data()
const {
return constCast(m_impl.data()); }
139 const TensorEvaluator<ArgType, Device>& impl()
const {
return m_impl; }
142 TensorEvaluator<ArgType, Device> m_impl;
143 Dimensions m_dimensions;
147template <
typename ArgType,
typename Device>
150 typedef TensorEvaluator<const TensorLayoutSwapOp<ArgType>, Device> Base;
151 typedef TensorLayoutSwapOp<ArgType> XprType;
153 static constexpr int Layout =
156 IsAligned = TensorEvaluator<ArgType, Device>::IsAligned,
157 PacketAccess = TensorEvaluator<ArgType, Device>::PacketAccess,
159 PreferBlockAccess = TensorEvaluator<ArgType, Device>::PreferBlockAccess,
164 typedef internal::TensorBlockNotImplemented TensorBlock;
167 EIGEN_STRONG_INLINE TensorEvaluator(
const XprType& op,
const Device& device) : Base(op, device) {}
169 typedef typename XprType::Index Index;
170 typedef typename XprType::Scalar Scalar;
171 typedef typename XprType::CoeffReturnType CoeffReturnType;
172 typedef typename PacketType<CoeffReturnType, Device>::type PacketReturnType;
174 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType& coeffRef(Index index)
const {
175 return this->m_impl.coeffRef(index);
177 template <
int StoreMode>
178 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void writePacket(Index index,
const PacketReturnType& x)
const {
179 this->m_impl.template writePacket<StoreMode>(index, x);
The tensor base class.
Definition TensorForwardDeclarations.h:68
Namespace containing all symbols from the Eigen library.
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The tensor evaluator class.
Definition TensorEvaluator.h:30