| 408 | // @pre is_static<RefOrder> |
| 409 | template <class Shape, class Order, class RefShape, class RefOrder> |
| 410 | CUTE_HOST_DEVICE constexpr |
| 411 | auto |
| 412 | compact_order(Shape const& shape, Order const& order, |
| 413 | RefShape const& ref_shape, RefOrder const& ref_order) |
| 414 | { |
| 415 | if constexpr (is_tuple<Order>::value) { |
| 416 | static_assert(tuple_size<Shape>::value == tuple_size<Order>::value, "Need equal rank of shape and order"); |
| 417 | return transform(shape, order, [&](auto const& s, auto const& o) { return compact_order(s, o, ref_shape, ref_order); }); |
| 418 | } else { |
| 419 | // Compute the starting stride for this shape by accumulating all shapes corresponding to lesser orders |
| 420 | auto stride_start = product(transform(ref_shape, ref_order, |
| 421 | [&](auto const& s, auto const& o) { |
| 422 | return conditional_return(o < order, s, Int<1>{}); |
| 423 | })); |
| 424 | return compact_col_major(shape, stride_start); |
| 425 | } |
| 426 | |
| 427 | CUTE_GCC_UNREACHABLE; |
| 428 | } |
| 429 | |
| 430 | } // end namespace detail |
| 431 |
no test coverage detected