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

Method offset

src/data/slot_reader.cc:174–197  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

172}
173
174SArray<size_t> SlotReader::offset(int slot_id) {
175 if (offset_cache_[slot_id].size() == info_.num_ex()+1) {
176 return offset_cache_[slot_id];
177 }
178 SArray<size_t> os(1); os[0] = 0;
179 if (nnzEle(slot_id) == 0) return os;
180 for (int i = 0; i < data_.file_size(); ++i) {
181 string file = cacheName(ithFile(data_, i), slot_id) + ".rowsiz";
182 SArray<char> comp;
183 SArray<uint16> uncomp;
184 if (comp.readFromFile(file) && !comp.empty()) {
185 uncomp.uncompressFrom(comp);
186 CHECK_EQ(uncomp.size(), num_ex_[i]) << file;
187 } else {
188 uncomp.resize(num_ex_[i], 0);
189 }
190 size_t n = os.size();
191 os.resize(n + uncomp.size());
192 for (size_t i = 0; i < uncomp.size(); ++i) os[i+n] = os[i+n-1] + uncomp[i];
193 }
194 CHECK_EQ(os.size(), info_.num_ex()+1);
195 offset_cache_[slot_id] = os;
196 return os;
197}
198
199} // namespace PS

Callers 6

TESTFunction · 0.45
TEST_FFunction · 0.45
TESTFunction · 0.45
computeGradientMethod · 0.45
updateDualMethod · 0.45
runMethod · 0.45

Calls 8

ithFileFunction · 0.85
num_exMethod · 0.80
file_sizeMethod · 0.80
sizeMethod · 0.45
readFromFileMethod · 0.45
emptyMethod · 0.45
uncompressFromMethod · 0.45
resizeMethod · 0.45

Tested by 3

TESTFunction · 0.36
TEST_FFunction · 0.36
TESTFunction · 0.36