TensorSyclExtractAccessor.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  * TensorSyclExtractAccessor.h
15  *
16  * \brief:
17  * ExtractAccessor takes Expression placeHolder expression and the tuple of sycl
18  * buffers as an input. Using pre-order tree traversal, ExtractAccessor
19  * recursively calls itself for its children in the expression tree. The
20  * leaf node in the PlaceHolder expression is nothing but a container preserving
21  * the order of the actual data in the tuple of sycl buffer. By invoking the
22  * extract accessor for the PlaceHolder<N>, an accessor is created for the Nth
23  * buffer in the tuple of buffers. This accessor is then added as an Nth
24  * element in the tuple of accessors. In this case we preserve the order of data
25  * in the expression tree.
26  *
27  * This is the specialisation of extract accessor method for different operation
28  * type in the PlaceHolder expression.
29  *
30 *****************************************************************/
31 
32 #ifndef UNSUPPORTED_EIGEN_CXX11_SRC_TENSOR_TENSORSYCL_EXTRACT_ACCESSOR_HPP
33 #define UNSUPPORTED_EIGEN_CXX11_SRC_TENSOR_TENSORSYCL_EXTRACT_ACCESSOR_HPP
34 
35 namespace Eigen {
36 namespace TensorSycl {
37 namespace internal {
42 template <typename Evaluator>
44 
46  template<typename Arg> static inline auto getTuple(cl::sycl::handler& cgh, Arg eval)
47  -> decltype(ExtractAccessor<Arg>::getTuple(cgh, eval)) {
48  return ExtractAccessor<Arg>::getTuple(cgh, eval);
49  }
50 
51  template<typename Arg1, typename Arg2> static inline auto getTuple(cl::sycl::handler& cgh, Arg1 eval1, Arg2 eval2)
54  }
55  template<typename Arg1, typename Arg2, typename Arg3> static inline auto getTuple(cl::sycl::handler& cgh, Arg1 eval1 , Arg2 eval2 , Arg3 eval3)
58  }
59  template< cl::sycl::access::mode AcM, typename Arg> static inline auto getAccessor(cl::sycl::handler& cgh, Arg eval)
60  -> decltype(utility::tuple::make_tuple( eval.device().template get_sycl_accessor<AcM,
61  typename Eigen::internal::remove_all<typename Arg::CoeffReturnType>::type>(eval.dimensions().TotalSize(), cgh,eval.data()))){
62  return utility::tuple::make_tuple(eval.device().template get_sycl_accessor<AcM, typename Eigen::internal::remove_all<typename Arg::CoeffReturnType>::type>(eval.dimensions().TotalSize(), cgh,eval.data()));
63  }
64 };
65 
68 template <template<class, class> class UnaryCategory, typename OP, typename RHSExpr, typename Dev>
69 struct ExtractAccessor<TensorEvaluator<const UnaryCategory<OP, RHSExpr>, Dev> > {
70  static inline auto getTuple(cl::sycl::handler& cgh, const TensorEvaluator<const UnaryCategory<OP, RHSExpr>, Dev> eval)
71  -> decltype(AccessorConstructor::getTuple(cgh, eval.impl())){
72  return AccessorConstructor::getTuple(cgh, eval.impl());
73  }
74 };
75 
77 template <template<class, class> class UnaryCategory, typename OP, typename RHSExpr, typename Dev>
78 struct ExtractAccessor<TensorEvaluator<UnaryCategory<OP, RHSExpr>, Dev> >
79 : ExtractAccessor<TensorEvaluator<const UnaryCategory<OP, RHSExpr>, Dev> > {};
80 
82 template <template<class, class, class> class BinaryCategory, typename OP, typename LHSExpr, typename RHSExpr, typename Dev>
83 struct ExtractAccessor<TensorEvaluator<const BinaryCategory<OP, LHSExpr, RHSExpr>, Dev> > {
84  static inline auto getTuple(cl::sycl::handler& cgh, const TensorEvaluator<const BinaryCategory<OP, LHSExpr, RHSExpr>, Dev> eval)
85  -> decltype(AccessorConstructor::getTuple(cgh, eval.left_impl(), eval.right_impl())){
86  return AccessorConstructor::getTuple(cgh, eval.left_impl(), eval.right_impl());
87  }
88 };
90 template <template<class, class, class> class BinaryCategory, typename OP, typename LHSExpr, typename RHSExpr, typename Dev>
91 struct ExtractAccessor<TensorEvaluator<BinaryCategory<OP, LHSExpr, RHSExpr>, Dev> >
92 : ExtractAccessor<TensorEvaluator<const BinaryCategory<OP, LHSExpr, RHSExpr>, Dev> >{};
93 
96 template <template<class, class, class, class> class TernaryCategory, typename OP, typename Arg1Expr, typename Arg2Expr, typename Arg3Expr, typename Dev>
97 struct ExtractAccessor<TensorEvaluator<const TernaryCategory<OP, Arg1Expr, Arg2Expr, Arg3Expr>, Dev> > {
98  static inline auto getTuple(cl::sycl::handler& cgh, const TensorEvaluator<const TernaryCategory<OP, Arg1Expr, Arg2Expr, Arg3Expr>, Dev> eval)
99  -> decltype(AccessorConstructor::getTuple(cgh, eval.arg1Impl(), eval.arg2Impl(), eval.arg3Impl())){
100  return AccessorConstructor::getTuple(cgh, eval.arg1Impl(), eval.arg2Impl(), eval.arg3Impl());
101  }
102 };
103 
105 template <template<class, class, class, class> class TernaryCategory, typename OP, typename Arg1Expr, typename Arg2Expr, typename Arg3Expr, typename Dev>
106 struct ExtractAccessor<TensorEvaluator<TernaryCategory<OP, Arg1Expr, Arg2Expr, Arg3Expr>, Dev> >
107 : ExtractAccessor<TensorEvaluator<const TernaryCategory<OP, Arg1Expr, Arg2Expr, Arg3Expr>, Dev> >{};
108 
111 template <typename IfExpr, typename ThenExpr, typename ElseExpr, typename Dev>
112 struct ExtractAccessor<TensorEvaluator<const TensorSelectOp<IfExpr, ThenExpr, ElseExpr>, Dev> > {
113  static inline auto getTuple(cl::sycl::handler& cgh, const TensorEvaluator<const TensorSelectOp<IfExpr, ThenExpr, ElseExpr>, Dev> eval)
114  -> decltype(AccessorConstructor::getTuple(cgh, eval.cond_impl(), eval.then_impl(), eval.else_impl())){
115  return AccessorConstructor::getTuple(cgh, eval.cond_impl(), eval.then_impl(), eval.else_impl());
116  }
117 };
118 
121 template <typename IfExpr, typename ThenExpr, typename ElseExpr, typename Dev>
122 struct ExtractAccessor<TensorEvaluator<TensorSelectOp<IfExpr, ThenExpr, ElseExpr>, Dev> >
123 : ExtractAccessor<TensorEvaluator<const TensorSelectOp<IfExpr, ThenExpr, ElseExpr>, Dev> >{};
124 
126 template <typename LHSExpr, typename RHSExpr, typename Dev>
127 struct ExtractAccessor<TensorEvaluator<const TensorAssignOp<LHSExpr, RHSExpr>, Dev> > {
128  static inline auto getTuple(cl::sycl::handler& cgh, const TensorEvaluator<const TensorAssignOp<LHSExpr, RHSExpr>, Dev> eval)
129  -> decltype(AccessorConstructor::getTuple(cgh, eval.left_impl(), eval.right_impl())){
130  return AccessorConstructor::getTuple(cgh, eval.left_impl(), eval.right_impl());
131  }
132 };
133 
135 template <typename LHSExpr, typename RHSExpr, typename Dev>
136 struct ExtractAccessor<TensorEvaluator<TensorAssignOp<LHSExpr, RHSExpr>, Dev> >
137 : ExtractAccessor<TensorEvaluator<const TensorAssignOp<LHSExpr, RHSExpr>, Dev> >{};
138 
140 #define TENSORMAPEXPR(CVQual, ACCType)\
141 template <typename PlainObjectType, int Options_, typename Dev>\
142 struct ExtractAccessor<TensorEvaluator<CVQual TensorMap<PlainObjectType, Options_>, Dev> > {\
143  static inline auto getTuple(cl::sycl::handler& cgh,const TensorEvaluator<CVQual TensorMap<PlainObjectType, Options_>, Dev> eval)\
144  -> decltype(AccessorConstructor::template getAccessor<ACCType>(cgh, eval)){\
145  return AccessorConstructor::template getAccessor<ACCType>(cgh, eval);\
146  }\
147 };
148 TENSORMAPEXPR(const, cl::sycl::access::mode::read)
149 TENSORMAPEXPR(, cl::sycl::access::mode::read_write)
150 #undef TENSORMAPEXPR
151 
153 template <typename Expr, typename Dev>
155  static inline auto getTuple(cl::sycl::handler& cgh, const TensorEvaluator<const TensorForcedEvalOp<Expr>, Dev> eval)
156  -> decltype(AccessorConstructor::template getAccessor<cl::sycl::access::mode::read>(cgh, eval)){
157  return AccessorConstructor::template getAccessor<cl::sycl::access::mode::read>(cgh, eval);
158  }
159 };
160 
162 template <typename Expr, typename Dev>
164 : ExtractAccessor<TensorEvaluator<const TensorForcedEvalOp<Expr>, Dev> >{};
165 
167 template <typename Expr, typename Dev>
168 struct ExtractAccessor<TensorEvaluator<const TensorEvalToOp<Expr>, Dev> > {
169  static inline auto getTuple(cl::sycl::handler& cgh,const TensorEvaluator<const TensorEvalToOp<Expr>, Dev> eval)
170  -> decltype(utility::tuple::append(AccessorConstructor::template getAccessor<cl::sycl::access::mode::write>(cgh, eval), AccessorConstructor::getTuple(cgh, eval.impl()))){
171  return utility::tuple::append(AccessorConstructor::template getAccessor<cl::sycl::access::mode::write>(cgh, eval), AccessorConstructor::getTuple(cgh, eval.impl()));
172  }
173 };
174 
176 template <typename Expr, typename Dev>
178 : ExtractAccessor<TensorEvaluator<const TensorEvalToOp<Expr>, Dev> >{};
179 
181 template <typename OP, typename Dim, typename Expr, typename Dev>
182 struct ExtractAccessor<TensorEvaluator<const TensorReductionOp<OP, Dim, Expr>, Dev> > {
183  static inline auto getTuple(cl::sycl::handler& cgh, const TensorEvaluator<const TensorReductionOp<OP, Dim, Expr>, Dev> eval)
184  -> decltype(AccessorConstructor::template getAccessor<cl::sycl::access::mode::read>(cgh, eval)){
185  return AccessorConstructor::template getAccessor<cl::sycl::access::mode::read>(cgh, eval);
186  }
187 };
188 
190 template <typename OP, typename Dim, typename Expr, typename Dev>
191 struct ExtractAccessor<TensorEvaluator<TensorReductionOp<OP, Dim, Expr>, Dev> >
192 : ExtractAccessor<TensorEvaluator<const TensorReductionOp<OP, Dim, Expr>, Dev> >{};
193 
195 template <typename Evaluator>
196 auto createTupleOfAccessors(cl::sycl::handler& cgh, const Evaluator& expr)
197 -> decltype(ExtractAccessor<Evaluator>::getTuple(cgh, expr)) {
198  return ExtractAccessor<Evaluator>::getTuple(cgh, expr);
199 }
200 
201 }
202 }
203 }
204 #endif // UNSUPPORTED_EIGEN_CXX11_SRC_TENSOR_TENSORSYCL_EXTRACT_ACCESSOR_HPP
static auto getTuple(cl::sycl::handler &cgh, Arg eval) -> decltype(ExtractAccessor< Arg >::getTuple(cgh, eval))
static auto getTuple(cl::sycl::handler &cgh, Arg1 eval1, Arg2 eval2) -> decltype(utility::tuple::append(ExtractAccessor< Arg1 >::getTuple(cgh, eval1), ExtractAccessor< Arg2 >::getTuple(cgh, eval2)))
static auto getTuple(cl::sycl::handler &cgh, const TensorEvaluator< const BinaryCategory< OP, LHSExpr, RHSExpr >, Dev > eval) -> decltype(AccessorConstructor::getTuple(cgh, eval.left_impl(), eval.right_impl()))
static auto getAccessor(cl::sycl::handler &cgh, Arg eval) -> decltype(utility::tuple::make_tuple(eval.device().template get_sycl_accessor< AcM, typename Eigen::internal::remove_all< typename Arg::CoeffReturnType >::type >(eval.dimensions().TotalSize(), cgh, eval.data())))
Definition: LDLT.h:16
Tuple< Args..., T > append(Tuple< Args... > t, T a)
the deduction function for append_base that automatically generate the IndexRange ...
static auto getTuple(cl::sycl::handler &cgh, const TensorEvaluator< const TensorReductionOp< OP, Dim, Expr >, Dev > eval) -> decltype(AccessorConstructor::template getAccessor< cl::sycl::access::mode::read >(cgh, eval))
A cost model used to limit the number of threads used for evaluating tensor expression.
auto createTupleOfAccessors(cl::sycl::handler &cgh, const Evaluator &expr) -> decltype(ExtractAccessor< Evaluator >::getTuple(cgh, expr))
template deduction for ExtractAccessor
Tuple< Args... > make_tuple(Args...args)
Creates a tuple object, deducing the target type from the types of arguments.
static auto getTuple(cl::sycl::handler &cgh, const TensorEvaluator< const UnaryCategory< OP, RHSExpr >, Dev > eval) -> decltype(AccessorConstructor::getTuple(cgh, eval.impl()))
static auto getTuple(cl::sycl::handler &cgh, const TensorEvaluator< const TensorAssignOp< LHSExpr, RHSExpr >, Dev > eval) -> decltype(AccessorConstructor::getTuple(cgh, eval.left_impl(), eval.right_impl()))
static auto getTuple(cl::sycl::handler &cgh, const TensorEvaluator< const TensorForcedEvalOp< Expr >, Dev > eval) -> decltype(AccessorConstructor::template getAccessor< cl::sycl::access::mode::read >(cgh, eval))
static auto getTuple(cl::sycl::handler &cgh, const TensorEvaluator< const TensorSelectOp< IfExpr, ThenExpr, ElseExpr >, Dev > eval) -> decltype(AccessorConstructor::getTuple(cgh, eval.cond_impl(), eval.then_impl(), eval.else_impl()))
static auto getTuple(cl::sycl::handler &cgh, const TensorEvaluator< const TensorEvalToOp< Expr >, Dev > eval) -> decltype(utility::tuple::append(AccessorConstructor::template getAccessor< cl::sycl::access::mode::write >(cgh, eval), AccessorConstructor::getTuple(cgh, eval.impl())))
static auto getTuple(cl::sycl::handler &cgh, Arg1 eval1, Arg2 eval2, Arg3 eval3) -> decltype(utility::tuple::append(ExtractAccessor< Arg1 >::getTuple(cgh, eval1), utility::tuple::append(ExtractAccessor< Arg2 >::getTuple(cgh, eval2), ExtractAccessor< Arg3 >::getTuple(cgh, eval3))))
static auto getTuple(cl::sycl::handler &cgh, const TensorEvaluator< const TernaryCategory< OP, Arg1Expr, Arg2Expr, Arg3Expr >, Dev > eval) -> decltype(AccessorConstructor::getTuple(cgh, eval.arg1Impl(), eval.arg2Impl(), eval.arg3Impl()))
#define TENSORMAPEXPR(CVQual, ACCType)
specialisation of the ExtractAccessor struct when the node type is const TensorMap ...


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