From f5b8d2a821fca86b4837993a2ce9d739d68ebb5b Mon Sep 17 00:00:00 2001 From: Yuanhong Wang Date: Fri, 29 Mar 2019 10:15:29 +0000 Subject: [PATCH] fix convert bug --- tf2onnx/tfonnx.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tf2onnx/tfonnx.py b/tf2onnx/tfonnx.py index d7acf6bc9..8ef3153fc 100644 --- a/tf2onnx/tfonnx.py +++ b/tf2onnx/tfonnx.py @@ -797,8 +797,16 @@ def slice_op(ctx, node, name, args): # T output = Slice(T input, Index begin, Index size, @type Index) # T output = Slice(T data, @INTS axes, @INTS ends, @INTS starts) starts = node.inputs[1].get_tensor_value() - size = node.inputs[2].get_tensor_value() - ends = np.add(starts, size) + sizes = node.inputs[2].get_tensor_value() + ends = [] + for start, size in zip(starts, sizes): + # get all elements + if size == -1: + dtype = ctx.get_dtype(node.input[1]) + utils.make_sure(dtype, "dtype of {} is None".format(node.input[1])) + ends.append(np.iinfo(dtype).max) + else: + ends.append(start + size) ctx.remove_input(node, node.input[2]) ctx.remove_input(node, node.input[1]) node.set_attr("starts", starts)