提交 dd3e679f 编写于 作者: B barrierye

speed up

上级 7e8d36d7
...@@ -446,14 +446,12 @@ class MultiLangClient(object): ...@@ -446,14 +446,12 @@ class MultiLangClient(object):
v_type = self.feed_types_[name] v_type = self.feed_types_[name]
if v_type == 0: # int64 if v_type == 0: # int64
if isinstance(var, np.ndarray): if isinstance(var, np.ndarray):
tensor.int64_data.extend( tensor.int64_data.extend(var.reshape(-1).tolist())
self._flatten_list(var.tolist()))
else: else:
tensor.int64_data.extend(self._flatten_list(var)) tensor.int64_data.extend(self._flatten_list(var))
elif v_type == 1: # float32 elif v_type == 1: # float32
if isinstance(var, np.ndarray): if isinstance(var, np.ndarray):
tensor.float_data.extend( tensor.float_data.extend(var.reshape(-1).tolist())
self._flatten_list(var.tolist()))
else: else:
tensor.float_data.extend(self._flatten_list(var)) tensor.float_data.extend(self._flatten_list(var))
else: else:
......
...@@ -513,11 +513,9 @@ class MultiLangServerService( ...@@ -513,11 +513,9 @@ class MultiLangServerService(
tensor = multi_lang_general_model_service_pb2.Tensor() tensor = multi_lang_general_model_service_pb2.Tensor()
v_type = self.fetch_types_[name] v_type = self.fetch_types_[name]
if v_type == 0: # int64 if v_type == 0: # int64
tensor.int64_data.extend( tensor.int64_data.extend(result[name].reshape(-1).tolist())
self._flatten_list(result[name].tolist()))
elif v_type == 1: # float32 elif v_type == 1: # float32
tensor.float_data.extend( tensor.float_data.extend(result[name].reshape(-1).tolist())
self._flatten_list(result[name].tolist()))
else: else:
raise Exception("error type.") raise Exception("error type.")
tensor.shape.extend(list(result[name].shape)) tensor.shape.extend(list(result[name].shape))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册