pybind_general_model.cpp 1.6 KB
Newer Older
G
guru4elephant 已提交
1 2 3 4 5 6 7
#include <pybind11/pybind11.h>
#include "general_model.h"

#include <pybind11/stl.h>

namespace py = pybind11;

G
guru4elephant 已提交
8 9
using baidu::paddle_serving::general_model::FetchedMap;

G
guru4elephant 已提交
10 11 12 13 14 15 16 17 18 19 20 21 22
namespace baidu {
namespace paddle_serving {
namespace general_model {

PYBIND11_MODULE(paddle_serving_client, m) {
  m.doc() = R"pddoc(this is a practice
       )pddoc";
  py::class_<PredictorClient>(m, "PredictorClient", py::buffer_protocol())
      .def(py::init())
      .def("init",
           [](PredictorClient &self, const std::string & conf) {
             self.init(conf);
           })
G
guru4elephant 已提交
23 24 25 26 27 28 29 30
      .def("set_predictor_conf",
           [](PredictorClient &self, const std::string & conf_path,
              const std::string & conf_file) {
             self.set_predictor_conf(conf_path, conf_file);
           })
      .def("create_predictor",
           [](PredictorClient & self) {
             self.create_predictor();
G
guru4elephant 已提交
31 32 33 34 35 36 37
           })
      .def("predict",
           [](PredictorClient &self,
              const std::vector<std::vector<float> > & float_feed,
              const std::vector<std::string> & float_feed_name,
              const std::vector<std::vector<int64_t> > & int_feed,
              const std::vector<std::string> & int_feed_name,
G
guru4elephant 已提交
38 39
              const std::vector<std::string> & fetch_name,
              FetchedMap * fetch_result) {
G
guru4elephant 已提交
40
             return self.predict(float_feed, float_feed_name,
G
guru4elephant 已提交
41 42
                                 int_feed, int_feed_name, fetch_name,
                                 fetch_result);
G
guru4elephant 已提交
43 44 45 46 47 48
           });
}

}  // namespace general_model
}  // namespace paddle_serving
}  // namespace baidu