Eigen::TensorContractionEvaluatorBase< Derived > Struct Template Reference

Public Types

enum  {
  IsAligned ,
  PacketAccess ,
  BlockAccess ,
  PreferBlockAccess ,
  CoordAccess ,
  RawAccess
}
 
typedef XprType::CoeffReturnType CoeffReturnType
 
typedef array< Index, ContractDimscontract_t
 
typedef internal::traits< Derived >::Device Device
 
typedef DSizes< Index, NumDimsDimensions
 
typedef std::conditional_t< static_cast< int >Layout)==static_cast< int >ColMajor), LeftArgType, RightArgTypeEvalLeftArgType
 
typedef std::conditional_t< static_cast< int >Layout)==static_cast< int >ColMajor), RightArgType, LeftArgTypeEvalRightArgType
 
typedef Storage::Type EvaluatorPointerType
 
typedef XprType::Index Index
 
typedef internal::traits< Derived >::Indices Indices
 
typedef array< Index, LDims - ContractDimsleft_nocontract_t
 
typedef internal::traits< Derived >::LeftArgType LeftArgType
 
typedef TensorEvaluator< EvalLeftArgType, DeviceLeftEvaluatorType
 
typedef internal::traits< Derived >::OutputKernelType OutputKernelType
 
typedef PacketType< CoeffReturnType, Device >::type PacketReturnType
 
typedef array< Index, RDims - ContractDimsright_nocontract_t
 
typedef internal::traits< Derived >::RightArgType RightArgType
 
typedef TensorEvaluator< EvalRightArgType, DeviceRightEvaluatorType
 
typedef std::remove_const_t< typename XprType::ScalarScalar
 
typedef StorageMemory< Scalar, DeviceStorage
 
typedef internal::TensorBlockNotImplemented TensorBlock
 
typedef TensorContractionOp< Indices, LeftArgType, RightArgType, OutputKernelTypeXprType
 

Public Member Functions

void cleanup ()
 
CoeffReturnType coeff (Index index) const
 
TensorOpCost costPerCoeff (bool) const
 
EvaluatorPointerType data () const
 
const Dimensionsdimensions () const
 
template<bool lhs_inner_dim_contiguous, bool rhs_inner_dim_contiguous, bool rhs_inner_dim_reordered, int Alignment>
void evalGemm (Scalar *buffer) const
 
template<bool lhs_inner_dim_contiguous, bool rhs_inner_dim_contiguous, bool rhs_inner_dim_reordered, int Alignment, bool use_output_kernel>
void evalGemmPartial (Scalar *buffer, Index k_start, Index k_end, int num_threads) const
 
template<bool lhs_inner_dim_contiguous, bool rhs_inner_dim_contiguous, bool rhs_inner_dim_reordered, int Alignment>
void evalGemmPartialWithoutOutputKernel (Scalar *buffer, Index k_start, Index k_end, int num_threads) const
 
template<bool lhs_inner_dim_contiguous, bool rhs_inner_dim_contiguous, bool rhs_inner_dim_reordered, int Alignment>
void evalGemv (Scalar *buffer) const
 
template<bool lhs_inner_dim_contiguous, bool rhs_inner_dim_contiguous, bool rhs_inner_dim_reordered, int Alignment>
void evalProductSequential (Scalar *buffer) const
 
bool evalSubExprsIfNeeded (EvaluatorPointerType data)
 
void evalTo (Scalar *buffer) const
 
template<int LoadMode>
PacketReturnType packet (Index index) const
 
 TensorContractionEvaluatorBase (const XprType &op, const Device &device)
 

Static Public Attributes

static constexpr int ContractDims
 
static constexpr int Layout
 
static constexpr int LDims
 
static constexpr int NumDims
 
static constexpr int RDims
 

Protected Attributes

const Device EIGEN_DEVICE_REF m_device
 
Dimensions m_dimensions
 
Index m_i_size
 
left_nocontract_t m_i_strides
 
Index m_j_size
 
right_nocontract_t m_j_strides
 
Index m_k_size
 
contract_t m_k_strides
 
contract_t m_left_contracting_strides
 
left_nocontract_t m_left_nocontract_strides
 
TensorEvaluator< EvalLeftArgType, Devicem_leftImpl
 
bool m_lhs_inner_dim_contiguous
 
OutputKernelType m_output_kernel
 
EvaluatorPointerType m_result
 
bool m_rhs_inner_dim_contiguous
 
bool m_rhs_inner_dim_reordered
 
contract_t m_right_contracting_strides
 
right_nocontract_t m_right_nocontract_strides
 
TensorEvaluator< EvalRightArgType, Devicem_rightImpl
 
