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

Function LoadScalarField

src/data/data.cc:110–130  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

108
109template <typename T>
110void LoadScalarField(dmlc::Stream* strm, const std::string& expected_name,
111 xgboost::DataType expected_type, T* field) {
112 const std::string invalid{"MetaInfo: Invalid format for " + expected_name};
113 std::string name;
114 xgboost::DataType type;
115 bool is_scalar;
116 CHECK(strm->Read(&name)) << invalid;
117 CHECK_EQ(name, expected_name) << invalid << " Expected field: " << expected_name
118 << ", got: " << name;
119 uint8_t type_val;
120 CHECK(strm->Read(&type_val)) << invalid;
121 type = static_cast<xgboost::DataType>(type_val);
122 CHECK(type == expected_type) << invalid
123 << "Expected field of type: " << static_cast<int>(expected_type)
124 << ", "
125 << "got field type: " << static_cast<int>(type);
126 CHECK(strm->Read(&is_scalar)) << invalid;
127 CHECK(is_scalar) << invalid << "Expected field " << expected_name
128 << " to be a scalar; got a vector";
129 CHECK(strm->Read(field)) << invalid;
130}
131
132template <typename T>
133void LoadVectorField(dmlc::Stream* strm, const std::string& expected_name,

Callers 1

LoadBinaryMethod · 0.85

Calls 1

ReadMethod · 0.45

Tested by

no test coverage detected