10 #include "etl/expr/base_temporary_expr.hpp" 34 static constexpr
bool gpu_computable = all_row_major<A> && all_floating<A> && impl::egblas::has_stranspose_front;
50 static void check([[maybe_unused]]
const A&
a, [[maybe_unused]]
const C& c) {
51 if constexpr (all_fast<A, C>) {
52 static_assert(etl::dim<0, A>() == etl::dim<1, C>(),
"Invalid dimensions for front transposition");
53 static_assert(etl::dim<1, A>() == etl::dim<0, C>(),
"Invalid dimensions for front transposition");
54 static_assert(etl::dim<2, A>() == etl::dim<2, C>(),
"Invalid dimensions for front transposition");
56 cpp_assert(etl::dim<0>(a) == etl::dim<1>(c),
"Invalid dimensions for front transposition");
57 cpp_assert(etl::dim<1>(a) == etl::dim<0>(c),
"Invalid dimensions for front transposition");
58 cpp_assert(etl::dim<2>(a) == etl::dim<2>(c),
"Invalid dimensions for front transposition");
74 const auto B = etl::dim<0>(
a);
75 const auto K = etl::dim<1>(
a);
77 if constexpr (all_row_major<A, C> && all_floating<A, C> && impl::egblas::has_stranspose_front) {
79 t1.ensure_gpu_up_to_date();
81 lhs.ensure_gpu_allocated();
88 auto batch_fun_b = [&](
const size_t first,
const size_t last) {
89 for (
size_t b = first; b < last; ++b) {
90 for (
size_t k = 0; k < K; ++k) {
100 a.ensure_cpu_up_to_date();
103 lhs.invalidate_gpu();
111 template <etl_expr L>
120 template <etl_expr L>
129 template <etl_expr L>
138 template <etl_expr L>
147 template <etl_expr L>
159 return os <<
"trans_front(" << expr.
_a <<
")";
167 template <
typename A>
174 static constexpr
bool is_etl =
true;
179 static constexpr
bool is_linear =
true;
181 static constexpr
bool is_value =
false;
182 static constexpr
bool is_direct =
true;
183 static constexpr
bool is_generator =
false;
184 static constexpr
bool is_padded =
false;
185 static constexpr
bool is_aligned =
true;
186 static constexpr
bool is_temporary =
true;
195 template <vector_mode_t V>
196 static constexpr
bool vectorizable =
true;
203 static constexpr
size_t dim() {
205 return sub_traits::template dim<1>();
206 }
else if (DD == 1) {
207 return sub_traits::template dim<0>();
209 return sub_traits::template dim<DD>();
221 return etl::dim<1>(e.
_a);
223 return etl::dim<0>(e.
_a);
242 static constexpr
size_t size() {
243 return sub_traits::size();
static constexpr bool gpu_computable
Indicates if the temporary expression can be directly evaluated using only GPU.
Definition: transpose_front_expr.hpp:34
std::add_lvalue_reference_t< A > a()
Returns the sub expression.
Definition: base_temporary_expr.hpp:489
void assign_to(C &&lhs) const
Assign to a matrix of the same storage order.
Definition: transpose_front_expr.hpp:69
void engine_dispatch_1d_serial(Functor &&functor, size_t first, size_t last, size_t threshold, [[maybe_unused]] size_t n_threads=etl::threads)
Dispatch the elements of a range to a functor in a parallel manner, using the global thread engine...
Definition: parallel_support.hpp:734
constexpr bool is_magic_view
Traits indicating if the given ETL type is a magic view expression.
Definition: traits.hpp:311
static constexpr auto storage_order
The sub storage order.
Definition: transpose_front_expr.hpp:28
static size_t dim(const expr_t &e, size_t d)
Returns the dth dimension of the expression.
Definition: transpose_front_expr.hpp:219
order
Storage order of a matrix.
Definition: order.hpp:15
constexpr bool cuda_enabled
Indicates if CUDA is available.
Definition: config.hpp:94
EGBLAS wrappers for the transpose_front operation.
friend std::ostream & operator<<(std::ostream &os, const transpose_front_expr &expr)
Print a representation of the expression on the given stream.
Definition: transpose_front_expr.hpp:158
A _a
The sub expression reference.
Definition: base_temporary_expr.hpp:447
static constexpr int complexity() noexcept
Estimate the complexity of computation.
Definition: transpose_front_expr.hpp:258
static void check([[maybe_unused]] const A &a, [[maybe_unused]] const C &c)
Validate the transposition dimensions.
Definition: transpose_front_expr.hpp:50
constexpr bool is_fast
Traits to test if the given ETL expresion type is fast (sizes known at compile-time) ...
Definition: traits.hpp:588
Traits to get information about ETL types.
Definition: tmp.hpp:68
Root namespace for the ETL library.
Definition: adapter.hpp:15
static constexpr size_t dimensions()
Return the number of dimensions of the expression.
Definition: traits_base.hpp:31
auto dim(E &&value, size_t i) -> detail::identity_helper< E, dim_view< detail::build_identity_type< E >, D >>
Return a view representing the ith Dth dimension.
Definition: view_expression_builder.hpp:25
static constexpr size_t dimensions()
Returns the number of dimensions of the expression.
Definition: transpose_front_expr.hpp:250
void assign_add_to(L &&lhs) const
Add to the given left-hand-side expression.
Definition: transpose_front_expr.hpp:112
void assign_div_to(L &&lhs) const
Divide the given left-hand-side expression.
Definition: transpose_front_expr.hpp:139
auto transpose_front(const E &value)
Returns the transpose of the given expression.
Definition: expression_builder.hpp:568
void assign_sub_to(L &&lhs) const
Sub from the given left-hand-side expression.
Definition: transpose_front_expr.hpp:121
void std_mod_evaluate(Expr &&expr, Result &&result)
Compound modulo evaluation of the expr into result.
Definition: evaluator.hpp:1271
void std_mul_evaluate(Expr &&expr, Result &&result)
Compound multiply evaluation of the expr into result.
Definition: evaluator.hpp:1233
constexpr bool is_transformer
Traits indicating if the given ETL type is a transformer expression.
Definition: traits.hpp:297
A transposition expression for the first layers.
Definition: transpose_front_expr.hpp:22
std::decay_t< A > sub_expr_t
The sub expression type.
Definition: transpose_front_expr.hpp:170
decltype(auto) smart_forward_gpu(E &expr)
Smart forwarding for a temporary expression that will be computed in GPU.
Definition: helpers.hpp:343
constexpr size_t size(const E &expr) noexcept
Returns the size of the given ETL expression.
Definition: helpers.hpp:108
value_t< A > value_type
The type of value of the expression.
Definition: transpose_front_expr.hpp:23
constexpr bool is_view
Traits indicating if the given ETL type is a view expression.
Definition: traits.hpp:304
value_t< A > value_type
The value type of the expression.
Definition: transpose_front_expr.hpp:172
static constexpr bool is_fast
Indicates if T is a fast structure.
Definition: traits_base.hpp:25
void std_sub_evaluate(Expr &&expr, Result &&result)
Compound subtract evaluation of the expr into result.
Definition: evaluator.hpp:1214
void assign_mod_to(L &&lhs) const
Modulo the given left-hand-side expression.
Definition: transpose_front_expr.hpp:148
Abstract base class for temporary unary expression.
Definition: base_temporary_expr.hpp:443
static constexpr size_t size()
Returns the size of the expression.
Definition: transpose_front_expr.hpp:242
transpose_front_expr(A a)
Construct a new expression.
Definition: transpose_front_expr.hpp:40
static size_t size(const expr_t &e)
Returns the size of the expression.
Definition: transpose_front_expr.hpp:234
constexpr bool is_thread_safe
Traits to test if the given ETL expresion type is thread safe.
Definition: traits.hpp:687
void assign_mul_to(L &&lhs) const
Multiply the given left-hand-side expression.
Definition: transpose_front_expr.hpp:130
typename decay_traits< E >::value_type value_t
Traits to extract the value type out of an ETL type.
Definition: tmp.hpp:81
void std_div_evaluate(Expr &&expr, Result &&result)
Compound divide evaluation of the expr into result.
Definition: evaluator.hpp:1252
static constexpr size_t dim()
Returns the DDth dimension of the expression.
Definition: transpose_front_expr.hpp:203
void std_add_evaluate(Expr &&expr, Result &&result)
Compound add evaluation of the expr into result.
Definition: evaluator.hpp:1195