TensorSyclExtractFunctors.h
Go to the documentation of this file.
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Mehdi Goli Codeplay Software Ltd.
5 // Ralph Potter Codeplay Software Ltd.
6 // Luke Iwanski Codeplay Software Ltd.
7 // Contact: <eigen@codeplay.com>
8 //
9 // This Source Code Form is subject to the terms of the Mozilla
10 // Public License v. 2.0. If a copy of the MPL was not distributed
11 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
12 
13 /*****************************************************************
14  * TensorSyclextractFunctors.h
15  *
16  * \brief:
17  * Used to extract all the functors allocated to each node of the expression
18 *tree.
19  *
20 *****************************************************************/
21 
22 #ifndef UNSUPPORTED_EIGEN_CXX11_SRC_TENSOR_TENSORSYCL_EXTRACT_FUNCTORS_HPP
23 #define UNSUPPORTED_EIGEN_CXX11_SRC_TENSOR_TENSORSYCL_EXTRACT_FUNCTORS_HPP
24 
25 namespace Eigen {
26 namespace TensorSycl {
27 namespace internal {
35 // This struct is used for leafNode (TensorMap) and nodes behaving like leafNode (TensorForcedEval).
36 template <typename Evaluator> struct FunctorExtractor{
37  typedef typename Evaluator::Dimensions Dimensions;
38  const Dimensions m_dimensions;
39  const Dimensions& dimensions() const { return m_dimensions; }
40  FunctorExtractor(const Evaluator& expr)
41  : m_dimensions(expr.dimensions()) {}
42 
43 };
44 
47 template <template <class, class> class UnaryCategory, typename OP, typename RHSExpr, typename Dev>
48 struct FunctorExtractor<TensorEvaluator<const UnaryCategory<OP, RHSExpr>, Dev> > {
50  OP func;
51  FunctorExtractor(const TensorEvaluator<const UnaryCategory<OP, RHSExpr>, Dev>& expr)
52  : rhsExpr(expr.impl()), func(expr.functor()) {}
53 };
56 template <template <class, class> class UnaryCategory, typename OP, typename RHSExpr, typename Dev>
57 struct FunctorExtractor<TensorEvaluator<UnaryCategory<OP, RHSExpr>, Dev> >
58 : FunctorExtractor<TensorEvaluator<const UnaryCategory<OP, RHSExpr>, Dev> >{};
59 
62 template <template<class, class, class> class BinaryCategory, typename OP, typename LHSExpr, typename RHSExpr, typename Dev>
63 struct FunctorExtractor<TensorEvaluator<const BinaryCategory<OP, LHSExpr, RHSExpr>, Dev> > {
66  OP func;
67  FunctorExtractor(const TensorEvaluator<const BinaryCategory<OP, LHSExpr, RHSExpr>, Dev>& expr)
68  : lhsExpr(expr.left_impl()),rhsExpr(expr.right_impl()),func(expr.functor()) {}
69 };
70 
73 template <template <class, class, class> class BinaryCategory, typename OP, typename LHSExpr, typename RHSExpr, typename Dev>
74 struct FunctorExtractor<TensorEvaluator<BinaryCategory<OP, LHSExpr, RHSExpr>, Dev> >
75 : FunctorExtractor<TensorEvaluator<const BinaryCategory<OP, LHSExpr, RHSExpr>, Dev> >{};
76 
79 template <template <class, class, class, class> class TernaryCategory, typename OP, typename Arg1Expr, typename Arg2Expr, typename Arg3Expr,typename Dev>
80 struct FunctorExtractor<TensorEvaluator<const TernaryCategory<OP, Arg1Expr, Arg2Expr, Arg3Expr>, Dev> > {
84  OP func;
85  FunctorExtractor(const TensorEvaluator<const TernaryCategory<OP, Arg1Expr, Arg2Expr, Arg3Expr>, Dev>& expr)
86  : arg1Expr(expr.arg1Impl()), arg2Expr(expr.arg2Impl()), arg3Expr(expr.arg3Impl()), func(expr.functor()) {}
87 };
88 
91 template <template <class, class, class, class> class TernaryCategory, typename OP, typename Arg1Expr, typename Arg2Expr, typename Arg3Expr, typename Dev>
92 struct FunctorExtractor<TensorEvaluator< TernaryCategory<OP, Arg1Expr, Arg2Expr, Arg3Expr>, Dev> >
93 :FunctorExtractor<TensorEvaluator<const TernaryCategory<OP, Arg1Expr, Arg2Expr, Arg3Expr>, Dev> >{};
94 
97 template <typename IfExpr, typename ThenExpr, typename ElseExpr, typename Dev>
98 struct FunctorExtractor< TensorEvaluator<const TensorSelectOp<IfExpr, ThenExpr, ElseExpr>, Dev> > {
103  : ifExpr(expr.cond_impl()), thenExpr(expr.then_impl()), elseExpr(expr.else_impl()) {}
104 };
105 
108 template <typename IfExpr, typename ThenExpr, typename ElseExpr, typename Dev>
109 struct FunctorExtractor<TensorEvaluator<TensorSelectOp<IfExpr, ThenExpr, ElseExpr>, Dev> >
110 :FunctorExtractor< TensorEvaluator<const TensorSelectOp<IfExpr, ThenExpr, ElseExpr>, Dev> > {};
111 
114 template <typename LHSExpr, typename RHSExpr, typename Dev>
115 struct FunctorExtractor<TensorEvaluator<const TensorAssignOp<LHSExpr, RHSExpr>, Dev> > {
119  : lhsExpr(expr.left_impl()), rhsExpr(expr.right_impl()) {}
120 };
121 
124 template <typename LHSExpr, typename RHSExpr, typename Dev>
125 struct FunctorExtractor<TensorEvaluator<TensorAssignOp<LHSExpr, RHSExpr>, Dev> >
126 :FunctorExtractor<TensorEvaluator<const TensorAssignOp<LHSExpr, RHSExpr>, Dev> >{};
127 
128 
131 template <typename RHSExpr, typename Dev>
132 struct FunctorExtractor<TensorEvaluator<const TensorEvalToOp<RHSExpr>, Dev> > {
135  : rhsExpr(expr.impl()) {}
136 };
137 
140 template <typename RHSExpr, typename Dev>
142 : FunctorExtractor<TensorEvaluator<const TensorEvalToOp<RHSExpr>, Dev> > {};
143 
144 template<typename Dim, size_t NumOutputDim> struct DimConstr {
145 template<typename InDim>
146  static inline Dim getDim(InDim dims ) {return dims;}
147 };
148 
149 template<typename Dim> struct DimConstr<Dim, 0> {
150  template<typename InDim>
151  static inline Dim getDim(InDim dims ) {return Dim(dims.TotalSize());}
152 };
153 
154 template<typename Op, typename Dims, typename ArgType, template <class> class MakePointer_, typename Device>
155 struct FunctorExtractor<TensorEvaluator<const TensorReductionOp<Op, Dims, ArgType, MakePointer_>, Device>>{
158  const Dimensions m_dimensions;
159  const Dimensions& dimensions() const { return m_dimensions; }
161  : m_dimensions(DimConstr<Dimensions, Evaluator::NumOutputDims>::getDim(expr.dimensions())) {}
162 };
163 
164 
165 template<typename Op, typename Dims, typename ArgType, template <class> class MakePointer_, typename Device>
166 struct FunctorExtractor<TensorEvaluator<TensorReductionOp<Op, Dims, ArgType, MakePointer_>, Device>>
167 : FunctorExtractor<TensorEvaluator<const TensorReductionOp<Op, Dims, ArgType, MakePointer_>, Device>>{};
169 template <typename Evaluator>
170 auto inline extractFunctors(const Evaluator& evaluator)-> FunctorExtractor<Evaluator> {
171  return FunctorExtractor<Evaluator>(evaluator);
172 }
173 } // namespace internal
174 } // namespace TensorSycl
175 } // namespace Eigen
176 
177 #endif // UNSUPPORTED_EIGEN_CXX11_SRC_TENSOR_TENSORSYCL_EXTRACT_FUNCTORS_HPP
Definition: LDLT.h:16
A cost model used to limit the number of threads used for evaluating tensor expression.
FunctorExtractor(const TensorEvaluator< const TensorReductionOp< Op, Dims, ArgType, MakePointer_ >, Device > &expr)
Eigen::internal::conditional< Evaluator::NumOutputDims==0, DSizes< typename Evaluator::Index, 1 >, typename Evaluator::Dimensions >::type Dimensions
FunctorExtractor(const TensorEvaluator< const TernaryCategory< OP, Arg1Expr, Arg2Expr, Arg3Expr >, Dev > &expr)
auto extractFunctors(const Evaluator &evaluator) -> FunctorExtractor< Evaluator >
template deduction function for FunctorExtractor
FunctorExtractor(const TensorEvaluator< const TensorSelectOp< IfExpr, ThenExpr, ElseExpr >, Dev > &expr)
FunctorExtractor(const TensorEvaluator< const BinaryCategory< OP, LHSExpr, RHSExpr >, Dev > &expr)


hebiros
Author(s): Xavier Artache , Matthew Tesch
autogenerated on Thu Sep 3 2020 04:09:38