"vscode:/vscode.git/clone" did not exist on "12878f3fd7802d9e12fb5a72b8434578b98674cc"
sequence_helper.hpp 712 Bytes
Newer Older
Chao Liu's avatar
Chao Liu committed
1
2
3
4
5
6
7
#ifndef CK_SEQUENCE_HELPER_HPP
#define CK_SEQUENCE_HELPER_HPP

#include "sequence_helper.hpp"

namespace ck {

8
9
10
11
12
13
14
template <index_t... Is>
__host__ __device__ constexpr auto make_sequence(Number<Is>...)
{
    return Sequence<Is...>{};
}

// F returns index_t
Chao Liu's avatar
Chao Liu committed
15
16
17
18
19
20
template <typename F, index_t N>
__host__ __device__ constexpr auto generate_sequence(F, Number<N>)
{
    return typename sequence_gen<N, F>::type{};
}

21
22
23
24
25
26
27
28
// F returns Number<>
template <typename F, index_t N>
__host__ __device__ constexpr auto generate_sequence_v2(F&& f, Number<N>)
{
    return unpack([&f](auto&&... xs) { return make_sequence(f(xs)...); },
                  typename arithmetic_sequence_gen<0, N, 1>::type{});
}

Chao Liu's avatar
Chao Liu committed
29
30
} // namespace ck
#endif