Clear all cache after model load. (#8904)

This commit is contained in:
Jiaming Yuan
2023-03-14 22:09:36 +08:00
committed by GitHub
parent c400fa1e8d
commit 910ce580c8
3 changed files with 37 additions and 0 deletions

View File

@@ -868,6 +868,8 @@ class LearnerIO : public LearnerConfiguration {
// Will be removed once JSON takes over. Right now we still loads some RDS files from R.
std::string const serialisation_header_ { u8"CONFIG-offset:" };
void ClearCaches() { this->prediction_container_ = PredictionContainer{}; }
public:
explicit LearnerIO(std::vector<std::shared_ptr<DMatrix>> cache) : LearnerConfiguration{cache} {}
@@ -920,6 +922,7 @@ class LearnerIO : public LearnerConfiguration {
}
this->need_configuration_ = true;
this->ClearCaches();
}
void SaveModel(Json* p_out) const override {
@@ -1096,6 +1099,7 @@ class LearnerIO : public LearnerConfiguration {
cfg_.insert(n.cbegin(), n.cend());
this->need_configuration_ = true;
this->ClearCaches();
}
// Save model into binary format. The code is about to be deprecated by more robust