MCPcopy Create free account
hub / github.com/alibaba/euler / Compiler

Method Compiler

euler/parser/compiler.cc:26–569  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24namespace euler {
25
26Compiler::Compiler(int32_t shard_num,
27 OptimizerType type, std::string index_info):
28 shard_num_(shard_num), optimizer_(type, shard_num), translator_(type) {
29 /* parse index info */
30 std::vector<std::string> index_info_list = Split(index_info, ",");
31 for (std::string name_type : index_info_list) {
32 std::vector<std::string> name_type_info = Split(name_type, ":");
33 index_info_[name_type_info[1]].push_back(name_type_info[0]);
34 EULER_LOG(INFO) << name_type_info[1] << " : " << name_type_info[0];
35 }
36
37 /* unique -> API_GET_NB_NODE -> gather */
38 {
39 std::vector<std::string> adj_info = {"API_GET_NB_NODE:0"};
40 std::vector<std::vector<std::string>> unique_op_info = {
41 {"ID_UNIQUE", "0"}};
42 std::vector<std::vector<std::string>> gather_op_info = {
43 {"IDX_GATHER", "0", "0"},
44 {"DATA_GATHER", "0", "1,0"},
45 {"DATA_GATHER", "0", "2,0"},
46 {"DATA_GATHER", "0", "3,0"}};
47 std::shared_ptr<UniqueAndGatherRule> optmz_rule =
48 std::make_shared<UniqueAndGatherRule>(
49 adj_info, unique_op_info, gather_op_info);
50 optimizer_.AddRule(optmz_rule);
51 }
52
53 /* unique -> API_GET_P -> gather */
54 {
55 std::vector<std::string> adj_info = {"API_GET_P:0"};
56 std::vector<std::vector<std::string>> unique_op_info = {
57 {"ID_UNIQUE", "0"}};
58 std::vector<std::vector<std::string>> gather_op_info;
59 std::shared_ptr<UniqueAndGatherRule> optmz_rule =
60 std::make_shared<UniqueAndGatherRule>(
61 adj_info, unique_op_info, gather_op_info);
62 optmz_rule->dynamic_gather_ = true;
63 optmz_rule->gen_gather_op_info_ =
64 [](const NodeDef& node,
65 std::vector<std::vector<std::string>>* gather_op_info) {
66 for (size_t i = 0; i < node.attrs_.size(); ++i) {
67 int32_t idx0 = i * 2, idx1 = i * 2 + 1;
68 gather_op_info->push_back({"IDX_GATHER", "0", ToString(idx0)});
69 gather_op_info->push_back(
70 {"DATA_GATHER", "0", ToString(idx1, ",", idx0)});
71 }
72 };
73 optimizer_.AddRule(optmz_rule);
74 }
75
76 /* unique -> API_SAMPLE_NB -> gather */
77 {
78 std::vector<std::string> adj_info = {"API_SAMPLE_NB:0"};
79 std::vector<std::vector<std::string>> unique_op_info = {
80 {"ID_UNIQUE", "0"}};
81 std::vector<std::vector<std::string>> gather_op_info = {
82 {"IDX_GATHER", "0", "0"},
83 {"DATA_GATHER", "0", "1,0"},

Callers

nothing calls this directly

Calls 4

SplitFunction · 0.85
ToStringFunction · 0.85
AddRuleMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected