MCPcopy Create free account
hub / github.com/PaddlePaddle/Serving / init

Method init

tools/cpp_examples/demo-client/src/general_model.cpp:31–66  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29namespace general_model {
30
31void PredictorClient::init(const std::string &conf_file) {
32 _conf_file = conf_file;
33 std::ifstream fin(conf_file);
34 if (!fin) {
35 LOG(ERROR) << "Your inference conf file can not be found";
36 exit(-1);
37 }
38 _feed_name_to_idx.clear();
39 _fetch_name_to_idx.clear();
40 _shape.clear();
41 int feed_var_num = 0;
42 int fetch_var_num = 0;
43 fin >> feed_var_num >> fetch_var_num;
44 std::string name;
45 std::string fetch_var_name;
46 int shape_num = 0;
47 int dim = 0;
48 for (int i = 0; i < feed_var_num; ++i) {
49 fin >> name;
50 _feed_name_to_idx[name] = i;
51 fin >> shape_num;
52 std::vector<int> tmp_feed_shape;
53 for (int j = 0; j < shape_num; ++j) {
54 fin >> dim;
55 tmp_feed_shape.push_back(dim);
56 }
57 _shape.push_back(tmp_feed_shape);
58 }
59
60 for (int i = 0; i < fetch_var_num; ++i) {
61 fin >> name;
62 fin >> fetch_var_name;
63 _fetch_name_to_idx[name] = i;
64 _fetch_name_to_var_name[name] = fetch_var_name;
65 }
66}
67
68void PredictorClient::set_predictor_conf(const std::string &conf_path,
69 const std::string &conf_file) {

Callers 2

PYBIND11_MODULEFunction · 0.45
mainFunction · 0.45

Calls 2

push_backMethod · 0.80
clearMethod · 0.45

Tested by

no test coverage detected