$darkmode
Eigen-unsupported  5.0.1-dev
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 // IWYU pragma: private
14 #include "./InternalHeaderCheck.h"
15 
16 namespace Eigen {
17 
18 // MakePointer class is used as a container of the address space of the pointer
19 // on the host and on the device. From the host side it generates the T* pointer
20 // and when EIGEN_USE_SYCL is used it construct a buffer with a map_allocator to
21 // T* m_data on the host. It is always called on the device.
22 // Specialisation of MakePointer class for creating the sycl buffer with
23 // map_allocator.
24 template <typename T>
25 struct MakePointer {
26  typedef T* Type;
27  typedef const T* ConstType;
28 };
29 
30 template <typename T>
31 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T* constCast(const T* data) {
32  return const_cast<T*>(data);
33 }
34 
35 // The StorageMemory class is a container of the device specific pointer
36 // used for referring to a Pointer on TensorEvaluator class. While the TensorExpression
37 // is a device-agnostic type and need MakePointer class for type conversion,
38 // the TensorEvaluator class can be specialized for a device, hence it is possible
39 // to construct different types of temporary storage memory in TensorEvaluator
40 // for different devices by specializing the following StorageMemory class.
41 template <typename T, typename device>
42 struct StorageMemory : MakePointer<T> {};
43 
44 namespace internal {
45 template <typename A, typename B>
46 struct Pointer_type_promotion {
47  static const bool val = false;
48 };
49 template <typename A>
50 struct Pointer_type_promotion<A, A> {
51  static const bool val = true;
52 };
53 template <typename A, typename B>
54 struct TypeConversion {
55  typedef A* type;
56 };
57 } // namespace internal
58 
59 template <typename PlainObjectType, int Options_ = Unaligned, template <class> class MakePointer_ = MakePointer>
60 class TensorMap;
61 template <typename Scalar_, int NumIndices_, int Options_ = 0, typename IndexType = DenseIndex>
62 class Tensor;
63 template <typename Scalar_, typename Dimensions, int Options_ = 0, typename IndexType = DenseIndex>
64 class TensorFixedSize;
65 template <typename PlainObjectType>
66 class TensorRef;
67 template <typename Derived, int AccessLevel>
68 class TensorBase;
69 
70 template <typename NullaryOp, typename PlainObjectType>
72 template <typename UnaryOp, typename XprType>
73 class TensorCwiseUnaryOp;
74 template <typename BinaryOp, typename LeftXprType, typename RightXprType>
76 template <typename TernaryOp, typename Arg1XprType, typename Arg2XprType, typename Arg3XprType>
77 class TensorCwiseTernaryOp;
78 template <typename IfXprType, typename ThenXprType, typename ElseXprType>
79 class TensorSelectOp;
80 template <typename Op, typename Dims, typename XprType, template <class> class MakePointer_ = MakePointer>
82 template <typename XprType>
83 class TensorIndexPairOp;
84 template <typename ReduceOp, typename Dims, typename XprType>
85 class TensorPairReducerOp;
86 template <typename Axis, typename LeftXprType, typename RightXprType>
88 template <typename Dimensions, typename LeftXprType, typename RightXprType, typename OutputKernelType>
90 template <typename TargetType, typename XprType>
91 class TensorConversionOp;
92 template <typename Dimensions, typename InputXprType, typename KernelXprType>
94 template <typename FFT, typename XprType, int FFTDataType, int FFTDirection>
95 class TensorFFTOp;
96 template <typename PatchDim, typename XprType>
98 template <DenseIndex Rows, DenseIndex Cols, typename XprType>
100 template <DenseIndex Planes, DenseIndex Rows, DenseIndex Cols, typename XprType>
102 template <typename Broadcast, typename XprType>
104 template <DenseIndex DimId, typename XprType>
105 class TensorChippingOp;
106 template <typename NewDimensions, typename XprType>
108 template <typename XprType>
109 class TensorLayoutSwapOp;
110 template <typename StartIndices, typename Sizes, typename XprType>
111 class TensorSlicingOp;
112 template <typename ReverseDimensions, typename XprType>
114 template <typename Rolls, typename XprType>
116 template <typename PaddingDimensions, typename XprType>
118 template <typename Shuffle, typename XprType>
120 template <typename Strides, typename XprType>
122 template <typename StartIndices, typename StopIndices, typename Strides, typename XprType>
123 class TensorStridingSlicingOp;
124 template <typename Strides, typename XprType>
126 template <typename Generator, typename XprType>
128 template <typename LeftXprType, typename RightXprType>
129 class TensorAssignOp;
130 template <typename Op, typename XprType>
132 template <typename Dims, typename XprType>
134 
135 template <typename CustomUnaryFunc, typename XprType>
136 class TensorCustomUnaryOp;
137 template <typename CustomBinaryFunc, typename LhsXprType, typename RhsXprType>
139 
140 template <typename XprType, template <class> class MakePointer_ = MakePointer>
141 class TensorEvalToOp;
142 template <typename XprType>
143 class TensorForcedEvalOp;
144 
145 template <typename ExpressionType, typename DeviceType>
146 class TensorDevice;
147 template <typename ExpressionType, typename DeviceType, typename DoneCallback>
148 class TensorAsyncDevice;
149 template <typename Derived, typename Device>
150 struct TensorEvaluator;
151 
152 struct NoOpOutputKernel;
153 
154 struct DefaultDevice;
155 struct ThreadPoolDevice;
156 struct GpuDevice;
157 struct SyclDevice;
158 
159 #ifdef EIGEN_USE_SYCL
160 namespace TensorSycl {
161 namespace internal {
162 template <typename Evaluator, typename Op>
163 class GenericNondeterministicReducer;
164 }
165 } // namespace TensorSycl
166 #endif
167 
168 enum FFTResultType { RealPart = 0, ImagPart = 1, BothParts = 2 };
169 
170 enum FFTDirection { FFT_FORWARD = 0, FFT_REVERSE = 1 };
171 
172 namespace internal {
173 
174 template <typename Device, typename Expression>
175 struct IsVectorizable {
176  static const bool value = TensorEvaluator<Expression, Device>::PacketAccess;
177 };
178 
179 template <typename Expression>
180 struct IsVectorizable<GpuDevice, Expression> {
181  static const bool value =
182  TensorEvaluator<Expression, GpuDevice>::PacketAccess && TensorEvaluator<Expression, GpuDevice>::IsAligned;
183 };
184 
185 // Tiled evaluation strategy.
186 enum TiledEvaluation {
187  Off = 0, // tiled evaluation is not supported
188  On = 1, // still work in progress (see TensorBlock.h)
189 };
190 
191 template <typename Device, typename Expression>
192 struct IsTileable {
193  // Check that block evaluation is supported and it's a preferred option (at
194  // least one sub-expression has much faster block evaluation, e.g.
195  // broadcasting).
196  static constexpr bool BlockAccess =
197  TensorEvaluator<Expression, Device>::BlockAccess && TensorEvaluator<Expression, Device>::PreferBlockAccess;
198 
199  static const TiledEvaluation value = BlockAccess ? TiledEvaluation::On : TiledEvaluation::Off;
200 };
201 
202 template <typename Expression, typename Device, bool Vectorizable = IsVectorizable<Device, Expression>::value,
203  TiledEvaluation Tiling = IsTileable<Device, Expression>::value>
204 class TensorExecutor;
205 
206 template <typename Expression, typename Device, typename DoneCallback,
207  bool Vectorizable = IsVectorizable<Device, Expression>::value,
208  TiledEvaluation Tiling = IsTileable<Device, Expression>::value>
209 class TensorAsyncExecutor;
210 
211 } // end namespace internal
212 
213 } // end namespace Eigen
214 
215 #endif // EIGEN_CXX11_TENSOR_TENSOR_FORWARD_DECLARATIONS_H
Tensor FFT class.
Definition: TensorFFT.h:101
Tensor custom class.
Definition: TensorCustomOp.h:49
Tensor + Index Pair class.
Definition: TensorArgMax.h:50
Tensor binary expression.
Definition: TensorExpr.h:170
Tensor scan class.
Definition: TensorForwardDeclarations.h:131
Tensor unary expression.
Definition: TensorExpr.h:98
Tensor custom class.
Definition: TensorCustomOp.h:192
Tensor reshaping class.
Definition: TensorForwardDeclarations.h:107
Tensor generator class.
Definition: TensorForwardDeclarations.h:127
Tensor inflation class.
Definition: TensorForwardDeclarations.h:125
Tensor striding class.
Definition: TensorForwardDeclarations.h:121
Tensor padding class. At the moment only padding with a constant value is supported.
Definition: TensorForwardDeclarations.h:117
Tensor reshaping class.
Definition: TensorForcedEval.h:55
Namespace containing all symbols from the Eigen library.
The tensor evaluator class.
Definition: TensorEvaluator.h:30
Pseudo expression providing an operator = that will evaluate its argument on the specified computing ...
Definition: TensorDevice.h:30
Definition: TensorAssign.h:55
Definition: TensorChipping.h:65
Patch extraction specialized for image processing. This assumes that the input has a least 3 dimensio...
Definition: TensorForwardDeclarations.h:99
Tensor reverse elements class.
Definition: TensorForwardDeclarations.h:113
A tensor expression mapping an existing array of data.
Definition: TensorForwardDeclarations.h:60
Patch extraction specialized for processing of volumetric data. This assumes that the input has a lea...
Definition: TensorForwardDeclarations.h:101
Tensor roll (circular shift) elements class.
Definition: TensorForwardDeclarations.h:115
Tensor shuffling class.
Definition: TensorForwardDeclarations.h:119
Definition: TensorBroadcasting.h:66
Tensor conversion class. This class makes it possible to vectorize type casting operations when the n...
Definition: TensorConversion.h:166
Definition: TensorContraction.h:302
Tensor reduction class.
Definition: TensorForwardDeclarations.h:81
The fixed sized version of the tensor class.
Definition: TensorFixedSize.h:29
The tensor base class.
Definition: TensorForwardDeclarations.h:68
Pseudo expression providing an operator = that will evaluate its argument asynchronously on the speci...
Definition: TensorDevice.h:87
Definition: TensorConvolution.h:231
Tensor patch class.
Definition: TensorForwardDeclarations.h:97
Tensor nullary expression.
Definition: TensorExpr.h:42
Tensor Trace class.
Definition: TensorForwardDeclarations.h:133
A reference to a tensor expression The expression will be evaluated lazily (as much as possible)...
Definition: TensorForwardDeclarations.h:66
Tensor concatenation class.
Definition: TensorConcatenation.h:58
The tensor class.
Definition: Tensor.h:68