TensorContractionParams m_tensor_contraction_params
 

Detailed Description

template<typename Derived>
struct Eigen::TensorContractionEvaluatorBase< Derived >

Definition at line 365 of file TensorContraction.h.

Member Typedef Documentation

◆ CoeffReturnType

template<typename Derived >
typedef XprType::CoeffReturnType Eigen::TensorContractionEvaluatorBase< Derived >::CoeffReturnType

Definition at line 375 of file TensorContraction.h.

◆ contract_t

template<typename Derived >
typedef array<Index, ContractDims> Eigen::TensorContractionEvaluatorBase< Derived >::contract_t

Definition at line 413 of file TensorContraction.h.

◆ Device

template<typename Derived >
typedef internal::traits<Derived>::Device Eigen::TensorContractionEvaluatorBase< Derived >::Device

Definition at line 370 of file TensorContraction.h.

◆ Dimensions

template<typename Derived >
typedef DSizes<Index, NumDims> Eigen::TensorContractionEvaluatorBase< Derived >::Dimensions

Definition at line 417 of file TensorContraction.h.

◆ EvalLeftArgType

template<typename Derived >
typedef std::conditional_t< static_cast<int>Layout) == static_cast<int>ColMajor), LeftArgType, RightArgType> Eigen::TensorContractionEvaluatorBase< Derived >::EvalLeftArgType

Definition at line 399 of file TensorContraction.h.

◆ EvalRightArgType

template<typename Derived >
typedef std::conditional_t< static_cast<int>Layout) == static_cast<int>ColMajor), RightArgType, LeftArgType> Eigen::TensorContractionEvaluatorBase< Derived >::EvalRightArgType

Definition at line 401 of file TensorContraction.h.

◆ EvaluatorPointerType

template<typename Derived >
typedef Storage::Type Eigen::TensorContractionEvaluatorBase< Derived >::EvaluatorPointerType

Definition at line 378 of file TensorContraction.h.

◆ Index

template<typename Derived >
typedef XprType::Index Eigen::TensorContractionEvaluatorBase< Derived >::Index

Definition at line 374 of file TensorContraction.h.

◆ Indices

template<typename Derived >
typedef internal::traits<Derived>::Indices Eigen::TensorContractionEvaluatorBase< Derived >::Indices

Definition at line 366 of file TensorContraction.h.

◆ left_nocontract_t

template<typename Derived >
typedef array<Index, LDims - ContractDims> Eigen::TensorContractionEvaluatorBase< Derived >::left_nocontract_t

Definition at line 414 of file TensorContraction.h.

◆ LeftArgType

template<typename Derived >
typedef internal::traits<Derived>::LeftArgType Eigen::TensorContractionEvaluatorBase< Derived >::LeftArgType

Definition at line 367 of file TensorContraction.h.

◆ LeftEvaluatorType

Definition at line 403 of file TensorContraction.h.

◆ OutputKernelType

template<typename Derived >
typedef internal::traits<Derived>::OutputKernelType Eigen::TensorContractionEvaluatorBase< Derived >::OutputKernelType

Definition at line 369 of file TensorContraction.h.

◆ PacketReturnType

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

Definition at line 376 of file TensorContraction.h.

◆ right_nocontract_t

template<typename Derived >
typedef array<Index, RDims - ContractDims> Eigen::TensorContractionEvaluatorBase< Derived >::right_nocontract_t

Definition at line 415 of file TensorContraction.h.

◆ RightArgType

template<typename Derived >
typedef internal::traits<Derived>::RightArgType Eigen::TensorContractionEvaluatorBase< Derived >::RightArgType

Definition at line 368 of file TensorContraction.h.

◆ RightEvaluatorType

Definition at line 404 of file TensorContraction.h.

◆ Scalar

template<typename Derived >
typedef std::remove_const_t<typename XprType::Scalar> Eigen::TensorContractionEvaluatorBase< Derived >::Scalar

Definition at line 373 of file TensorContraction.h.

◆ Storage

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

Definition at line 377 of file TensorContraction.h.

◆ TensorBlock

template<typename Derived >
typedef internal::TensorBlockNotImplemented Eigen::TensorContractionEvaluatorBase< Derived >::TensorBlock

Definition at line 391 of file TensorContraction.h.

◆ XprType

Definition at line 372 of file TensorContraction.h.

Member Enumeration Documentation

◆ anonymous enum

template<typename Derived >
anonymous enum
Enumerator
IsAligned 
PacketAccess 
BlockAccess 
PreferBlockAccess 
CoordAccess 
RawAccess 

Definition at line 381 of file TensorContraction.h.

