11#ifndef EIGEN_TENSOR_TENSOR_META_H
12#define EIGEN_TENSOR_TENSOR_META_H
15#include "./InternalHeaderCheck.h"
22template <
typename T1,
typename T2>
23constexpr EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
const T1& choose(Cond<true>,
const T1& first,
const T2&) {
27template <
typename T1,
typename T2>
28constexpr EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
const T2& choose(Cond<false>,
const T1&,
const T2& second) {
34 static constexpr size_t size = n;
38 static constexpr size_t size = 1;
42EIGEN_DEPRECATED EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
constexpr T divup(
const T x,
const T y) {
43 return Eigen::numext::div_ceil(x, y);
47template <
typename Scalar,
typename Device>
48struct PacketType : internal::packet_traits<Scalar> {
49 typedef typename internal::packet_traits<Scalar>::type type;
53#if defined(EIGEN_USE_GPU) && defined(EIGEN_GPU_COMPILE_PHASE)
55typedef ulonglong2 Packet4h2;
57struct PacketType<half, GpuDevice> {
58 typedef Packet4h2 type;
59 static constexpr int size = 8;
87#if defined(EIGEN_USE_SYCL)
92template <
typename Index, Index A, Index B>
94 static constexpr Index Value = A + B;
97template <
typename Index, Index A, Index B>
99 static constexpr Index Value = A / B;
102template <
typename Index, Index start, Index end, Index step,
template <
class Indx, Indx...>
class StepOp>
104 template <
typename UnaryOperator>
105 static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void loop(UnaryOperator op) {
107 static_for<Index, StepOp<Index, start, step>::Value, end, step, StepOp>::loop(op);
110template <
typename Index, Index end, Index step,
template <
class Indx, Indx...>
class StepOp>
111struct static_for<Index, end, end, step, StepOp> {
112 template <
typename UnaryOperator>
113 static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void loop(UnaryOperator) {}
116template <
typename OutScalar,
typename Device,
bool Vectorizable>
118 static constexpr int PacketSize = 1;
119 typedef OutScalar PacketReturnType;
122template <
typename OutScalar,
typename Device>
123struct Vectorise<OutScalar, Device, true> {
124 static constexpr int PacketSize = Eigen::PacketType<OutScalar, Device>::size;
125 typedef typename Eigen::PacketType<OutScalar, Device>::type PacketReturnType;
128static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE Index roundUp(Index x, Index y) {
return ((((x) + (y)-1) / (y)) * (y)); }
134struct PacketType<half, SyclDevice> {
136 static constexpr int size = 1;
152template <
typename Scalar>
153struct PacketType<Scalar, SyclDevice> : internal::default_packet_traits {
175template <
typename Scalar>
176struct PacketType<Scalar, const SyclDevice> : PacketType<Scalar, SyclDevice> {};
178#ifndef EIGEN_DONT_VECTORIZE_SYCL
179#define PACKET_TYPE(CVQual, Type, val, lengths, DEV) \
181 struct PacketType<CVQual Type, DEV> : internal::sycl_packet_traits<val, lengths> { \
182 typedef typename internal::packet_traits<Type>::type type; \
183 typedef typename internal::packet_traits<Type>::half half; \
186PACKET_TYPE(
const,
float, 1, 4, SyclDevice)
187PACKET_TYPE(,
float, 1, 4, SyclDevice)
188PACKET_TYPE(
const,
float, 1, 4,
const SyclDevice)
189PACKET_TYPE(,
float, 1, 4,
const SyclDevice)
191PACKET_TYPE(
const,
double, 0, 2, SyclDevice)
192PACKET_TYPE(,
double, 0, 2, SyclDevice)
193PACKET_TYPE(
const,
double, 0, 2,
const SyclDevice)
194PACKET_TYPE(,
double, 0, 2,
const SyclDevice)
198struct PacketType<half, const SyclDevice> : PacketType<half, SyclDevice> {};
200struct PacketType<const half, const SyclDevice> : PacketType<half, SyclDevice> {};
205template <
typename U,
typename V>
208 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
213 typedef U first_type;
214 typedef V second_type;
216 constexpr EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Pair() =
default;
218 constexpr EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Pair(
const U& f,
const V& s) : first(f), second(s) {}
220 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void swap(Pair& rhs) {
222 swap(first, rhs.first);
223 swap(second, rhs.second);
227template <
typename U,
typename V>
228constexpr EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
bool operator==(
const Pair<U, V>& x,
const Pair<U, V>& y) {
229 return x.first == y.first && x.second == y.second;
232template <
typename U,
typename V>
233constexpr EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
bool operator!=(
const Pair<U, V>& x,
const Pair<U, V>& y) {
238template <
typename Idx>
240 constexpr EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE IndexPair() =
default;
241 constexpr EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE IndexPair(Idx f, Idx s) : first(f), second(s) {}
243 EIGEN_DEVICE_FUNC
void set(IndexPair<Idx> val) {
254template <
typename IndexType,
typename Index, Index First, Index... Is>
255constexpr EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE array<Index, 1 +
sizeof...(Is)> customIndices2Array(
256 IndexType& idx, std::integer_sequence<Index, First, Is...>) {
257 return {
static_cast<Index
>(idx[First]),
static_cast<Index
>(idx[Is])...};
259template <
typename IndexType,
typename Index>
260constexpr EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE array<Index, 0> customIndices2Array(IndexType&,
261 std::integer_sequence<Index>) {
262 return array<Index, 0>();
266template <
typename Index, std::
size_t NumIndices,
typename IndexType>
267constexpr EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE array<Index, NumIndices> customIndices2Array(IndexType& idx) {
268 return customIndices2Array(idx, std::make_integer_sequence<Index, NumIndices>{});
278template <
typename Index,
typename T,
279 std::enable_if_t<std::is_integral<T>::value && std::is_integral<Index>::value,
bool> =
true>
280constexpr EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
bool index_fits(T index) {
281 return static_cast<T
>(
static_cast<Index
>(index)) == index &&
282 (numext::signbit(
static_cast<Index
>(index)) == Index(0)) == (numext::signbit(index) == T(0));
285template <
typename Index,
typename T,
286 std::enable_if_t<!(std::is_integral<T>::value && std::is_integral<Index>::value),
bool> =
true>
287constexpr EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
bool index_fits(
const T&) {
292template <
typename Index,
typename... IndexTypes>
293constexpr EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
bool indices_fit(IndexTypes... indices) {
294 return all(index_fits<Index>(indices)...);
Namespace containing all symbols from the Eigen library.