10 #ifndef EIGEN_CXX11_TENSOR_TENSOR_CUSTOM_OP_H
11 #define EIGEN_CXX11_TENSOR_TENSOR_CUSTOM_OP_H
25 template<
typename CustomUnaryFunc,
typename XprType>
26 struct traits<TensorCustomUnaryOp<CustomUnaryFunc, XprType> >
28 typedef typename XprType::Scalar Scalar;
29 typedef typename XprType::StorageKind StorageKind;
30 typedef typename XprType::Index
Index;
31 typedef typename XprType::Nested Nested;
32 typedef std::remove_reference_t<Nested> Nested_;
38 template<
typename CustomUnaryFunc,
typename XprType>
39 struct eval<TensorCustomUnaryOp<CustomUnaryFunc, XprType>,
Eigen::Dense>
41 typedef const TensorCustomUnaryOp<CustomUnaryFunc, XprType>
EIGEN_DEVICE_REF type;
44 template<
typename CustomUnaryFunc,
typename XprType>
45 struct nested<TensorCustomUnaryOp<CustomUnaryFunc, XprType> >
47 typedef TensorCustomUnaryOp<CustomUnaryFunc, XprType> type;
54 template<
typename CustomUnaryFunc,
typename XprType>
58 typedef typename internal::traits<TensorCustomUnaryOp>::Scalar
Scalar;
61 typedef typename internal::nested<TensorCustomUnaryOp>::type
Nested;
62 typedef typename internal::traits<TensorCustomUnaryOp>::StorageKind
StorageKind;
63 typedef typename internal::traits<TensorCustomUnaryOp>::Index
Index;
82 template<
typename CustomUnaryFunc,
typename XprType,
typename Device>
86 typedef typename internal::traits<ArgType>::Index
Index;
87 static constexpr
int NumDims = internal::traits<ArgType>::NumDimensions;
89 typedef std::remove_const_t<typename ArgType::Scalar>
Scalar;
102 PreferBlockAccess =
false,
112 : m_op(op),
m_device(device), m_result(NULL)
139 return m_result[index];
142 template<
int LoadMode>
144 return internal::ploadt<PacketReturnType, LoadMode>(m_result + index);
157 m_op.func().eval(m_op.expression(), result,
m_device);
176 template<
typename CustomBinaryFunc,
typename LhsXprType,
typename RhsXprType>
179 typedef typename internal::promote_storage_type<
typename LhsXprType::Scalar,
180 typename RhsXprType::Scalar>::ret Scalar;
181 typedef typename internal::promote_storage_type<
typename LhsXprType::CoeffReturnType,
182 typename RhsXprType::CoeffReturnType>::ret CoeffReturnType;
183 typedef typename promote_storage_type<typename traits<LhsXprType>::StorageKind,
185 typedef typename promote_index_type<typename traits<LhsXprType>::Index,
187 typedef typename LhsXprType::Nested LhsNested;
188 typedef typename RhsXprType::Nested RhsNested;
189 typedef std::remove_reference_t<LhsNested> LhsNested_;
190 typedef std::remove_reference_t<RhsNested> RhsNested_;
193 typedef std::conditional_t<Pointer_type_promotion<typename LhsXprType::Scalar, Scalar>::val,
197 template<
typename CustomBinaryFunc,
typename LhsXprType,
typename RhsXprType>
198 struct eval<TensorCustomBinaryOp<CustomBinaryFunc, LhsXprType, RhsXprType>,
Eigen::Dense>
200 typedef const TensorCustomBinaryOp<CustomBinaryFunc, LhsXprType, RhsXprType>& type;
203 template<
typename CustomBinaryFunc,
typename LhsXprType,
typename RhsXprType>
204 struct nested<TensorCustomBinaryOp<CustomBinaryFunc, LhsXprType, RhsXprType> >
206 typedef TensorCustomBinaryOp<CustomBinaryFunc, LhsXprType, RhsXprType> type;
213 template<
typename CustomBinaryFunc,
typename LhsXprType,
typename RhsXprType>
217 typedef typename internal::traits<TensorCustomBinaryOp>::Scalar
Scalar;
219 typedef typename internal::traits<TensorCustomBinaryOp>::CoeffReturnType
CoeffReturnType;
220 typedef typename internal::nested<TensorCustomBinaryOp>::type
Nested;
221 typedef typename internal::traits<TensorCustomBinaryOp>::StorageKind
StorageKind;
222 typedef typename internal::traits<TensorCustomBinaryOp>::Index
Index;
247 template<
typename CustomBinaryFunc,
typename LhsXprType,
typename RhsXprType,
typename Device>
251 typedef typename internal::traits<XprType>::Index
Index;
252 static constexpr
int NumDims = internal::traits<XprType>::NumDimensions;
268 PreferBlockAccess =
false,
278 : m_op(op),
m_device(device), m_result(NULL)
298 if (m_result != NULL) {
305 return m_result[index];
308 template<
int LoadMode>
310 return internal::ploadt<PacketReturnType, LoadMode>(m_result + index);
324 m_op.func().eval(m_op.lhsExpression(), m_op.rhsExpression(), result,
m_device);
#define EIGEN_DEVICE_FUNC
internal::traits< TensorCustomBinaryOp >::StorageKind StorageKind
const CustomBinaryFunc m_func
internal::traits< TensorCustomBinaryOp >::CoeffReturnType CoeffReturnType
internal::traits< TensorCustomBinaryOp >::Index Index
Eigen::NumTraits< Scalar >::Real RealScalar
TensorCustomBinaryOp(const LhsXprType &lhs, const RhsXprType &rhs, const CustomBinaryFunc &func)
const internal::remove_all_t< typename RhsXprType::Nested > & rhsExpression() const
const internal::remove_all_t< typename LhsXprType::Nested > & lhsExpression() const
LhsXprType::Nested m_lhs_xpr
RhsXprType::Nested m_rhs_xpr
internal::nested< TensorCustomBinaryOp >::type Nested
internal::traits< TensorCustomBinaryOp >::Scalar Scalar
const CustomBinaryFunc & func() const
const CustomUnaryFunc & func() const
internal::traits< TensorCustomUnaryOp >::Index Index
Eigen::NumTraits< Scalar >::Real RealScalar
const internal::remove_all_t< typename XprType::Nested > & expression() const
const CustomUnaryFunc m_func
XprType::CoeffReturnType CoeffReturnType
TensorCustomUnaryOp(const XprType &expr, const CustomUnaryFunc &func)
internal::traits< TensorCustomUnaryOp >::StorageKind StorageKind
internal::traits< TensorCustomUnaryOp >::Scalar Scalar
internal::nested< TensorCustomUnaryOp >::type Nested
A tensor expression mapping an existing array of data.
typename remove_all< T >::type remove_all_t
: TensorContractionSycl.h, provides various tensor contraction kernel for SYCL backend
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
internal::packet_traits< Scalar >::type type
Storage::Type EvaluatorPointerType
StorageMemory< CoeffReturnType, Device > Storage
internal::traits< XprType >::Index Index
const Dimensions & dimensions() const
EvaluatorPointerType data() const
const Device EIGEN_DEVICE_REF m_device
EvaluatorPointerType m_result
bool evalSubExprsIfNeeded(EvaluatorPointerType data)
std::remove_const_t< typename XprType::CoeffReturnType > CoeffReturnType
Eigen::internal::traits< XprType >::PointerType TensorPointerType
void evalTo(EvaluatorPointerType data)
PacketReturnType packet(Index index) const
DSizes< Index, NumDims > Dimensions
PacketType< CoeffReturnType, Device >::type PacketReturnType
CoeffReturnType coeff(Index index) const
TensorEvaluator(const XprType &op, const Device &device)
internal::TensorBlockNotImplemented TensorBlock
TensorCustomBinaryOp< CustomBinaryFunc, LhsXprType, RhsXprType > XprType
TensorOpCost costPerCoeff(bool vectorized) const
void evalTo(EvaluatorPointerType data)
Eigen::internal::traits< XprType >::PointerType TensorPointerType
std::remove_const_t< typename ArgType::Scalar > Scalar
bool evalSubExprsIfNeeded(EvaluatorPointerType data)
CoeffReturnType coeff(Index index) const
StorageMemory< CoeffReturnType, Device > Storage
PacketReturnType packet(Index index) const
TensorEvaluator(const ArgType &op, const Device &device)
internal::TensorBlockNotImplemented TensorBlock
EvaluatorPointerType data() const
DSizes< Index, NumDims > Dimensions
internal::traits< ArgType >::Index Index
Storage::Type EvaluatorPointerType
PacketType< CoeffReturnType, Device >::type PacketReturnType
TensorOpCost costPerCoeff(bool vectorized) const
TensorCustomUnaryOp< CustomUnaryFunc, XprType > ArgType
EvaluatorPointerType m_result
const Device EIGEN_DEVICE_REF m_device
std::remove_const_t< typename XprType::CoeffReturnType > CoeffReturnType
const Dimensions & dimensions() const
A cost model used to limit the number of threads used for evaluating tensor expression.
const Dimensions & dimensions() const
static constexpr int Layout
const Device EIGEN_DEVICE_REF m_device
static constexpr int PacketSize
EvaluatorPointerType data() const