Constructor & Destructor Documentation

◆ TensorContractionEvaluatorBase()

template<typename Derived >
Eigen::TensorContractionEvaluatorBase< Derived >::TensorContractionEvaluatorBase ( const XprType op,
const Device device 
)
inline

Definition at line 420 of file TensorContraction.h.

421  : m_leftImpl(choose(Cond<static_cast<int>(Layout) == static_cast<int>(ColMajor)>(),
422  op.lhsExpression(), op.rhsExpression()), device),
423  m_rightImpl(choose(Cond<static_cast<int>(Layout) == static_cast<int>(ColMajor)>(),
424  op.rhsExpression(), op.lhsExpression()), device),
425  m_device(device),
426  m_output_kernel(op.outputKernel()),
427  m_result(NULL) {
430  YOU_MADE_A_PROGRAMMING_MISTAKE);
431 
432 
433  DSizes<Index, LDims> eval_left_dims;
434  DSizes<Index, RDims> eval_right_dims;
435  array<IndexPair<Index>, ContractDims> eval_op_indices;
436  if (static_cast<int>(Layout) == static_cast<int>(ColMajor)) {
437  // For ColMajor, we keep using the existing dimensions
438  for (int i = 0; i < LDims; i++) {
439  eval_left_dims[i] = m_leftImpl.dimensions()[i];
440  }
441  for (int i = 0; i < RDims; i++) {
442  eval_right_dims[i] = m_rightImpl.dimensions()[i];
443  }
444  // We keep the pairs of contracting indices.
445  for (int i = 0; i < ContractDims; i++) {
446  eval_op_indices[i].first = op.indices()[i].first;
447  eval_op_indices[i].second = op.indices()[i].second;
448  }
449  } else {
450  // For RowMajor, we need to reverse the existing dimensions
451  for (int i = 0; i < LDims; i++) {
452  eval_left_dims[i] = m_leftImpl.dimensions()[LDims - i - 1];
453  }
454  for (int i = 0; i < RDims; i++) {
455  eval_right_dims[i] = m_rightImpl.dimensions()[RDims - i - 1];
456  }
457  // We need to flip all the pairs of contracting indices as well as
458  // reversing the dimensions.
459  for (int i = 0; i < ContractDims; i++) {
460  eval_op_indices[i].first = LDims - 1 - op.indices()[ContractDims - 1 - i].second;
461  eval_op_indices[i].second = RDims - 1 - op.indices()[ContractDims - 1 - i].first;
462  }
463  }
464 
465  // Check for duplicate axes and make sure the first index in eval_op_indices
466  // is increasing. Using O(n^2) sorting is OK since ContractDims is small
467  for (int i = 0; i < ContractDims; i++) {
468  for (int j = i + 1; j < ContractDims; j++) {
469  eigen_assert(eval_op_indices[j].first != eval_op_indices[i].first &&
470  eval_op_indices[j].second != eval_op_indices[i].second &&
471  "contraction axes should be unique");
472  if (eval_op_indices[j].first < eval_op_indices[i].first) {
473  numext::swap(eval_op_indices[j], eval_op_indices[i]);
474  }
475  }
476  }
477 
478  array<Index, LDims> lhs_strides;
479  lhs_strides[0] = 1;
480  for (int i = 0; i < LDims-1; ++i) {
481  lhs_strides[i+1] = lhs_strides[i] * eval_left_dims[i];
482  }
483 
484  array<Index, RDims> rhs_strides;
485  rhs_strides[0] = 1;
486  for (int i = 0; i < RDims-1; ++i) {
487  rhs_strides[i+1] = rhs_strides[i] * eval_right_dims[i];
488  }
489 
490  if (m_i_strides.size() > 0) m_i_strides[0] = 1;
491  if (m_j_strides.size() > 0) m_j_strides[0] = 1;
492  if (m_k_strides.size() > 0) m_k_strides[0] = 1;
493 
494  m_i_size = 1;
495  m_j_size = 1;
496  m_k_size = 1;
497 
498  // To compute the dimension, we simply concatenate the non-contracting
499  // dimensions of the left and then the right tensor. Additionally, we also
500  // compute the strides corresponding to the left non-contracting
501  // dimensions and right non-contracting dimensions.
503  int dim_idx = 0;
504  Index nocontract_idx = 0;
505 
506  for (int i = 0; i < LDims; i++) {
507  // find if we are contracting on index i of left tensor
508  bool contracting = false;
509  for (int j = 0; j < ContractDims; j++) {
510  if (eval_op_indices[j].first == i) {
511  contracting = true;
512  break;
513  }
514  }
515  if (!contracting) {
516  // add dimension size to output dimensions
517  m_dimensions[dim_idx] = eval_left_dims[i];
518  m_left_nocontract_strides[nocontract_idx] = lhs_strides[i];
519  if (dim_idx != i) {
521  }
522  if (nocontract_idx+1 < internal::array_size<left_nocontract_t>::value) {
523  m_i_strides[nocontract_idx+1] =
524  m_i_strides[nocontract_idx] * eval_left_dims[i];
525  } else {
526  m_i_size = m_i_strides[nocontract_idx] * eval_left_dims[i];
527  }
528  dim_idx++;
529  nocontract_idx++;
530  }
531  }
532 
533  nocontract_idx = 0;
534  for (int i = 0; i < RDims; i++) {
535  bool contracting = false;
536  // find if we are contracting on index i of right tensor
537  for (int j = 0; j < ContractDims; j++) {
538  if (eval_op_indices[j].second == i) {
539  contracting = true;
540  break;
541  }
542  }
543  if (!contracting) {
544  m_dimensions[dim_idx] = eval_right_dims[i];
545  if (nocontract_idx+1 < internal::array_size<right_nocontract_t>::value) {
546  m_j_strides[nocontract_idx+1] =
547  m_j_strides[nocontract_idx] * eval_right_dims[i];
548  } else {
549  m_j_size = m_j_strides[nocontract_idx] * eval_right_dims[i];
550  }
551  m_right_nocontract_strides[nocontract_idx] = rhs_strides[i];
552  dim_idx++;
553  nocontract_idx++;
554  }
555  }
556 
557  // Now compute the strides corresponding to the contracting dimensions. We
558  // assumed above that non-contracting axes are represented in the same order
559  // in the matrix as they are in the tensor. This is not the case for
560  // contracting axes. As the contracting axes must be of the same size in
561  // each tensor, we'll only look at the first tensor here.
564  for (int i = 0; i < ContractDims; i++) {
565  Index left = eval_op_indices[i].first;
566  Index right = eval_op_indices[i].second;
567 
568  Index size = eval_left_dims[left];
569  eigen_assert(size == eval_right_dims[right] &&
570  "Contraction axes must be same size");
571 
572  if (i+1 < static_cast<int>(internal::array_size<contract_t>::value)) {
573  m_k_strides[i+1] = m_k_strides[i] * size;
574  } else {
575  m_k_size = m_k_strides[i] * size;
576  }
577  m_left_contracting_strides[i] = lhs_strides[left];
578  m_right_contracting_strides[i] = rhs_strides[right];
579 
580  if (i > 0 && right < eval_op_indices[i-1].second) {
582  }
583  if (right != i) {
585  }
586  }
587 
588  // If the layout is RowMajor, we need to reverse the m_dimensions
589  if (static_cast<int>(Layout) == static_cast<int>(RowMajor)) {
590  for (int i = 0, j = NumDims - 1; i < j; i++, j--) {
592  }
593  }
594 
595  // A set of parameters that will allow output kernel to get from output
596  // tensor dimensions (i, j) into the original tensor dimensions.
597  // TODO(ezhulenev): Add parameters required to infer output tensor index for
598  // more complex contractions than 2x2 on internal dimension.
600  }
int i
#define eigen_assert(x)
#define EIGEN_STATIC_ASSERT(X, MSG)
void swap(T &a, T &b)
std::array< T, N > array
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
EIGEN_ALWAYS_INLINE const T1 & choose(Cond< true >, const T1 &first, const T2 &)
Definition: TensorMeta.h:20
SparseMat::Index size
const Device EIGEN_DEVICE_REF m_device
TensorEvaluator< EvalRightArgType, Device > m_rightImpl
TensorContractionParams m_tensor_contraction_params
TensorEvaluator< EvalLeftArgType, Device > m_leftImpl
const Dimensions & dimensions() const
std::ptrdiff_t j

