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 using Scalar = Scalar_;
50 using StorageKind = Dense;
51 using Index = IndexType_;
52 static constexpr int NumDimensions = NumIndices_;
56 Flags = compute_tensor_flags<Scalar_, Options_>::value | (std::is_const<Scalar_>::value ? 0 :
LvalueBit)
62 using PointerType =
typename MakePointer<Scalar>::Type;
65template <
typename Scalar_,
typename Dimensions,
int Options_,
typename IndexType_>
66struct traits<TensorFixedSize<Scalar_, Dimensions, Options_, IndexType_> > {
67 using Scalar = Scalar_;
68 using StorageKind = Dense;
69 using Index = IndexType_;
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 using PointerType =
typename MakePointer<Scalar>::Type;
83template <
typename PlainObjectType,
int Options_,
template <
class>
class MakePointer_>
84struct traits<TensorMap<PlainObjectType, Options_, MakePointer_> > :
public traits<PlainObjectType> {
85 using BaseTraits = traits<PlainObjectType>;
86 using Scalar =
typename BaseTraits::Scalar;
87 using StorageKind =
typename BaseTraits::StorageKind;
88 using Index =
typename BaseTraits::Index;
89 static constexpr int NumDimensions = BaseTraits::NumDimensions;
90 static constexpr int Layout = BaseTraits::Layout;
91 enum { Options = Options_, Flags = BaseTraits::Flags };
94 using Type =
typename MakePointer_<T>::Type;
96 using PointerType =
typename MakePointer<Scalar>::Type;
99template <
typename PlainObjectType_>
100struct traits<TensorRef<PlainObjectType_> > :
public traits<PlainObjectType_> {
101 using PlainObjectType = PlainObjectType_;
102 using BaseTraits = traits<PlainObjectType>;
103 using Scalar =
typename BaseTraits::Scalar;
104 using StorageKind =
typename BaseTraits::StorageKind;
105 using Index =
typename BaseTraits::Index;
106 static constexpr int NumDimensions = BaseTraits::NumDimensions;
107 static constexpr int Layout = BaseTraits::Layout;
108 enum { Options = BaseTraits::Options, Flags = BaseTraits::Flags };
109 using PointerType =
typename BaseTraits::PointerType;
112template <
typename Scalar_,
int NumIndices_,
int Options,
typename IndexType_>
113struct eval<Tensor<Scalar_, NumIndices_, Options, IndexType_>, Eigen::Dense> {
114 using type =
const Tensor<Scalar_, NumIndices_, Options, IndexType_> EIGEN_DEVICE_REF;
117template <
typename Scalar_,
int NumIndices_,
int Options,
typename IndexType_>
118struct eval<const Tensor<Scalar_, NumIndices_, Options, IndexType_>, Eigen::Dense> {
119 using type =
const Tensor<Scalar_, NumIndices_, Options, IndexType_> EIGEN_DEVICE_REF;
122template <
typename Scalar_,
typename Dimensions,
int Options,
typename IndexType_>
123struct eval<TensorFixedSize<Scalar_, Dimensions, Options, IndexType_>, Eigen::Dense> {
124 using type =
const TensorFixedSize<Scalar_, Dimensions, Options, IndexType_> EIGEN_DEVICE_REF;
127template <
typename Scalar_,
typename Dimensions,
int Options,
typename IndexType_>
128struct eval<const TensorFixedSize<Scalar_, Dimensions, Options, IndexType_>, Eigen::Dense> {
129 using type =
const TensorFixedSize<Scalar_, Dimensions, Options, IndexType_> EIGEN_DEVICE_REF;
132template <
typename PlainObjectType,
int Options,
template <
class>
class MakePointer>
133struct eval<TensorMap<PlainObjectType, Options, MakePointer>, Eigen::Dense> {
134 using type =
const TensorMap<PlainObjectType, Options, MakePointer> EIGEN_DEVICE_REF;
137template <
typename PlainObjectType,
int Options,
template <
class>
class MakePointer>
138struct eval<const TensorMap<PlainObjectType, Options, MakePointer>, Eigen::Dense> {
139 using type =
const TensorMap<PlainObjectType, Options, MakePointer> EIGEN_DEVICE_REF;
142template <
typename PlainObjectType>
143struct eval<TensorRef<PlainObjectType>, Eigen::Dense> {
144 using type =
const TensorRef<PlainObjectType> EIGEN_DEVICE_REF;
147template <
typename PlainObjectType>
148struct eval<const TensorRef<PlainObjectType>, Eigen::Dense> {
149 using type =
const TensorRef<PlainObjectType> EIGEN_DEVICE_REF;
153struct tensor_ref_selector {
154 using type =
const T EIGEN_DEVICE_REF;
155 using non_const_type = T EIGEN_DEVICE_REF;
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.