Skip to content

Commit 1539100

Browse files
committed
Cleaning up XGBoosterInplacePredict
1 parent a770841 commit 1539100

File tree

1 file changed

+4
-38
lines changed

1 file changed

+4
-38
lines changed

src/c_api/c_api.cc

Lines changed: 4 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,48 +1027,14 @@ XGB_DLL int XGBoosterInplacePredict(BoosterHandle handle,
10271027
API_BEGIN();
10281028
CHECK_HANDLE();
10291029
xgboost::bst_ulong out_dim;
1030-
std::shared_ptr<xgboost::data::DenseAdapter> x{new xgboost::data::DenseAdapter(data, num_rows, num_features)};
1031-
//std::shared_ptr<DMatrix> p_m(dMatrixHandle);
1032-
std::shared_ptr<DMatrix> p_m{nullptr};
1033-
/*if (!dMatrixHandle) {
1034-
fprintf (stderr, "dMatrixHandle is null");
1035-
exit(1);
1036-
}*/
1037-
if (!dMatrixHandle) {
1038-
p_m.reset(new data::DMatrixProxy);
1039-
//fprintf (stdout, "dmatrix handle is null");
1040-
if (!p_m) {
1041-
fprintf (stderr, "p_m 1 is null");
1042-
exit(1);
1043-
}
1044-
} else {
1045-
p_m = *static_cast<std::shared_ptr<DMatrix> *>(dMatrixHandle);
1046-
//fprintf (stdout, "dmatrix handle is not null");
1047-
if (!p_m) {
1048-
fprintf (stderr, "p_m 2 is null");
1049-
exit(1);
1050-
}
1051-
}
1052-
//fprintf (stdout, reinterpret_cast<const char *>(p_m.get()));
1053-
p_m.reset(new data::DMatrixProxy);
1054-
auto stuff = dynamic_cast<data::DMatrixProxy *>(p_m.get());
1055-
auto proxy = new std::shared_ptr<xgboost::data::DMatrixProxy>(new xgboost::data::DMatrixProxy);
1056-
//printf ("stuff is %s", typeid(stuff).name());
1057-
//printf ("proxy is %s", typeid(proxy).name());
1058-
if (!proxy) {
1059-
fprintf (stderr, "proxy is null line 1058");
1060-
exit(1);
1061-
}
1062-
if (!stuff) {
1063-
fprintf (stderr, "stuff is null line 1062");
1064-
exit(1);
1065-
}
1030+
1031+
auto *proxy = new data::DMatrixProxy;
10661032
auto *learner = static_cast<xgboost::Learner *>(handle);
10671033
auto iteration_end = GetIterationFromTreeLimit(ntree_limit, learner);
1068-
stuff->SetDenseData(data, num_rows, num_features);
1034+
proxy->SetDenseData(data, num_rows, num_features);
1035+
std::shared_ptr<DMatrix> p_m{proxy};
10691036
InplacePredictImplCore(p_m, learner, (xgboost::PredictionType)0, missing, num_rows, num_features,
10701037
0, iteration_end, true, len, &out_dim, out_result);
1071-
// printf("XGBoosterInplacePredict len = %u, dim = %u\n", **len, out_dim);
10721038
API_END();
10731039
}
10741040

0 commit comments

Comments
 (0)