10#ifndef EIGEN_CXX11_TENSOR_TENSOR_META_H
11#define EIGEN_CXX11_TENSOR_TENSOR_META_H
14#include "./InternalHeaderCheck.h"
21template <
typename T1,
typename T2>
22EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
const T1& choose(Cond<true>,
const T1& first,
const T2&) {
26template <
typename T1,
typename T2>
27EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
const T2& choose(Cond<false>,
const T1&,
const T2& second) {
33 static const size_t size = n;
37 static const size_t size = 1;
41EIGEN_DEPRECATED EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
constexpr T divup(
const T x,
const T y) {
42 return Eigen::numext::div_ceil(x, y);
46template <
typename Scalar,
typename Device>
47struct PacketType : internal::packet_traits<Scalar> {
48 typedef typename internal::packet_traits<Scalar>::type type;
52#if defined(EIGEN_USE_GPU) && defined(EIGEN_HAS_GPU_FP16) && defined(EIGEN_GPU_COMPILE_PHASE)
54typedef ulonglong2 Packet4h2;
56struct PacketType<half, GpuDevice> {
57 typedef Packet4h2 type;
58 static const int size = 8;
86#if defined(EIGEN_USE_SYCL)
91template <
typename Index, Index A, Index B>
93 static constexpr Index Value = A + B;
96template <
typename Index, Index A, Index B>
98 static constexpr Index Value = A / B;
101template <
typename Index,
Index start,
Index end,
Index step,
template <
class Indx, Indx...>
class StepOp>
103 template <
typename UnaryOperator>
104 static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void loop(UnaryOperator op) {
106 static_for<Index, StepOp<Index, start, step>::Value, end, step, StepOp>::loop(op);
109template <
typename Index,
Index end,
Index step,
template <
class Indx, Indx...>
class StepOp>
110struct static_for<
Index, end, end, step, StepOp> {
111 template <
typename UnaryOperator>
112 static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void loop(UnaryOperator) {}
115template <
typename OutScalar,
typename Device,
bool Vectorizable>
117 static constexpr int PacketSize = 1;
118 typedef OutScalar PacketReturnType;
121template <
typename OutScalar,
typename Device>
122struct Vectorise<OutScalar, Device, true> {
123 static constexpr int PacketSize = Eigen::PacketType<OutScalar, Device>::size;
124 typedef typename Eigen::PacketType<OutScalar, Device>::type PacketReturnType;
127static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
Index roundUp(
Index x,
Index y) {
return ((((x) + (y)-1) / (y)) * (y)); }
133struct PacketType<half, SyclDevice> {
135 static const int size = 1;
151template <
typename Scalar>
152struct PacketType<
Scalar, SyclDevice> : internal::default_packet_traits {
174template <
typename Scalar>
175struct PacketType<
Scalar, const SyclDevice> : PacketType<Scalar, SyclDevice> {};
177#ifndef EIGEN_DONT_VECTORIZE_SYCL
178#define PACKET_TYPE(CVQual, Type, val, lengths, DEV) \
180 struct PacketType<CVQual Type, DEV> : internal::sycl_packet_traits<val, lengths> { \
181 typedef typename internal::packet_traits<Type>::type type; \
182 typedef typename internal::packet_traits<Type>::half half; \
185PACKET_TYPE(
const,
float, 1, 4, SyclDevice)
186PACKET_TYPE(,
float, 1, 4, SyclDevice)
187PACKET_TYPE(
const,
float, 1, 4,
const SyclDevice)
188PACKET_TYPE(,
float, 1, 4,
const SyclDevice)
190PACKET_TYPE(
const,
double, 0, 2, SyclDevice)
191PACKET_TYPE(,
double, 0, 2, SyclDevice)
192PACKET_TYPE(
const,
double, 0, 2,
const SyclDevice)
193PACKET_TYPE(,
double, 0, 2,
const SyclDevice)
197struct PacketType<half, const SyclDevice> : PacketType<half, SyclDevice> {};
199struct PacketType<const half, const SyclDevice> : PacketType<half, SyclDevice> {};
204template <
typename U,
typename V>
207 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
212 typedef U first_type;
213 typedef V second_type;
215 constexpr EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Pair() : first(), second() {}
217 constexpr EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Pair(
const U& f,
const V& s) : first(f), second(s) {}
219 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void swap(Pair& rhs) {
221 swap(first, rhs.first);
222 swap(second, rhs.second);
226template <
typename U,
typename V>
227constexpr EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
bool operator==(
const Pair<U, V>& x,
const Pair<U, V>& y) {
228 return (x.first == y.first && x.second == y.second);
231template <
typename U,
typename V>
232constexpr EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
bool operator!=(
const Pair<U, V>& x,
const Pair<U, V>& y) {
237template <
typename Idx>
239 constexpr EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE IndexPair() : first(0), second(0) {}
240 constexpr EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE IndexPair(Idx f, Idx s) : first(f), second(s) {}
242 EIGEN_DEVICE_FUNC
void set(IndexPair<Idx> val) {
254constexpr EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE array<
Index, 1 +
sizeof...(Is)> customIndices2Array(
255 IndexType& idx, numeric_list<Index, First, Is...>) {
256 return {
static_cast<Index>(idx[First]),
static_cast<Index>(idx[Is])...};
258template <
typename IndexType,
typename Index>
259constexpr EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE array<Index, 0> customIndices2Array(IndexType&, numeric_list<Index>) {
260 return array<Index, 0>();
264template <
typename Index, std::
size_t NumIndices,
typename IndexType>
265constexpr EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE array<Index, NumIndices> customIndices2Array(IndexType& idx) {
266 return customIndices2Array(idx,
typename gen_numeric_list<Index, NumIndices>::type{});
269template <
typename B,
typename D>
271 typedef char (&yes)[1];
272 typedef char (&no)[2];
274 template <
typename BB,
typename DD>
276 operator BB*()
const;
280 template <
typename T>
281 static yes check(D*, T);
282 static no check(B*,
int);
284 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