Eigen::TensorEvaluator< Derived, Device > Class Template Reference

A cost model used to limit the number of threads used for evaluating tensor expression. More...

Public Types

enum  {
  IsAligned ,
  PacketAccess
}
 
typedef Derived::Scalar CoeffReturnType
 
typedef Derived::Dimensions Dimensions
 
typedef Storage::Type EvaluatorPointerType
 
typedef Derived::Index Index
 
typedef PacketType< CoeffReturnType, Device >::type PacketReturnType
 
typedef Derived::Scalar Scalar
 
typedef std::remove_const_t< ScalarScalarNoConst
 
typedef StorageMemory< Scalar, Device > Storage
 
typedef internal::TensorMaterializedBlock< ScalarNoConst, NumCoords, Layout, IndexTensorBlock
 
typedef internal::TensorBlockDescriptor< NumCoords, IndexTensorBlockDesc
 
typedef internal::TensorBlockScratchAllocator< Device > TensorBlockScratch
 
typedef internal::traits< Derived >::template MakePointer< Scalar >::Type TensorPointerType
 
typedef Derived XprType
 

Public Member Functions

TensorBlock block (TensorBlockDesc &desc, TensorBlockScratch &scratch, bool=false) const
 
void cleanup ()
 
CoeffReturnType coeff (const array< DenseIndex, NumCoords > &coords) const
 
CoeffReturnType coeff (Index index) const
 
CoeffReturnTypecoeffRef (const array< DenseIndex, NumCoords > &coords) const
 
CoeffReturnTypecoeffRef (Index index) const
 
TensorOpCost costPerCoeff (bool vectorized) const
 
EvaluatorPointerType data () const
 
const Dimensionsdimensions () const
 
bool evalSubExprsIfNeeded (EvaluatorPointerType dest)
 
internal::TensorBlockResourceRequirements getResourceRequirements () const
 
template<int LoadMode>
PacketReturnType packet (Index index) const
 
template<typename PacketReturnTypeT >
std::enable_if_t< internal::unpacket_traits< PacketReturnTypeT >::masked_load_available, PacketReturnTypeT > partialPacket (Index index, typename internal::unpacket_traits< PacketReturnTypeT >::mask_t umask) const
 
 TensorEvaluator (const Derived &m, const Device &device)
 
template<typename TensorBlock >
void writeBlock (const TensorBlockDesc &desc, const TensorBlock &block)
 
template<int StoreMode>
void writePacket (Index index, const PacketReturnType &x) const
 

Static Public Attributes

static constexpr int Layout
 
static constexpr int NumCoords
 
static constexpr int PacketSize
 

Protected Attributes

EvaluatorPointerType m_data
 
const Device EIGEN_DEVICE_REF m_device
 
Dimensions m_dims
 

Detailed Description

template<typename Derived, typename Device>
class Eigen::TensorEvaluator< Derived, Device >

A cost model used to limit the number of threads used for evaluating tensor expression.

The tensor evaluator classes.

These classes are responsible for the evaluation of the tensor expression.

TODO: add support for more types of expressions, in particular expressions leading to lvalues (slicing, reshaping, etc...)

Definition at line 30 of file TensorEvaluator.h.

Member Typedef Documentation

◆ CoeffReturnType

template<typename Derived , typename Device >
typedef Derived::Scalar Eigen::TensorEvaluator< Derived, Device >::CoeffReturnType

◆ Dimensions

template<typename Derived , typename Device >
typedef Derived::Dimensions Eigen::TensorEvaluator< Derived, Device >::Dimensions

◆ EvaluatorPointerType

template<typename Derived , typename Device >
typedef Storage::Type Eigen::TensorEvaluator< Derived, Device >::EvaluatorPointerType

◆ Index

template<typename Derived , typename Device >
typedef Derived::Index Eigen::TensorEvaluator< Derived, Device >::Index

◆ PacketReturnType

