提交 1ebe608f 编写于 作者: B barrierye

speed up

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