diff --git a/core/configure/proto/general_model_config.proto b/core/configure/proto/general_model_config.proto index 310ad9e2eb612687d360edba82afa3aaf2c71885..22f31047f11f8642ce53261fc2ac720448918485 100644 --- a/core/configure/proto/general_model_config.proto +++ b/core/configure/proto/general_model_config.proto @@ -15,17 +15,15 @@ syntax = "proto2"; package baidu.paddle_serving.configure; -message Shape { repeated int32 shape = 1; }; - message FeedVar { required string name = 1; required bool is_lod_tensor = 2; required int32 feed_type = 3; - required Shape feed_shape = 4; + repeated int32 shape = 4; } message FetchVar { required string name = 1; - required Shape fetch_shape = 2; + repeated int32 shape = 2; } message GeneralModelConfig { repeated FeedVar feed_var = 1; diff --git a/core/predictor/framework/resource.cpp b/core/predictor/framework/resource.cpp index 0fa5e035b290ab8ff9dcc2d980561ccd014b33c2..e24f3e88b9ad9bce4f625f8e99a34bb815d21f94 100644 --- a/core/predictor/framework/resource.cpp +++ b/core/predictor/framework/resource.cpp @@ -23,7 +23,6 @@ namespace predictor { using configure::ResourceConf; using configure::GeneralModelConfig; -using configure::Shape; using rec::mcube::CubeAPI; // __thread bool p_thread_initialized = false; @@ -198,9 +197,8 @@ int Resource::general_model_initialize(const std::string& path, } else { _config->_capacity[i] = 1; _config->_is_lod_feed[i] = false; - for (int j = 0; j < model_config.feed_var(i).feed_shape().shape_size(); - ++j) { - int32_t dim = model_config.feed_var(i).feed_shape().shape(j); + for (int j = 0; j < model_config.feed_var(i).shape_size(); ++j) { + int32_t dim = model_config.feed_var(i).shape(j); _config->_feed_shape[i].push_back(dim); _config->_capacity[i] *= dim; } @@ -212,9 +210,8 @@ int Resource::general_model_initialize(const std::string& path, _config->_fetch_shape.resize(fetch_var_num); for (int i = 0; i < fetch_var_num; ++i) { _config->_fetch_name[i] = model_config.fetch_var(i).name(); - for (int j = 0; j < model_config.fetch_var(i).fetch_shape().shape_size(); - ++j) { - int dim = model_config.fetch_var(i).fetch_shape().shape(j); + for (int j = 0; j < model_config.fetch_var(i).shape_size(); ++j) { + int dim = model_config.fetch_var(i).shape(j); _config->_fetch_shape[i].push_back(dim); } } diff --git a/examples/demo-serving/conf/general_model.prototxt b/examples/demo-serving/conf/general_model.prototxt index efb0913731a309fbc6d9214091303a18bf485a24..984526e6c8152c35639a9a04e15ee3fd22dd16b5 100644 --- a/examples/demo-serving/conf/general_model.prototxt +++ b/examples/demo-serving/conf/general_model.prototxt @@ -1,34 +1,24 @@ feed_var { name: "words" - is_lod_tensor: false + is_lod_tensor: true feed_type: 0 - feed_shape { - shape: -1 - } + shape: -1 } feed_var { name: "label" is_lod_tensor: false feed_type: 0 - feed_shape { - shape: 1 - } + shape: 1 } fetch_var { - name: "mean_0.tmp_0" - fetch_shape { - shape: 1 - } + name: "cost" + shape: 1 } fetch_var { - name: "accuracy_0.tmp_0" - fetch_shape { - shape: 1 - } + name: "acc" + shape: 1 } fetch_var { - name: "fc_1.tmp_2" - fetch_shape { - shape: 1 - } + name: "prediction" + shape: 2 } diff --git a/examples/demo-serving/op/general_model_op.cpp b/examples/demo-serving/op/general_model_op.cpp index 1b6c3695949894acd17c7c9a1ef717710a23f14b..3e4896b3613d0914fc638fcf1d016460d5aaa056 100644 --- a/examples/demo-serving/op/general_model_op.cpp +++ b/examples/demo-serving/op/general_model_op.cpp @@ -48,16 +48,6 @@ int GeneralModelOp::inference() { std::vector elem_size; std::vector capacity; - // config - LOG(INFO) << "start to call load general model_conf op"; - baidu::paddle_serving::predictor::Resource &resource = - baidu::paddle_serving::predictor::Resource::instance(); - LOG(INFO) << "get resource pointer done."; - std::shared_ptr model_config = - resource.get_general_model_config(); - LOG(INFO) << "get general model config pointer done."; - resource.print_general_model_config(model_config); - // infer if (batch_size > 0) { int var_num = req->insts(0).tensor_array_size();