From ccb5bce359a05b704fa253595629a875eb01fcbf Mon Sep 17 00:00:00 2001 From: chenfei Date: Thu, 24 Dec 2020 09:33:25 +0800 Subject: [PATCH] don't slice shape if shape size<=1 of sparsegatherv2 grad --- mindspore/ops/_grad/grad_array_ops.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mindspore/ops/_grad/grad_array_ops.py b/mindspore/ops/_grad/grad_array_ops.py index 4ef13eec44..123ce3fd63 100644 --- a/mindspore/ops/_grad/grad_array_ops.py +++ b/mindspore/ops/_grad/grad_array_ops.py @@ -433,7 +433,10 @@ def get_bprop_sparse_gather_v2(self): x_shp = shape_op(x) if axis == 0: indices_size = (size_op(indices),) - x_tail_shp = x_shp[1:] + if len(x_shp) <= 1: + x_tail_shp = () + else: + x_tail_shp = x_shp[1:] values_shape = indices_size + x_tail_shp values = reshape(dout, values_shape) indices_new = reshape(indices, indices_size)