|
26 | 26 | #include <butil/iobuf.h>
|
27 | 27 | #include <butil/logging.h>
|
28 | 28 | #include <Eigen/Dense>
|
| 29 | +#include <cstring> |
| 30 | +#include <cstdio> |
29 | 31 |
|
30 | 32 | #include <boost/iostreams/stream.hpp>
|
31 | 33 |
|
@@ -389,10 +391,22 @@ class SparseKernelBlock {
|
389 | 391 | << " you must make sure that use same optimizer when incremental training";
|
390 | 392 |
|
391 | 393 | is.ignore(std::numeric_limits<std::streamsize>::max(), ':') >> block.dim_;
|
| 394 | + |
| 395 | + std::tuple<bool, std::string> tuple = block.opt_->NeedOldCompat(is, block.dim_); |
| 396 | + bool need_old_compat = std::get<0>(tuple); |
| 397 | + std::string sample_line = std::get<1>(tuple); |
| 398 | + std::istringstream sample_is(sample_line); |
392 | 399 |
|
393 | 400 | uint64_t sign = 0;
|
| 401 | + while (sample_is >> sign) { |
| 402 | + ValueType* value = block.alloc_.allocate(block.dim_, block.opt_); |
| 403 | + value->SetOldCompat(need_old_compat); |
| 404 | + value->DeSerialize(sample_is, block.dim_); |
| 405 | + block.values_[sign] = value; |
| 406 | + } |
394 | 407 | while (is >> sign) {
|
395 | 408 | ValueType* value = block.alloc_.allocate(block.dim_, block.opt_);
|
| 409 | + value->SetOldCompat(need_old_compat); |
396 | 410 | value->DeSerialize(is, block.dim_);
|
397 | 411 | block.values_[sign] = value;
|
398 | 412 | }
|
@@ -495,7 +509,11 @@ class SparseOptimizerKernel : public SparseOptimizerKernelBase {
|
495 | 509 | for (size_t i = 0; i < SPARSE_KERNEL_BLOCK_NUM; ++i) {
|
496 | 510 | threads.push_back(std::thread([this, i, &mode, &filepath]() {
|
497 | 511 | std::string file = filepath;
|
498 |
| - file.append("/block_").append(std::to_string(i)).append(".gz"); |
| 512 | + if(FileUtils::CheckFileExists(filepath + "/block_" + std::to_string(i) + ".gz")){ |
| 513 | + file.append("/block_").append(std::to_string(i)).append(".gz"); |
| 514 | + } else { |
| 515 | + file.append("/sparse_block_").append(std::to_string(i)).append(".gz"); |
| 516 | + } |
499 | 517 |
|
500 | 518 | FileReaderSource reader_source(file, FCT_ZLIB);
|
501 | 519 | boost::iostreams::stream<FileReaderSource> in_stream(reader_source);
|
|
0 commit comments