提交 ec898861 编写于 作者: C chenxuyi 提交者: Meiyim

propeller server 1.6 compat

上级 2660a5c2
...@@ -54,6 +54,8 @@ if __name__ == "__main__": ...@@ -54,6 +54,8 @@ if __name__ == "__main__":
raise RuntimeError('CUDA_VISIBLE_DEVICES not set') raise RuntimeError('CUDA_VISIBLE_DEVICES not set')
if not os.path.exists(args.model_dir): if not os.path.exists(args.model_dir):
raise ValueError('model_dir not found: %s' % args.model_dir) raise ValueError('model_dir not found: %s' % args.model_dir)
if not os.path.exists(args.model_dir):
raise ValueError('model_dir not found: %s' % args.model_dir)
n_devices = len(cuda_env.split(",")) n_devices = len(cuda_env.split(","))
if args.encode_layer.lower() == 'pooler': if args.encode_layer.lower() == 'pooler':
model_dir = os.path.join(args.model_dir, 'pooler') model_dir = os.path.join(args.model_dir, 'pooler')
......
...@@ -65,22 +65,19 @@ def slot_to_paddlearray(slot): ...@@ -65,22 +65,19 @@ def slot_to_paddlearray(slot):
"""doc""" """doc"""
import paddle.fluid.core as core import paddle.fluid.core as core
if slot.type == interface_pb2.Slot.FP32: if slot.type == interface_pb2.Slot.FP32:
dtype = np.float32
type_str = 'f' type_str = 'f'
dtype = core.PaddleDType.FLOAT32
elif slot.type == interface_pb2.Slot.INT32: elif slot.type == interface_pb2.Slot.INT32:
dtype = np.int32
type_str = 'i' type_str = 'i'
dtype = core.PaddleDType.INT32
elif slot.type == interface_pb2.Slot.INT64: elif slot.type == interface_pb2.Slot.INT64:
dtype = np.int64
type_str = 'q' type_str = 'q'
dtype = core.PaddleDType.INT64
else: else:
raise RuntimeError('know type %s' % slot.type) raise RuntimeError('know type %s' % slot.type)
ret = core.PaddleTensor()
ret.shape = slot.dims
ret.dtype = dtype
num = len(slot.data) // struct.calcsize(type_str) num = len(slot.data) // struct.calcsize(type_str)
arr = struct.unpack('%d%s' % (num, type_str), slot.data) arr = struct.unpack('%d%s' % (num, type_str), slot.data)
ret.data = core.PaddleBuf(arr) ret = core.PaddleTensor(data=np.array(arr, dtype=dtype).reshape(slot.dims))
return ret return ret
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册