26 static constexpr
bool gpu_computable = impl::egblas::has_sone_if_max_sub && all_row_major<T> && all_floating<T>;
31 std::vector<size_t> max_indices;
39 for (
size_t i = 0; i < etl::dim<0>(expr); ++i) {
50 size_t i_i = i / dim<1>(sub);
51 size_t i_j = i % dim<1>(sub);
62 size_t i_i = i / dim<1>(sub);
63 size_t i_j = i % dim<1>(sub);
83 bool alias(
const E& rhs)
const noexcept {
84 return sub.alias(rhs);
113 template <
typename Y>
131 template <
typename V>
133 sub.visit(std::forward<V>(visitor));
142 sub.ensure_cpu_up_to_date();
151 sub.ensure_gpu_up_to_date();
161 return os <<
"one_if_max_sub(" << transformer.sub <<
")";
169 template <
typename T>
176 static constexpr
bool gpu_computable =
false;
188 static constexpr
bool matrix = is_2d<sub_type>;
196 if constexpr (matrix) {
197 size_t i_i = i / dim<1>(sub);
198 size_t i_j = i % dim<1>(sub);
199 return sub[i_i * dim<1>(sub) + (dim<1>(sub) - 1 - i_j)];
212 if constexpr (matrix) {
213 size_t i_i = i / dim<1>(sub);
214 size_t i_j = i % dim<1>(sub);
215 return sub.read_flat(i_i * dim<1>(sub) + (dim<1>(sub) - 1 - i_j));
217 return sub.read_flat(
etl::size(sub) - i - 1);
237 return sub(i,
columns(sub) - 1 - j);
245 template <
typename E>
246 bool alias(
const E& rhs)
const noexcept {
247 return sub.alias(rhs);
256 template <
typename V>
258 sub.visit(std::forward<V>(visitor));
267 sub.ensure_cpu_up_to_date();
276 sub.ensure_gpu_up_to_date();
286 return os <<
"hflip(" << transformer.sub <<
")";
294 template <
typename T>
301 static constexpr
bool gpu_computable =
false;
313 static constexpr
bool matrix = is_2d<sub_type>;
321 if constexpr (matrix) {
322 size_t i_i = i / dim<1>(sub);
323 size_t i_j = i % dim<1>(sub);
324 return sub[(dim<0>(sub) - 1 - i_i) * dim<1>(sub) + i_j];
337 if constexpr (matrix) {
338 size_t i_i = i / dim<1>(sub);
339 size_t i_j = i % dim<1>(sub);
340 return sub.read_flat((dim<0>(sub) - 1 - i_i) * dim<1>(sub) + i_j);
342 return sub.read_flat(i);
362 return sub(
rows(sub) - 1 - i, j);
370 template <
typename E>
371 bool alias(
const E& rhs)
const noexcept {
372 return sub.alias(rhs);
381 template <
typename V>
383 sub.visit(std::forward<V>(visitor));
392 sub.ensure_cpu_up_to_date();
401 sub.ensure_gpu_up_to_date();
411 return os <<
"vflip(" << transformer.sub <<
")";
419 template <
typename T>
426 static constexpr
bool gpu_computable =
false;
444 if (dimensions(sub) == 1) {
458 if (dimensions(sub) == 1) {
459 return sub.read_flat(i);
461 return sub.read_flat(
etl::size(sub) - i - 1);
481 return sub(
rows(sub) - 1 - i,
columns(sub) - 1 - j);
489 template <
typename E>
490 bool alias(
const E& rhs)
const noexcept {
491 return sub.alias(rhs);
500 template <
typename V>
502 sub.visit(std::forward<V>(visitor));
511 sub.ensure_cpu_up_to_date();
520 sub.ensure_gpu_up_to_date();
530 return os <<
"fflip(" << transformer.sub <<
")";
537 template <
typename T>
538 requires( cpp::specialization_of<etl::hflip_transformer, T>
539 || cpp::specialization_of<etl::vflip_transformer, T>
540 || cpp::specialization_of<etl::fflip_transformer, T>
541 || cpp::specialization_of<etl::one_if_max_sub_transformer, T>)
544 using sub_expr_t = std::decay_t<typename T::sub_type>;
547 static constexpr
bool is_etl =
true;
549 static constexpr
bool is_view =
false;
552 static constexpr
bool is_linear =
false;
554 static constexpr
bool is_value =
false;
555 static constexpr
bool is_direct =
false;
556 static constexpr
bool is_generator =
false;
557 static constexpr
bool is_padded =
false;
558 static constexpr
bool is_aligned =
false;
560 static constexpr
bool gpu_computable = T::gpu_computable;
568 template <vector_mode_t V>
569 static constexpr
bool vectorizable =
false;
576 static size_t size(
const expr_t& v) {
586 static size_t dim(
const expr_t& v,
size_t d) {
594 static constexpr
size_t size() {
604 static constexpr
size_t dim() {
612 static constexpr
size_t dimensions() {
constexpr int complexity([[maybe_unused]] const E &expr) noexcept
Return the complexity of the expression.
Definition: helpers.hpp:38
value_t< sub_type > value_type
The value contained in the expression.
Definition: dyn_matrix_view.hpp:31
constexpr bool is_magic_view
Traits indicating if the given ETL type is a magic view expression.
Definition: traits.hpp:311
decltype(auto) select_smart_gpu_compute(X &x, Y &y)
Compute the expression into a representation that is GPU up to date and possibly store this represent...
Definition: helpers.hpp:434
order
Storage order of a matrix.
Definition: order.hpp:15
auto one_if_max_sub(const E &value)
Return, for each original position, 1.0 if the value is the max of the sub matrix, 0.0 otherwise.
Definition: expression_builder.hpp:488
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
size_t max_index(E &&values)
Returns the index of the maximum element contained in the expression.
Definition: expression_builder.hpp:720
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
size_t columns(const E &expr)
Returns the number of columns of the given ETL expression.
Definition: helpers.hpp:78
decltype(auto) force_temporary_gpu_dim_only(E &&expr)
Force a temporary out of the expression, without copying its content.
Definition: temporary.hpp:223
constexpr bool is_transformer
Traits indicating if the given ETL type is a transformer expression.
Definition: traits.hpp:297
constexpr size_t size(const E &expr) noexcept
Returns the size of the given ETL expression.
Definition: helpers.hpp:108
requires(D > 0) struct dyn_base
Matrix with run-time fixed dimensions.
Definition: dyn_base.hpp:113
constexpr bool is_view
Traits indicating if the given ETL type is a view expression.
Definition: traits.hpp:304
EGBLAS wrappers for the one_if_max_sub operation.
constexpr bool is_thread_safe
Traits to test if the given ETL expresion type is thread safe.
Definition: traits.hpp:687
size_t rows(const E &expr)
Returns the number of rows of the given ETL expression.
Definition: helpers.hpp:58
decltype(auto) smart_gpu_compute_hint(E &expr, Y &y)
Compute the expression into a representation that is GPU up to date.
Definition: helpers.hpp:368
typename decay_traits< E >::value_type value_t
Traits to extract the value type out of an ETL type.
Definition: tmp.hpp:81