Go to the documentation of this file.
10 #ifndef EIGEN_CXX11_TENSOR_TENSOR_SHUFFLING_H
11 #define EIGEN_CXX11_TENSOR_TENSOR_SHUFFLING_H
23 template<
typename Shuffle,
typename XprType>
30 typedef typename XprType::Nested
Nested;
32 static const int NumDimensions = XprTraits::NumDimensions;
33 static const int Layout = XprTraits::Layout;
36 template<
typename Shuffle,
typename XprType>
42 template<
typename Shuffle,
typename XprType>
52 template<
typename Shuffle,
typename XprType>
77 Assign assign(*
this, other);
82 template<
typename OtherDerived>
87 Assign assign(*
this, other);
99 template<
typename Shuffle,
typename ArgType,
typename Device>
124 for (
int i = 0; i < NumDims; ++i) {
125 m_dimensions[i] = input_dims[shuffle[i]];
132 m_outputStrides[0] = 1;
133 for (
int i = 1; i < NumDims; ++i) {
134 inputStrides[i] = inputStrides[i - 1] * input_dims[i - 1];
135 m_outputStrides[i] = m_outputStrides[i - 1] * m_dimensions[i - 1];
138 inputStrides[NumDims - 1] = 1;
139 m_outputStrides[NumDims - 1] = 1;
140 for (
int i = NumDims - 2; i >= 0; --i) {
141 inputStrides[i] = inputStrides[i + 1] * input_dims[i + 1];
142 m_outputStrides[i] = m_outputStrides[i + 1] * m_dimensions[i + 1];
146 for (
int i = 0; i < NumDims; ++i) {
147 m_inputStrides[i] = inputStrides[shuffle[i]];
154 m_impl.evalSubExprsIfNeeded(NULL);
163 return m_impl.coeff(srcCoeff(index));
166 template<
int LoadMode>
173 for (
int i = 0; i < PacketSize; ++i) {
174 values[i] =
coeff(index+i);
181 const double compute_cost = NumDims * (2 * TensorOpCost::AddCost<Index>() +
182 2 * TensorOpCost::MulCost<Index>() +
183 TensorOpCost::DivCost<Index>());
184 return m_impl.costPerCoeff(vectorized) +
192 Index inputIndex = 0;
194 for (
int i = NumDims - 1; i > 0; --i) {
195 const Index idx = index / m_outputStrides[i];
196 inputIndex += idx * m_inputStrides[i];
197 index -= idx * m_outputStrides[i];
199 return inputIndex + index * m_inputStrides[0];
201 for (
int i = 0; i < NumDims - 1; ++i) {
202 const Index idx = index / m_outputStrides[i];
203 inputIndex += idx * m_inputStrides[i];
204 index -= idx * m_outputStrides[i];
206 return inputIndex + index * m_inputStrides[NumDims - 1];
218 template<
typename Shuffle,
typename ArgType,
typename Device>
220 :
public TensorEvaluator<const TensorShufflingOp<Shuffle, ArgType>, Device>
245 return this->
m_impl.coeffRef(this->srcCoeff(index));
254 internal::pstore<CoeffReturnType, PacketReturnType>(values,
x);
255 for (
int i = 0; i < PacketSize; ++i) {
256 this->
coeffRef(index+i) = values[i];
264 #endif // EIGEN_CXX11_TENSOR_TENSOR_SHUFFLING_H
EIGEN_DEVICE_FUNC const EIGEN_STRONG_INLINE Dimensions & dimensions() const
TensorShufflingOp< Shuffle, XprType > type
const Device & device() const
required by sycl in order to construct sycl buffer from raw pointer
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorShufflingOp(const XprType &expr, const Shuffle &shuffle)
EIGEN_DEVICE_FUNC Scalar * data() const
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorEvaluator(const XprType &op, const Device &device)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorShufflingOp & operator=(const TensorShufflingOp &other)
DSizes< Index, NumDims > Dimensions
Eigen::internal::traits< TensorShufflingOp >::Index Index
EIGEN_STRONG_INLINE void writePacket(Index index, const PacketReturnType &x)
XprType::CoeffReturnType CoeffReturnType
internal::packet_traits< Scalar >::type type
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType & coeffRef(Index index)
Eigen::internal::nested< TensorShufflingOp >::type Nested
Eigen::NumTraits< Scalar >::Real RealScalar
traits< XprType > XprTraits
array< Index, NumDims > m_inputStrides
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar & coeffRef(Index index)
XprTraits::StorageKind StorageKind
TensorShufflingOp< Shuffle, ArgType > XprType
const EIGEN_DEVICE_FUNC Shuffle & shufflePermutation() const
EIGEN_DEVICE_FUNC const EIGEN_STRONG_INLINE Dimensions & dimensions() const
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketReturnType packet(Index index) const
#define EIGEN_STRONG_INLINE
Eigen::internal::traits< TensorShufflingOp >::StorageKind StorageKind
const EIGEN_DEVICE_FUNC internal::remove_all< typename XprType::Nested >::type & expression() const
DSizes< Index, NumDims > Dimensions
const typedef TensorShufflingOp< Shuffle, XprType > & type
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void cleanup()
remove_reference< Nested >::type _Nested
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index srcCoeff(Index index) const
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE bool evalSubExprsIfNeeded(Scalar *)
#define EIGEN_STATIC_ASSERT(CONDITION, MSG)
XprType::CoeffReturnType CoeffReturnType
array< Index, NumDims > m_outputStrides
XprType::CoeffReturnType CoeffReturnType
static EIGEN_DEVICE_FUNC void run(const Expression &expr, const Device &device=Device())
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index) const
PacketType< CoeffReturnType, Device >::type PacketReturnType
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorOpCost costPerCoeff(bool vectorized) const
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index) const
TensorEvaluator< ArgType, Device > m_impl
A cost model used to limit the number of threads used for evaluating tensor expression.
TensorEvaluator< const TensorShufflingOp< Shuffle, ArgType >, Device > Base
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorEvaluator(const XprType &op, const Device &device)
PacketType< CoeffReturnType, Device >::type PacketReturnType
TensorShufflingOp< Shuffle, ArgType > XprType
Eigen::internal::traits< TensorShufflingOp >::Scalar Scalar
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
control_box_rst
Author(s): Christoph Rösmann
autogenerated on Wed Mar 2 2022 00:07:04