ops.hpp 2.05 KB
Newer Older
1
2
3
4
5
6
7
#ifndef __INFINIOPTEST_OPS_HPP__
#define __INFINIOPTEST_OPS_HPP__
#include "test.hpp"

/*
 * Declare all the tests here
 */
PanZezhong's avatar
PanZezhong committed
8
DECLARE_INFINIOP_TEST(gemm)
9
DECLARE_INFINIOP_TEST(random_sample)
10
DECLARE_INFINIOP_TEST(rms_norm)
11
DECLARE_INFINIOP_TEST(mul)
Catheriany's avatar
Catheriany committed
12
DECLARE_INFINIOP_TEST(rope)
13
DECLARE_INFINIOP_TEST(clip)
MaHang's avatar
MaHang committed
14
DECLARE_INFINIOP_TEST(swiglu)
15
16
17
18
DECLARE_INFINIOP_TEST(add)
DECLARE_INFINIOP_TEST(causal_softmax)
DECLARE_INFINIOP_TEST(rearrange)
DECLARE_INFINIOP_TEST(sub)
19

20
21
22
23
24
25
26
#define REGISTER_INFINIOP_TEST(name)                      \
    {                                                     \
        #name,                                            \
        {                                                 \
            infiniop_test::name::Test::build,             \
            infiniop_test::name::Test::attribute_names(), \
            infiniop_test::name::Test::tensor_names(),    \
27
            infiniop_test::name::Test::output_names(),    \
28
        }},
29
30
31
32

/*
 * Register all the tests here
 */
33
34
35
36
37
38
39
40
41
42
43
44
45
#define TEST_BUILDER_MAPPINGS                  \
    {                                          \
        REGISTER_INFINIOP_TEST(gemm)           \
        REGISTER_INFINIOP_TEST(random_sample)  \
        REGISTER_INFINIOP_TEST(add)            \
        REGISTER_INFINIOP_TEST(mul)            \
        REGISTER_INFINIOP_TEST(clip)           \
        REGISTER_INFINIOP_TEST(swiglu)         \
        REGISTER_INFINIOP_TEST(rope)           \
        REGISTER_INFINIOP_TEST(rms_norm)       \
        REGISTER_INFINIOP_TEST(causal_softmax) \
        REGISTER_INFINIOP_TEST(rearrange)      \
        REGISTER_INFINIOP_TEST(sub)            \
Catheriany's avatar
Catheriany committed
46
    }
47
48

namespace infiniop_test {
PanZezhong's avatar
PanZezhong committed
49
50

// Global variable for {op_name: builder} mappings
51
52
extern std::unordered_map<std::string, const TestBuilder> TEST_BUILDERS;

53
54
55
56
57
58
59
60
61
62
63
64
template <typename V>
bool check_names(
    const std::unordered_map<std::string, V> &map,
    const std::vector<std::string> &names) {
    for (auto const &name : names) {
        if (map.find(name) == map.end()) {
            return false;
        }
    }
    return true;
}

65
66
67
} // namespace infiniop_test

#endif