12 #include "etl/concepts.hpp" 17 namespace temporary_detail {
24 template <
typename E,
bool Fast>
53 template <
bool Fast,
typename E>
65 template <
typename D,
bool Fast>
75 mutable std::shared_ptr<result_type>
_c;
106 template <
typename VV = default_vec>
123 return *
static_cast<const derived_t*
>(
this);
152 cpp_assert(is_allocated(),
"The result has not been allocated");
153 as_derived().assign_to(*_c);
170 template <
size_t... I>
179 if constexpr (is_fast<derived_t>) {
205 return result().read_flat(i);
213 template <size_c... S>
215 return result()(args...);
224 return sub(as_derived(), i);
233 auto slice(
size_t first,
size_t last) noexcept {
234 return slice(*
this, first, last);
243 auto slice(
size_t first,
size_t last)
const noexcept {
244 return slice(*
this, first, last);
253 template <
typename VV = default_vec>
264 template <
typename VV = default_vec>
273 template <
typename Y>
284 template <
typename Y>
298 return result().memory_start();
306 return result().memory_start();
314 return result().memory_end();
322 return result().memory_end();
330 return result().gpu_memory();
337 result().gpu_evict();
344 result().invalidate_cpu();
351 result().invalidate_gpu();
358 result().validate_cpu();
365 result().validate_gpu();
373 result().ensure_gpu_allocated();
380 result().ensure_gpu_up_to_date();
388 result().ensure_cpu_up_to_date();
396 result().gpu_copy_from(gpu_memory);
404 return result().is_cpu_up_to_date();
412 return result().is_gpu_up_to_date();
421 cpp_assert(is_allocated(),
"The result has not been allocated");
422 cpp_assert(*evaluated,
"The result has not been evaluated");
431 cpp_assert(is_allocated(),
"The result has not been allocated");
432 cpp_assert(*evaluated,
"The result has not been evaluated");
442 template <
typename D, etl_expr A,
bool Fast = true>
449 using base_type::evaluated;
480 template <
typename E>
482 return _a.alias(rhs);
489 std::add_lvalue_reference_t<A>
a() {
497 cpp::add_const_lvalue_t<A>
a()
const {
514 this->allocate_temporary();
528 template <
typename D, etl_expr A, etl_expr B,
bool Fast = true>
536 using base_type::evaluated;
568 template <
typename E>
570 return _a.alias(rhs) || _b.alias(rhs);
577 std::add_lvalue_reference_t<A>
a() {
585 cpp::add_const_lvalue_t<A>
a()
const {
593 std::add_lvalue_reference_t<B>
b() {
601 cpp::add_const_lvalue_t<B>
b()
const {
618 this->allocate_temporary();
633 template <
typename D, etl_expr A, etl_expr B, etl_expr C,
bool Fast = true>
642 using base_type::evaluated;
676 template <
typename E>
678 return _a.alias(rhs) || _b.alias(rhs) || _c.alias(rhs);
686 std::add_lvalue_reference_t<A>
a() {
694 cpp::add_const_lvalue_t<A>
a()
const {
702 std::add_lvalue_reference_t<B>
b() {
710 cpp::add_const_lvalue_t<B>
b()
const {
718 std::add_lvalue_reference_t<C>
c() {
726 cpp::add_const_lvalue_t<C>
c()
const {
744 this->allocate_temporary();
void allocate_temporary() const
Allocate the necessary temporaries, if necessary.
Definition: base_temporary_expr.hpp:161
cpp::add_const_lvalue_t< A > a() const
Returns the sub expression.
Definition: base_temporary_expr.hpp:497
CRTP class to inject iterators functions.
Definition: iterable.hpp:23
std::add_lvalue_reference_t< B > b()
Returns the sub expression.
Definition: base_temporary_expr.hpp:702
result_type * allocate() const
Allocate the temporary.
Definition: base_temporary_expr.hpp:178
std::add_lvalue_reference_t< A > a()
Returns the sub expression.
Definition: base_temporary_expr.hpp:489
void ensure_gpu_allocated() const
Ensures that the GPU memory is allocated and that the GPU memory is up to date (to undefined value)...
Definition: sub_view.hpp:717
value_type * memory_type
The memory type.
Definition: base_temporary_expr.hpp:70
B _b
The sub expression reference.
Definition: base_temporary_expr.hpp:534
auto slice(E &&value, size_t first, size_t last) -> slice_view< detail::build_identity_type< E >>
Returns view representing a slice view of the given expression.
Definition: view_expression_builder.hpp:112
A temporary expression base.
Definition: base_temporary_expr.hpp:66
bool alias(const E &rhs) const
Test if this expression aliases with the given expression.
Definition: base_temporary_expr.hpp:569
A _a
The sub expression reference.
Definition: base_temporary_expr.hpp:533
base_temporary_expr_bin(const base_temporary_expr_bin &e)
Construct a new expression by copy.
Definition: base_temporary_expr.hpp:551
void visit(detail::evaluator_visitor &visitor) const
Apply the given visitor to this expression and its descendants.
Definition: base_temporary_expr.hpp:611
D D
The number of dimensions.
Definition: dyn_matrix_view.hpp:24
cpp::add_const_lvalue_t< A > a() const
Returns the sub expression.
Definition: base_temporary_expr.hpp:694
void visit(detail::evaluator_visitor &visitor) const
Apply the given visitor to this expression and its descendants.
Definition: base_temporary_expr.hpp:507
bool is_allocated() const noexcept
Indicates if the temporary has been allocated.
Definition: base_temporary_expr.hpp:131
bool alias(const E &rhs) const
Test if this expression aliases with the given expression.
Definition: base_temporary_expr.hpp:677
const derived_t & as_derived() const noexcept
Returns a reference to the derived object, i.e. the object using the CRTP injector.
Definition: base_temporary_expr.hpp:122
const value_type * const_memory_type
The const memory type.
Definition: base_temporary_expr.hpp:71
A _a
The first sub expression reference.
Definition: base_temporary_expr.hpp:638
Abstract base class for temporary binary expression.
Definition: base_temporary_expr.hpp:529
bool is_cpu_up_to_date() const noexcept
Indicates if the CPU memory is up to date.
Definition: sub_view.hpp:777
std::add_lvalue_reference_t< B > b()
Returns the sub expression.
Definition: base_temporary_expr.hpp:593
void gpu_copy_from([[maybe_unused]] const value_type *new_gpu_memory) const
Copy from GPU to GPU.
Definition: sub_view.hpp:761
A _a
The sub expression reference.
Definition: base_temporary_expr.hpp:447
dyn_base< this_type, T, D > base_type
The base type.
Definition: sparse.hpp:227
std::add_lvalue_reference_t< A > a()
Returns the sub expression.
Definition: base_temporary_expr.hpp:686
void gpu_evict() const noexcept
Evict the expression from GPU.
Definition: sub_view.hpp:681
CRTP class to inject functions testing values of the expressions.
Definition: value_testable.hpp:26
typename VV::template vec_type< value_type > vec_type
The vectorization type for VV.
Definition: base_temporary_expr.hpp:107
base_temporary_expr_un(A a)
Construct a new expression.
Definition: base_temporary_expr.hpp:455
bool is_evaluated() const noexcept
Indicates if the temporary has been evaluated.
Definition: base_temporary_expr.hpp:140
Build a fast_dyn_matrix type from some expression.
Definition: temporary.hpp:26
derived_t & as_derived() noexcept
Returns a reference to the derived object, i.e. the object using the CRTP injector.
Definition: base_temporary_expr.hpp:114
auto load(size_t x) const noexcept
Load several elements of the expression at once.
Definition: dyn_matrix_view.hpp:143
Traits to get information about ETL types.
Definition: tmp.hpp:68
Root namespace for the ETL library.
Definition: adapter.hpp:15
base_temporary_expr_bin(A a, B b)
Construct a new expression.
Definition: base_temporary_expr.hpp:543
static constexpr size_t dimensions()
Return the number of dimensions of the expression.
Definition: traits_base.hpp:31
cpp::add_const_lvalue_t< A > a() const
Returns the sub expression.
Definition: base_temporary_expr.hpp:585
result_type * dyn_allocate(std::index_sequence< I... >) const
Allocate the dynamic temporary.
Definition: base_temporary_expr.hpp:171
void invalidate_gpu() const noexcept
Invalidates the GPU memory.
Definition: sub_view.hpp:695
void evaluate() const
Evaluate the expression, if not evaluated.
Definition: base_temporary_expr.hpp:150
void ensure_cpu_up_to_date() const
Ensures that the GPU memory is allocated and that the GPU memory is up to date (to undefined value)...
Definition: dyn_matrix_view.hpp:271
bool alias(const E &rhs) const
Test if this expression aliases with the given expression.
Definition: base_temporary_expr.hpp:481
Visitor to perform local evaluation when necessary.
Definition: eval_visitors.hpp:23
void invalidate_cpu() const noexcept
Invalidates the CPU memory.
Definition: sub_view.hpp:688
temporary_detail::expr_result_t< Fast, conv_4d_valid_filter_expr< A, B, S1, S2, P1, P2, Flipped > > result_type
The result type.
Definition: base_temporary_expr.hpp:69
Abstract base class for temporary ternary expression.
Definition: base_temporary_expr.hpp:634
const_return_type operator()(size_t j) const
Access to the element at the given position.
Definition: dyn_matrix_view.hpp:89
typename decay_traits< conv_4d_valid_filter_expr< A, B, S1, S2, P1, P2, Flipped > >::value_type value_type
The value type.
Definition: base_temporary_expr.hpp:68
Matrix with run-time fixed dimensions.
Definition: dyn.hpp:26
auto loadu(size_t x) const noexcept
Load several elements of the expression at once.
Definition: dyn_matrix_view.hpp:154
value_type operator[](size_t i) const
Returns the element at the given index.
Definition: base_temporary_expr.hpp:194
cpp::add_const_lvalue_t< B > b() const
Returns the sub expression.
Definition: base_temporary_expr.hpp:601
base_temporary_expr(base_temporary_expr &&rhs)
Move construct a base_temporary_expr The right hand side cannot be used anymore after ths move...
Definition: base_temporary_expr.hpp:95
cpp::add_const_lvalue_t< C > c() const
Returns the sub expression.
Definition: base_temporary_expr.hpp:726
base_temporary_expr_tern(A a, B b, C c)
Construct a new expression.
Definition: base_temporary_expr.hpp:651
base_temporary_expr()
Construct a new base_temporary_expr.
Definition: base_temporary_expr.hpp:81
requires(D > 0) struct dyn_base
Matrix with run-time fixed dimensions.
Definition: dyn_base.hpp:113
D derived_t
The derived type.
Definition: dim_testable.hpp:46
bool is_gpu_up_to_date() const noexcept
Indicates if the GPU memory is up to date.
Definition: sub_view.hpp:785
void ensure_gpu_up_to_date() const
Copy back from the GPU to the expression memory if necessary.
Definition: dyn_matrix_view.hpp:280
void visit(detail::evaluator_visitor &visitor) const
Apply the given visitor to this expression and its descendants.
Definition: base_temporary_expr.hpp:737
void validate_gpu() const noexcept
Validates the GPU memory.
Definition: sub_view.hpp:709
base_temporary_expr_tern(base_temporary_expr_tern &&e) noexcept
Construct a new expression by move.
Definition: base_temporary_expr.hpp:667
base_temporary_expr_un(base_temporary_expr_un &&e) noexcept
Construct a new expression by move.
Definition: base_temporary_expr.hpp:471
Abstract base class for temporary unary expression.
Definition: base_temporary_expr.hpp:443
auto allocate(size_t size, mangling_faker< S >=mangling_faker< S >())
Allocate an array of the given size for the given type.
Definition: allocator.hpp:80
Iterator implementation for ETL expressions.
B _b
The second sub expression reference.
Definition: base_temporary_expr.hpp:639
std::shared_ptr< bool > evaluated
Indicates if the expression has been evaluated.
Definition: base_temporary_expr.hpp:74
C _c
The third sub expression reference.
Definition: base_temporary_expr.hpp:640
cpp::add_const_lvalue_t< B > b() const
Returns the sub expression.
Definition: base_temporary_expr.hpp:710
typename detail::build_fast_dyn_matrix_type< E, std::make_index_sequence< decay_traits< E >::dimensions()> >::type type
The built type for the given Subs.
Definition: base_temporary_expr.hpp:46
const auto & gpu_compute_hint([[maybe_unused]] Y &y) const
Return a GPU computed version of this expression.
Definition: sub_view.hpp:653
std::shared_ptr< result_type > _c
The result reference.
Definition: base_temporary_expr.hpp:75
std::add_lvalue_reference_t< A > a()
Returns the sub expression.
Definition: base_temporary_expr.hpp:577
void validate_cpu() const noexcept
Validates the CPU memory.
Definition: sub_view.hpp:702
base_temporary_expr_tern(const base_temporary_expr_tern &e)
Construct a new expression by copy.
Definition: base_temporary_expr.hpp:659
base_temporary_expr_un(const base_temporary_expr_un &e)
Construct a new expression by copy.
Definition: base_temporary_expr.hpp:463
std::add_lvalue_reference_t< C > c()
Returns the sub expression.
Definition: base_temporary_expr.hpp:718
value_type * gpu_memory() const noexcept
Return GPU memory of this expression, if any.
Definition: sub_view.hpp:674
Traits to build the result type of a temporary expression.
Definition: base_temporary_expr.hpp:25
CRTP class to inject functions testing the dimensions.
Definition: dim_testable.hpp:45
base_temporary_expr_bin(base_temporary_expr_bin &&e) noexcept
Construct a new expression by move.
Definition: base_temporary_expr.hpp:559
value_type read_flat(size_t i) const
Returns the value at the given index This function never alters the state of the container.
Definition: base_temporary_expr.hpp:204