MCPcopy Create free account
hub / github.com/PaddlePaddle/Paddle-Lite / LoadModelNaiveFromFile

Function LoadModelNaiveFromFile

lite/model_parser/model_parser.cc:744–782  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

742 */
743
744void LoadModelNaiveFromFile(const std::string &filename,
745 Scope *scope,
746 cpp::ProgramDesc *cpp_prog) {
747 CHECK(cpp_prog);
748 CHECK(scope);
749 // ModelFile
750 const std::string prog_path = filename;
751 // Offset
752 model_parser::BinaryFileReader reader(filename, 0);
753
754 // (1)get meta version
755 uint16_t meta_version;
756 reader.Read(&meta_version, sizeof(uint16_t));
757 VLOG(4) << "Meta_version:" << meta_version;
758
759 switch (meta_version) {
760 case 0:
761#ifndef LITE_ON_TINY_PUBLISH
762 LoadModelNaiveV0FromFile(filename, scope, cpp_prog);
763#else
764 LOG(FATAL) << "Paddle-Lite v2.7 has upgraded the naive-buffer model "
765 "format. Please use the OPT to generate a new model. "
766 "Thanks!";
767#endif
768 break;
769 case 1:
770 LoadModelFbsFromFile(&reader, scope, cpp_prog, 1);
771 break;
772 case 2:
773 LoadModelFbsFromFile(&reader, scope, cpp_prog, 2);
774 break;
775 default:
776 LOG(FATAL) << "The model format cannot be recognized. Please make sure "
777 "you use the correct interface and model file.";
778 break;
779 }
780 VLOG(4) << "paddle_version:" << cpp_prog->Version();
781 VLOG(4) << "Load naive buffer model in '" << filename << "' successfully";
782}
783#ifndef LITE_ON_TINY_PUBLISH
784void LoadModelNaiveV0FromFile(const std::string &filename,
785 Scope *scope,

Callers 4

BuildMethod · 0.85
BuildMethod · 0.85
TESTFunction · 0.85

Calls 4

LoadModelNaiveV0FromFileFunction · 0.85
LoadModelFbsFromFileFunction · 0.85
ReadMethod · 0.45
VersionMethod · 0.45

Tested by 1

TESTFunction · 0.68