10 #ifndef EIGEN_CXX11_TENSOR_TENSOR_GENERATOR_H 11 #define EIGEN_CXX11_TENSOR_TENSOR_GENERATOR_H 23 template<
typename Generator,
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 Generator,
typename XprType>
42 template<
typename Generator,
typename XprType>
52 template<
typename Generator,
typename XprType>
64 : m_xpr(expr), m_generator(generator) {}
67 const Generator&
generator()
const {
return m_generator; }
80 template<
typename Generator,
typename ArgType,
typename Device>
100 : m_generator(op.generator())
105 if (static_cast<int>(Layout) == static_cast<int>(
ColMajor)) {
107 for (
int i = 1;
i < NumDims; ++
i) {
108 m_strides[
i] = m_strides[
i - 1] * m_dimensions[
i - 1];
111 m_strides[NumDims - 1] = 1;
112 for (
int i = NumDims - 2;
i >= 0; --
i) {
113 m_strides[
i] = m_strides[
i + 1] * m_dimensions[
i + 1];
129 extract_coordinates(index, coords);
130 return m_generator(coords);
133 template<
int LoadMode>
141 for (
int i = 0;
i < packetSize; ++
i) {
142 values[
i] = coeff(index+
i);
144 PacketReturnType rslt = internal::pload<PacketReturnType>(
values);
152 return TensorOpCost(0, 0, TensorOpCost::AddCost<Scalar>() +
153 TensorOpCost::MulCost<Scalar>());
156 EIGEN_DEVICE_FUNC Scalar*
data()
const {
return NULL; }
161 if (static_cast<int>(Layout) == static_cast<int>(
ColMajor)) {
162 for (
int i = NumDims - 1;
i > 0; --
i) {
163 const Index idx = index / m_strides[
i];
164 index -= idx * m_strides[
i];
169 for (
int i = 0;
i < NumDims - 1; ++
i) {
170 const Index idx = index / m_strides[
i];
171 index -= idx * m_strides[
i];
174 coords[NumDims-1] = index;
185 #endif // EIGEN_CXX11_TENSOR_TENSOR_GENERATOR_H const TensorGeneratorOp< Generator, XprType > & type
Eigen::internal::traits< TensorGeneratorOp >::Scalar Scalar
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Dimensions & dimensions() const
#define EIGEN_STRONG_INLINE
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Dimensions & dimensions() const
TensorEvaluator< ArgType, Device >::Dimensions Dimensions
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void extract_coordinates(Index index, array< Index, NumDims > &coords) const
Namespace containing all symbols from the Eigen library.
A cost model used to limit the number of threads used for evaluating tensor expression.
#define EIGEN_STATIC_ASSERT(CONDITION, MSG)
array< Index, NumDims > m_strides
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorEvaluator(const XprType &op, const Device &device)
vector< size_t > dimensions(L.begin(), L.end())
EIGEN_DEVICE_FUNC const internal::remove_all< typename XprType::Nested >::type & expression() const
PacketType< CoeffReturnType, Device >::type PacketReturnType
XprType::CoeffReturnType CoeffReturnType
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Eigen::internal::traits< TensorGeneratorOp >::StorageKind StorageKind
traits< XprType > XprTraits
Eigen::internal::nested< TensorGeneratorOp >::type Nested
EIGEN_DEVICE_FUNC const Generator & generator() const
const Generator m_generator
XprTraits::StorageKind StorageKind
Eigen::internal::traits< TensorGeneratorOp >::Index Index
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketReturnType packet(Index index) const
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index) const
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE bool evalSubExprsIfNeeded(Scalar *)
EIGEN_DEVICE_FUNC Scalar * data() const
Eigen::NumTraits< Scalar >::Real RealScalar
TensorGeneratorOp< Generator, XprType > type
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void cleanup()
remove_reference< Nested >::type _Nested
TensorGeneratorOp< Generator, ArgType > XprType
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorGeneratorOp(const XprType &expr, const Generator &generator)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorOpCost costPerCoeff(bool) const
XprType::CoeffReturnType CoeffReturnType