MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / TEST

Function TEST

src/custom/test/manager.cpp:13–59  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11namespace custom {
12
13TEST(TestOpManager, TestOpManager) {
14 CustomOpManager* com = CustomOpManager::inst();
15 std::vector<std::string> builtin_op_names = com->op_name_list();
16 size_t builtin_op_num = builtin_op_names.size();
17
18 com->insert("Op1", CUSTOM_OP_VERSION);
19 com->insert("Op2", CUSTOM_OP_VERSION);
20
21 std::vector<std::string> op_names = com->op_name_list();
22 std::vector<RunTimeId> op_ids = com->op_id_list();
23
24 ASSERT_TRUE(op_names.size() == builtin_op_num + 2);
25 ASSERT_TRUE(op_ids.size() == builtin_op_num + 2);
26
27#if MANAGER_TEST_LOG
28 for (std::string& name : op_names) {
29 std::cout << name << std::endl;
30 }
31#endif
32
33 for (std::string& name : op_names) {
34 std::shared_ptr<const CustomOp> op = com->find(name);
35 ASSERT_TRUE(op != nullptr);
36 ASSERT_TRUE(op->op_type() == name);
37 RunTimeId id = com->to_id(name);
38 ASSERT_TRUE(com->find(id) == op);
39 }
40
41 for (RunTimeId& id : op_ids) {
42 std::shared_ptr<const CustomOp> op = com->find(id);
43 ASSERT_TRUE(op != nullptr);
44 ASSERT_TRUE(op->runtime_id() == id);
45 std::string name = com->to_name(id);
46 ASSERT_TRUE(com->find(name) == op);
47 }
48
49 ASSERT_FALSE(com->erase("Op0"));
50#if MANAGER_TEST_LOG
51 for (auto& name : com->op_name_list()) {
52 std::cout << name << std::endl;
53 }
54#endif
55 ASSERT_TRUE(com->erase("Op1"));
56 ASSERT_TRUE(com->op_id_list().size() == builtin_op_num + 1);
57 ASSERT_TRUE(com->op_name_list().size() == builtin_op_num + 1);
58 ASSERT_TRUE(com->erase("Op2"));
59}
60
61TEST(TestOpManager, TestOpReg) {
62 CUSTOM_OP_REG(Op1)

Callers

nothing calls this directly

Calls 15

instFunction · 0.85
op_name_listMethod · 0.80
op_id_listMethod · 0.80
to_idMethod · 0.80
to_nameMethod · 0.80
add_inputsMethod · 0.80
sizeMethod · 0.45
insertMethod · 0.45
findMethod · 0.45
op_typeMethod · 0.45
runtime_idMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected