MCPcopy Create free account
hub / github.com/catboost/catboost / Load

Method Load

catboost/libs/model/model.cpp:1179–1228  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1177}
1178
1179void TFullModel::Load(IInputStream* s) {
1180 ReferenceMainFactoryRegistrators();
1181 using namespace flatbuffers;
1182 using namespace NCatBoostFbs;
1183 ui32 fileDescriptor;
1184 ::Load(s, fileDescriptor);
1185 CB_ENSURE(fileDescriptor == GetModelFormatDescriptor(), "Incorrect model file descriptor");
1186 auto coreSize = ::LoadSize(s);
1187 TArrayHolder<ui8> arrayHolder(new ui8[coreSize]);
1188 s->LoadOrFail(arrayHolder.Get(), coreSize);
1189
1190 {
1191 flatbuffers::Verifier verifier(arrayHolder.Get(), coreSize, 64 /* max depth */, 256000000 /* max tables */);
1192 CB_ENSURE(VerifyTModelCoreBuffer(verifier), "Flatbuffers model verification failed");
1193 }
1194 auto fbModelCore = GetTModelCore(arrayHolder.Get());
1195 DefaultFullModelInit(fbModelCore);
1196
1197 if (fbModelCore->ModelTrees()) {
1198 ModelTrees.GetMutable()->FBDeserializeOwning(fbModelCore->ModelTrees());
1199 }
1200
1201 TVector<TString> modelParts;
1202 if (fbModelCore->ModelPartIds()) {
1203 for (auto part : *fbModelCore->ModelPartIds()) {
1204 modelParts.emplace_back(part->str());
1205 }
1206 }
1207 if (!modelParts.empty()) {
1208 for (const auto& modelPartId : modelParts) {
1209 if (modelPartId == TStaticCtrProvider::ModelPartId()) {
1210 CtrProvider = new TStaticCtrProvider;
1211 CtrProvider->Load(s);
1212 } else if (modelPartId == NCB::TTextProcessingCollection::GetStringIdentifier()) {
1213 TextProcessingCollection = new NCB::TTextProcessingCollection();
1214 TextProcessingCollection->Load(s);
1215 } else if (modelPartId == NCB::TEmbeddingProcessingCollection::GetStringIdentifier()) {
1216 EmbeddingProcessingCollection = new NCB::TEmbeddingProcessingCollection();
1217 EmbeddingProcessingCollection->Load(s);
1218 } else {
1219 CB_ENSURE(
1220 false,
1221 "Got unknown partId = " << modelPartId << " via deserialization. "
1222 << "Only static ctr, text or embedding processing collection model parts are supported"
1223 );
1224 }
1225 }
1226 }
1227 UpdateDynamicData();
1228}
1229
1230void TFullModel::InitNonOwning(const void* binaryBuffer, size_t binarySize) {
1231 using namespace flatbuffers;

Callers 15

LoadOptionsFunction · 0.45
mode_model_based_evalFunction · 0.45
mode_eval_featureFunction · 0.45
TryGetLossDescriptionFunction · 0.45
TryGetObjectiveMetricFunction · 0.45
GetLossDescriptionFunction · 0.45
GetModelClassLabelsMethod · 0.45
IsClassifierModelFunction · 0.45
Y_UNIT_TESTFunction · 0.45
DoSerializeDeserializeFunction · 0.45
SaveLoadCBMFunction · 0.45
TrainModelFunction · 0.45

Calls 11

LoadSizeFunction · 0.85
LoadOrFailMethod · 0.80
FBDeserializeOwningMethod · 0.80
GetMutableMethod · 0.80
GetModelFormatDescriptorFunction · 0.70
LoadFunction · 0.50
GetMethod · 0.45
emplace_backMethod · 0.45
strMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected