11 #ifndef EIGEN_CXX11_TENSOR_TENSOR_ARG_MAX_H
12 #define EIGEN_CXX11_TENSOR_TENSOR_ARG_MAX_H
27 template <
typename XprType>
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>
44 template <
typename XprType>
51 template <
typename XprType>
70 template <
typename ArgType,
typename Device>
101 m_impl.evalSubExprsIfNeeded(NULL);
111 return m_impl.costPerCoeff(vectorized) +
TensorOpCost(0, 0, 1);
128 template <
typename ReduceOp,
typename Dims,
typename XprType>
135 typedef std::remove_reference_t<Nested>
Nested_;
137 static constexpr
int Layout = XprTraits::Layout;
140 template <
typename ReduceOp,
typename Dims,
typename XprType>
145 template <
typename ReduceOp,
typename Dims,
typename XprType>
153 template <
typename ReduceOp,
typename Dims,
typename XprType>
183 template <
typename ReduceOp,
typename Dims,
typename ArgType,
typename Device>
214 : m_orig_impl(
op.expression(), device),
215 m_impl(
op.expression().index_pairs().reduce(
op.reduce_dims(),
op.reduce_op()), device),
216 m_return_dim(
op.return_dim()) {
217 gen_strides(m_orig_impl.dimensions(), m_strides);
220 m_stride_mod = (m_return_dim < NumDims - 1) ? m_strides[m_return_dim + 1] : total_size;
223 m_stride_mod = (m_return_dim > 0) ? m_strides[m_return_dim - 1] : total_size;
227 ((m_return_dim >= 0) && (m_return_dim <
static_cast<Index>(m_strides.size()))) ? m_strides[m_return_dim] : 1;
233 m_impl.evalSubExprsIfNeeded(NULL);
240 return (m_return_dim < 0) ?
v.first : (
v.first % m_stride_mod) / m_stride_div;
246 const double compute_cost =
247 1.0 + (m_return_dim < 0 ? 0.0 : (TensorOpCost::ModCost<Index>() + TensorOpCost::DivCost<Index>()));
248 return m_orig_impl.costPerCoeff(vectorized) + m_impl.costPerCoeff(vectorized) +
TensorOpCost(0, 0, compute_cost);
253 if (m_return_dim < 0) {
256 eigen_assert(m_return_dim < NumDims &&
"Asking to convert index to a dimension outside of the rank");
262 for (
int i = 1;
i < NumDims; ++
i) {
267 for (
int i = NumDims - 2;
i >= 0; --
i) {
Array< int, Dynamic, 1 > v
Definition: Array_initializer_list_vector_cxx11.cpp:1
int i
Definition: BiCGSTAB_step_by_step.cpp:9
#define EIGEN_DEVICE_FUNC
Definition: Macros.h:892
#define eigen_assert(x)
Definition: Macros.h:910
#define EIGEN_STRONG_INLINE
Definition: Macros.h:834
#define EIGEN_DEVICE_REF
Definition: TensorMacros.h:34
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
Definition: TensorArgMax.h:52
Eigen::internal::traits< TensorIndexPairOp >::Scalar Scalar
Definition: TensorArgMax.h:54
Eigen::internal::traits< TensorIndexPairOp >::Index Index
Definition: TensorArgMax.h:58
XprType::Nested m_xpr
Definition: TensorArgMax.h:66
Eigen::internal::traits< TensorIndexPairOp >::StorageKind StorageKind
Definition: TensorArgMax.h:57
Eigen::NumTraits< Scalar >::Real RealScalar
Definition: TensorArgMax.h:55
Eigen::internal::nested< TensorIndexPairOp >::type Nested
Definition: TensorArgMax.h:56
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorIndexPairOp(const XprType &expr)
Definition: TensorArgMax.h:61
Pair< Index, typename XprType::CoeffReturnType > CoeffReturnType
Definition: TensorArgMax.h:59
EIGEN_DEVICE_FUNC const internal::remove_all_t< typename XprType::Nested > & expression() const
Definition: TensorArgMax.h:63
Definition: TensorCostModel.h:28
Definition: TensorArgMax.h:154
EIGEN_DEVICE_FUNC Index return_dim() const
Definition: TensorArgMax.h:173
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorPairReducerOp(const XprType &expr, const ReduceOp &reduce_op, const Index return_dim, const Dims &reduce_dims)
Definition: TensorArgMax.h:163
Eigen::internal::traits< TensorPairReducerOp >::StorageKind StorageKind
Definition: TensorArgMax.h:159
Eigen::internal::traits< TensorPairReducerOp >::Index Index
Definition: TensorArgMax.h:160
Eigen::NumTraits< Scalar >::Real RealScalar
Definition: TensorArgMax.h:157
XprType::Nested m_xpr
Definition: TensorArgMax.h:176
Eigen::internal::traits< TensorPairReducerOp >::Scalar Scalar
Definition: TensorArgMax.h:156
const Dims m_reduce_dims
Definition: TensorArgMax.h:179
const Index m_return_dim
Definition: TensorArgMax.h:178
Eigen::internal::nested< TensorPairReducerOp >::type Nested
Definition: TensorArgMax.h:158
EIGEN_DEVICE_FUNC const ReduceOp & reduce_op() const
Definition: TensorArgMax.h:169
EIGEN_DEVICE_FUNC const internal::remove_all_t< typename XprType::Nested > & expression() const
Definition: TensorArgMax.h:167
const ReduceOp m_reduce_op
Definition: TensorArgMax.h:177
EIGEN_DEVICE_FUNC const Dims & reduce_dims() const
Definition: TensorArgMax.h:171
Index CoeffReturnType
Definition: TensorArgMax.h:161
Definition: TensorBlock.h:566
@ ColMajor
Definition: Constants.h:318
char char * op
Definition: level2_impl.h:374
constexpr EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE auto array_prod(const array< T, N > &arr) -> decltype(array_reduce< product_op, T, N >(arr, static_cast< T >(1)))
Definition: MoreMeta.h:497
typename remove_all< T >::type remove_all_t
Definition: Meta.h:142
EIGEN_ALWAYS_INLINE DSizes< IndexType, NumDims > strides(const DSizes< IndexType, NumDims > &dimensions)
Definition: TensorBlock.h:29
Namespace containing all symbols from the Eigen library.
Definition: bench_norm.cpp:70
std::array< T, N > array
Definition: EmulateArray.h:231
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:83
Definition: Eigen_Colamd.h:49
Definition: Constants.h:519
T Real
Definition: NumTraits.h:183
Definition: TensorMeta.h:205
Definition: TensorForwardDeclarations.h:42
XprType::CoeffReturnType CoeffReturnType
Definition: TensorArgMax.h:75
EIGEN_DEVICE_FUNC EvaluatorPointerType data() const
Definition: TensorArgMax.h:114
EIGEN_STRONG_INLINE void cleanup()
Definition: TensorArgMax.h:104
TensorEvaluator< ArgType, Device > m_impl
Definition: TensorArgMax.h:117
TensorEvaluator< ArgType, Device >::Dimensions Dimensions
Definition: TensorArgMax.h:77
StorageMemory< CoeffReturnType, Device > Storage
Definition: TensorArgMax.h:79
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Dimensions & dimensions() const
Definition: TensorArgMax.h:98
EIGEN_STRONG_INLINE bool evalSubExprsIfNeeded(EvaluatorPointerType)
Definition: TensorArgMax.h:100
XprType::Scalar Scalar
Definition: TensorArgMax.h:74
Storage::Type EvaluatorPointerType
Definition: TensorArgMax.h:80
EIGEN_STRONG_INLINE TensorEvaluator(const XprType &op, const Device &device)
Definition: TensorArgMax.h:96
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index) const
Definition: TensorArgMax.h:106
internal::TensorBlockNotImplemented TensorBlock
Definition: TensorArgMax.h:93
XprType::Index Index
Definition: TensorArgMax.h:73
TensorIndexPairOp< ArgType > XprType
Definition: TensorArgMax.h:72
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorOpCost costPerCoeff(bool vectorized) const
Definition: TensorArgMax.h:110
const Index m_return_dim
Definition: TensorArgMax.h:276
EIGEN_DEVICE_FUNC void gen_strides(const InputDimensions &dims, StrideDims &strides)
Definition: TensorArgMax.h:252
EIGEN_STRONG_INLINE bool evalSubExprsIfNeeded(EvaluatorPointerType)
Definition: TensorArgMax.h:232
EIGEN_STRONG_INLINE TensorEvaluator(const XprType &op, const Device &device)
Definition: TensorArgMax.h:213
TensorIndexPairOp< ArgType >::CoeffReturnType PairType
Definition: TensorArgMax.h:189
XprType::Scalar Scalar
Definition: TensorArgMax.h:187
Index m_stride_mod
Definition: TensorArgMax.h:278
EIGEN_STRONG_INLINE void cleanup()
Definition: TensorArgMax.h:236
TensorEvaluator< const TensorIndexPairOp< ArgType >, Device >::Dimensions InputDimensions
Definition: TensorArgMax.h:192
array< Index, NumDims > StrideDims
Definition: TensorArgMax.h:194
TensorEvaluator< const TensorReductionOp< ReduceOp, Dims, const TensorIndexPairOp< ArgType > >, Device >::Dimensions Dimensions
Definition: TensorArgMax.h:191
StorageMemory< PairType, Device > PairStorageMem
Definition: TensorArgMax.h:197
TensorPairReducerOp< ReduceOp, Dims, ArgType > XprType
Definition: TensorArgMax.h:185
EIGEN_DEVICE_FUNC EvaluatorPointerType data() const
Definition: TensorArgMax.h:243
StorageMemory< CoeffReturnType, Device > Storage
Definition: TensorArgMax.h:195
TensorEvaluator< const TensorIndexPairOp< ArgType >, Device > m_orig_impl
Definition: TensorArgMax.h:274
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Dimensions & dimensions() const
Definition: TensorArgMax.h:230
StrideDims m_strides
Definition: TensorArgMax.h:277
internal::TensorBlockNotImplemented TensorBlock
Definition: TensorArgMax.h:210
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index) const
Definition: TensorArgMax.h:238
XprType::Index Index
Definition: TensorArgMax.h:186
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorOpCost costPerCoeff(bool vectorized) const
Definition: TensorArgMax.h:245
TensorEvaluator< const TensorReductionOp< ReduceOp, Dims, const TensorIndexPairOp< ArgType > >, Device > m_impl
Definition: TensorArgMax.h:275
Storage::Type EvaluatorPointerType
Definition: TensorArgMax.h:196
Index m_stride_div
Definition: TensorArgMax.h:279
XprType::CoeffReturnType CoeffReturnType
Definition: TensorArgMax.h:188
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
@ PacketAccess
Definition: TensorEvaluator.h:50
@ IsAligned
Definition: TensorEvaluator.h:49
Derived::Scalar CoeffReturnType
Definition: TensorEvaluator.h:34
const TensorIndexPairOp< XprType > EIGEN_DEVICE_REF type
Definition: TensorArgMax.h:41
const TensorPairReducerOp< ReduceOp, Dims, XprType > EIGEN_DEVICE_REF type
Definition: TensorArgMax.h:142
Definition: XprHelper.h:427
TensorIndexPairOp< XprType > type
Definition: TensorArgMax.h:46
TensorPairReducerOp< ReduceOp, Dims, XprType > type
Definition: TensorArgMax.h:148
Definition: TensorTraits.h:152
ref_selector< T >::type type
Definition: TensorTraits.h:153
XprTraits::StorageKind StorageKind
Definition: TensorArgMax.h:30
XprTraits::Index Index
Definition: TensorArgMax.h:31
traits< XprType > XprTraits
Definition: TensorArgMax.h:29
XprType::Nested Nested
Definition: TensorArgMax.h:33
Pair< Index, typename XprTraits::Scalar > Scalar
Definition: TensorArgMax.h:32
std::remove_reference_t< Nested > Nested_
Definition: TensorArgMax.h:34
XprTraits::Index Index
Definition: TensorArgMax.h:132
std::remove_reference_t< Nested > Nested_
Definition: TensorArgMax.h:135
XprTraits::StorageKind StorageKind
Definition: TensorArgMax.h:131
traits< XprType > XprTraits
Definition: TensorArgMax.h:130
Index Scalar
Definition: TensorArgMax.h:133
XprType::Nested Nested
Definition: TensorArgMax.h:134
Definition: ForwardDeclarations.h:21