template<typename Derived , typename Device >
typedef PacketType<CoeffReturnType, Device>::type Eigen::TensorEvaluator< Derived, Device >::PacketReturnType

◆ Scalar

template<typename Derived , typename Device >
typedef Derived::Scalar Eigen::TensorEvaluator< Derived, Device >::Scalar

◆ ScalarNoConst

template<typename Derived , typename Device >
typedef std::remove_const_t<Scalar> Eigen::TensorEvaluator< Derived, Device >::ScalarNoConst

Definition at line 57 of file TensorEvaluator.h.

◆ Storage

template<typename Derived , typename Device >
typedef StorageMemory<Scalar, Device> Eigen::TensorEvaluator< Derived, Device >::Storage

◆ TensorBlock

template<typename Derived , typename Device >
typedef internal::TensorMaterializedBlock<ScalarNoConst, NumCoords, Layout, Index> Eigen::TensorEvaluator< Derived, Device >::TensorBlock

◆ TensorBlockDesc

template<typename Derived , typename Device >
typedef internal::TensorBlockDescriptor<NumCoords, Index> Eigen::TensorEvaluator< Derived, Device >::TensorBlockDesc

Definition at line 60 of file TensorEvaluator.h.

◆ TensorBlockScratch

template<typename Derived , typename Device >
typedef internal::TensorBlockScratchAllocator<Device> Eigen::TensorEvaluator< Derived, Device >::TensorBlockScratch

Definition at line 61 of file TensorEvaluator.h.

◆ TensorPointerType

template<typename Derived , typename Device >
typedef internal::traits<Derived>::template MakePointer<Scalar>::Type Eigen::TensorEvaluator< Derived, Device >::TensorPointerType

Definition at line 39 of file TensorEvaluator.h.

◆ XprType

template<typename Derived , typename Device >
typedef Derived Eigen::TensorEvaluator< Derived, Device >::XprType

Member Enumeration Documentation

◆ anonymous enum

template<typename Derived , typename Device >
anonymous enum
Enumerator
IsAligned 
PacketAccess 

Definition at line 48 of file TensorEvaluator.h.

48  {
49  IsAligned = Derived::IsAligned,
50  PacketAccess = (PacketType<CoeffReturnType, Device>::size > 1),
51  BlockAccess = internal::is_arithmetic<std::remove_const_t<Scalar>>::value,
52  PreferBlockAccess = false,
53  CoordAccess = NumCoords > 0,
54  RawAccess = true
55  };
static constexpr int NumCoords

Constructor & Destructor Documentation

◆ TensorEvaluator()

template<typename Derived , typename Device >
Eigen::TensorEvaluator< Derived, Device >::TensorEvaluator ( const Derived &  m,
const Device &  device 
)
inline
Examples
/home/runner/work/eigen/eigen/unsupported/Eigen/CXX11/src/Tensor/TensorLayoutSwap.h.

Definition at line 69 of file TensorEvaluator.h.

70  : m_data(device.get((const_cast<TensorPointerType>(m.data())))),
71  m_dims(m.dimensions()),
72  m_device(device)
73  { }
Matrix3f m
const Device EIGEN_DEVICE_REF m_device
internal::traits< Derived >::template MakePointer< Scalar >::Type TensorPointerType
EvaluatorPointerType m_data

Member Function Documentation

◆ block()

template<typename Derived , typename Device >
TensorBlock Eigen::TensorEvaluator< Derived, Device >::block ( TensorBlockDesc desc,
TensorBlockScratch scratch,
bool  = false 
) const
inline

Definition at line 161 of file TensorEvaluator.h.

162  {
163  eigen_assert(m_data != NULL);
164  return TensorBlock::materialize(m_data, m_dims, desc, scratch);
165  }
#define eigen_assert(x)

◆ cleanup()

template<typename Derived , typename Device >
void Eigen::TensorEvaluator< Derived, Device >::cleanup ( )
inline

◆ coeff() [1/2]

