Eigen-unsupported  3.4.90 (git rev 67eeba6e720c5745abc77ae6c92ce0a44aa7b7ae)
TensorForwardDeclarations.h
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2014 Benoit Steiner <benoit.steiner.goog@gmail.com>
5 //
6 // This Source Code Form is subject to the terms of the Mozilla
7 // Public License v. 2.0. If a copy of the MPL was not distributed
8 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 
10 #ifndef EIGEN_CXX11_TENSOR_TENSOR_FORWARD_DECLARATIONS_H
11 #define EIGEN_CXX11_TENSOR_TENSOR_FORWARD_DECLARATIONS_H
12 
13 #include "./InternalHeaderCheck.h"
14 
15 namespace Eigen {
16 
17 // MakePointer class is used as a container of the address space of the pointer
18 // on the host and on the device. From the host side it generates the T* pointer
19 // and when EIGEN_USE_SYCL is used it construct a buffer with a map_allocator to
20 // T* m_data on the host. It is always called on the device.
21 // Specialisation of MakePointer class for creating the sycl buffer with
22 // map_allocator.
23 template<typename T> struct MakePointer {
24  typedef T* Type;
25  typedef const T* ConstType;
26 };
27 
28 template <typename T>
29 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T* constCast(const T* data) {
30  return const_cast<T*>(data);
31 }
32 
33 // The StorageMemory class is a container of the device specific pointer
34 // used for referring to a Pointer on TensorEvaluator class. While the TensorExpression
35 // is a device-agnostic type and need MakePointer class for type conversion,
36 // the TensorEvaluator class can be specialized for a device, hence it is possible
37 // to construct different types of temproray storage memory in TensorEvaluator
38 // for different devices by specializing the following StorageMemory class.
39 template<typename T, typename device> struct StorageMemory: MakePointer <T> {};
40 
41 namespace internal{
42 template<typename A, typename B> struct Pointer_type_promotion {
43  static const bool val=false;
44 };
45 template<typename A> struct Pointer_type_promotion<A, A> {
46  static const bool val = true;
47 };
48 template<typename A, typename B> struct TypeConversion {
49  typedef A* type;
50 };
51 }
52 
53 
54 template<typename PlainObjectType, int Options_ = Unaligned, template <class> class MakePointer_ = MakePointer> class TensorMap;
55 template<typename Scalar_, int NumIndices_, int Options_ = 0, typename IndexType = DenseIndex> class Tensor;
56 template<typename Scalar_, typename Dimensions, int Options_ = 0, typename IndexType = DenseIndex> class TensorFixedSize;
57 template<typename PlainObjectType> class TensorRef;
58 template<typename Derived, int AccessLevel> class TensorBase;
59 
60 template<typename NullaryOp, typename PlainObjectType> class TensorCwiseNullaryOp;
61 template<typename UnaryOp, typename XprType> class TensorCwiseUnaryOp;
62 template<typename BinaryOp, typename LeftXprType, typename RightXprType> class TensorCwiseBinaryOp;
63 template<typename TernaryOp, typename Arg1XprType, typename Arg2XprType, typename Arg3XprType> class TensorCwiseTernaryOp;
64 template<typename IfXprType, typename ThenXprType, typename ElseXprType> class TensorSelectOp;
65 template<typename Op, typename Dims, typename XprType, template <class> class MakePointer_ = MakePointer > class TensorReductionOp;
66 template<typename XprType> class TensorIndexPairOp;
67 template<typename ReduceOp, typename Dims, typename XprType> class TensorPairReducerOp;
68 template<typename Axis, typename LeftXprType, typename RightXprType> class TensorConcatenationOp;
69 template<typename Dimensions, typename LeftXprType, typename RightXprType, typename OutputKernelType> class TensorContractionOp;
70 template<typename TargetType, typename XprType> class TensorConversionOp;
71 template<typename Dimensions, typename InputXprType, typename KernelXprType> class TensorConvolutionOp;
72 template<typename FFT, typename XprType, int FFTDataType, int FFTDirection> class TensorFFTOp;
73 template<typename PatchDim, typename XprType> class TensorPatchOp;
74 template<DenseIndex Rows, DenseIndex Cols, typename XprType> class TensorImagePatchOp;
75 template<DenseIndex Planes, DenseIndex Rows, DenseIndex Cols, typename XprType> class TensorVolumePatchOp;
76 template<typename Broadcast, typename XprType> class TensorBroadcastingOp;
77 template<DenseIndex DimId, typename XprType> class TensorChippingOp;
78 template<typename NewDimensions, typename XprType> class TensorReshapingOp;
79 template<typename XprType> class TensorLayoutSwapOp;
80 template<typename StartIndices, typename Sizes, typename XprType> class TensorSlicingOp;
81 template<typename ReverseDimensions, typename XprType> class TensorReverseOp;
82 template<typename PaddingDimensions, typename XprType> class TensorPaddingOp;
83 template<typename Shuffle, typename XprType> class TensorShufflingOp;
84 template<typename Strides, typename XprType> class TensorStridingOp;
85 template<typename StartIndices, typename StopIndices, typename Strides, typename XprType> class TensorStridingSlicingOp;
86 template<typename Strides, typename XprType> class TensorInflationOp;
87 template<typename Generator, typename XprType> class TensorGeneratorOp;
88 template<typename LeftXprType, typename RightXprType> class TensorAssignOp;
89 template<typename Op, typename XprType> class TensorScanOp;
90 template<typename Dims, typename XprType> class TensorTraceOp;
91 
92 template<typename CustomUnaryFunc, typename XprType> class TensorCustomUnaryOp;
93 template<typename CustomBinaryFunc, typename LhsXprType, typename RhsXprType> class TensorCustomBinaryOp;
94 
95 template<typename XprType, template <class> class MakePointer_ = MakePointer> class TensorEvalToOp;
96 template<typename XprType> class TensorForcedEvalOp;
97 
98 template<typename ExpressionType, typename DeviceType> class TensorDevice;
99 template<typename ExpressionType, typename DeviceType, typename DoneCallback> class TensorAsyncDevice;
100 template<typename Derived, typename Device> struct TensorEvaluator;
101 
102 struct NoOpOutputKernel;
103 
104 struct DefaultDevice;
105 struct ThreadPoolDevice;
106 struct GpuDevice;
107 struct SyclDevice;
108 
109 #ifdef EIGEN_USE_SYCL
110 
111 template <typename T> struct MakeSYCLPointer {
112  typedef Eigen::TensorSycl::internal::RangeAccess<cl::sycl::access::mode::read_write, T> Type;
113 };
114 
115 template <typename T>
116 EIGEN_STRONG_INLINE const Eigen::TensorSycl::internal::RangeAccess<cl::sycl::access::mode::read_write, T>&
117 constCast(const Eigen::TensorSycl::internal::RangeAccess<cl::sycl::access::mode::read_write, T>& data) {
118  return data;
119 }
120 
121 template <typename T>
122 struct StorageMemory<T, SyclDevice> : MakeSYCLPointer<T> {};
123 template <typename T>
124 struct StorageMemory<T, const SyclDevice> : StorageMemory<T, SyclDevice> {};
125 
126 namespace TensorSycl {
127 namespace internal{
128 template <typename Evaluator, typename Op> class GenericNondeterministicReducer;
129 }
130 }
131 #endif
132 
133 
134 enum FFTResultType {
135  RealPart = 0,
136  ImagPart = 1,
137  BothParts = 2
138 };
139 
140 enum FFTDirection {
141  FFT_FORWARD = 0,
142  FFT_REVERSE = 1
143 };
144 
145 
146 namespace internal {
147 
148 template <typename Device, typename Expression>
149 struct IsVectorizable {
150  static const bool value = TensorEvaluator<Expression, Device>::PacketAccess;
151 };
152 
153 template <typename Expression>
154 struct IsVectorizable<GpuDevice, Expression> {
155  static const bool value = TensorEvaluator<Expression, GpuDevice>::PacketAccess &&
156  TensorEvaluator<Expression, GpuDevice>::IsAligned;
157 };
158 
159 // Tiled evaluation strategy.
160 enum TiledEvaluation {
161  Off = 0, // tiled evaluation is not supported
162  On = 1, // still work in progress (see TensorBlock.h)
163 };
164 
165 template <typename Device, typename Expression>
166 struct IsTileable {
167  // Check that block evaluation is supported and it's a preferred option (at
168  // least one sub-expression has much faster block evaluation, e.g.
169  // broadcasting).
170  static constexpr bool BlockAccess =
171  TensorEvaluator<Expression, Device>::BlockAccess &&
172  TensorEvaluator<Expression, Device>::PreferBlockAccess;
173 
174  static const TiledEvaluation value =
175  BlockAccess ? TiledEvaluation::On : TiledEvaluation::Off;
176 };
177 
178 template <typename Expression, typename Device,
179  bool Vectorizable = IsVectorizable<Device, Expression>::value,
180  TiledEvaluation Tiling = IsTileable<Device, Expression>::value>
181 class TensorExecutor;
182 
183 template <typename Expression, typename Device, typename DoneCallback,
184  bool Vectorizable = IsVectorizable<Device, Expression>::value,
185  TiledEvaluation Tiling = IsTileable<Device, Expression>::value>
186 class TensorAsyncExecutor;
187 
188 
189 } // end namespace internal
190 
191 } // end namespace Eigen
192 
193 #endif // EIGEN_CXX11_TENSOR_TENSOR_FORWARD_DECLARATIONS_H
Pseudo expression providing an operator = that will evaluate its argument asynchronously on the speci...
Definition: TensorDevice.h:85
The tensor base class.
Definition: TensorForwardDeclarations.h:58
Tensor concatenation class.
Definition: TensorConcatenation.h:63
Tensor conversion class. This class makes it possible to vectorize type casting operations when the n...
Definition: TensorConversion.h:179
Tensor custom class.
Definition: TensorCustomOp.h:222
Tensor custom class.
Definition: TensorCustomOp.h:56
Pseudo expression providing an operator = that will evaluate its argument on the specified computing ...
Definition: TensorDevice.h:29
Tensor generator class.
Definition: TensorGenerator.h:57
The tensor executor class.
Namespace containing all symbols from the Eigen library.
A cost model used to limit the number of threads used for evaluating tensor expression.
Definition: TensorEvaluator.h:31