9 #ifndef PARSE_TREE_COMPLEX_EVALUATOR_H_ 10 #define PARSE_TREE_COMPLEX_EVALUATOR_H_ 41 template<
class Is_SubXpr=std::false_type>
44 template<
class Xpr,
class Stream>
45 static void nd_evaluate(
const Xpr expression,
Stream stream)
47 using system_tag =
typename Stream::system_tag;
50 bc::traits::constexpr_if<expression_traits<Xpr>::is_expr::value>([&]() {
51 nd_evaluator::template nd_evaluate<Xpr::tensor_iterator_dim>(expression, stream);
55 template<
class AssignmentOp,
class Left,
class Right,
class Stream>
56 static void greedy_optimization(Left left, Right right,
Stream stream)
59 auto assign_xpr = make_bin_expr<AssignmentOp>(left, right_xpr);
60 nd_evaluate(assign_xpr, stream);
62 if (!Is_SubXpr::value) {
63 using right_xpr_t = std::decay_t<decltype(right_xpr)>;
70 template<
class lv,
class rv,
class Stream,
class Op>
71 static std::enable_if_t<
80 auto output = make_output_data<alpha_mod, beta_mod>(expression.
left);
83 if (!entirely_blas_expression)
84 greedy_optimization<Op>(expression.
left, right, stream);
85 else if (!Is_SubXpr::value) {
91 template<
class lv,
class rv,
class Stream>
92 static std::enable_if_t<
101 auto output = make_output_data<alpha, beta>(expression.
left);
102 using expr_rv_t = std::decay_t<decltype(expression.
right)>;
104 auto right = bc::traits::constexpr_ternary<partial_blas_expr>(
107 expression.
right, output, stream);
111 expression.
right, output, stream);
114 using assignment_oper = std::conditional_t<
117 bc::traits::constexpr_if<!entirely_blas_expr>([&]() {
118 greedy_optimization<assignment_oper>(expression.
left, right, stream);
123 template<
class lv,
class rv,
class Stream,
class Op>
124 static std::enable_if_t<
128 greedy_optimization<Op>(expression.
left, expression.
right, stream);
132 template<
class Xpr,
class Stream>
133 static std::enable_if_t<!optimizer<Xpr>::requires_greedy_eval>
135 nd_evaluate(expression, stream);
144 class=std::enable_if_t<expression_traits<Xpr>::is_array::value>>
145 static auto evaluate(Xpr expression, Stream stream) {
157 class=std::enable_if_t<expression_traits<Xpr>::is_expr::value>,
159 static auto evaluate(Xpr expression, Stream stream)
161 using value_type =
typename Xpr::value_type;
162 auto allocator = stream.template get_allocator_rebound<value_type>();
163 auto shape = expression.get_shape();
167 make_bin_expr<oper::Assign>(temporary, expression), stream);
173 template<
class Xpr,
class Stream>
174 static auto greedy_evaluate(Xpr expression,
Stream stream) {
184 template<
class Xpr,
class Stream>
195 template<
class Xpr,
class SystemTag>
200 template<
class Xpr,
class SystemTag>
Definition: tree_evaluator.h:139
auto make_kernel_array(Shape< N > shape, Allocator allocator, Tags...)
Definition: array_kernel_array.h:134
static std::enable_if_t< optimizer< Bin_Op< Op, lv, rv > >::requires_greedy_eval &&bc::oper::operation_traits< Op >::is_linear_assignment_operation > evaluate(Bin_Op< Op, lv, rv > expression, Stream stream)
Definition: tree_evaluator.h:74
Rv right
Definition: expression_binary.h:62
Definition: expression_template_traits.h:48
static auto evaluate(Xpr expression, Stream stream)
Definition: tree_evaluator.h:145
Lv left
Definition: expression_binary.h:61
static std::enable_if_t< optimizer< Bin_Op< Op, lv, rv > >::requires_greedy_eval &&!bc::oper::operation_traits< Op >::is_linear_assignment_operation > evaluate(Bin_Op< Op, lv, rv > expression, Stream stream)
Definition: tree_evaluator.h:127
unsigned get_max_allocated() const
Definition: logging_stream.h:79
static std::enable_if_t<!optimizer< Xpr >::requires_greedy_eval > evaluate(Xpr expression, Stream stream)
Definition: tree_evaluator.h:134
Definition: tree_evaluator.h:42
Definition: tree_evaluator_optimizer.h:28
Definition: operation_traits.h:24
static auto evaluate(Xpr expression, Stream stream)
Returns a kernel_array containing the tag temporary_tag, the caller of the function is responsible fo...
Definition: tree_evaluator.h:159
Definition: logging_stream.h:56
BCINLINE auto shape(Integers... ints)
Definition: shape.h:264
static std::enable_if_t< optimizer< Bin_Op< bc::oper::Assign, lv, rv > >::requires_greedy_eval > evaluate(Bin_Op< oper::Assign, lv, rv > expression, Stream stream)
Definition: tree_evaluator.h:94
The Evaluator determines if an expression needs to be greedily optimized.
Definition: algorithms.h:22