11 #ifndef EIGEN_CXX11_TENSOR_TENSOR_ARG_MAX_H
12 #define EIGEN_CXX11_TENSOR_TENSOR_ARG_MAX_H
26 template<
typename XprType>
27 struct traits<TensorIndexPairOp<XprType> > :
public traits<XprType>
30 typedef typename XprTraits::StorageKind StorageKind;
31 typedef typename XprTraits::Index
Index;
32 typedef Pair<Index, typename XprTraits::Scalar> Scalar;
33 typedef typename XprType::Nested Nested;
34 typedef std::remove_reference_t<Nested> Nested_;
35 static constexpr
int NumDimensions = XprTraits::NumDimensions;
36 static constexpr
int Layout = XprTraits::Layout;
39 template<
typename XprType>
40 struct eval<TensorIndexPairOp<XprType>,
Eigen::Dense>
45 template<
typename XprType>
46 struct nested<TensorIndexPairOp<XprType>, 1,
47 typename eval<TensorIndexPairOp<XprType> >::type>
49 typedef TensorIndexPairOp<XprType> type;
54 template<
typename XprType>
58 typedef typename Eigen::internal::traits<TensorIndexPairOp>::Scalar
Scalar;
60 typedef typename Eigen::internal::nested<TensorIndexPairOp>::type
Nested;
61 typedef typename Eigen::internal::traits<TensorIndexPairOp>::StorageKind
StorageKind;
62 typedef typename Eigen::internal::traits<TensorIndexPairOp>::Index
Index;
77 template<
typename ArgType,
typename Device>
86 static constexpr
int NumDims = internal::array_size<Dimensions>::value;
105 : m_impl(op.expression(), device) { }
108 return m_impl.dimensions();
112 m_impl.evalSubExprsIfNeeded(NULL);
126 return m_impl.costPerCoeff(vectorized) +
TensorOpCost(0, 0, 1);
143 template<
typename ReduceOp,
typename Dims,
typename XprType>
147 typedef typename XprTraits::StorageKind StorageKind;
148 typedef typename XprTraits::Index
Index;
149 typedef Index Scalar;
150 typedef typename XprType::Nested Nested;
151 typedef std::remove_reference_t<Nested> Nested_;
152 static constexpr
int NumDimensions = XprTraits::NumDimensions - array_size<Dims>::value;
153 static constexpr
int Layout = XprTraits::Layout;
156 template<
typename ReduceOp,
typename Dims,
typename XprType>
157 struct eval<TensorPairReducerOp<ReduceOp, Dims, XprType>,
Eigen::Dense>
159 typedef const TensorPairReducerOp<ReduceOp, Dims, XprType>
EIGEN_DEVICE_REF type;
162 template<
typename ReduceOp,
typename Dims,
typename XprType>
163 struct nested<TensorPairReducerOp<ReduceOp, Dims, XprType>, 1,
164 typename eval<TensorPairReducerOp<ReduceOp, Dims, XprType> >::type>
166 typedef TensorPairReducerOp<ReduceOp, Dims, XprType> type;
171 template<
typename ReduceOp,
typename Dims,
typename XprType>
175 typedef typename Eigen::internal::traits<TensorPairReducerOp>::Scalar
Scalar;
177 typedef typename Eigen::internal::nested<TensorPairReducerOp>::type
Nested;
178 typedef typename Eigen::internal::traits<TensorPairReducerOp>::StorageKind
StorageKind;
179 typedef typename Eigen::internal::traits<TensorPairReducerOp>::Index
Index;
209 template<
typename ReduceOp,
typename Dims,
typename ArgType,
typename Device>
219 static constexpr
int NumDims = internal::array_size<InputDimensions>::value;
239 : m_orig_impl(op.expression(), device),
240 m_impl(op.expression().index_pairs().reduce(op.reduce_dims(), op.reduce_op()), device),
241 m_return_dim(op.return_dim())
243 gen_strides(m_orig_impl.dimensions(), m_strides);
246 m_stride_mod = (m_return_dim < NumDims - 1) ? m_strides[m_return_dim + 1] : total_size;
249 m_stride_mod = (m_return_dim > 0) ? m_strides[m_return_dim - 1] : total_size;
252 m_stride_div = ((m_return_dim >= 0) &&
253 (m_return_dim <
static_cast<Index>(m_strides.size())))
254 ? m_strides[m_return_dim] : 1;
258 return m_impl.dimensions();
262 m_impl.evalSubExprsIfNeeded(NULL);
271 return (m_return_dim < 0) ?
v.first : (
v.first % m_stride_mod) / m_stride_div;
278 const double compute_cost = 1.0 +
279 (m_return_dim < 0 ? 0.0 : (TensorOpCost::ModCost<Index>() + TensorOpCost::DivCost<Index>()));
280 return m_orig_impl.costPerCoeff(vectorized) +
281 m_impl.costPerCoeff(vectorized) +
TensorOpCost(0, 0, compute_cost);
286 if (m_return_dim < 0) {
290 "Asking to convert index to a dimension outside of the rank");
296 for (
int i = 1;
i < NumDims; ++
i) {
301 for (
int i = NumDims - 2;
i >= 0; --
i) {
Array< int, Dynamic, 1 > v
#define EIGEN_DEVICE_FUNC
Eigen::internal::traits< TensorIndexPairOp >::Scalar Scalar
Eigen::internal::traits< TensorIndexPairOp >::Index Index
Eigen::internal::traits< TensorIndexPairOp >::StorageKind StorageKind
TensorIndexPairOp(const XprType &expr)
const internal::remove_all_t< typename XprType::Nested > & expression() const
Eigen::NumTraits< Scalar >::Real RealScalar
Eigen::internal::nested< TensorIndexPairOp >::type Nested
Pair< Index, typename XprType::CoeffReturnType > CoeffReturnType
const Dims & reduce_dims() const
Eigen::internal::traits< TensorPairReducerOp >::StorageKind StorageKind
const internal::remove_all_t< typename XprType::Nested > & expression() const
TensorPairReducerOp(const XprType &expr, const ReduceOp &reduce_op, const Index return_dim, const Dims &reduce_dims)
Eigen::internal::traits< TensorPairReducerOp >::Index Index
Eigen::NumTraits< Scalar >::Real RealScalar
const ReduceOp & reduce_op() const
Eigen::internal::traits< TensorPairReducerOp >::Scalar Scalar
Eigen::internal::nested< TensorPairReducerOp >::type Nested
const ReduceOp m_reduce_op
typename remove_all< T >::type remove_all_t
EIGEN_ALWAYS_INLINE DSizes< IndexType, NumDims > strides(const DSizes< IndexType, NumDims > &dimensions)
constexpr auto array_prod(const array< T, N > &arr) -> decltype(array_reduce< product_op, T, N >(arr, static_cast< T >(1)))
: TensorContractionSycl.h, provides various tensor contraction kernel for SYCL backend
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
XprType::CoeffReturnType CoeffReturnType
bool evalSubExprsIfNeeded(EvaluatorPointerType)
EvaluatorPointerType data() const
CoeffReturnType coeff(Index index) const
TensorEvaluator< ArgType, Device > m_impl
TensorEvaluator< ArgType, Device >::Dimensions Dimensions
StorageMemory< CoeffReturnType, Device > Storage
Storage::Type EvaluatorPointerType
TensorEvaluator(const XprType &op, const Device &device)
TensorOpCost costPerCoeff(bool vectorized) const
internal::TensorBlockNotImplemented TensorBlock
TensorIndexPairOp< ArgType > XprType
const Dimensions & dimensions() const
CoeffReturnType coeff(Index index) const
bool evalSubExprsIfNeeded(EvaluatorPointerType)
TensorIndexPairOp< ArgType >::CoeffReturnType PairType
TensorEvaluator(const XprType &op, const Device &device)
const Dimensions & dimensions() const
EvaluatorPointerType data() const
array< Index, NumDims > StrideDims
TensorOpCost costPerCoeff(bool vectorized) const
TensorEvaluator< const TensorReductionOp< ReduceOp, Dims, const TensorIndexPairOp< ArgType > >, Device >::Dimensions Dimensions
StorageMemory< PairType, Device > PairStorageMem
TensorPairReducerOp< ReduceOp, Dims, ArgType > XprType
StorageMemory< CoeffReturnType, Device > Storage
TensorEvaluator< const TensorIndexPairOp< ArgType >, Device > m_orig_impl
internal::TensorBlockNotImplemented TensorBlock
void gen_strides(const InputDimensions &dims, StrideDims &strides)
TensorEvaluator< const TensorReductionOp< ReduceOp, Dims, const TensorIndexPairOp< ArgType > >, Device > m_impl
Storage::Type EvaluatorPointerType
TensorEvaluator< const TensorIndexPairOp< ArgType >, Device >::Dimensions InputDimensions
XprType::CoeffReturnType CoeffReturnType
A cost model used to limit the number of threads used for evaluating tensor expression.
static constexpr int Layout
Derived::Scalar CoeffReturnType