ops.hpp 1.96 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
 */
8
9
DECLARE_INFINIOP_TEST(add)
DECLARE_INFINIOP_TEST(clip)
PanZezhong's avatar
PanZezhong committed
10
DECLARE_INFINIOP_TEST(gemm)
11
DECLARE_INFINIOP_TEST(mul)
12
DECLARE_INFINIOP_TEST(random_sample)
13
DECLARE_INFINIOP_TEST(rearrange)
14
DECLARE_INFINIOP_TEST(rms_norm)
Catheriany's avatar
Catheriany committed
15
DECLARE_INFINIOP_TEST(rope)
16
DECLARE_INFINIOP_TEST(sub)
MaHang's avatar
MaHang committed
17
DECLARE_INFINIOP_TEST(swiglu)
18

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

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

namespace infiniop_test {
PanZezhong's avatar
PanZezhong committed
47
48

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

51
52
53
54
55
56
57
58
59
60
61
62
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;
}

63
64
65
} // namespace infiniop_test

#endif