template<typename Derived , typename Device >
CoeffReturnType Eigen::TensorEvaluator< Derived, Device >::coeff ( const array< DenseIndex, NumCoords > &  coords) const
inline

Definition at line 131 of file TensorEvaluator.h.

131  {
132  eigen_assert(m_data != NULL);
133  if (static_cast<int>(Layout) == static_cast<int>(ColMajor)) {
134  return m_data[m_dims.IndexOfColMajor(coords)];
135  } else {
136  return m_data[m_dims.IndexOfRowMajor(coords)];
137  }
138  }
static constexpr int Layout

◆ coeff() [2/2]

template<typename Derived , typename Device >
CoeffReturnType Eigen::TensorEvaluator< Derived, Device >::coeff ( Index  index) const
inline
Examples
/home/runner/work/eigen/eigen/unsupported/Eigen/CXX11/src/Tensor/TensorLayoutSwap.h.

Definition at line 97 of file TensorEvaluator.h.

97  {
98  eigen_assert(m_data != NULL);
99  return m_data[index];
100  }

◆ coeffRef() [1/2]

template<typename Derived , typename Device >
CoeffReturnType& Eigen::TensorEvaluator< Derived, Device >::coeffRef ( const array< DenseIndex, NumCoords > &  coords) const
inline

Definition at line 141 of file TensorEvaluator.h.

141  {
142  eigen_assert(m_data != NULL);
143  if (static_cast<int>(Layout) == static_cast<int>(ColMajor)) {
144  return m_data[m_dims.IndexOfColMajor(coords)];
145  } else {
146  return m_data[m_dims.IndexOfRowMajor(coords)];
147  }
148  }

◆ coeffRef() [2/2]

template<typename Derived , typename Device >
CoeffReturnType& Eigen::TensorEvaluator< Derived, Device >::coeffRef ( Index  index) const
inline
Examples
/home/runner/work/eigen/eigen/unsupported/Eigen/CXX11/src/Tensor/TensorLayoutSwap.h.

Definition at line 102 of file TensorEvaluator.h.

102  {
103  eigen_assert(m_data != NULL);
104  return m_data[index];
105  }

◆ costPerCoeff()

template<typename Derived , typename Device >
TensorOpCost Eigen::TensorEvaluator< Derived, Device >::costPerCoeff ( bool  vectorized) const
inline
Examples
/home/runner/work/eigen/eigen/unsupported/Eigen/CXX11/src/Tensor/TensorLayoutSwap.h.

Definition at line 150 of file TensorEvaluator.h.

150  {
151  return TensorOpCost(sizeof(CoeffReturnType), 0, 0, vectorized,
152  PacketType<CoeffReturnType, Device>::size);
153  }
Derived::Scalar CoeffReturnType

◆ data()

template<typename Derived , typename Device >
EvaluatorPointerType Eigen::TensorEvaluator< Derived, Device >::data ( ) const
inline

◆ dimensions()

template<typename Derived , typename Device >
const Dimensions& Eigen::TensorEvaluator< Derived, Device >::dimensions ( ) const
inline

◆ evalSubExprsIfNeeded()

template<typename Derived , typename Device >
bool Eigen::TensorEvaluator< Derived, Device >::evalSubExprsIfNeeded ( EvaluatorPointerType  dest)
inline
Examples
/home/runner/work/eigen/eigen/unsupported/Eigen/CXX11/src/Tensor/TensorLayoutSwap.h.

Definition at line 78 of file TensorEvaluator.h.

78  {
79  if (!NumTraits<std::remove_const_t<Scalar>>::RequireInitialization && dest) {
80  m_device.memcpy((void*)(m_device.get(dest)), m_device.get(m_data), m_dims.TotalSize() * sizeof(Scalar));
81  return false;
82  }
83  return true;
84  }
Derived::Scalar Scalar

◆ getResourceRequirements()

template<typename Derived , typename Device >
internal::TensorBlockResourceRequirements Eigen::TensorEvaluator< Derived, Device >::getResourceRequirements ( ) const
inline

