2014-04-28 10:32:27 -07:00
|
|
|
// This file is part of Eigen, a lightweight C++ template library
|
|
|
|
|
// for linear algebra.
|
|
|
|
|
//
|
|
|
|
|
// Copyright (C) 2014 Benoit Steiner <benoit.steiner.goog@gmail.com>
|
|
|
|
|
//
|
|
|
|
|
// This Source Code Form is subject to the terms of the Mozilla
|
|
|
|
|
// Public License v. 2.0. If a copy of the MPL was not distributed
|
|
|
|
|
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
|
|
|
|
|
|
#ifndef EIGEN_CXX11_TENSOR_TENSOR_FORWARD_DECLARATIONS_H
|
|
|
|
|
#define EIGEN_CXX11_TENSOR_TENSOR_FORWARD_DECLARATIONS_H
|
|
|
|
|
|
2023-08-21 16:25:22 +00:00
|
|
|
// IWYU pragma: private
|
2021-09-10 19:12:26 +00:00
|
|
|
#include "./InternalHeaderCheck.h"
|
|
|
|
|
|
2014-04-28 10:32:27 -07:00
|
|
|
namespace Eigen {
|
|
|
|
|
|
2018-06-07 14:43:02 +02:00
|
|
|
// MakePointer class is used as a container of the address space of the pointer
|
2016-09-19 12:44:13 +01:00
|
|
|
// on the host and on the device. From the host side it generates the T* pointer
|
|
|
|
|
// and when EIGEN_USE_SYCL is used it construct a buffer with a map_allocator to
|
|
|
|
|
// T* m_data on the host. It is always called on the device.
|
|
|
|
|
// Specialisation of MakePointer class for creating the sycl buffer with
|
|
|
|
|
// map_allocator.
|
2016-10-25 20:40:58 -07:00
|
|
|
template <typename T>
|
|
|
|
|
struct MakePointer {
|
|
|
|
|
typedef T* Type;
|
2019-08-28 17:46:05 -07:00
|
|
|
typedef const T* ConstType;
|
2016-09-19 12:44:13 +01:00
|
|
|
};
|
2017-06-28 17:55:23 +00:00
|
|
|
|
2019-06-28 10:08:23 +01:00
|
|
|
template <typename T>
|
2019-07-02 20:02:46 +00:00
|
|
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T* constCast(const T* data) {
|
2019-06-28 10:08:23 +01:00
|
|
|
return const_cast<T*>(data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// The StorageMemory class is a container of the device specific pointer
|
2021-09-22 16:15:06 +00:00
|
|
|
// used for referring to a Pointer on TensorEvaluator class. While the TensorExpression
|
2018-08-16 00:07:02 +01:00
|
|
|
// is a device-agnostic type and need MakePointer class for type conversion,
|
2019-06-28 10:08:23 +01:00
|
|
|
// the TensorEvaluator class can be specialized for a device, hence it is possible
|
2024-08-02 00:06:24 +00:00
|
|
|
// to construct different types of temporary storage memory in TensorEvaluator
|
2019-06-28 10:08:23 +01:00
|
|
|
// for different devices by specializing the following StorageMemory class.
|
|
|
|
|
template <typename T, typename device>
|
|
|
|
|
struct StorageMemory : MakePointer<T> {};
|
2018-08-16 00:07:02 +01:00
|
|
|
|
2017-06-28 17:55:23 +00:00
|
|
|
namespace internal {
|
|
|
|
|
template <typename A, typename B>
|
|
|
|
|
struct Pointer_type_promotion {
|
2026-04-01 17:49:56 -07:00
|
|
|
static constexpr bool val = false;
|
2017-06-28 17:55:23 +00:00
|
|
|
};
|
|
|
|
|
template <typename A>
|
|
|
|
|
struct Pointer_type_promotion<A, A> {
|
2026-04-01 17:49:56 -07:00
|
|
|
static constexpr bool val = true;
|
2017-06-28 17:55:23 +00:00
|
|
|
};
|
2019-06-28 10:08:23 +01:00
|
|
|
template <typename A, typename B>
|
|
|
|
|
struct TypeConversion {
|
2017-06-28 17:55:23 +00:00
|
|
|
typedef A* type;
|
|
|
|
|
};
|
2016-11-25 16:19:07 +00:00
|
|
|
} // namespace internal
|
2023-11-29 11:12:48 +00:00
|
|
|
|
2016-09-19 12:44:13 +01:00
|
|
|
template <typename PlainObjectType, int Options_ = Unaligned, template <class> class MakePointer_ = MakePointer>
|
|
|
|
|
class TensorMap;
|
2015-12-04 10:15:11 -08:00
|
|
|
template <typename Scalar_, int NumIndices_, int Options_ = 0, typename IndexType = DenseIndex>
|
|
|
|
|
class Tensor;
|
2016-10-26 18:47:37 -07:00
|
|
|
template <typename Scalar_, typename Dimensions, int Options_ = 0, typename IndexType = DenseIndex>
|
|
|
|
|
class TensorFixedSize;
|
2014-10-28 23:10:13 -07:00
|
|
|
template <typename PlainObjectType>
|
|
|
|
|
class TensorRef;
|
2016-07-04 12:49:19 +02:00
|
|
|
template <typename Derived, int AccessLevel>
|
|
|
|
|
class TensorBase;
|
2023-11-29 11:12:48 +00:00
|
|
|
|
2014-05-22 16:22:35 -07:00
|
|
|
template <typename NullaryOp, typename PlainObjectType>
|
|
|
|
|
class TensorCwiseNullaryOp;
|
2014-04-28 10:32:27 -07:00
|
|
|
template <typename UnaryOp, typename XprType>
|
|
|
|
|
class TensorCwiseUnaryOp;
|
|
|
|
|
template <typename BinaryOp, typename LeftXprType, typename RightXprType>
|
|
|
|
|
class TensorCwiseBinaryOp;
|
2016-06-02 17:04:19 -07:00
|
|
|
template <typename TernaryOp, typename Arg1XprType, typename Arg2XprType, typename Arg3XprType>
|
|
|
|
|
class TensorCwiseTernaryOp;
|
2014-05-22 16:22:35 -07:00
|
|
|
template <typename IfXprType, typename ThenXprType, typename ElseXprType>
|
|
|
|
|
class TensorSelectOp;
|
2016-11-04 18:18:19 +00:00
|
|
|
template <typename Op, typename Dims, typename XprType, template <class> class MakePointer_ = MakePointer>
|
|
|
|
|
class TensorReductionOp;
|
2021-08-26 12:25:31 -07:00
|
|
|
template <typename XprType>
|
|
|
|
|
class TensorIndexPairOp;
|
|
|
|
|
template <typename ReduceOp, typename Dims, typename XprType>
|
|
|
|
|
class TensorPairReducerOp;
|
2014-10-01 20:38:22 -07:00
|
|
|
template <typename Axis, typename LeftXprType, typename RightXprType>
|
|
|
|
|
class TensorConcatenationOp;
|
2018-07-10 13:16:38 -07:00
|
|
|
template <typename Dimensions, typename LeftXprType, typename RightXprType, typename OutputKernelType>
|
|
|
|
|
class TensorContractionOp;
|
2015-02-27 08:46:04 -08:00
|
|
|
template <typename TargetType, typename XprType>
|
|
|
|
|
class TensorConversionOp;
|
2014-06-06 16:25:16 -07:00
|
|
|
template <typename Dimensions, typename InputXprType, typename KernelXprType>
|
|
|
|
|
class TensorConvolutionOp;
|
2015-10-22 16:54:21 -07:00
|
|
|
template <typename FFT, typename XprType, int FFTDataType, int FFTDirection>
|
|
|
|
|
class TensorFFTOp;
|
2014-10-13 10:04:04 -07:00
|
|
|
template <typename PatchDim, typename XprType>
|
|
|
|
|
class TensorPatchOp;
|
2014-11-13 09:28:54 -08:00
|
|
|
template <DenseIndex Rows, DenseIndex Cols, typename XprType>
|
|
|
|
|
class TensorImagePatchOp;
|
2015-06-30 14:48:26 -07:00
|
|
|
template <DenseIndex Planes, DenseIndex Rows, DenseIndex Cols, typename XprType>
|
|
|
|
|
class TensorVolumePatchOp;
|
2014-10-10 16:11:27 -07:00
|
|
|
template <typename Broadcast, typename XprType>
|
|
|
|
|
class TensorBroadcastingOp;
|
2015-01-14 15:38:48 -08:00
|
|
|
template <DenseIndex DimId, typename XprType>
|
|
|
|
|
class TensorChippingOp;
|
2014-06-06 16:25:16 -07:00
|
|
|
template <typename NewDimensions, typename XprType>
|
|
|
|
|
class TensorReshapingOp;
|
2015-01-14 15:38:48 -08:00
|
|
|
template <typename XprType>
|
|
|
|
|
class TensorLayoutSwapOp;
|
2014-07-07 14:10:36 -07:00
|
|
|
template <typename StartIndices, typename Sizes, typename XprType>
|
|
|
|
|
class TensorSlicingOp;
|
2015-01-14 15:38:48 -08:00
|
|
|
template <typename ReverseDimensions, typename XprType>
|
|
|
|
|
class TensorReverseOp;
|
2024-11-05 14:10:19 +00:00
|
|
|
template <typename Rolls, typename XprType>
|
|
|
|
|
class TensorRollOp;
|
2014-08-14 00:22:47 -07:00
|
|
|
template <typename PaddingDimensions, typename XprType>
|
|
|
|
|
class TensorPaddingOp;
|
|
|
|
|
template <typename Shuffle, typename XprType>
|
|
|
|
|
class TensorShufflingOp;
|
|
|
|
|
template <typename Strides, typename XprType>
|
|
|
|
|
class TensorStridingOp;
|
2016-05-27 12:22:25 -07:00
|
|
|
template <typename StartIndices, typename StopIndices, typename Strides, typename XprType>
|
|
|
|
|
class TensorStridingSlicingOp;
|
2015-07-16 09:04:05 -07:00
|
|
|
template <typename Strides, typename XprType>
|
|
|
|
|
class TensorInflationOp;
|
2015-04-22 11:14:58 -07:00
|
|
|
template <typename Generator, typename XprType>
|
|
|
|
|
class TensorGeneratorOp;
|
2014-06-13 09:56:51 -07:00
|
|
|
template <typename LeftXprType, typename RightXprType>
|
|
|
|
|
class TensorAssignOp;
|
2016-06-02 13:35:47 +01:00
|
|
|
template <typename Op, typename XprType>
|
|
|
|
|
class TensorScanOp;
|
2017-07-07 04:18:03 +00:00
|
|
|
template <typename Dims, typename XprType>
|
|
|
|
|
class TensorTraceOp;
|
2023-11-29 11:12:48 +00:00
|
|
|
|
2015-06-30 15:36:29 -07:00
|
|
|
template <typename CustomUnaryFunc, typename XprType>
|
|
|
|
|
class TensorCustomUnaryOp;
|
|
|
|
|
template <typename CustomBinaryFunc, typename LhsXprType, typename RhsXprType>
|
|
|
|
|
class TensorCustomBinaryOp;
|
2023-11-29 11:12:48 +00:00
|
|
|
|
2016-09-19 12:44:13 +01:00
|
|
|
template <typename XprType, template <class> class MakePointer_ = MakePointer>
|
|
|
|
|
class TensorEvalToOp;
|
2017-01-16 13:58:49 +00:00
|
|
|
template <typename XprType>
|
|
|
|
|
class TensorForcedEvalOp;
|
2023-11-29 11:12:48 +00:00
|
|
|
|
2014-06-10 09:14:44 -07:00
|
|
|
template <typename ExpressionType, typename DeviceType>
|
|
|
|
|
class TensorDevice;
|
2019-09-03 17:20:56 -07:00
|
|
|
template <typename ExpressionType, typename DeviceType, typename DoneCallback>
|
|
|
|
|
class TensorAsyncDevice;
|
2014-06-10 09:14:44 -07:00
|
|
|
template <typename Derived, typename Device>
|
|
|
|
|
struct TensorEvaluator;
|
2014-04-28 10:32:27 -07:00
|
|
|
|
2018-08-06 13:16:32 -07:00
|
|
|
struct NoOpOutputKernel;
|
2018-07-10 13:16:38 -07:00
|
|
|
|
2015-07-06 15:03:11 -07:00
|
|
|
struct DefaultDevice;
|
|
|
|
|
struct ThreadPoolDevice;
|
|
|
|
|
struct GpuDevice;
|
2016-09-19 12:44:13 +01:00
|
|
|
struct SyclDevice;
|
2015-07-01 11:32:04 -07:00
|
|
|
|
2019-06-28 10:08:23 +01:00
|
|
|
#ifdef EIGEN_USE_SYCL
|
|
|
|
|
namespace TensorSycl {
|
|
|
|
|
namespace internal {
|
2019-11-28 10:08:54 +00:00
|
|
|
template <typename Evaluator, typename Op>
|
|
|
|
|
class GenericNondeterministicReducer;
|
2019-06-28 10:08:23 +01:00
|
|
|
}
|
|
|
|
|
} // namespace TensorSycl
|
|
|
|
|
#endif
|
|
|
|
|
|
2015-10-22 16:54:21 -07:00
|
|
|
enum FFTResultType { RealPart = 0, ImagPart = 1, BothParts = 2 };
|
2019-06-28 10:08:23 +01:00
|
|
|
|
2015-10-22 16:54:21 -07:00
|
|
|
enum FFTDirection { FFT_FORWARD = 0, FFT_REVERSE = 1 };
|
|
|
|
|
|
2014-06-09 09:45:30 -07:00
|
|
|
namespace internal {
|
2015-07-01 11:32:04 -07:00
|
|
|
|
|
|
|
|
template <typename Device, typename Expression>
|
|
|
|
|
struct IsVectorizable {
|
2026-04-01 17:49:56 -07:00
|
|
|
static constexpr bool value = TensorEvaluator<Expression, Device>::PacketAccess;
|
2015-07-01 11:32:04 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
template <typename Expression>
|
|
|
|
|
struct IsVectorizable<GpuDevice, Expression> {
|
2026-04-01 17:49:56 -07:00
|
|
|
static constexpr bool value =
|
2015-07-01 11:32:04 -07:00
|
|
|
TensorEvaluator<Expression, GpuDevice>::PacketAccess && TensorEvaluator<Expression, GpuDevice>::IsAligned;
|
|
|
|
|
};
|
|
|
|
|
|
2019-09-24 12:52:45 -07:00
|
|
|
// Tiled evaluation strategy.
|
|
|
|
|
enum TiledEvaluation {
|
|
|
|
|
Off = 0, // tiled evaluation is not supported
|
2019-12-10 15:40:23 -08:00
|
|
|
On = 1, // still work in progress (see TensorBlock.h)
|
2019-09-24 12:52:45 -07:00
|
|
|
};
|
|
|
|
|
|
2018-07-25 13:51:10 -07:00
|
|
|
template <typename Device, typename Expression>
|
|
|
|
|
struct IsTileable {
|
2018-08-10 16:53:36 -07:00
|
|
|
// Check that block evaluation is supported and it's a preferred option (at
|
|
|
|
|
// least one sub-expression has much faster block evaluation, e.g.
|
|
|
|
|
// broadcasting).
|
2022-04-04 17:33:33 +00:00
|
|
|
static constexpr bool BlockAccess =
|
2019-09-24 12:52:45 -07:00
|
|
|
TensorEvaluator<Expression, Device>::BlockAccess && TensorEvaluator<Expression, Device>::PreferBlockAccess;
|
|
|
|
|
|
2026-04-01 17:49:56 -07:00
|
|
|
static constexpr TiledEvaluation value = BlockAccess ? TiledEvaluation::On : TiledEvaluation::Off;
|
2018-07-25 13:51:10 -07:00
|
|
|
};
|
|
|
|
|
|
2019-09-24 12:52:45 -07:00
|
|
|
template <typename Expression, typename Device, bool Vectorizable = IsVectorizable<Device, Expression>::value,
|
|
|
|
|
TiledEvaluation Tiling = IsTileable<Device, Expression>::value>
|
|
|
|
|
class TensorExecutor;
|
2015-07-01 11:32:04 -07:00
|
|
|
|
2019-09-03 17:20:56 -07:00
|
|
|
template <typename Expression, typename Device, typename DoneCallback,
|
2019-08-30 14:49:40 -07:00
|
|
|
bool Vectorizable = IsVectorizable<Device, Expression>::value,
|
2019-10-22 12:42:44 -07:00
|
|
|
TiledEvaluation Tiling = IsTileable<Device, Expression>::value>
|
2019-08-30 14:49:40 -07:00
|
|
|
class TensorAsyncExecutor;
|
|
|
|
|
|
2014-06-09 09:45:30 -07:00
|
|
|
} // end namespace internal
|
|
|
|
|
|
2014-04-28 10:32:27 -07:00
|
|
|
} // end namespace Eigen
|
|
|
|
|
|
|
|
|
|
#endif // EIGEN_CXX11_TENSOR_TENSOR_FORWARD_DECLARATIONS_H
|