Synchronize feature type in case of empty DMatrix
| 66 | namespace cpu_impl { |
| 67 | // Synchronize feature type in case of empty DMatrix |
| 68 | void SyncFeatureType(Context const* ctx, std::vector<FeatureType>* p_h_ft) { |
| 69 | if (!collective::IsDistributed()) { |
| 70 | return; |
| 71 | } |
| 72 | auto& h_ft = *p_h_ft; |
| 73 | bst_idx_t n_ft = h_ft.size(); |
| 74 | collective::SafeColl(collective::Allreduce(ctx, &n_ft, collective::Op::kMax)); |
| 75 | if (!h_ft.empty()) { |
| 76 | // Check correct size if this is not an empty DMatrix. |
| 77 | CHECK_EQ(h_ft.size(), n_ft); |
| 78 | } |
| 79 | if (n_ft > 0) { |
| 80 | h_ft.resize(n_ft); |
| 81 | auto ptr = reinterpret_cast<std::underlying_type_t<FeatureType>*>(h_ft.data()); |
| 82 | collective::SafeColl( |
| 83 | collective::Allreduce(ctx, linalg::MakeVec(ptr, h_ft.size()), collective::Op::kMax)); |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | void GetDataShape(Context const* ctx, DMatrixProxy* proxy, |
| 88 | DataIterProxy<DataIterResetCallback, XGDMatrixCallbackNext>* iter, float missing, |
no test coverage detected