11#ifndef EIGEN_TENSOR_TENSOR_TRAITS_H
12#define EIGEN_TENSOR_TENSOR_TRAITS_H
15#include "./InternalHeaderCheck.h"
21struct tensor_alignment_for_options {
23 is_dynamic_size_storage = 1,
25 value = (((Options &
DontAlign) == 0) && (
26#if EIGEN_MAX_STATIC_ALIGN_BYTES > 0
27 (!is_dynamic_size_storage)
32#if EIGEN_MAX_ALIGN_BYTES > 0
33 is_dynamic_size_storage
41template <
typename Scalar,
int Options>
42struct compute_tensor_flags
43 : std::integral_constant<int, packet_traits<Scalar>::Vectorizable && tensor_alignment_for_options<Options>::value
47template <
typename Scalar_,
int NumIndices_,
int Options_,
typename IndexType_>
48struct traits<Tensor<Scalar_, NumIndices_, Options_, IndexType_> > {
49 typedef Scalar_ Scalar;
50 typedef Dense StorageKind;
51 typedef IndexType_ Index;
52 static constexpr int NumDimensions = NumIndices_;
56 Flags = compute_tensor_flags<Scalar_, Options_>::value | (std::is_const<Scalar_>::value ? 0 :
LvalueBit)
62 typedef typename MakePointer<Scalar>::Type PointerType;
65template <
typename Scalar_,
typename Dimensions,
int Options_,
typename IndexType_>
66struct traits<TensorFixedSize<Scalar_, Dimensions, Options_, IndexType_> > {
67 typedef Scalar_ Scalar;
68 typedef Dense StorageKind;
69 typedef IndexType_ Index;
70 static constexpr int NumDimensions = array_size<Dimensions>::value;
74 Flags = compute_tensor_flags<Scalar_, Options_>::value | (std::is_const<Scalar_>::value ? 0 :
LvalueBit)
80 typedef typename MakePointer<Scalar>::Type PointerType;
83template <
typename PlainObjectType,
int Options_,
template <
class>
class MakePointer_>
84struct traits<TensorMap<PlainObjectType, Options_, MakePointer_> > :
public traits<PlainObjectType> {
85 typedef traits<PlainObjectType> BaseTraits;
86 typedef typename BaseTraits::Scalar Scalar;
87 typedef typename BaseTraits::StorageKind StorageKind;
88 typedef typename BaseTraits::Index Index;
89 static constexpr int NumDimensions = BaseTraits::NumDimensions;
90 static constexpr int Layout = BaseTraits::Layout;
91 enum { Options = Options_, Flags = BaseTraits::Flags };
94 typedef typename MakePointer_<T>::Type Type;
96 typedef typename MakePointer<Scalar>::Type PointerType;
99template <
typename PlainObjectType_>
100struct traits<TensorRef<PlainObjectType_> > :
public traits<PlainObjectType_> {
101 typedef PlainObjectType_ PlainObjectType;
102 typedef traits<PlainObjectType> BaseTraits;
103 typedef typename BaseTraits::Scalar Scalar;
104 typedef typename BaseTraits::StorageKind StorageKind;
105 typedef typename BaseTraits::Index Index;
106 static constexpr int NumDimensions = BaseTraits::NumDimensions;
107 static constexpr int Layout = BaseTraits::Layout;
108 enum { Options = BaseTraits::Options, Flags = BaseTraits::Flags };
109 typedef typename BaseTraits::PointerType PointerType;
112template <
typename Scalar_,
int NumIndices_,
int Options,
typename IndexType_>
113struct eval<Tensor<Scalar_, NumIndices_, Options, IndexType_>, Eigen::Dense> {
114 typedef const Tensor<Scalar_, NumIndices_, Options, IndexType_> EIGEN_DEVICE_REF type;
117template <
typename Scalar_,
int NumIndices_,
int Options,
typename IndexType_>
118struct eval<const Tensor<Scalar_, NumIndices_, Options, IndexType_>, Eigen::Dense> {
119 typedef const Tensor<Scalar_, NumIndices_, Options, IndexType_> EIGEN_DEVICE_REF type;
122template <
typename Scalar_,
typename Dimensions,
int Options,
typename IndexType_>
123struct eval<TensorFixedSize<Scalar_, Dimensions, Options, IndexType_>, Eigen::Dense> {
124 typedef const TensorFixedSize<Scalar_, Dimensions, Options, IndexType_> EIGEN_DEVICE_REF type;
127template <
typename Scalar_,
typename Dimensions,
int Options,
typename IndexType_>
128struct eval<const TensorFixedSize<Scalar_, Dimensions, Options, IndexType_>, Eigen::Dense> {
129 typedef const TensorFixedSize<Scalar_, Dimensions, Options, IndexType_> EIGEN_DEVICE_REF type;
132template <
typename PlainObjectType,
int Options,
template <
class>
class MakePointer>
133struct eval<TensorMap<PlainObjectType, Options, MakePointer>, Eigen::Dense> {
134 typedef const TensorMap<PlainObjectType, Options, MakePointer> EIGEN_DEVICE_REF type;
137template <
typename PlainObjectType,
int Options,
template <
class>
class MakePointer>
138struct eval<const TensorMap<PlainObjectType, Options, MakePointer>, Eigen::Dense> {
139 typedef const TensorMap<PlainObjectType, Options, MakePointer> EIGEN_DEVICE_REF type;
142template <
typename PlainObjectType>
143struct eval<TensorRef<PlainObjectType>, Eigen::Dense> {
144 typedef const TensorRef<PlainObjectType> EIGEN_DEVICE_REF type;
147template <
typename PlainObjectType>
148struct eval<const TensorRef<PlainObjectType>, Eigen::Dense> {
149 typedef const TensorRef<PlainObjectType> EIGEN_DEVICE_REF type;
153struct tensor_ref_selector {
154 typedef const T EIGEN_DEVICE_REF type;
155 typedef T EIGEN_DEVICE_REF non_const_type;
158template <
typename Scalar_,
int NumIndices_,
int Options_,
typename IndexType_>
159struct ref_selector<Tensor<Scalar_, NumIndices_, Options_, IndexType_> >
160 : tensor_ref_selector<Tensor<Scalar_, NumIndices_, Options_, IndexType_> > {};
162template <
typename Scalar_,
int NumIndices_,
int Options_,
typename IndexType_>
163struct ref_selector<const Tensor<Scalar_, NumIndices_, Options_, IndexType_> >
164 : tensor_ref_selector<const Tensor<Scalar_, NumIndices_, Options_, IndexType_> > {};
166template <
typename Scalar_,
typename Dimensions,
int Options,
typename IndexType_>
167struct ref_selector<TensorFixedSize<Scalar_, Dimensions, Options, IndexType_> >
168 : tensor_ref_selector<TensorFixedSize<Scalar_, Dimensions, Options, IndexType_> > {};
170template <
typename Scalar_,
typename Dimensions,
int Options,
typename IndexType_>
171struct ref_selector<const TensorFixedSize<Scalar_, Dimensions, Options, IndexType_> >
172 : tensor_ref_selector<const TensorFixedSize<Scalar_, Dimensions, Options, IndexType_> > {};
174template <
typename PlainObjectType>
175struct ref_selector<TensorRef<PlainObjectType> > : tensor_ref_selector<TensorRef<PlainObjectType> > {};
177template <
typename PlainObjectType>
178struct ref_selector<const TensorRef<PlainObjectType> > : tensor_ref_selector<const TensorRef<PlainObjectType> > {};
221enum PaddingType { PADDING_VALID = 1, PADDING_SAME = 2 };
constexpr unsigned int LvalueBit
Namespace containing all symbols from the Eigen library.