10#ifndef EIGEN_CXX11_TENSOR_TENSOR_META_H
11#define EIGEN_CXX11_TENSOR_TENSOR_META_H
15template<
bool cond>
struct Cond {};
17template<
typename T1,
typename T2> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
18const T1& choose(Cond<true>,
const T1& first,
const T2&) {
22template<
typename T1,
typename T2> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
23const T2& choose(Cond<false>,
const T1&,
const T2& second) {
28template <
typename T,
typename X,
typename Y>
29EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
30T divup(
const X x,
const Y y) {
31 return static_cast<T
>((x + y - 1) / y);
35EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
36T divup(
const T x,
const T y) {
37 return static_cast<T
>((x + y - 1) / y);
40template <
size_t n>
struct max_n_1 {
41 static const size_t size = n;
43template <>
struct max_n_1<0> {
44 static const size_t size = 1;
49template <
typename Scalar,
typename Device>
50struct PacketType : internal::packet_traits<Scalar> {
51 typedef typename internal::packet_traits<Scalar>::type type;
55#if defined(EIGEN_USE_GPU) && defined(EIGEN_HAS_GPU_FP16)
57typedef ulonglong2 Packet4h2;
59struct PacketType<half, GpuDevice> {
60 typedef Packet4h2 type;
61 static const int size = 8;
89#if defined(EIGEN_USE_SYCL)
94template <
typename Index, Index A, Index B>
struct PlusOp {
95 static constexpr Index Value = A + B;
98template <
typename Index, Index A, Index B>
struct DivOp {
99 static constexpr Index Value = A / B;
103 template <
class Indx, Indx...>
class StepOp>
105 template <
typename UnaryOperator>
106 static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void loop(UnaryOperator op) {
108 static_for<Index, StepOp<Index, start, step>::Value, end, step,
113 template <
class Indx, Indx...>
class StepOp>
114struct static_for<
Index, end, end, step, StepOp> {
115 template <
typename UnaryOperator>
116 static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void loop(UnaryOperator) {}
119template <
typename OutScalar,
typename Device,
bool Vectorizable>
121 static const int PacketSize = 1;
122 typedef OutScalar PacketReturnType;
125template <
typename OutScalar,
typename Device>
126struct Vectorise<OutScalar, Device, true> {
127 static const int PacketSize = Eigen::PacketType<OutScalar, Device>::size;
128 typedef typename Eigen::PacketType<OutScalar, Device>::type PacketReturnType;
131static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
Index roundUp(
Index x,
Index y) {
132 return ((((x) + (y)-1) / (y)) * (y));
139 struct PacketType<half, SyclDevice> {
141 static const int size = 1;
157template <
typename Scalar>
158struct PacketType<Scalar, SyclDevice> : internal::default_packet_traits {
182template <
typename Scalar>
183struct PacketType<Scalar, const SyclDevice> : PacketType<Scalar, SyclDevice>{};
185#ifndef EIGEN_DONT_VECTORIZE_SYCL
186#define PACKET_TYPE(CVQual, Type, val, lengths, DEV)\
187template<> struct PacketType<CVQual Type, DEV> : internal::sycl_packet_traits<val, lengths> \
189 typedef typename internal::packet_traits<Type>::type type;\
190 typedef typename internal::packet_traits<Type>::half half;\
194PACKET_TYPE(
const,
float, 1, 4, SyclDevice)
195PACKET_TYPE(,
float, 1, 4, SyclDevice)
196PACKET_TYPE(
const,
float, 1, 4,
const SyclDevice)
197PACKET_TYPE(,
float, 1, 4,
const SyclDevice)
199PACKET_TYPE(
const,
double, 0, 2, SyclDevice)
200PACKET_TYPE(,
double, 0, 2, SyclDevice)
201PACKET_TYPE(
const,
double, 0, 2,
const SyclDevice)
202PACKET_TYPE(,
double, 0, 2,
const SyclDevice)
205template<>
struct PacketType<half, const SyclDevice>: PacketType<half, SyclDevice>{};
206template<>
struct PacketType<const half, const SyclDevice>: PacketType<half, SyclDevice>{};
211template <
typename U,
typename V>
struct Tuple {
216 typedef U first_type;
217 typedef V second_type;
219 EIGEN_CONSTEXPR EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
220 Tuple() : first(), second() {}
222 EIGEN_CONSTEXPR EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
223 Tuple(
const U& f,
const V& s) : first(f), second(s) {}
225 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
226 void swap(Tuple& rhs) {
228 swap(first, rhs.first);
229 swap(second, rhs.second);
233template <
typename U,
typename V>
234EIGEN_CONSTEXPR EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
235bool operator==(
const Tuple<U, V>& x,
const Tuple<U, V>& y) {
236 return (x.first == y.first && x.second == y.second);
239template <
typename U,
typename V>
240EIGEN_CONSTEXPR EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
241bool operator!=(
const Tuple<U, V>& x,
const Tuple<U, V>& y) {
247template <
typename Idx>
struct IndexPair {
248 EIGEN_CONSTEXPR EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE IndexPair() : first(0), second(0) {}
249 EIGEN_CONSTEXPR EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE IndexPair(Idx f, Idx s) : first(f), second(s) {}
251 EIGEN_DEVICE_FUNC
void set(IndexPair<Idx> val) {
261#ifdef EIGEN_HAS_SFINAE
264 template<
typename IndexType,
typename Index,
Index... Is>
265 EIGEN_CONSTEXPR EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
266 array<
Index,
sizeof...(Is)> customIndices2Array(IndexType& idx, numeric_list<Index, Is...>) {
267 return { idx[Is]... };
269 template<
typename IndexType,
typename Index>
270 EIGEN_CONSTEXPR EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
271 array<Index, 0> customIndices2Array(IndexType&, numeric_list<Index>) {
272 return array<Index, 0>();
276 template<
typename Index, std::
size_t NumIndices,
typename IndexType>
277 EIGEN_CONSTEXPR EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
278 array<Index, NumIndices> customIndices2Array(IndexType& idx) {
279 return customIndices2Array(idx,
typename gen_numeric_list<Index, NumIndices>::type{});
283 template <
typename B,
typename D>
287 typedef char (&yes)[1];
288 typedef char (&no)[2];
290 template <
typename BB,
typename DD>
293 operator BB*()
const;
298 static yes check(D*, T);
299 static no check(B*,
int);
301 static const bool value =
sizeof(check(Host<B,D>(),
int())) ==
sizeof(yes);
Namespace containing all symbols from the Eigen library.
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index