Member Function Documentation

◆ cleanup()

template<typename Derived >
void Eigen::TensorContractionEvaluatorBase< Derived >::cleanup ( )
inline

Definition at line 914 of file TensorContraction.h.

914  {
917 
918  if (m_result != NULL) {
919  m_device.deallocate(m_result);
920  m_result = NULL;
921  }
922  }

◆ coeff()

template<typename Derived >
CoeffReturnType Eigen::TensorContractionEvaluatorBase< Derived >::coeff ( Index  index) const
inline

Definition at line 924 of file TensorContraction.h.

924  {
925  return m_result[index];
926  }

◆ costPerCoeff()

template<typename Derived >
TensorOpCost Eigen::TensorContractionEvaluatorBase< Derived >::costPerCoeff ( bool  ) const
inline

Definition at line 928 of file TensorContraction.h.

928  {
929  return TensorOpCost(sizeof(CoeffReturnType), 0, 0);
930  }
XprType::CoeffReturnType CoeffReturnType

◆ data()

template<typename Derived >
EvaluatorPointerType Eigen::TensorContractionEvaluatorBase< Derived >::data ( ) const
inline

Definition at line 937 of file TensorContraction.h.

937 { return m_result; }

◆ dimensions()

template<typename Derived >
const Dimensions& Eigen::TensorContractionEvaluatorBase< Derived >::dimensions ( ) const
inline

