10 #ifndef EIGEN_CXX11_TENSOR_TENSOR_TRAITS_H
11 #define EIGEN_CXX11_TENSOR_TENSOR_TRAITS_H
19 template<
typename Scalar,
int Options>
20 class compute_tensor_flags
23 is_dynamic_size_storage = 1,
28 #if EIGEN_MAX_STATIC_ALIGN_BYTES>0
29 (!is_dynamic_size_storage)
34 #
if EIGEN_MAX_ALIGN_BYTES>0
35 is_dynamic_size_storage
41 packet_access_bit = packet_traits<Scalar>::Vectorizable && is_aligned ?
PacketAccessBit : 0
45 enum { ret = packet_access_bit };
49 template<
typename Scalar_,
int NumIndices_,
int Options_,
typename IndexType_>
50 struct traits<Tensor<Scalar_, NumIndices_, Options_, IndexType_> >
52 typedef Scalar_ Scalar;
53 typedef Dense StorageKind;
54 typedef IndexType_
Index;
55 static constexpr
int NumDimensions = NumIndices_;
59 Flags = compute_tensor_flags<Scalar_, Options_>::ret | (is_const<Scalar_>::value ? 0 :
LvalueBit)
61 template <
typename T>
struct MakePointer {
68 template<
typename Scalar_,
typename Dimensions,
int Options_,
typename IndexType_>
69 struct traits<TensorFixedSize<Scalar_, Dimensions, Options_, IndexType_> >
71 typedef Scalar_ Scalar;
72 typedef Dense StorageKind;
73 typedef IndexType_
Index;
74 static constexpr
int NumDimensions = array_size<Dimensions>::value;
78 Flags = compute_tensor_flags<Scalar_, Options_>::ret | (is_const<Scalar_>::value ? 0:
LvalueBit)
80 template <
typename T>
struct MakePointer {
87 template<
typename PlainObjectType,
int Options_,
template <
class>
class MakePointer_>
88 struct traits<TensorMap<PlainObjectType, Options_, MakePointer_> >
89 :
public traits<PlainObjectType>
92 typedef typename BaseTraits::Scalar Scalar;
93 typedef typename BaseTraits::StorageKind StorageKind;
94 typedef typename BaseTraits::Index
Index;
95 static constexpr
int NumDimensions = BaseTraits::NumDimensions;
96 static constexpr
int Layout = BaseTraits::Layout;
99 Flags = BaseTraits::Flags
101 template <
class T>
struct MakePointer {
103 typedef MakePointer_<T> MakePointerT;
104 typedef typename MakePointerT::Type
Type;
109 template<
typename PlainObjectType>
110 struct traits<TensorRef<PlainObjectType> >
111 :
public traits<PlainObjectType>
114 typedef typename BaseTraits::Scalar Scalar;
115 typedef typename BaseTraits::StorageKind StorageKind;
116 typedef typename BaseTraits::Index
Index;
117 static constexpr
int NumDimensions = BaseTraits::NumDimensions;
118 static constexpr
int Layout = BaseTraits::Layout;
120 Options = BaseTraits::Options,
121 Flags = BaseTraits::Flags
123 typedef typename BaseTraits::PointerType PointerType;
127 template<
typename Scalar_,
int NumIndices_,
int Options,
typename IndexType_>
128 struct eval<Tensor<Scalar_, NumIndices_, Options, IndexType_>,
Eigen::Dense>
130 typedef const Tensor<Scalar_, NumIndices_, Options, IndexType_>
EIGEN_DEVICE_REF type;
133 template<
typename Scalar_,
int NumIndices_,
int Options,
typename IndexType_>
134 struct eval<const Tensor<Scalar_, NumIndices_, Options, IndexType_>,
Eigen::Dense>
136 typedef const Tensor<Scalar_, NumIndices_, Options, IndexType_>
EIGEN_DEVICE_REF type;
139 template<
typename Scalar_,
typename Dimensions,
int Options,
typename IndexType_>
140 struct eval<TensorFixedSize<Scalar_, Dimensions, Options, IndexType_>,
Eigen::Dense>
142 typedef const TensorFixedSize<Scalar_, Dimensions, Options, IndexType_>
EIGEN_DEVICE_REF type;
145 template<
typename Scalar_,
typename Dimensions,
int Options,
typename IndexType_>
146 struct eval<const TensorFixedSize<Scalar_, Dimensions, Options, IndexType_>,
Eigen::Dense>
148 typedef const TensorFixedSize<Scalar_, Dimensions, Options, IndexType_>
EIGEN_DEVICE_REF type;
151 template<
typename PlainObjectType,
int Options,
template <
class>
class MakePointer>
152 struct eval<TensorMap<PlainObjectType, Options, MakePointer>,
Eigen::Dense>
154 typedef const TensorMap<PlainObjectType, Options, MakePointer>
EIGEN_DEVICE_REF type;
157 template<
typename PlainObjectType,
int Options,
template <
class>
class MakePointer>
158 struct eval<const TensorMap<PlainObjectType, Options, MakePointer>,
Eigen::Dense>
160 typedef const TensorMap<PlainObjectType, Options, MakePointer>
EIGEN_DEVICE_REF type;
163 template<
typename PlainObjectType>
164 struct eval<TensorRef<PlainObjectType>,
Eigen::Dense>
169 template<
typename PlainObjectType>
170 struct eval<const TensorRef<PlainObjectType>,
Eigen::Dense>
176 template<
typename T,
int n=1,
typename PlainObject =
void>
struct nested
178 typedef typename ref_selector<T>::type type;
181 template <
typename Scalar_,
int NumIndices_,
int Options_,
typename IndexType_>
182 struct nested<Tensor<Scalar_, NumIndices_, Options_, IndexType_> >
184 typedef const Tensor<Scalar_, NumIndices_, Options_, IndexType_>
EIGEN_DEVICE_REF type;
187 template <
typename Scalar_,
int NumIndices_,
int Options_,
typename IndexType_>
188 struct nested<const Tensor<Scalar_, NumIndices_, Options_, IndexType_> >
190 typedef const Tensor<Scalar_, NumIndices_, Options_, IndexType_>
EIGEN_DEVICE_REF type;
193 template <
typename Scalar_,
typename Dimensions,
int Options,
typename IndexType_>
194 struct nested<TensorFixedSize<Scalar_, Dimensions, Options, IndexType_> >
196 typedef const TensorFixedSize<Scalar_, Dimensions, Options, IndexType_>
EIGEN_DEVICE_REF type;
199 template <
typename Scalar_,
typename Dimensions,
int Options,
typename IndexType_>
200 struct nested<const TensorFixedSize<Scalar_, Dimensions, Options, IndexType_> >
202 typedef const TensorFixedSize<Scalar_, Dimensions, Options, IndexType_>
EIGEN_DEVICE_REF type;
206 template <
typename PlainObjectType>
207 struct nested<TensorRef<PlainObjectType> >
212 template <
typename PlainObjectType>
213 struct nested<const TensorRef<PlainObjectType> >
const unsigned int PacketAccessBit
const unsigned int LvalueBit
: TensorContractionSycl.h, provides various tensor contraction kernel for SYCL backend
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index