diff --git a/core/general-client/include/general_model.h b/core/general-client/include/general_model.h index 9059a26600457194b8586ab8df1a26feddd198df..9d0cc8b66cfe2e3fe2f4d012c7920f518d32ef5a 100644 --- a/core/general-client/include/general_model.h +++ b/core/general-client/include/general_model.h @@ -49,6 +49,8 @@ class ModelRes { res._int64_value_map.end()); _float_value_map.insert(res._float_value_map.begin(), res._float_value_map.end()); + _shape_map.insert(res._shape_map.begin(), res._shape_map.end()); + _lod_map.insert(res._lod_map.begin(), res._lod_map.end()); } ModelRes(ModelRes&& res) { _engine_name = std::move(res._engine_name); @@ -58,6 +60,10 @@ class ModelRes { _float_value_map.insert( std::make_move_iterator(std::begin(res._float_value_map)), std::make_move_iterator(std::end(res._float_value_map))); + _shape_map.insert(std::make_move_iterator(std::begin(res._shape_map)), + std::make_move_iterator(std::end(res._shape_map))); + _lod_map.insert(std::make_move_iterator(std::begin(res._lod_map)), + std::make_move_iterator(std::end(res._lod_map))); } ~ModelRes() {} const std::vector& get_int64_by_name(const std::string& name) { @@ -85,6 +91,10 @@ class ModelRes { _float_value_map.insert( std::make_move_iterator(std::begin(res._float_value_map)), std::make_move_iterator(std::end(res._float_value_map))); + _shape_map.insert(std::make_move_iterator(std::begin(res._shape_map)), + std::make_move_iterator(std::end(res._shape_map))); + _lod_map.insert(std::make_move_iterator(std::begin(res._lod_map)), + std::make_move_iterator(std::end(res._lod_map))); } return *this; } diff --git a/doc/MODEL_ENSEMBLE_IN_PADDLE_SERVING.md b/doc/MODEL_ENSEMBLE_IN_PADDLE_SERVING.md index dd83bc29093288df49ba5d55ea7afa081e1d8b59..7f583342cf2437b29916f6711c7bd0701206bf8d 100644 --- a/doc/MODEL_ENSEMBLE_IN_PADDLE_SERVING.md +++ b/doc/MODEL_ENSEMBLE_IN_PADDLE_SERVING.md @@ -100,11 +100,11 @@ for i in range(3): fetch = ["acc", "cost", "prediction"] fetch_maps = client.predict(feed=feed, fetch=fetch) if len(fetch_maps) == 1: - print("step: {}, res: {}".format(i, fetch_maps['prediction'][1])) + print("step: {}, res: {}".format(i, fetch_maps['prediction'][0][1])) else: for model, fetch_map in fetch_maps.items(): print("step: {}, model: {}, res: {}".format(i, model, fetch_map[ - 'prediction'][1])) + 'prediction'][0][1])) ``` Compared with the normal prediction service, the client side has not changed much. When multiple model predictions are used, the prediction service will return a dictionary with engine name `engine_name`(the value is defined on the server side) as the key, and the corresponding model prediction results as the value. diff --git a/doc/MODEL_ENSEMBLE_IN_PADDLE_SERVING_CN.md b/doc/MODEL_ENSEMBLE_IN_PADDLE_SERVING_CN.md index 12af427ed2e7bbd688ea854673dfac716a6050bb..ee816aa5a441610e845a933217041a774fad8129 100644 --- a/doc/MODEL_ENSEMBLE_IN_PADDLE_SERVING_CN.md +++ b/doc/MODEL_ENSEMBLE_IN_PADDLE_SERVING_CN.md @@ -100,11 +100,11 @@ for i in range(3): fetch = ["acc", "cost", "prediction"] fetch_maps = client.predict(feed=feed, fetch=fetch) if len(fetch_maps) == 1: - print("step: {}, res: {}".format(i, fetch_maps['prediction'][1])) + print("step: {}, res: {}".format(i, fetch_maps['prediction'][0][1])) else: for model, fetch_map in fetch_maps.items(): print("step: {}, model: {}, res: {}".format(i, model, fetch_map[ - 'prediction'][1])) + 'prediction'][0][1])) ``` Client端与普通预测服务没有发生太大的变化。当使用多个模型预测时,预测服务将返回一个key为Server端定义的引擎名称`engine_name`,value为对应的模型预测结果的字典。 diff --git a/python/examples/imdb/test_ensemble_client.py b/python/examples/imdb/test_ensemble_client.py index 5fd97f665f6e892e7619d320d945ca6b7b372cf9..6cafb3389fff5a25103bcb2b3a867b73b35b9e8e 100644 --- a/python/examples/imdb/test_ensemble_client.py +++ b/python/examples/imdb/test_ensemble_client.py @@ -35,8 +35,8 @@ for i in range(3): fetch = ["acc", "cost", "prediction"] fetch_maps = client.predict(feed=feed, fetch=fetch) if len(fetch_maps) == 1: - print("step: {}, res: {}".format(i, fetch_maps['prediction'][1])) + print("step: {}, res: {}".format(i, fetch_maps['prediction'][0][1])) else: for model, fetch_map in fetch_maps.items(): print("step: {}, model: {}, res: {}".format(i, model, fetch_map[ - 'prediction'][1])) + 'prediction'][0][1]))