TR-mbed 1.0
Loading...
Searching...
No Matches
TensorLayoutSwap.h
Go to the documentation of this file.
1// This file is part of Eigen, a lightweight C++ template library
2// for linear algebra.
3//
4// Copyright (C) 2014 Benoit Steiner <benoit.steiner.goog@gmail.com>
5//
6// This Source Code Form is subject to the terms of the Mozilla
7// Public License v. 2.0. If a copy of the MPL was not distributed
8// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9
10#ifndef EIGEN_CXX11_TENSOR_TENSOR_LAYOUT_SWAP_H
11#define EIGEN_CXX11_TENSOR_TENSOR_LAYOUT_SWAP_H
12
13namespace Eigen {
14
37namespace internal {
38template<typename XprType>
39struct traits<TensorLayoutSwapOp<XprType> > : public traits<XprType>
40{
41 typedef typename XprType::Scalar Scalar;
43 typedef typename XprTraits::StorageKind StorageKind;
44 typedef typename XprTraits::Index Index;
45 typedef typename XprType::Nested 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;
50};
51
52template<typename XprType>
57
58template<typename XprType>
63
64} // end namespace internal
65
66
67
68template<typename XprType>
91
92
93// Eval as rvalue
94template<typename ArgType, typename Device>
95struct TensorEvaluator<const TensorLayoutSwapOp<ArgType>, Device>
96{
98 typedef typename XprType::Index Index;
101
102 enum {
105 BlockAccess = false,
107 Layout = (static_cast<int>(TensorEvaluator<ArgType, Device>::Layout) == static_cast<int>(ColMajor)) ? RowMajor : ColMajor,
108 CoordAccess = false, // to be implemented
109 RawAccess = TensorEvaluator<ArgType, Device>::RawAccess
110 };
111
112 //===- Tensor block evaluation strategy (see TensorBlock.h) -------------===//
114 //===--------------------------------------------------------------------===//
115
116 EIGEN_STRONG_INLINE TensorEvaluator(const XprType& op, const Device& device)
117 : m_impl(op.expression(), device)
118 {
119 for(int i = 0; i < NumDims; ++i) {
120 m_dimensions[i] = m_impl.dimensions()[NumDims-1-i];
121 }
122 }
123
124#ifdef EIGEN_USE_SYCL
125 // binding placeholder accessors to a command group handler for SYCL
126 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void bind(cl::sycl::handler &cgh) const {
127 m_impl.bind(cgh);
128 }
129#endif
130
131 typedef typename XprType::Scalar Scalar;
136
137 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Dimensions& dimensions() const { return m_dimensions; }
138
140 return m_impl.evalSubExprsIfNeeded(data);
141 }
143 m_impl.cleanup();
144 }
145
147 {
148 return m_impl.coeff(index);
149 }
150
151 template<int LoadMode>
153 {
154 return m_impl.template packet<LoadMode>(index);
155 }
156
158 return m_impl.costPerCoeff(vectorized);
159 }
160
162 return constCast(m_impl.data());
163 }
164
165 const TensorEvaluator<ArgType, Device>& impl() const { return m_impl; }
166
167 protected:
170};
171
172
173// Eval as lvalue
174template<typename ArgType, typename Device>
175 struct TensorEvaluator<TensorLayoutSwapOp<ArgType>, Device>
176 : public TensorEvaluator<const TensorLayoutSwapOp<ArgType>, Device>
177{
180
181 enum {
184 BlockAccess = false,
186 Layout = (static_cast<int>(TensorEvaluator<ArgType, Device>::Layout) == static_cast<int>(ColMajor)) ? RowMajor : ColMajor,
187 CoordAccess = false // to be implemented
188 };
189
190 //===- Tensor block evaluation strategy (see TensorBlock.h) -------------===//
192 //===--------------------------------------------------------------------===//
193
194 EIGEN_STRONG_INLINE TensorEvaluator(const XprType& op, const Device& device)
195 : Base(op, device)
196 { }
197
198 typedef typename XprType::Index Index;
199 typedef typename XprType::Scalar Scalar;
202
204 {
205 return this->m_impl.coeffRef(index);
206 }
207 template <int StoreMode> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
209 {
210 this->m_impl.template writePacket<StoreMode>(index, x);
211 }
212};
213
214} // end namespace Eigen
215
216#endif // EIGEN_CXX11_TENSOR_TENSOR_LAYOUT_SWAP_H
int i
Definition BiCGSTAB_step_by_step.cpp:9
#define EIGEN_DEVICE_FUNC
Definition Macros.h:976
#define EIGEN_STRONG_INLINE
Definition Macros.h:917
#define EIGEN_TENSOR_INHERIT_ASSIGNMENT_OPERATORS(Derived)
Definition TensorMacros.h:94
Generic expression where a coefficient-wise binary operator is applied to two expressions.
Definition CwiseBinaryOp.h:84
The tensor base class.
Definition TensorBase.h:973
Definition TensorLayoutSwap.h:70
Eigen::internal::traits< TensorLayoutSwapOp >::Scalar Scalar
Definition TensorLayoutSwap.h:73
XprType::Nested m_xpr
Definition TensorLayoutSwap.h:89
internal::remove_const< typenameXprType::CoeffReturnType >::type CoeffReturnType
Definition TensorLayoutSwap.h:75
Eigen::internal::traits< TensorLayoutSwapOp >::StorageKind StorageKind
Definition TensorLayoutSwap.h:77
TensorBase< TensorLayoutSwapOp< XprType >, WriteAccessors > Base
Definition TensorLayoutSwap.h:72
EIGEN_DEVICE_FUNC const internal::remove_all< typenameXprType::Nested >::type & expression() const
Definition TensorLayoutSwap.h:85
Eigen::internal::nested< TensorLayoutSwapOp >::type Nested
Definition TensorLayoutSwap.h:76
Eigen::NumTraits< Scalar >::Real RealScalar
Definition TensorLayoutSwap.h:74
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorLayoutSwapOp(const XprType &expr)
Definition TensorLayoutSwap.h:80
Eigen::internal::traits< TensorLayoutSwapOp >::Index Index
Definition TensorLayoutSwap.h:78
Definition TensorCostModel.h:25
Definition TensorBlock.h:617
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
Definition gnuplot_common_settings.hh:12
@ WriteAccessors
Definition Constants.h:378
@ ColMajor
Definition Constants.h:319
@ RowMajor
Definition Constants.h:321
Namespace containing all symbols from the Eigen library.
Definition bench_norm.cpp:85
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T * constCast(const T *data)
Definition TensorForwardDeclarations.h:27
Definition BandTriangularSolver.h:13
Definition TensorDimensions.h:263
Definition Constants.h:507
Definition TensorForwardDeclarations.h:37
internal::TensorBlockNotImplemented TensorBlock
Definition TensorLayoutSwap.h:191
EIGEN_STRONG_INLINE TensorEvaluator(const XprType &op, const Device &device)
Definition TensorLayoutSwap.h:194
XprType::Scalar Scalar
Definition TensorLayoutSwap.h:199
PacketType< CoeffReturnType, Device >::type PacketReturnType
Definition TensorLayoutSwap.h:201
XprType::Index Index
Definition TensorLayoutSwap.h:198
TensorLayoutSwapOp< ArgType > XprType
Definition TensorLayoutSwap.h:179
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void writePacket(Index index, const PacketReturnType &x)
Definition TensorLayoutSwap.h:208
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType & coeffRef(Index index)
Definition TensorLayoutSwap.h:203
TensorEvaluator< const TensorLayoutSwapOp< ArgType >, Device > Base
Definition TensorLayoutSwap.h:178
XprType::CoeffReturnType CoeffReturnType
Definition TensorLayoutSwap.h:200
Dimensions m_dimensions
Definition TensorLayoutSwap.h:169
DSizes< Index, NumDims > Dimensions
Definition TensorLayoutSwap.h:100
EIGEN_STRONG_INLINE void cleanup()
Definition TensorLayoutSwap.h:142
EIGEN_STRONG_INLINE bool evalSubExprsIfNeeded(EvaluatorPointerType data)
Definition TensorLayoutSwap.h:139
EIGEN_STRONG_INLINE TensorEvaluator(const XprType &op, const Device &device)
Definition TensorLayoutSwap.h:116
TensorEvaluator< ArgType, Device > m_impl
Definition TensorLayoutSwap.h:168
XprType::Index Index
Definition TensorLayoutSwap.h:98
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketReturnType packet(Index index) const
Definition TensorLayoutSwap.h:152
internal::TensorBlockNotImplemented TensorBlock
Definition TensorLayoutSwap.h:113
Storage::Type EvaluatorPointerType
Definition TensorLayoutSwap.h:135
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorOpCost costPerCoeff(bool vectorized) const
Definition TensorLayoutSwap.h:157
XprType::CoeffReturnType CoeffReturnType
Definition TensorLayoutSwap.h:132
TensorLayoutSwapOp< ArgType > XprType
Definition TensorLayoutSwap.h:97
const TensorEvaluator< ArgType, Device > & impl() const
Definition TensorLayoutSwap.h:165
XprType::Scalar Scalar
Definition TensorLayoutSwap.h:131
EIGEN_DEVICE_FUNC Storage::Type data() const
Definition TensorLayoutSwap.h:161
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index) const
Definition TensorLayoutSwap.h:146
StorageMemory< CoeffReturnType, Device > Storage
Definition TensorLayoutSwap.h:134
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Dimensions & dimensions() const
Definition TensorLayoutSwap.h:137
PacketType< CoeffReturnType, Device >::type PacketReturnType
Definition TensorLayoutSwap.h:133
A cost model used to limit the number of threads used for evaluating tensor expression.
Definition TensorEvaluator.h:29
EIGEN_DEVICE_FUNC EvaluatorPointerType data() const
Definition TensorEvaluator.h:181
@ BlockAccess
Definition TensorEvaluator.h:48
@ PreferBlockAccess
Definition TensorEvaluator.h:49
@ PacketAccess
Definition TensorEvaluator.h:47
@ Layout
Definition TensorEvaluator.h:50
@ IsAligned
Definition TensorEvaluator.h:46
const TensorLayoutSwapOp< XprType > & type
Definition TensorLayoutSwap.h:55
Definition XprHelper.h:332
Definition TensorTraits.h:175
XprTraits::StorageKind StorageKind
Definition TensorLayoutSwap.h:43
remove_reference< Nested >::type _Nested
Definition TensorLayoutSwap.h:46
XprTraits::PointerType PointerType
Definition TensorLayoutSwap.h:49
XprTraits::Index Index
Definition TensorLayoutSwap.h:44
XprType::Scalar Scalar
Definition TensorLayoutSwap.h:41
traits< XprType > XprTraits
Definition TensorLayoutSwap.h:42
XprType::Nested Nested
Definition TensorLayoutSwap.h:45
Definition ForwardDeclarations.h:17