10 #ifndef EIGEN_CXX11_TENSOR_TENSOR_CUSTOM_OP_H 11 #define EIGEN_CXX11_TENSOR_TENSOR_CUSTOM_OP_H 23 template<
typename CustomUnaryFunc,
typename XprType>
29 typedef typename XprType::Nested
Nested;
36 template<
typename CustomUnaryFunc,
typename XprType>
42 template<
typename CustomUnaryFunc,
typename XprType>
52 template<
typename CustomUnaryFunc,
typename XprType>
64 : m_expr(expr), m_func(func) {}
67 const CustomUnaryFunc&
func()
const {
return m_func; }
80 template<
typename CustomUnaryFunc,
typename XprType,
typename Device>
99 PreferBlockAccess =
false,
110 : m_op(op), m_device(device), m_result(
NULL)
122 m_result =
static_cast<EvaluatorPointerType
>(m_device.get( (CoeffReturnType*)
123 m_device.allocate_temp(
dimensions().TotalSize() *
sizeof(Scalar))));
131 m_device.deallocate_temp(m_result);
137 return m_result[index];
140 template<
int LoadMode>
142 return internal::ploadt<PacketReturnType, LoadMode>(m_result + index);
147 return TensorOpCost(
sizeof(CoeffReturnType), 0, 0, vectorized, PacketSize);
152 #ifdef EIGEN_USE_SYCL 162 m_op.func().eval(m_op.expression(),
result, m_device);
181 template<
typename CustomBinaryFunc,
typename LhsXprType,
typename RhsXprType>
202 template<
typename CustomBinaryFunc,
typename LhsXprType,
typename RhsXprType>
208 template<
typename CustomBinaryFunc,
typename LhsXprType,
typename RhsXprType>
218 template<
typename CustomBinaryFunc,
typename LhsXprType,
typename RhsXprType>
231 : m_lhs_xpr(lhs), m_rhs_xpr(rhs), m_func(func) {}
234 const CustomBinaryFunc&
func()
const {
return m_func; }
252 template<
typename CustomBinaryFunc,
typename LhsXprType,
typename RhsXprType,
typename Device>
272 PreferBlockAccess =
false,
283 : m_op(op), m_device(device), m_result(
NULL)
295 m_result =
static_cast<EvaluatorPointerType
>(m_device.get( (CoeffReturnType*)
296 m_device.allocate_temp(
dimensions().TotalSize() *
sizeof(CoeffReturnType))));
303 if (m_result !=
NULL) {
304 m_device.deallocate_temp(m_result);
310 return m_result[index];
313 template<
int LoadMode>
315 return internal::ploadt<PacketReturnType, LoadMode>(m_result + index);
320 return TensorOpCost(
sizeof(CoeffReturnType), 0, 0, vectorized, PacketSize);
325 #ifdef EIGEN_USE_SYCL 335 m_op.func().eval(m_op.lhsExpression(), m_op.rhsExpression(),
result, m_device);
347 #endif // EIGEN_CXX11_TENSOR_TENSOR_CUSTOM_OP_H
EIGEN_DEVICE_FUNC EvaluatorPointerType data() const
remove_reference< RhsNested >::type _RhsNested
EIGEN_DEVICE_FUNC const internal::remove_all< typename LhsXprType::Nested >::type & lhsExpression() const
LhsXprType::Nested LhsNested
EIGEN_DEVICE_FUNC PacketReturnType packet(Index index) const
internal::traits< XprType >::Index Index
DSizes< Index, NumDims > Dimensions
#define EIGEN_STRONG_INLINE
EIGEN_STRONG_INLINE void cleanup()
PacketType< CoeffReturnType, Device >::type PacketReturnType
EIGEN_DEVICE_FUNC const CustomUnaryFunc & func() const
internal::traits< TensorCustomBinaryOp >::StorageKind StorageKind
internal::nested< TensorCustomBinaryOp >::type Nested
Eigen::internal::traits< XprType >::PointerType TensorPointerType
internal::traits< TensorCustomBinaryOp >::Scalar Scalar
TensorCustomBinaryOp< CustomBinaryFunc, LhsXprType, RhsXprType > XprType
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorCustomUnaryOp(const XprType &expr, const CustomUnaryFunc &func)
EIGEN_STRONG_INLINE bool evalSubExprsIfNeeded(EvaluatorPointerType data)
internal::TensorBlockNotImplemented TensorBlock
const TensorCustomUnaryOp< CustomUnaryFunc, XprType > EIGEN_DEVICE_REF type
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorOpCost costPerCoeff(bool vectorized) const
internal::remove_const< typename ArgType::Scalar >::type Scalar
Eigen::internal::traits< XprType >::PointerType TensorPointerType
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorCustomBinaryOp(const LhsXprType &lhs, const RhsXprType &rhs, const CustomBinaryFunc &func)
EIGEN_STRONG_INLINE bool evalSubExprsIfNeeded(EvaluatorPointerType data)
Namespace containing all symbols from the Eigen library.
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Dimensions & dimensions() const
Storage::Type EvaluatorPointerType
A cost model used to limit the number of threads used for evaluating tensor expression.
TensorCustomUnaryOp< CustomUnaryFunc, XprType > type
StorageMemory< CoeffReturnType, Device > Storage
EIGEN_DEVICE_FUNC PacketReturnType packet(Index index) const
EIGEN_DEVICE_FUNC const internal::remove_all< typename RhsXprType::Nested >::type & rhsExpression() const
RhsXprType::Nested m_rhs_xpr
XprType::CoeffReturnType CoeffReturnType
internal::traits< TensorCustomBinaryOp >::CoeffReturnType CoeffReturnType
remove_reference< Nested >::type _Nested
const CustomUnaryFunc m_func
Generic expression where a coefficient-wise binary operator is applied to two expressions.
StorageMemory< CoeffReturnType, Device > Storage
XprType::StorageKind StorageKind
TensorCustomBinaryOp< CustomBinaryFunc, LhsXprType, RhsXprType > type
A tensor expression mapping an existing array of data.
EIGEN_DEVICE_FUNC const CustomBinaryFunc & func() const
TensorCustomUnaryOp< CustomUnaryFunc, XprType > ArgType
const CustomBinaryFunc m_func
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorOpCost costPerCoeff(bool vectorized) const
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index) const
remove_reference< LhsNested >::type _LhsNested
EIGEN_DEVICE_FUNC EvaluatorPointerType data() const
internal::traits< ArgType >::Index Index
const Device EIGEN_DEVICE_REF m_device
internal::traits< TensorCustomBinaryOp >::Index Index
EIGEN_DEVICE_FUNC const internal::remove_all< typename XprType::Nested >::type & expression() const
Eigen::NumTraits< Scalar >::Real RealScalar
RhsXprType::Nested RhsNested
EIGEN_STRONG_INLINE TensorEvaluator(const ArgType &op, const Device &device)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Dimensions & dimensions() const
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index) const
internal::promote_storage_type< typename LhsXprType::CoeffReturnType, typename RhsXprType::CoeffReturnType >::ret CoeffReturnType
PacketType< CoeffReturnType, Device >::type PacketReturnType
LhsXprType::Nested m_lhs_xpr
#define EIGEN_DEVICE_FUNC
EvaluatorPointerType m_result
internal::promote_storage_type< typename LhsXprType::Scalar, typename RhsXprType::Scalar >::ret Scalar
void evalTo(EvaluatorPointerType data)
const TensorCustomBinaryOp< CustomBinaryFunc, LhsXprType, RhsXprType > & type
EIGEN_STRONG_INLINE TensorEvaluator(const XprType &op, const Device &device)
internal::nested< TensorCustomUnaryOp >::type Nested
traits< XprType >::PointerType PointerType
internal::remove_const< typename XprType::CoeffReturnType >::type CoeffReturnType
internal::TensorBlockNotImplemented TensorBlock
void evalTo(EvaluatorPointerType data)
internal::traits< TensorCustomUnaryOp >::StorageKind StorageKind
EIGEN_STRONG_INLINE void cleanup()
Generic expression where a coefficient-wise unary operator is applied to an expression.
Eigen::NumTraits< Scalar >::Real RealScalar
conditional< Pointer_type_promotion< typename LhsXprType::Scalar, Scalar >::val, typename traits< LhsXprType >::PointerType, typename traits< RhsXprType >::PointerType >::type PointerType
internal::remove_const< typename XprType::CoeffReturnType >::type CoeffReturnType
const std::vector< size_t > dimensions
internal::traits< TensorCustomUnaryOp >::Scalar Scalar
EvaluatorPointerType m_result
const Device EIGEN_DEVICE_REF m_device
promote_index_type< typename traits< LhsXprType >::Index, typename traits< RhsXprType >::Index >::type Index
DSizes< Index, NumDims > Dimensions
promote_storage_type< typename traits< LhsXprType >::StorageKind, typename traits< RhsXprType >::StorageKind >::ret StorageKind
internal::traits< TensorCustomUnaryOp >::Index Index
Storage::Type EvaluatorPointerType