Definition at line 602 of file TensorContraction.h.

602 { return m_dimensions; }

◆ evalGemm()

template<typename Derived >
template<bool lhs_inner_dim_contiguous, bool rhs_inner_dim_contiguous, bool rhs_inner_dim_reordered, int Alignment>
void Eigen::TensorContractionEvaluatorBase< Derived >::evalGemm ( Scalar buffer) const
inline

Definition at line 780 of file TensorContraction.h.

780  {
781  // columns in left side, rows in right side
782  const Index k = this->m_k_size;
783  this->template evalGemmPartial<lhs_inner_dim_contiguous,
784  rhs_inner_dim_contiguous,
785  rhs_inner_dim_reordered,
786  Alignment, true>(buffer, 0, k, 1);
787  }
void evalGemmPartial(Scalar *buffer, Index k_start, Index k_end, int num_threads) const

◆ evalGemmPartial()

template<typename Derived >
template<bool lhs_inner_dim_contiguous, bool rhs_inner_dim_contiguous, bool rhs_inner_dim_reordered, int Alignment, bool use_output_kernel>
void Eigen::TensorContractionEvaluatorBase< Derived >::evalGemmPartial ( Scalar buffer,
Index  k_start,
Index  k_end,
int  num_threads 
) const
inline

Definition at line 800 of file TensorContraction.h.

800  {
801  eigen_assert(k_end >= k_start && k_start >= 0 && k_end <= this->m_k_size);
802  // columns in slice on left side, rows on right side
803  const Index k_slice = k_end - k_start;
804 
805  // rows in left side
806  const Index m = this->m_i_size;
807 
808  // columns in right side
809  const Index n = this->m_j_size;
810 
811  // define data mappers for Lhs and Rhs
812  typedef std::remove_const_t<typename EvalLeftArgType::Scalar> LhsScalar;
813  typedef std::remove_const_t<typename EvalRightArgType::Scalar> RhsScalar;
814 
815  typedef TensorEvaluator<EvalLeftArgType, Device> LeftEvaluator;
816  typedef TensorEvaluator<EvalRightArgType, Device> RightEvaluator;
817 
818  const Index lhs_packet_size = internal::unpacket_traits<typename LeftEvaluator::PacketReturnType>::size;
819  const Index rhs_packet_size = internal::unpacket_traits<typename RightEvaluator::PacketReturnType>::size;
820 
821  typedef internal::TensorContractionInputMapper<LhsScalar, Index, internal::Lhs,
822  LeftEvaluator, left_nocontract_t,
823  contract_t, lhs_packet_size,
824  lhs_inner_dim_contiguous,
825  false, Unaligned> LhsMapper;
826 
827  typedef internal::TensorContractionInputMapper<RhsScalar, Index, internal::Rhs,
828  RightEvaluator, right_nocontract_t,
829  contract_t, rhs_packet_size,
830  rhs_inner_dim_contiguous,
831  rhs_inner_dim_reordered, Unaligned> RhsMapper;
832 
833  typedef internal::blas_data_mapper<Scalar, Index, ColMajor> OutputMapper;
834 
835  typedef internal::TensorContractionKernel<
836  Scalar, LhsScalar, RhsScalar, Index, OutputMapper, LhsMapper, RhsMapper>
837  TensorContractionKernel;
838 
839  // initialize data mappers
840  LhsMapper lhs(this->m_leftImpl, this->m_left_nocontract_strides, this->m_i_strides,
842 
843  RhsMapper rhs(this->m_rightImpl, this->m_right_nocontract_strides, this->m_j_strides,
845 
846  OutputMapper output(buffer, m);
847 
848  // Sizes of the blocks to load in cache. See the Goto paper for details.
849  internal::TensorContractionBlocking<Scalar, LhsScalar, RhsScalar,
851  blocking(k_slice, m, n, num_threads);
852  const Index kc = blocking.kc();
853  const Index mc = numext::mini(m, blocking.mc());
854  const Index nc = numext::mini(n, blocking.nc());
855 
856  typedef typename TensorContractionKernel::LhsBlock LhsBlock;
857  typedef typename TensorContractionKernel::RhsBlock RhsBlock;
858 
859  LhsBlock blockA;
860  RhsBlock blockB;
861 
862  TensorContractionKernel kernel(m, k_slice, n, mc, kc, nc);
863 
864  typedef typename TensorContractionKernel::BlockMemHandle BlockMemHandle;
865  const BlockMemHandle packed_mem =
866  kernel.allocate(this->m_device, &blockA, &blockB);
867 
868  // If a contraction kernel does not support beta, explicitly initialize
869  // output buffer with zeroes.
870  if (!TensorContractionKernel::HasBeta) {
871  this->m_device.fill(buffer, buffer + m * n, Scalar(0));
872  }
873 
874  for(Index i2=0; i2<m; i2+=mc)
875  {
876  const Index actual_mc = numext::mini(i2+mc,m)-i2;
877  for (Index k2 = k_start; k2 < k_end; k2 += kc) {
878  // make sure we don't overshoot right edge of left matrix, then pack vertical panel
879  const Index actual_kc = numext::mini(k2 + kc, k_end) - k2;
880  kernel.packLhs(&blockA, lhs.getSubMapper(i2, k2), actual_kc, actual_mc);
881 
882  // If kernel supports beta, there is no need to initialize output
883  // buffer with zeroes.
884  const Scalar alpha = Scalar(1);
885  const Scalar beta = (TensorContractionKernel::HasBeta && k2 == k_start)
886  ? Scalar(0)
887  : Scalar(1);
888 
889  // series of horizontal blocks
890  for (Index j2 = 0; j2 < n; j2 += nc) {
891  // make sure we don't overshoot right edge of right matrix, then pack block
892  const Index actual_nc = numext::mini(j2 + nc, n) - j2;
893  kernel.packRhs(&blockB, rhs.getSubMapper(k2, j2), actual_kc,
894  actual_nc);
895 
896  // call gebp (matrix kernel)
897  // The parameters here are copied from Eigen's GEMM implementation
898  const OutputMapper output_mapper = output.getSubMapper(i2, j2);
899  kernel.invoke(output_mapper, blockA, blockB, actual_mc, actual_kc,
900  actual_nc, alpha, beta);
901 
902  // We are done with this [i2, j2] output block.
903  if (use_output_kernel && k2 + kc >= k_end) {
904  m_output_kernel(output_mapper, m_tensor_contraction_params, i2, j2,
905  actual_mc, actual_nc);
906  }
907  }
908  }
909  }
910 
911  kernel.deallocate(this->m_device, packed_mem);
912  }
Matrix3f m
int n
EIGEN_ALWAYS_INLINE T mini(const T &x, const T &y)
array< Index, RDims - ContractDims > right_nocontract_t
std::remove_const_t< typename XprType::Scalar > Scalar
array< Index, ContractDims > contract_t
array< Index, LDims - ContractDims > left_nocontract_t

◆ evalGemmPartialWithoutOutputKernel()

template<typename Derived >
template<bool lhs_inner_dim_contiguous, bool rhs_inner_dim_contiguous, bool rhs_inner_dim_reordered, int Alignment>
void Eigen::TensorContractionEvaluatorBase< Derived >::evalGemmPartialWithoutOutputKernel ( Scalar buffer,
Index  k_start,
Index  k_end,
int  num_threads 
) const
inline

Definition at line 791 of file TensorContraction.h.

792  {
793  evalGemmPartial<lhs_inner_dim_contiguous, rhs_inner_dim_contiguous,
794  rhs_inner_dim_reordered, Alignment,
795  /*use_output_kernel*/ false>(buffer, k_start, k_end,
796  num_threads);
797  }

◆ evalGemv()

template<typename Derived >
template<bool lhs_inner_dim_contiguous, bool rhs_inner_dim_contiguous, bool rhs_inner_dim_reordered, int Alignment>
void Eigen::TensorContractionEvaluatorBase< Derived >::evalGemv ( Scalar buffer) const
inline

Definition at line 731 of file TensorContraction.h.

731  {
732  const Index rows = m_i_size;
733  const Index cols = m_k_size;
734 
735  typedef std::remove_const_t<typename EvalLeftArgType::Scalar> LhsScalar;
736  typedef std::remove_const_t<typename EvalRightArgType::Scalar> RhsScalar;
737  typedef TensorEvaluator<EvalLeftArgType, Device> LeftEvaluator;
738  typedef TensorEvaluator<EvalRightArgType, Device> RightEvaluator;
739  const Index lhs_packet_size = internal::unpacket_traits<typename LeftEvaluator::PacketReturnType>::size;
740  const Index rhs_packet_size = internal::unpacket_traits<typename RightEvaluator::PacketReturnType>::size;
741  const int lhs_alignment = LeftEvaluator::IsAligned ? Aligned : Unaligned;
742  const int rhs_alignment = RightEvaluator::IsAligned ? Aligned : Unaligned;
743  typedef internal::TensorContractionInputMapper<LhsScalar, Index, internal::Lhs,
744  LeftEvaluator, left_nocontract_t,
745  contract_t, lhs_packet_size,
746  lhs_inner_dim_contiguous,
747  false, lhs_alignment> LhsMapper;
748 
749  typedef internal::TensorContractionInputMapper<RhsScalar, Index, internal::Rhs,
750  RightEvaluator, right_nocontract_t,
751  contract_t, rhs_packet_size,
752  rhs_inner_dim_contiguous,
753  rhs_inner_dim_reordered, rhs_alignment> RhsMapper;
754 
759 
760  const Scalar alpha(1);
761  const Index resIncr(1);
762 
763  // zero out the result buffer (which must be of size at least rows * sizeof(Scalar)
764  m_device.fill(buffer, buffer + rows, Scalar(0));
765 
766  internal::general_matrix_vector_product<Index,LhsScalar,LhsMapper,ColMajor,false,RhsScalar,RhsMapper,false>::run(
767  rows, cols, lhs, rhs,
768  buffer, resIncr, alpha);
769 
770  typedef internal::blas_data_mapper<Scalar, Index, ColMajor> OutputMapper;
771  m_output_kernel(OutputMapper(buffer, rows), m_tensor_contraction_params,
772  static_cast<Index>(0), static_cast<Index>(0), rows,
773  static_cast<Index>(1));
774  }
Derived::Index cols
Derived::Index rows

◆ evalProductSequential()

template<typename Derived >
template<bool lhs_inner_dim_contiguous, bool rhs_inner_dim_contiguous, bool rhs_inner_dim_reordered, int Alignment>
void Eigen::TensorContractionEvaluatorBase< Derived >::evalProductSequential ( Scalar buffer) const
inline

Definition at line 716 of file TensorContraction.h.

716  {
717  if (this->m_j_size == 1) {
718  this->template evalGemv<lhs_inner_dim_contiguous,
719  rhs_inner_dim_contiguous, rhs_inner_dim_reordered,
720  Alignment>(buffer);
721  } else {
722  this->template evalGemm<lhs_inner_dim_contiguous, rhs_inner_dim_contiguous,
723  rhs_inner_dim_reordered, Alignment>(buffer);
724  }
725  }
void evalGemv(Scalar *buffer) const
void evalGemm(Scalar *buffer) const

◆ evalSubExprsIfNeeded()

template<typename Derived >
bool Eigen::TensorContractionEvaluatorBase< Derived >::evalSubExprsIfNeeded ( EvaluatorPointerType  data)
inline

Definition at line 604 of file TensorContraction.h.

604  {
607  if (data) {
608  evalTo(data);
609  return false;
610  } else {
611  m_result = static_cast<EvaluatorPointerType>(m_device.allocate(dimensions().TotalSize() * sizeof(Scalar)));
612  evalTo(m_result);
613  return true;
614  }
615  }
EvaluatorPointerType data() const
const Dimensions & dimensions() const
bool evalSubExprsIfNeeded(EvaluatorPointerType dest)

◆ evalTo()

template<typename Derived >
void Eigen::TensorContractionEvaluatorBase< Derived >::evalTo ( Scalar buffer) const
inline

Definition at line 701 of file TensorContraction.h.

701  {
702  static_cast<const Derived*>(this)->template evalProduct<Unaligned>(buffer);
703  }

◆ packet()

template<typename Derived >
template<int LoadMode>
PacketReturnType Eigen::TensorContractionEvaluatorBase< Derived >::packet ( Index  index) const
inline

Definition at line 933 of file TensorContraction.h.

933  {
934  return internal::ploadt<PacketReturnType, LoadMode>(m_result + index);
935  }

Member Data Documentation

◆ ContractDims

template<typename Derived >
constexpr int Eigen::TensorContractionEvaluatorBase< Derived >::ContractDims
staticconstexpr

Definition at line 410 of file TensorContraction.h.

◆ Layout

template<typename Derived >
constexpr int Eigen::TensorContractionEvaluatorBase< Derived >::Layout
staticconstexpr

Definition at line 380 of file TensorContraction.h.

◆ LDims

template<typename Derived >
constexpr int Eigen::TensorContractionEvaluatorBase< Derived >::LDims
staticconstexpr

Definition at line 406 of file TensorContraction.h.

◆ m_device

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

Definition at line 963 of file TensorContraction.h.

◆ m_dimensions

template<typename Derived >
Dimensions Eigen::TensorContractionEvaluatorBase< Derived >::m_dimensions
protected

Definition at line 940 of file TensorContraction.h.

◆ m_i_size

template<typename Derived >
Index Eigen::TensorContractionEvaluatorBase< Derived >::m_i_size
protected

Definition at line 955 of file TensorContraction.h.

◆ m_i_strides

template<typename Derived >
left_nocontract_t Eigen::TensorContractionEvaluatorBase< Derived >::m_i_strides
protected

Definition at line 950 of file TensorContraction.h.

◆ m_j_size

template<typename Derived >
Index Eigen::TensorContractionEvaluatorBase< Derived >::m_j_size
protected

Definition at line 956 of file TensorContraction.h.

◆ m_j_strides

template<typename Derived >
right_nocontract_t Eigen::TensorContractionEvaluatorBase< Derived >::m_j_strides
protected

Definition at line 951 of file TensorContraction.h.

◆ m_k_size

template<typename Derived >
Index Eigen::TensorContractionEvaluatorBase< Derived >::m_k_size
protected

Definition at line 957 of file TensorContraction.h.

◆ m_k_strides

template<typename Derived >
contract_t Eigen::TensorContractionEvaluatorBase< Derived >::m_k_strides
protected

Definition at line 942 of file TensorContraction.h.

◆ m_left_contracting_strides

template<typename Derived >
contract_t Eigen::TensorContractionEvaluatorBase< Derived >::m_left_contracting_strides
protected

Definition at line 943 of file TensorContraction.h.

◆ m_left_nocontract_strides

template<typename Derived >
left_nocontract_t Eigen::TensorContractionEvaluatorBase< Derived >::m_left_nocontract_strides
protected

Definition at line 952 of file TensorContraction.h.

◆ m_leftImpl

template<typename Derived >
TensorEvaluator<EvalLeftArgType, Device> Eigen::TensorContractionEvaluatorBase< Derived >::m_leftImpl
protected

Definition at line 961 of file TensorContraction.h.

◆ m_lhs_inner_dim_contiguous

template<typename Derived >
bool Eigen::TensorContractionEvaluatorBase< Derived >::m_lhs_inner_dim_contiguous
protected

Definition at line 946 of file TensorContraction.h.

◆ m_output_kernel

template<typename Derived >
OutputKernelType Eigen::TensorContractionEvaluatorBase< Derived >::m_output_kernel
protected

Definition at line 964 of file TensorContraction.h.

◆ m_result

template<typename Derived >
EvaluatorPointerType Eigen::TensorContractionEvaluatorBase< Derived >::m_result
protected

Definition at line 965 of file TensorContraction.h.

◆ m_rhs_inner_dim_contiguous

template<typename Derived >
bool Eigen::TensorContractionEvaluatorBase< Derived >::m_rhs_inner_dim_contiguous
protected

Definition at line 947 of file TensorContraction.h.

◆ m_rhs_inner_dim_reordered

template<typename Derived >
bool Eigen::TensorContractionEvaluatorBase< Derived >::m_rhs_inner_dim_reordered
protected

Definition at line 948 of file TensorContraction.h.

◆ m_right_contracting_strides

template<typename Derived >
contract_t Eigen::TensorContractionEvaluatorBase< Derived >::m_right_contracting_strides
protected

Definition at line 944 of file TensorContraction.h.

◆ m_right_nocontract_strides

template<typename Derived >
right_nocontract_t Eigen::TensorContractionEvaluatorBase< Derived >::m_right_nocontract_strides
protected

Definition at line 953 of file TensorContraction.h.

◆ m_rightImpl

template<typename Derived >
TensorEvaluator<EvalRightArgType, Device> Eigen::TensorContractionEvaluatorBase< Derived >::m_rightImpl
protected

Definition at line 962 of file TensorContraction.h.

◆ m_tensor_contraction_params

template<typename Derived >
TensorContractionParams Eigen::TensorContractionEvaluatorBase< Derived >::m_tensor_contraction_params
protected

Definition at line 959 of file TensorContraction.h.

◆ NumDims

template<typename Derived >
constexpr int Eigen::TensorContractionEvaluatorBase< Derived >::NumDims
staticconstexpr

Definition at line 411 of file TensorContraction.h.

◆ RDims

template<typename Derived >
constexpr int Eigen::TensorContractionEvaluatorBase< Derived >::RDims
staticconstexpr

Definition at line 408 of file TensorContraction.h.


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