10 #ifndef EIGEN_CXX11_TENSOR_TENSOR_CUSTOM_OP_H
11 #define EIGEN_CXX11_TENSOR_TENSOR_CUSTOM_OP_H
26 template <
typename CustomUnaryFunc,
typename XprType>
31 typedef typename XprType::Nested
Nested;
32 typedef std::remove_reference_t<Nested>
Nested_;
38 template <
typename CustomUnaryFunc,
typename XprType>
43 template <
typename CustomUnaryFunc,
typename XprType>
50 template <
typename CustomUnaryFunc,
typename XprType>
73 template <
typename CustomUnaryFunc,
typename XprType,
typename Device>
79 typedef std::remove_const_t<typename ArgType::Scalar>
Scalar;
92 PreferBlockAccess =
false,
102 : m_op(
op),
m_device(device), m_result(NULL) {
103 m_dimensions =
op.func().dimensions(
op.expression());
129 template <
int LoadMode>
131 return internal::ploadt<PacketReturnType, LoadMode>(m_result + index);
144 m_op.func().eval(m_op.expression(), result,
m_device);
161 template <
typename CustomBinaryFunc,
typename LhsXprType,
typename RhsXprType>
181 template <
typename CustomBinaryFunc,
typename LhsXprType,
typename RhsXprType>
186 template <
typename CustomBinaryFunc,
typename LhsXprType,
typename RhsXprType>
193 template <
typename CustomBinaryFunc,
typename LhsXprType,
typename RhsXprType>
195 :
public TensorBase<TensorCustomBinaryOp<CustomBinaryFunc, LhsXprType, RhsXprType>, ReadOnlyAccessors> {
205 const CustomBinaryFunc&
func)
226 template <
typename CustomBinaryFunc,
typename LhsXprType,
typename RhsXprType,
typename Device>
246 PreferBlockAccess =
false,
256 : m_op(
op),
m_device(device), m_result(NULL) {
257 m_dimensions =
op.func().dimensions(
op.lhsExpression(),
op.rhsExpression());
275 if (m_result != NULL) {
283 template <
int LoadMode>
285 return internal::ploadt<PacketReturnType, LoadMode>(m_result + index);
298 m_op.func().eval(m_op.lhsExpression(), m_op.rhsExpression(), result,
m_device);
#define EIGEN_DEVICE_FUNC
Definition: Macros.h:892
#define EIGEN_STRONG_INLINE
Definition: Macros.h:834
#define EIGEN_DEVICE_REF
Definition: TensorMacros.h:34
SCALAR Scalar
Definition: bench_gemm.cpp:45
Generic expression where a coefficient-wise binary operator is applied to two expressions.
Definition: CwiseBinaryOp.h:79
The tensor base class.
Definition: TensorBase.h:1026
Tensor custom class.
Definition: TensorCustomOp.h:195
internal::traits< TensorCustomBinaryOp >::StorageKind StorageKind
Definition: TensorCustomOp.h:201
const CustomBinaryFunc m_func
Definition: TensorCustomOp.h:222
internal::traits< TensorCustomBinaryOp >::CoeffReturnType CoeffReturnType
Definition: TensorCustomOp.h:199
internal::traits< TensorCustomBinaryOp >::Index Index
Definition: TensorCustomOp.h:202
EIGEN_DEVICE_FUNC const internal::remove_all_t< typename RhsXprType::Nested > & rhsExpression() const
Definition: TensorCustomOp.h:215
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorCustomBinaryOp(const LhsXprType &lhs, const RhsXprType &rhs, const CustomBinaryFunc &func)
Definition: TensorCustomOp.h:204
Eigen::NumTraits< Scalar >::Real RealScalar
Definition: TensorCustomOp.h:198
EIGEN_DEVICE_FUNC const internal::remove_all_t< typename LhsXprType::Nested > & lhsExpression() const
Definition: TensorCustomOp.h:211
EIGEN_DEVICE_FUNC const CustomBinaryFunc & func() const
Definition: TensorCustomOp.h:209
LhsXprType::Nested m_lhs_xpr
Definition: TensorCustomOp.h:220
RhsXprType::Nested m_rhs_xpr
Definition: TensorCustomOp.h:221
internal::nested< TensorCustomBinaryOp >::type Nested
Definition: TensorCustomOp.h:200
internal::traits< TensorCustomBinaryOp >::Scalar Scalar
Definition: TensorCustomOp.h:197
Tensor custom class.
Definition: TensorCustomOp.h:51
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorCustomUnaryOp(const XprType &expr, const CustomUnaryFunc &func)
Definition: TensorCustomOp.h:60
internal::traits< TensorCustomUnaryOp >::Index Index
Definition: TensorCustomOp.h:58
EIGEN_DEVICE_FUNC const CustomUnaryFunc & func() const
Definition: TensorCustomOp.h:63
Eigen::NumTraits< Scalar >::Real RealScalar
Definition: TensorCustomOp.h:54
const CustomUnaryFunc m_func
Definition: TensorCustomOp.h:69
XprType::Nested m_expr
Definition: TensorCustomOp.h:68
EIGEN_DEVICE_FUNC const internal::remove_all_t< typename XprType::Nested > & expression() const
Definition: TensorCustomOp.h:65
XprType::CoeffReturnType CoeffReturnType
Definition: TensorCustomOp.h:55
internal::traits< TensorCustomUnaryOp >::StorageKind StorageKind
Definition: TensorCustomOp.h:57
internal::traits< TensorCustomUnaryOp >::Scalar Scalar
Definition: TensorCustomOp.h:53
internal::nested< TensorCustomUnaryOp >::type Nested
Definition: TensorCustomOp.h:56
A tensor expression mapping an existing array of data.
Definition: TensorMap.h:33
Definition: TensorCostModel.h:28
Definition: TensorBlock.h:566
Eigen::DenseIndex ret
Definition: level1_cplx_impl.h:43
char char * op
Definition: level2_impl.h:374
typename remove_all< T >::type remove_all_t
Definition: Meta.h:142
Namespace containing all symbols from the Eigen library.
Definition: bench_norm.cpp:70
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:83
val
Definition: calibrate.py:119
type
Definition: compute_granudrum_aor.py:141
Definition: Eigen_Colamd.h:49
Definition: Constants.h:519
T Real
Definition: NumTraits.h:183
Definition: TensorMeta.h:47
Definition: TensorForwardDeclarations.h:42
Storage::Type EvaluatorPointerType
Definition: TensorCustomOp.h:239
StorageMemory< CoeffReturnType, Device > Storage
Definition: TensorCustomOp.h:238
internal::traits< XprType >::Index Index
Definition: TensorCustomOp.h:229
EIGEN_STRONG_INLINE bool evalSubExprsIfNeeded(EvaluatorPointerType data)
Definition: TensorCustomOp.h:262
Dimensions m_dimensions
Definition: TensorCustomOp.h:301
XprType::Scalar Scalar
Definition: TensorCustomOp.h:232
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorOpCost costPerCoeff(bool vectorized) const
Definition: TensorCustomOp.h:288
const Device EIGEN_DEVICE_REF m_device
Definition: TensorCustomOp.h:303
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Dimensions & dimensions() const
Definition: TensorCustomOp.h:260
EvaluatorPointerType m_result
Definition: TensorCustomOp.h:304
std::remove_const_t< typename XprType::CoeffReturnType > CoeffReturnType
Definition: TensorCustomOp.h:233
Eigen::internal::traits< XprType >::PointerType TensorPointerType
Definition: TensorCustomOp.h:237
EIGEN_STRONG_INLINE void cleanup()
Definition: TensorCustomOp.h:274
void evalTo(EvaluatorPointerType data)
Definition: TensorCustomOp.h:296
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index) const
Definition: TensorCustomOp.h:281
DSizes< Index, NumDims > Dimensions
Definition: TensorCustomOp.h:231
PacketType< CoeffReturnType, Device >::type PacketReturnType
Definition: TensorCustomOp.h:234
EIGEN_DEVICE_FUNC EvaluatorPointerType data() const
Definition: TensorCustomOp.h:293
EIGEN_STRONG_INLINE TensorEvaluator(const XprType &op, const Device &device)
Definition: TensorCustomOp.h:255
const XprType m_op
Definition: TensorCustomOp.h:302
internal::TensorBlockNotImplemented TensorBlock
Definition: TensorCustomOp.h:252
TensorCustomBinaryOp< CustomBinaryFunc, LhsXprType, RhsXprType > XprType
Definition: TensorCustomOp.h:228
EIGEN_DEVICE_FUNC PacketReturnType packet(Index index) const
Definition: TensorCustomOp.h:284
const ArgType m_op
Definition: TensorCustomOp.h:148
void evalTo(EvaluatorPointerType data)
Definition: TensorCustomOp.h:142
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index) const
Definition: TensorCustomOp.h:127
Eigen::internal::traits< XprType >::PointerType TensorPointerType
Definition: TensorCustomOp.h:83
std::remove_const_t< typename ArgType::Scalar > Scalar
Definition: TensorCustomOp.h:79
EIGEN_STRONG_INLINE void cleanup()
Definition: TensorCustomOp.h:120
EIGEN_STRONG_INLINE bool evalSubExprsIfNeeded(EvaluatorPointerType data)
Definition: TensorCustomOp.h:108
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Dimensions & dimensions() const
Definition: TensorCustomOp.h:106
EIGEN_STRONG_INLINE TensorEvaluator(const ArgType &op, const Device &device)
Definition: TensorCustomOp.h:101
StorageMemory< CoeffReturnType, Device > Storage
Definition: TensorCustomOp.h:84
internal::TensorBlockNotImplemented TensorBlock
Definition: TensorCustomOp.h:98
DSizes< Index, NumDims > Dimensions
Definition: TensorCustomOp.h:78
internal::traits< ArgType >::Index Index
Definition: TensorCustomOp.h:76
EIGEN_DEVICE_FUNC EvaluatorPointerType data() const
Definition: TensorCustomOp.h:139
Storage::Type EvaluatorPointerType
Definition: TensorCustomOp.h:85
PacketType< CoeffReturnType, Device >::type PacketReturnType
Definition: TensorCustomOp.h:81
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorOpCost costPerCoeff(bool vectorized) const
Definition: TensorCustomOp.h:134
Dimensions m_dimensions
Definition: TensorCustomOp.h:147
TensorCustomUnaryOp< CustomUnaryFunc, XprType > ArgType
Definition: TensorCustomOp.h:75
EvaluatorPointerType m_result
Definition: TensorCustomOp.h:150
EIGEN_DEVICE_FUNC PacketReturnType packet(Index index) const
Definition: TensorCustomOp.h:130
const Device EIGEN_DEVICE_REF m_device
Definition: TensorCustomOp.h:149
std::remove_const_t< typename XprType::CoeffReturnType > CoeffReturnType
Definition: TensorCustomOp.h:80
A cost model used to limit the number of threads used for evaluating tensor expression.
Definition: TensorEvaluator.h:31
static constexpr int Layout
Definition: TensorEvaluator.h:46
const Device EIGEN_DEVICE_REF m_device
Definition: TensorEvaluator.h:170
@ PacketAccess
Definition: TensorEvaluator.h:50
@ IsAligned
Definition: TensorEvaluator.h:49
static constexpr int PacketSize
Definition: TensorEvaluator.h:38
EIGEN_DEVICE_FUNC EvaluatorPointerType data() const
Definition: TensorEvaluator.h:165
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Dimensions & dimensions() const
Definition: TensorEvaluator.h:69
const TensorCustomBinaryOp< CustomBinaryFunc, LhsXprType, RhsXprType > & type
Definition: TensorCustomOp.h:183
const TensorCustomUnaryOp< CustomUnaryFunc, XprType > EIGEN_DEVICE_REF type
Definition: TensorCustomOp.h:40
Definition: XprHelper.h:427
TensorCustomBinaryOp< CustomBinaryFunc, LhsXprType, RhsXprType > type
Definition: TensorCustomOp.h:188
TensorCustomUnaryOp< CustomUnaryFunc, XprType > type
Definition: TensorCustomOp.h:45
Definition: TensorTraits.h:152
ref_selector< T >::type type
Definition: TensorTraits.h:153
std::conditional_t< Pointer_type_promotion< typename LhsXprType::Scalar, Scalar >::val, typename traits< LhsXprType >::PointerType, typename traits< RhsXprType >::PointerType > PointerType
Definition: TensorCustomOp.h:178
promote_storage_type< typename traits< LhsXprType >::StorageKind, typename traits< RhsXprType >::StorageKind >::ret StorageKind
Definition: TensorCustomOp.h:167
LhsXprType::Nested LhsNested
Definition: TensorCustomOp.h:170
std::remove_reference_t< RhsNested > RhsNested_
Definition: TensorCustomOp.h:173
RhsXprType::Nested RhsNested
Definition: TensorCustomOp.h:171
internal::promote_storage_type< typename LhsXprType::Scalar, typename RhsXprType::Scalar >::ret Scalar
Definition: TensorCustomOp.h:163
std::remove_reference_t< LhsNested > LhsNested_
Definition: TensorCustomOp.h:172
promote_index_type< typename traits< LhsXprType >::Index, typename traits< RhsXprType >::Index >::type Index
Definition: TensorCustomOp.h:169
internal::promote_storage_type< typename LhsXprType::CoeffReturnType, typename RhsXprType::CoeffReturnType >::ret CoeffReturnType
Definition: TensorCustomOp.h:165
traits< XprType >::PointerType PointerType
Definition: TensorCustomOp.h:35
XprType::Index Index
Definition: TensorCustomOp.h:30
XprType::Scalar Scalar
Definition: TensorCustomOp.h:28
XprType::StorageKind StorageKind
Definition: TensorCustomOp.h:29
std::remove_reference_t< Nested > Nested_
Definition: TensorCustomOp.h:32
XprType::Nested Nested
Definition: TensorCustomOp.h:31
Definition: ForwardDeclarations.h:21
Definition: benchGeometry.cpp:21