MCPcopy Create free account
hub / github.com/dmlc/xgboost / ConfigureNumFeatures

Method ConfigureNumFeatures

src/learner.cc:797–819  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

795 }
796
797 void ConfigureNumFeatures() {
798 // Compute number of global features if parameter not already set
799 if (mparam_.num_feature == 0) {
800 // TODO(hcho3): Change num_feature to 64-bit integer
801 unsigned num_feature = 0;
802 for (auto const& matrix : prediction_container_.Container()) {
803 CHECK(matrix.first.ptr);
804 CHECK(!matrix.second.ref.expired());
805 const uint64_t num_col = matrix.first.ptr->Info().num_col_;
806 error::MaxFeatureSize(num_col);
807 num_feature = std::max(num_feature, static_cast<uint32_t>(num_col));
808 }
809
810 auto rc =
811 collective::Allreduce(&ctx_, linalg::MakeVec(&num_feature, 1), collective::Op::kMax);
812 collective::SafeColl(rc);
813 if (num_feature > mparam_.num_feature) {
814 mparam_.num_feature = num_feature;
815 }
816 }
817 CHECK_NE(mparam_.num_feature, 0)
818 << "0 feature is supplied. Are you using raw Booster interface?";
819 }
820
821 void ConfigureGBM(LearnerTrainParam const& old, Args const& args) {
822 tparam_.booster = CanonicalizeBoosterName(tparam_.booster);

Callers 1

ConfigureMethod · 0.95

Calls 5

MaxFeatureSizeFunction · 0.85
MakeVecFunction · 0.85
SafeCollFunction · 0.85
AllreduceFunction · 0.50
InfoMethod · 0.45

Tested by

no test coverage detected