TensorForwardDeclarations.h
Go to the documentation of this file.
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 namespace TensorSycl {
111 namespace internal{
112 template <typename Evaluator, typename Op> class GenericNondeterministicReducer;
113 }
114 }
115 #endif
116 
117 
119  RealPart = 0,
120  ImagPart = 1,
121  BothParts = 2
122 };
123 
126  FFT_REVERSE = 1
127 };
128 
129 
130 namespace internal {
131 
132 template <typename Device, typename Expression>
133 struct IsVectorizable {
134  static const bool value = TensorEvaluator<Expression, Device>::PacketAccess;
135 };
136 
137 template <typename Expression>
138 struct IsVectorizable<GpuDevice, Expression> {
139  static const bool value = TensorEvaluator<Expression, GpuDevice>::PacketAccess &&
141 };
142 
143 // Tiled evaluation strategy.
145  Off = 0, // tiled evaluation is not supported
146  On = 1, // still work in progress (see TensorBlock.h)
147 };
148 
149 template <typename Device, typename Expression>
150 struct IsTileable {
151  // Check that block evaluation is supported and it's a preferred option (at
152  // least one sub-expression has much faster block evaluation, e.g.
153  // broadcasting).
154  static constexpr bool BlockAccess =
157 
158  static const TiledEvaluation value =
160 };
161 
162 template <typename Expression, typename Device,
163  bool Vectorizable = IsVectorizable<Device, Expression>::value,
164  TiledEvaluation Tiling = IsTileable<Device, Expression>::value>
165 class TensorExecutor;
166 
167 template <typename Expression, typename Device, typename DoneCallback,
168  bool Vectorizable = IsVectorizable<Device, Expression>::value,
169  TiledEvaluation Tiling = IsTileable<Device, Expression>::value>
170 class TensorAsyncExecutor;
171 
172 
173 } // end namespace internal
174 
175 } // end namespace Eigen
176 
177 #endif // EIGEN_CXX11_TENSOR_TENSOR_FORWARD_DECLARATIONS_H
SparseMatrix< double > A(n, n)
#define EIGEN_DEVICE_FUNC
int data[]
Pseudo expression providing an operator = that will evaluate its argument asynchronously on the speci...
Definition: TensorDevice.h:85
The tensor base class.
Tensor concatenation class.
Tensor conversion class. This class makes it possible to vectorize type casting operations when the n...
Tensor custom class.
Tensor custom class.
Pseudo expression providing an operator = that will evaluate its argument on the specified computing ...
Definition: TensorDevice.h:29
Tensor generator class.
The tensor executor class.
: TensorContractionSycl.h, provides various tensor contraction kernel for SYCL backend
T * constCast(const T *data)
A cost model used to limit the number of threads used for evaluating tensor expression.