From 1354acc9b084bded9f89ed40b20596ed7826ac37 Mon Sep 17 00:00:00 2001 From: wangjiawei04 Date: Sat, 10 Oct 2020 12:33:40 +0000 Subject: [PATCH] support lod forced true --- core/general-server/op/general_response_op.cpp | 8 +++++--- python/paddle_serving_client/__init__.py | 16 +++++++++------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/core/general-server/op/general_response_op.cpp b/core/general-server/op/general_response_op.cpp index 3a723e5c..69b8e01e 100644 --- a/core/general-server/op/general_response_op.cpp +++ b/core/general-server/op/general_response_op.cpp @@ -155,9 +155,11 @@ int GeneralResponseOp::inference() { } if (model_config->_is_lod_fetch[idx]) { - for (int j = 0; j < in->at(idx).lod[0].size(); ++j) { - fetch_p->mutable_tensor_array(var_idx)->add_lod( - in->at(idx).lod[0][j]); + if (in->at(idx).lod.size() > 0) { + for (int j = 0; j < in->at(idx).lod[0].size(); ++j) { + fetch_p->mutable_tensor_array(var_idx)->add_lod( + in->at(idx).lod[0][j]); + } } } diff --git a/python/paddle_serving_client/__init__.py b/python/paddle_serving_client/__init__.py index 1af7f754..d350b584 100644 --- a/python/paddle_serving_client/__init__.py +++ b/python/paddle_serving_client/__init__.py @@ -354,8 +354,9 @@ class Client(object): name)) result_map[name].shape = shape if name in self.lod_tensor_set: - result_map["{}.lod".format( - name)] = result_batch_handle.get_lod(mi, name) + tmp_lod = result_batch_handle.get_lod(mi, name) + if np.size(tmp_lod) > 0: + result_map["{}.lod".format(name)] = tmp_lod elif self.fetch_names_to_type_[name] == float32_type: result_map[name] = result_batch_handle.get_float_by_name( mi, name) @@ -367,9 +368,9 @@ class Client(object): shape = result_batch_handle.get_shape(mi, name) result_map[name].shape = shape if name in self.lod_tensor_set: - result_map["{}.lod".format( - name)] = result_batch_handle.get_lod(mi, name) - + tmp_lod = result_batch_handle.get_lod(mi, name) + if np.size(tmp_lod) > 0: + result_map["{}.lod".format(name)] = tmp_lod elif self.fetch_names_to_type_[name] == int32_type: # result_map[name] will be py::array(numpy array) result_map[name] = result_batch_handle.get_int32_by_name( @@ -382,8 +383,9 @@ class Client(object): shape = result_batch_handle.get_shape(mi, name) result_map[name].shape = shape if name in self.lod_tensor_set: - result_map["{}.lod".format( - name)] = result_batch_handle.get_lod(mi, name) + tmp_lod = result_batch_handle.get_lod(mi, name) + if np.size(tmp_lod) > 0: + result_map["{}.lod".format(name)] = tmp_lod multi_result_map.append(result_map) ret = None if len(model_engine_names) == 1: -- GitLab