Skip to content

Commit

Permalink
Revert "Remove raw pointer."
Browse files Browse the repository at this point in the history
This reverts commit 3d5f319.
  • Loading branch information
trivialfis committed Jul 14, 2021
1 parent 3d5f319 commit d8bbf8b
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 15 deletions.
1 change: 1 addition & 0 deletions include/xgboost/data.h
Expand Up @@ -403,6 +403,7 @@ template<typename T>
class BatchIterator {
public:
using iterator_category = std::forward_iterator_tag; // NOLINT
explicit BatchIterator(BatchIteratorImpl<T>* impl) { impl_.reset(impl); }
explicit BatchIterator(std::shared_ptr<BatchIteratorImpl<T>> impl) { impl_ = impl; }

BatchIterator &operator++() {
Expand Down
4 changes: 2 additions & 2 deletions src/data/iterative_device_dmatrix.cu
Expand Up @@ -162,8 +162,8 @@ void IterativeDeviceDMatrix::Initialize(DataIterHandle iter_handle, float missin

BatchSet<EllpackPage> IterativeDeviceDMatrix::GetEllpackBatches(const BatchParam& param) {
CHECK(page_);
auto begin_iter = BatchIterator<EllpackPage>(
std::make_shared<SimpleBatchIteratorImpl<EllpackPage>>(page_));
auto begin_iter =
BatchIterator<EllpackPage>(new SimpleBatchIteratorImpl<EllpackPage>(page_));
return BatchSet<EllpackPage>(begin_iter);
}
} // namespace data
Expand Down
4 changes: 2 additions & 2 deletions src/data/iterative_device_dmatrix.h
Expand Up @@ -83,8 +83,8 @@ inline void IterativeDeviceDMatrix::Initialize(DataIterHandle iter, float missin
}
inline BatchSet<EllpackPage> IterativeDeviceDMatrix::GetEllpackBatches(const BatchParam& param) {
common::AssertGPUSupport();
auto begin_iter = BatchIterator<EllpackPage>(
std::make_shared<SimpleBatchIteratorImpl<EllpackPage>>(page_));
auto begin_iter =
BatchIterator<EllpackPage>(new SimpleBatchIteratorImpl<EllpackPage>(page_));
return BatchSet<EllpackPage>(BatchIterator<EllpackPage>(begin_iter));
}
#endif // !defined(XGBOOST_USE_CUDA)
Expand Down
16 changes: 7 additions & 9 deletions src/data/simple_dmatrix.cc
Expand Up @@ -48,7 +48,7 @@ DMatrix* SimpleDMatrix::Slice(common::Span<int32_t const> ridxs) {
BatchSet<SparsePage> SimpleDMatrix::GetRowBatches() {
// since csr is the default data structure so `source_` is always available.
auto begin_iter = BatchIterator<SparsePage>(
std::make_shared<SimpleBatchIteratorImpl<SparsePage>>(sparse_page_));
new SimpleBatchIteratorImpl<SparsePage>(sparse_page_));
return BatchSet<SparsePage>(begin_iter);
}

Expand All @@ -57,8 +57,8 @@ BatchSet<CSCPage> SimpleDMatrix::GetColumnBatches() {
if (!column_page_) {
column_page_.reset(new CSCPage(sparse_page_->GetTranspose(info_.num_col_)));
}
auto begin_iter = BatchIterator<CSCPage>(
std::make_shared<SimpleBatchIteratorImpl<CSCPage>>(column_page_));
auto begin_iter =
BatchIterator<CSCPage>(new SimpleBatchIteratorImpl<CSCPage>(column_page_));
return BatchSet<CSCPage>(begin_iter);
}

Expand All @@ -70,8 +70,7 @@ BatchSet<SortedCSCPage> SimpleDMatrix::GetSortedColumnBatches() {
sorted_column_page_->SortRows();
}
auto begin_iter = BatchIterator<SortedCSCPage>(
std::make_shared<SimpleBatchIteratorImpl<SortedCSCPage>>(
sorted_column_page_));
new SimpleBatchIteratorImpl<SortedCSCPage>(sorted_column_page_));
return BatchSet<SortedCSCPage>(begin_iter);
}

Expand All @@ -86,8 +85,8 @@ BatchSet<EllpackPage> SimpleDMatrix::GetEllpackBatches(const BatchParam& param)
ellpack_page_.reset(new EllpackPage(this, param));
batch_param_ = param;
}
auto begin_iter = BatchIterator<EllpackPage>(
std::make_shared<SimpleBatchIteratorImpl<EllpackPage>>(ellpack_page_));
auto begin_iter =
BatchIterator<EllpackPage>(new SimpleBatchIteratorImpl<EllpackPage>(ellpack_page_));
return BatchSet<EllpackPage>(begin_iter);
}

Expand All @@ -101,8 +100,7 @@ BatchSet<GHistIndexMatrix> SimpleDMatrix::GetGradientIndex(const BatchParam& par
batch_param_ = param;
}
auto begin_iter = BatchIterator<GHistIndexMatrix>(
std::make_shared<SimpleBatchIteratorImpl<GHistIndexMatrix>>(
gradient_index_));
new SimpleBatchIteratorImpl<GHistIndexMatrix>(gradient_index_));
return BatchSet<GHistIndexMatrix>(begin_iter);
}

Expand Down
3 changes: 1 addition & 2 deletions src/data/sparse_page_dmatrix.cc
Expand Up @@ -132,8 +132,7 @@ BatchSet<GHistIndexMatrix> SparsePageDMatrix::GetGradientIndex(const BatchParam&
}
this->InitializeSparsePage();
auto begin_iter = BatchIterator<GHistIndexMatrix>(
std::make_shared<SimpleBatchIteratorImpl<GHistIndexMatrix>>(
ghist_index_source_));
new SimpleBatchIteratorImpl<GHistIndexMatrix>(ghist_index_source_));
return BatchSet<GHistIndexMatrix>(begin_iter);
}

Expand Down

0 comments on commit d8bbf8b

Please sign in to comment.