MCPcopy Create free account
hub / github.com/dmlc/parameter_server / mergeExampleInfo

Function mergeExampleInfo

src/data/common.cc:50–73  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48}
49
50ExampleInfo mergeExampleInfo(const ExampleInfo& A, const ExampleInfo& B) {
51 std::map<int, SlotInfo> slots;
52 for (int i = 0; i < A.slot_size(); ++i) {
53 slots[A.slot(i).id()] = A.slot(i);
54 }
55
56 for (int i = 0; i < B.slot_size(); ++i) {
57 int id = B.slot(i).id();
58 if (slots.count(id) == 0) { slots[id] = B.slot(i); continue; }
59 auto a = slots[id];
60 auto b = B.slot(i);
61 CHECK_EQ(a.format(), b.format());
62 a.set_min_key(std::min(a.min_key(), b.min_key()));
63 a.set_max_key(std::max(a.max_key(), b.max_key()));
64 a.set_nnz_ele(a.nnz_ele() + b.nnz_ele());
65 a.set_nnz_ex(a.nnz_ex() + b.nnz_ex());
66 slots[id] = a;
67 }
68
69 ExampleInfo C;
70 C.set_num_ex(A.num_ex() + B.num_ex());
71 for (const auto& it : slots) *C.add_slot() = it.second;
72 return C;
73}
74
75// InstanceInfo mergeInstanceInfo(const InstanceInfo& A, const InstanceInfo& B) {
76// auto as = A.fea_grp_size();

Callers 2

readOneFileMethod · 0.85
loadTrainingDataMethod · 0.85

Calls 15

slot_sizeMethod · 0.80
countMethod · 0.80
set_min_keyMethod · 0.80
min_keyMethod · 0.80
set_max_keyMethod · 0.80
max_keyMethod · 0.80
set_nnz_eleMethod · 0.80
nnz_eleMethod · 0.80
set_nnz_exMethod · 0.80
nnz_exMethod · 0.80
set_num_exMethod · 0.80
num_exMethod · 0.80

Tested by

no test coverage detected