Definition at line 156 of file TensorEvaluator.h.

156  {
157  return internal::TensorBlockResourceRequirements::any();
158  }

◆ packet()

template<typename Derived , typename Device >
template<int LoadMode>
PacketReturnType Eigen::TensorEvaluator< Derived, Device >::packet ( Index  index) const
inline
Examples
/home/runner/work/eigen/eigen/unsupported/Eigen/CXX11/src/Tensor/TensorLayoutSwap.h.

Definition at line 108 of file TensorEvaluator.h.

109  {
110  return internal::ploadt<PacketReturnType, LoadMode>(m_data + index);
111  }

◆ partialPacket()

template<typename Derived , typename Device >
template<typename PacketReturnTypeT >
std::enable_if_t<internal::unpacket_traits<PacketReturnTypeT>::masked_load_available, PacketReturnTypeT> Eigen::TensorEvaluator< Derived, Device >::partialPacket ( Index  index,
typename internal::unpacket_traits< PacketReturnTypeT >::mask_t  umask 
) const
inline

Definition at line 120 of file TensorEvaluator.h.

121  {
122  return internal::ploadu<PacketReturnTypeT>(m_data + index, umask);
123  }

◆ writeBlock()

template<typename Derived , typename Device >
template<typename TensorBlock >
void Eigen::TensorEvaluator< Derived, Device >::writeBlock ( const TensorBlockDesc desc,
const TensorBlock block 
)
inline

Definition at line 168 of file TensorEvaluator.h.

169  {
170  eigen_assert(m_data != NULL);
171 
172  typedef typename TensorBlock::XprType TensorBlockExpr;
173  typedef internal::TensorBlockAssignment<Scalar, NumCoords, TensorBlockExpr,
174  Index>
175  TensorBlockAssign;
176 
177  TensorBlockAssign::Run(
178  TensorBlockAssign::target(desc.dimensions(),
179  internal::strides<Layout>(m_dims), m_data,
180  desc.offset()),
181  block.expr());
182  }
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
TensorBlock block(TensorBlockDesc &desc, TensorBlockScratch &scratch, bool=false) const

◆ writePacket()

template<typename Derived , typename Device >
template<int StoreMode>
void Eigen::TensorEvaluator< Derived, Device >::writePacket ( Index  index,
const PacketReturnType x 
) const
inline
Examples
/home/runner/work/eigen/eigen/unsupported/Eigen/CXX11/src/Tensor/TensorLayoutSwap.h.

Definition at line 126 of file TensorEvaluator.h.

127  {
128  return internal::pstoret<Scalar, PacketReturnType, StoreMode>(m_data + index, x);
129  }

Member Data Documentation

◆ Layout

template<typename Derived , typename Device >
constexpr int Eigen::TensorEvaluator< Derived, Device >::Layout
staticconstexpr

◆ m_data

template<typename Derived , typename Device >
EvaluatorPointerType Eigen::TensorEvaluator< Derived, Device >::m_data
protected

Definition at line 187 of file TensorEvaluator.h.

◆ m_device

template<typename Derived , typename Device >
const Device EIGEN_DEVICE_REF Eigen::TensorEvaluator< Derived, Device >::m_device
protected

Definition at line 189 of file TensorEvaluator.h.

◆ m_dims

template<typename Derived , typename Device >
Dimensions Eigen::TensorEvaluator< Derived, Device >::m_dims
protected

Definition at line 188 of file TensorEvaluator.h.

◆ NumCoords

template<typename Derived , typename Device >
constexpr int Eigen::TensorEvaluator< Derived, Device >::NumCoords
staticconstexpr

Definition at line 44 of file TensorEvaluator.h.

◆ PacketSize

template<typename Derived , typename Device >
constexpr int Eigen::TensorEvaluator< Derived, Device >::PacketSize
staticconstexpr

Definition at line 38 of file TensorEvaluator.h.


The documentation for this class was generated from the following file: