10 #include "etl/expr/base_temporary_expr.hpp" 13 #include "etl/impl/std/gemm.hpp" 14 #include "etl/impl/blas/gemm.hpp" 15 #include "etl/impl/vec/gemv.hpp" 16 #include "etl/impl/vec/gemm_conv.hpp" 17 #include "etl/impl/cublas/gemm.hpp" 25 template <etl_expr A, etl_expr B>
55 static void check([[maybe_unused]]
const A&
a, [[maybe_unused]]
const B&
b, [[maybe_unused]]
const C& c) {
56 if constexpr (all_fast<A, B, C>) {
57 static_assert(dim<1, A>() == dim<0, B>()
58 && dim<0, A>() == dim<0, C>()
60 "Invalid sizes for multiplication");
62 cpp_assert(dim<1>(a) == dim<0>(b)
63 && dim<0>(a) == dim<0>(c)
65 "Invalid sizes for multiplication");
77 constexpr
bool homo = all_homogeneous<A, B, C>;
94 #ifdef ETL_MANUAL_SELECT 100 template <
typename C>
109 std::cerr <<
"Forced selection to CUBLAS gemv implementation, but not possible for this expression" 119 std::cerr <<
"Forced selection to BLAS gemv implementation, but not possible for this expression" << std::endl;
128 std::cerr <<
"Forced selection to VEC gemv implementation, but not possible for this expression" << std::endl;
150 template <
typename C>
152 return select_default_gemv_impl<C>(
false);
163 template <
typename AA,
typename BB,
typename C>
165 constexpr_select
auto impl = select_gemv_impl<C>();
168 if constexpr (is_transpose_expr<BB>) {
182 cpp_unreachable(
"Invalid selection for gevm");
198 cpp_unreachable(
"Invalid selection for gevm");
208 template <etl_expr C>
212 check(this->
a(), this->
b(), c);
221 template <
typename L>
230 template <
typename L>
239 template <
typename L>
248 template <
typename L>
257 template <
typename L>
269 return os << expr.
_a <<
" * " << expr.
_b;
277 template <
typename A,
typename B>
286 static constexpr
bool is_etl =
true;
291 static constexpr
bool is_linear =
false;
293 static constexpr
bool is_value =
false;
294 static constexpr
bool is_direct =
true;
295 static constexpr
bool is_generator =
false;
296 static constexpr
bool is_padded =
false;
297 static constexpr
bool is_aligned =
true;
298 static constexpr
bool is_temporary =
true;
307 template <vector_mode_t V>
308 static constexpr
bool vectorizable =
true;
315 static constexpr
size_t dim() {
342 static constexpr
size_t size() {
369 template <etl_2d A, etl_1d B>
380 template <etl_2d A, etl_1d B>
381 auto mul(A&&
a, B&&
b) {
392 template <etl_2d A, etl_1d B, etl_1d C>
393 auto mul(A&&
a, B&&
b, C&& c) {
static constexpr bool gpu_computable
Indicates if the temporary expression can be directly evaluated using only GPU.
Definition: gemv_expr.hpp:38
gemm_impl
Enumeration describing the different matrix-matrix multiplication implementations.
Definition: gemm_impl.hpp:21
B _b
The sub expression reference.
Definition: base_temporary_expr.hpp:534
auto mul(A &&a, B &&b)
Multiply two matrices together.
Definition: gemm_expr.hpp:442
static size_t size(const expr_t &e)
Returns the size of the expression.
Definition: gemv_expr.hpp:334
constexpr bool is_magic_view
Traits indicating if the given ETL type is a magic view expression.
Definition: traits.hpp:311
std::decay_t< B > right_expr_t
The right sub expression type.
Definition: gemv_expr.hpp:281
A _a
The sub expression reference.
Definition: base_temporary_expr.hpp:533
void assign_div_to(L &&lhs) const
Divide the given left-hand-side expression.
Definition: gemv_expr.hpp:249
static constexpr auto storage_order
The sub storage order.
Definition: gemv_expr.hpp:32
std::decay_t< A > left_expr_t
The left sub expression type.
Definition: gemv_expr.hpp:280
static constexpr size_t size()
Returns the size of the expression.
Definition: gemv_expr.hpp:342
void assign_sub_to(L &&lhs) const
Sub from the given left-hand-side expression.
Definition: gemv_expr.hpp:231
constexpr bool vectorize_impl
Indicates if the implementations can be automatically vectorized by ETL.
Definition: config.hpp:35
constexpr bool vec_enabled
Indicates if vectorization is available in any format.
Definition: config.hpp:220
order
Storage order of a matrix.
Definition: order.hpp:15
Abstract base class for temporary binary expression.
Definition: base_temporary_expr.hpp:529
auto operator*(LE &&lhs, RE rhs)
Builds an expression representing the multiplication of lhs and rhs (scalar)
Definition: binary_expression_builder.hpp:149
void assign_to(C &&c) const
Assign to a matrix of the same storage order.
Definition: gemv_expr.hpp:209
std::add_lvalue_reference_t< B > b()
Returns the sub expression.
Definition: base_temporary_expr.hpp:593
constexpr bool is_fast
Traits to test if the given ETL expresion type is fast (sizes known at compile-time) ...
Definition: traits.hpp:588
static void check([[maybe_unused]] const A &a, [[maybe_unused]] const B &b, [[maybe_unused]] const C &c)
Assert for the validity of the matrix-matrix multiplication operation.
Definition: gemv_expr.hpp:55
Traits to get information about ETL types.
Definition: tmp.hpp:68
Root namespace for the ETL library.
Definition: adapter.hpp:15
context & local_context()
Return the configuration context of the current thread.
Definition: context.hpp:50
value_t< A > value_type
The value type of the expression.
Definition: gemv_expr.hpp:284
static constexpr size_t dim()
Returns the DDth dimension of the expression.
Definition: gemv_expr.hpp:315
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
constexpr bool cublas_enabled
Indicates if the NVIDIA CUBLAS library is available for ETL.
Definition: config.hpp:99
std::conditional_t< is_etl_value< T >, const std::decay_t< T > &, std::decay_t< T > > build_type
Helper to build the type for a sub expression.
Definition: expression_helpers.hpp:24
bool cpu
Force CPU evaluation.
Definition: context.hpp:29
static constexpr gemm_impl select_default_gemv_impl(bool no_gpu)
Select an implementation of GEMV, not considering local context.
Definition: gemv_expr.hpp:76
value_t< A > value_type
The type of value of the expression.
Definition: gemv_expr.hpp:27
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
friend std::ostream & operator<<(std::ostream &os, const gemv_expr &expr)
Print a representation of the expression on the given stream.
Definition: gemv_expr.hpp:268
constexpr bool is_transformer
Traits indicating if the given ETL type is a transformer expression.
Definition: traits.hpp:297
decltype(auto) smart_forward_gpu(E &expr)
Smart forwarding for a temporary expression that will be computed in GPU.
Definition: helpers.hpp:343
static void apply_raw(AA &&a, BB &&b, C &&c)
Compute c = trans(A) * b.
Definition: gemv_expr.hpp:164
constexpr bool is_view
Traits indicating if the given ETL type is a view expression.
Definition: traits.hpp:304
static constexpr int complexity() noexcept
Estimate the complexity of computation.
Definition: gemv_expr.hpp:358
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
decltype(auto) smart_forward(E &expr)
Smart forwarding for a temporary expression.
Definition: helpers.hpp:323
void assign_mod_to(L &&lhs) const
Modulo the given left-hand-side expression.
Definition: gemv_expr.hpp:258
static constexpr size_t dimensions()
Returns the number of dimensions of the expression.
Definition: gemv_expr.hpp:350
constexpr bool cblas_enabled
Indicates if a BLAS library is available for ETL.
Definition: config.hpp:76
constexpr bool is_thread_safe
Traits to test if the given ETL expresion type is thread safe.
Definition: traits.hpp:687
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
void inc_counter([[maybe_unused]] const char *name)
Increase the given counter.
Definition: counters.hpp:25
gemv_expr(A a, B b)
Construct a new expression.
Definition: gemv_expr.hpp:44
static constexpr gemm_impl select_gemv_impl()
Select the best implementation of GEMV.
Definition: gemv_expr.hpp:151
std::add_lvalue_reference_t< A > a()
Returns the sub expression.
Definition: base_temporary_expr.hpp:577
void assign_add_to(L &&lhs) const
Add to the given left-hand-side expression.
Definition: gemv_expr.hpp:222
void assign_mul_to(L &&lhs) const
Multiply the given left-hand-side expression.
Definition: gemv_expr.hpp:240
static size_t dim(const expr_t &e, size_t d)
Returns the dth dimension of the expression.
Definition: gemv_expr.hpp:325
void std_add_evaluate(Expr &&expr, Result &&result)
Compound add evaluation of the expr into result.
Definition: evaluator.hpp:1195
A transposition expression.
Definition: gemv_expr.hpp:26