Parallel model dump for trees. (#7040)
This commit is contained in:
parent
2567404ab6
commit
5c2d7a18c9
@ -17,6 +17,8 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "../common/threading_utils.h"
|
||||
|
||||
namespace xgboost {
|
||||
|
||||
class Json;
|
||||
@ -107,12 +109,12 @@ struct GBTreeModel : public Model {
|
||||
void SaveModel(Json* p_out) const override;
|
||||
void LoadModel(Json const& p_out) override;
|
||||
|
||||
std::vector<std::string> DumpModel(const FeatureMap& fmap, bool with_stats,
|
||||
std::vector<std::string> DumpModel(const FeatureMap &fmap, bool with_stats,
|
||||
std::string format) const {
|
||||
std::vector<std::string> dump;
|
||||
for (const auto & tree : trees) {
|
||||
dump.push_back(tree->DumpModel(fmap, with_stats, format));
|
||||
}
|
||||
std::vector<std::string> dump(trees.size());
|
||||
common::ParallelFor(static_cast<omp_ulong>(trees.size()), [&](size_t i) {
|
||||
dump[i] = trees[i]->DumpModel(fmap, with_stats, format);
|
||||
});
|
||||
return dump;
|
||||
}
|
||||
void CommitModel(std::vector<std::unique_ptr<RegTree> >&& new_trees,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user