| 290 | // Return (result, current * product(shape)) to enable recurrence |
| 291 | template <class Major, class Shape, class Current> |
| 292 | CUTE_HOST_DEVICE constexpr |
| 293 | auto |
| 294 | compact(Shape const& shape, |
| 295 | Current const& current) |
| 296 | { |
| 297 | if constexpr (is_tuple<Shape>::value) { // Shape::tuple Current::int |
| 298 | using Lambda = CompactLambda<Major>; // Append or Prepend |
| 299 | using Seq = typename Lambda::template seq<Shape>; // Seq or RSeq |
| 300 | return cute::detail::fold(shape, cute::make_tuple(cute::make_tuple(), current), Lambda{}, Seq{}); |
| 301 | } else { // Shape::int Current::int |
| 302 | if constexpr (is_constant<1, Shape>::value) { |
| 303 | return cute::make_tuple(Int<0>{}, current); // If current is dynamic, this could save a reg |
| 304 | } else { |
| 305 | return cute::make_tuple(current, current * shape); |
| 306 | } |
| 307 | } |
| 308 | |
| 309 | CUTE_GCC_UNREACHABLE; |
| 310 | } |
| 311 | |
| 312 | // For GCC8.5 -- Specialization LayoutLeft |
| 313 | template <> |