11#ifndef EIGEN_CXX11_TENSOR_TENSOR_ARG_MAX_H
12#define EIGEN_CXX11_TENSOR_TENSOR_ARG_MAX_H
24template<
typename XprType>
29 typedef typename XprTraits::Index
Index;
31 typedef typename XprType::Nested
Nested;
33 static const int NumDimensions = XprTraits::NumDimensions;
34 static const int Layout = XprTraits::Layout;
37template<
typename XprType>
43template<
typename XprType>
52template<
typename XprType>
75template<
typename ArgType,
typename Device>
103 : m_impl(op.expression(), device) { }
106 return m_impl.dimensions();
110 m_impl.evalSubExprsIfNeeded(NULL);
124 return m_impl.costPerCoeff(vectorized) +
TensorOpCost(0, 0, 1);
147template<
typename ReduceOp,
typename Dims,
typename XprType>
152 typedef typename XprTraits::Index
Index;
157 static const int Layout = XprTraits::Layout;
160template<
typename ReduceOp,
typename Dims,
typename XprType>
166template<
typename ReduceOp,
typename Dims,
typename XprType>
175template<
typename ReduceOp,
typename Dims,
typename XprType>
213template<
typename ReduceOp,
typename Dims,
typename ArgType,
typename Device>
244 : m_orig_impl(op.expression(), device),
245 m_impl(op.expression().index_tuples().reduce(op.reduce_dims(), op.reduce_op()), device),
246 m_return_dim(op.return_dim())
248 gen_strides(m_orig_impl.dimensions(), m_strides);
251 m_stride_mod = (m_return_dim < NumDims - 1) ? m_strides[m_return_dim + 1] : total_size;
254 m_stride_mod = (m_return_dim > 0) ? m_strides[m_return_dim - 1] : total_size;
257 m_stride_div = ((m_return_dim >= 0) &&
258 (m_return_dim <
static_cast<Index>(m_strides.size())))
259 ? m_strides[m_return_dim] : 1;
263 return m_impl.dimensions();
267 m_impl.evalSubExprsIfNeeded(NULL);
276 return (m_return_dim < 0) ?
v.
first : (
v.first % m_stride_mod) / m_stride_div;
283 m_orig_impl.bind(cgh);
289 const double compute_cost = 1.0 +
290 (m_return_dim < 0 ? 0.0 : (TensorOpCost::ModCost<Index>() + TensorOpCost::DivCost<Index>()));
291 return m_orig_impl.costPerCoeff(vectorized) +
292 m_impl.costPerCoeff(vectorized) +
TensorOpCost(0, 0, compute_cost);
296 EIGEN_DEVICE_FUNC void gen_strides(
const InputDimensions& dims, StrideDims& strides) {
297 if (m_return_dim < 0) {
301 "Asking to convert index to a dimension outside of the rank");
307 for (
int i = 1;
i < NumDims; ++
i) {
308 strides[
i] = strides[
i-1] * dims[
i-1];
312 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:976
#define eigen_assert(x)
Definition Macros.h:1037
#define EIGEN_STRONG_INLINE
Definition Macros.h:917
#define EIGEN_DEVICE_REF
Definition TensorMacros.h:50
Generic expression where a coefficient-wise binary operator is applied to two expressions.
Definition CwiseBinaryOp.h:84
The tensor base class.
Definition TensorBase.h:973
Definition TensorArgMax.h:54
Eigen::NumTraits< Scalar >::Real RealScalar
Definition TensorArgMax.h:57
Tuple< Index, typename XprType::CoeffReturnType > CoeffReturnType
Definition TensorArgMax.h:61
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorIndexTupleOp(const XprType &expr)
Definition TensorArgMax.h:63
Eigen::internal::nested< TensorIndexTupleOp >::type Nested
Definition TensorArgMax.h:58
EIGEN_DEVICE_FUNC const internal::remove_all< typenameXprType::Nested >::type & expression() const
Definition TensorArgMax.h:68
Eigen::internal::traits< TensorIndexTupleOp >::Index Index
Definition TensorArgMax.h:60
Eigen::internal::traits< TensorIndexTupleOp >::StorageKind StorageKind
Definition TensorArgMax.h:59
Eigen::internal::traits< TensorIndexTupleOp >::Scalar Scalar
Definition TensorArgMax.h:56
XprType::Nested m_xpr
Definition TensorArgMax.h:71
Definition TensorCostModel.h:25
Definition TensorArgMax.h:177
Eigen::internal::nested< TensorTupleReducerOp >::type Nested
Definition TensorArgMax.h:181
EIGEN_DEVICE_FUNC Index return_dim() const
Definition TensorArgMax.h:203
EIGEN_DEVICE_FUNC const Dims & reduce_dims() const
Definition TensorArgMax.h:200
Index CoeffReturnType
Definition TensorArgMax.h:184
const ReduceOp m_reduce_op
Definition TensorArgMax.h:207
Eigen::internal::traits< TensorTupleReducerOp >::StorageKind StorageKind
Definition TensorArgMax.h:182
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorTupleReducerOp(const XprType &expr, const ReduceOp &reduce_op, const Index return_dim, const Dims &reduce_dims)
Definition TensorArgMax.h:186
Eigen::internal::traits< TensorTupleReducerOp >::Scalar Scalar
Definition TensorArgMax.h:179
EIGEN_DEVICE_FUNC const ReduceOp & reduce_op() const
Definition TensorArgMax.h:197
const Index m_return_dim
Definition TensorArgMax.h:208
EIGEN_DEVICE_FUNC const internal::remove_all< typenameXprType::Nested >::type & expression() const
Definition TensorArgMax.h:194
Eigen::internal::traits< TensorTupleReducerOp >::Index Index
Definition TensorArgMax.h:183
XprType::Nested m_xpr
Definition TensorArgMax.h:206
const Dims m_reduce_dims
Definition TensorArgMax.h:209
Eigen::NumTraits< Scalar >::Real RealScalar
Definition TensorArgMax.h:180
Definition EmulateArray.h:21
Definition TensorBlock.h:617
Definition TensorRef.h:81
@ ColMajor
Definition Constants.h:319
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE std::ptrdiff_t array_prod(const Sizes< Indices... > &)
Definition TensorDimensions.h:140
EIGEN_ALWAYS_INLINE DSizes< IndexType, NumDims > strides(const DSizes< IndexType, NumDims > &dimensions)
Definition TensorBlock.h:26
Namespace containing all symbols from the Eigen library.
Definition bench_norm.cpp:85
Definition BandTriangularSolver.h:13
Definition Constants.h:507
Definition TensorForwardDeclarations.h:37
TensorIndexTupleOp< ArgType > XprType
Definition TensorArgMax.h:78
StorageMemory< CoeffReturnType, Device > Storage
Definition TensorArgMax.h:85
Storage::Type EvaluatorPointerType
Definition TensorArgMax.h:86
EIGEN_STRONG_INLINE void cleanup()
Definition TensorArgMax.h:113
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Dimensions & dimensions() const
Definition TensorArgMax.h:105
internal::TensorBlockNotImplemented TensorBlock
Definition TensorArgMax.h:99
EIGEN_DEVICE_FUNC EvaluatorPointerType data() const
Definition TensorArgMax.h:127
XprType::Scalar Scalar
Definition TensorArgMax.h:80
TensorEvaluator< ArgType, Device >::Dimensions Dimensions
Definition TensorArgMax.h:83
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index) const
Definition TensorArgMax.h:117
XprType::CoeffReturnType CoeffReturnType
Definition TensorArgMax.h:81
TensorEvaluator< ArgType, Device > m_impl
Definition TensorArgMax.h:136
XprType::Index Index
Definition TensorArgMax.h:79
EIGEN_STRONG_INLINE TensorEvaluator(const XprType &op, const Device &device)
Definition TensorArgMax.h:102
EIGEN_STRONG_INLINE bool evalSubExprsIfNeeded(EvaluatorPointerType)
Definition TensorArgMax.h:109
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorOpCost costPerCoeff(bool vectorized) const
Definition TensorArgMax.h:123
TensorEvaluator< constTensorReductionOp< ReduceOp, Dims, constTensorIndexTupleOp< ArgType > >, Device >::Dimensions Dimensions
Definition TensorArgMax.h:221
XprType::CoeffReturnType CoeffReturnType
Definition TensorArgMax.h:219
EIGEN_STRONG_INLINE bool evalSubExprsIfNeeded(EvaluatorPointerType)
Definition TensorArgMax.h:266
XprType::Scalar Scalar
Definition TensorArgMax.h:218
const Index m_return_dim
Definition TensorArgMax.h:321
Storage::Type EvaluatorPointerType
Definition TensorArgMax.h:226
EIGEN_STRONG_INLINE TensorEvaluator(const XprType &op, const Device &device)
Definition TensorArgMax.h:243
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Dimensions & dimensions() const
Definition TensorArgMax.h:262
Index m_stride_mod
Definition TensorArgMax.h:323
StorageMemory< TupleType, Device > TupleStorageMem
Definition TensorArgMax.h:227
StorageMemory< CoeffReturnType, Device > Storage
Definition TensorArgMax.h:225
TensorIndexTupleOp< ArgType >::CoeffReturnType TupleType
Definition TensorArgMax.h:220
TensorTupleReducerOp< ReduceOp, Dims, ArgType > XprType
Definition TensorArgMax.h:216
array< Index, NumDims > StrideDims
Definition TensorArgMax.h:224
internal::TensorBlockNotImplemented TensorBlock
Definition TensorArgMax.h:240
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index) const
Definition TensorArgMax.h:274
EIGEN_DEVICE_FUNC EvaluatorPointerType data() const
Definition TensorArgMax.h:279
XprType::Index Index
Definition TensorArgMax.h:217
EIGEN_STRONG_INLINE void cleanup()
Definition TensorArgMax.h:270
Index m_stride_div
Definition TensorArgMax.h:324
TensorEvaluator< const TensorReductionOp< ReduceOp, Dims, const TensorIndexTupleOp< ArgType > >, Device > m_impl
Definition TensorArgMax.h:320
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorOpCost costPerCoeff(bool vectorized) const
Definition TensorArgMax.h:288
TensorEvaluator< constTensorIndexTupleOp< ArgType >, Device >::Dimensions InputDimensions
Definition TensorArgMax.h:222
TensorEvaluator< const TensorIndexTupleOp< ArgType >, Device > m_orig_impl
Definition TensorArgMax.h:319
StrideDims m_strides
Definition TensorArgMax.h:322
A cost model used to limit the number of threads used for evaluating tensor expression.
Definition TensorEvaluator.h:29
Derived::Scalar CoeffReturnType
Definition TensorEvaluator.h:32
@ BlockAccess
Definition TensorEvaluator.h:48
@ PreferBlockAccess
Definition TensorEvaluator.h:49
@ PacketAccess
Definition TensorEvaluator.h:47
@ Layout
Definition TensorEvaluator.h:50
@ IsAligned
Definition TensorEvaluator.h:46
Derived::Dimensions Dimensions
Definition TensorEvaluator.h:34
Definition TensorMeta.h:211
U first
Definition TensorMeta.h:213
const TensorIndexTupleOp< XprType > EIGEN_DEVICE_REF type
Definition TensorArgMax.h:40
const TensorTupleReducerOp< ReduceOp, Dims, XprType > EIGEN_DEVICE_REF type
Definition TensorArgMax.h:163
Definition XprHelper.h:332
TensorIndexTupleOp< XprType > type
Definition TensorArgMax.h:47
TensorTupleReducerOp< ReduceOp, Dims, XprType > type
Definition TensorArgMax.h:170
Definition TensorTraits.h:175
remove_reference< Nested >::type _Nested
Definition TensorArgMax.h:32
traits< XprType > XprTraits
Definition TensorArgMax.h:27
XprType::Nested Nested
Definition TensorArgMax.h:31
XprTraits::StorageKind StorageKind
Definition TensorArgMax.h:28
XprTraits::Index Index
Definition TensorArgMax.h:29
Tuple< Index, typename XprTraits::Scalar > Scalar
Definition TensorArgMax.h:30
XprType::Nested Nested
Definition TensorArgMax.h:154
XprTraits::Index Index
Definition TensorArgMax.h:152
Index Scalar
Definition TensorArgMax.h:153
traits< XprType > XprTraits
Definition TensorArgMax.h:150
XprTraits::StorageKind StorageKind
Definition TensorArgMax.h:151
remove_reference< Nested >::type _Nested
Definition TensorArgMax.h:155
Definition ForwardDeclarations.h:17