Medial Code Documentation
Loading...
Searching...
No Matches
External
xgboost
src
data
simple_dmatrix.h
Go to the documentation of this file.
1
7
#ifndef XGBOOST_DATA_SIMPLE_DMATRIX_H_
8
#define XGBOOST_DATA_SIMPLE_DMATRIX_H_
9
10
#include <
xgboost/base.h
>
11
#include <
xgboost/data.h
>
12
13
#include <memory>
14
#include <string>
15
16
#include "gradient_index.h"
17
18
namespace
xgboost
{
19
namespace
data {
20
// Used for single batch data.
21
class
SimpleDMatrix
:
public
DMatrix
{
22
public
:
23
SimpleDMatrix
() =
default
;
24
template
<
typename
AdapterT>
25
explicit
SimpleDMatrix
(AdapterT* adapter,
float
missing,
int
nthread,
26
DataSplitMode
data_split_mode = DataSplitMode::kRow);
27
28
explicit
SimpleDMatrix
(
dmlc::Stream
* in_stream);
29
~SimpleDMatrix
()
override
=
default
;
30
31
void
SaveToLocalFile(
const
std::string& fname);
32
33
MetaInfo
& Info()
override
;
34
const
MetaInfo
& Info()
const override
;
35
Context
const
* Ctx()
const override
{
return
&fmat_ctx_; }
36
37
bool
SingleColBlock()
const override
{
return
true
; }
38
DMatrix
* Slice(
common::Span<int32_t const>
ridxs)
override
;
39
DMatrix
* SliceCol(
int
num_slices,
int
slice_id)
override
;
40
42
static
const
int
kMagic
= 0xffffab01;
43
44
protected
:
45
BatchSet<SparsePage>
GetRowBatches()
override
;
46
BatchSet<CSCPage>
GetColumnBatches(
Context
const
* ctx)
override
;
47
BatchSet<SortedCSCPage>
GetSortedColumnBatches(
Context
const
* ctx)
override
;
48
BatchSet<EllpackPage>
GetEllpackBatches(
Context
const
* ctx,
const
BatchParam
& param)
override
;
49
BatchSet<GHistIndexMatrix>
GetGradientIndex(
Context
const
* ctx,
const
BatchParam
& param)
override
;
50
BatchSet<ExtSparsePage>
GetExtBatches(
Context
const
* ctx,
BatchParam
const
& param)
override
;
51
52
MetaInfo
info_;
53
// Primary storage type
54
std::shared_ptr<SparsePage> sparse_page_ = std::make_shared<SparsePage>();
55
std::shared_ptr<CSCPage> column_page_{
nullptr
};
56
std::shared_ptr<SortedCSCPage> sorted_column_page_{
nullptr
};
57
std::shared_ptr<EllpackPage> ellpack_page_{
nullptr
};
58
std::shared_ptr<GHistIndexMatrix> gradient_index_{
nullptr
};
59
BatchParam batch_param_;
60
61
bool
EllpackExists()
const override
{
return
static_cast<
bool
>
(ellpack_page_); }
62
bool
GHistIndexExists()
const override
{
return
static_cast<
bool
>
(gradient_index_); }
63
bool
SparsePageExists()
const override
{
return
true
; }
64
72
void
ReindexFeatures
(Context
const
* ctx);
73
74
private
:
75
// Context used only for DMatrix initialization.
76
Context fmat_ctx_;
77
};
78
}
// namespace data
79
}
// namespace xgboost
80
#endif
// XGBOOST_DATA_SIMPLE_DMATRIX_H_
dmlc::Stream
interface of stream I/O for serialization
Definition
io.h:30
xgboost::BatchSet
Definition
data.h:494
xgboost::MetaInfo
Meta information about dataset, always sit in memory.
Definition
data.h:48
xgboost::common::Span
span class implementation, based on ISO++20 span<T>. The interface should be the same.
Definition
span.h:424
xgboost.core.DMatrix
Definition
core.py:748
xgboost.core.DataSplitMode
Definition
core.py:741
xgboost.data::SimpleDMatrix
Definition
simple_dmatrix.h:21
xgboost.data::SimpleDMatrix::ReindexFeatures
void ReindexFeatures(Context const *ctx)
Reindex the features based on a global view.
Definition
simple_dmatrix.cc:77
xgboost.data::SimpleDMatrix::kMagic
static const int kMagic
magic number used to identify SimpleDMatrix binary files
Definition
simple_dmatrix.h:42
base.h
Copyright 2015-2023 by XGBoost Contributors.
data.h
Copyright 2015-2023 by XGBoost Contributors.
xgboost
namespace of xgboost
Definition
base.h:90
xgboost::BatchParam
Parameters for constructing histogram index batches.
Definition
data.h:244
xgboost::Context
Runtime context for XGBoost.
Definition
context.h:84
Generated on Mon Sep 15 2025 12:12:20 for Medial Code Documentation by
1.9.8