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