From c3eb913a9b8d68c1f96c633af1bfbd091a84c918 Mon Sep 17 00:00:00 2001 From: Payne Date: Fri, 25 Dec 2020 16:43:09 +0800 Subject: [PATCH] fix the bug of ellipsis dim-size confusion and the ErrorType --- mindspore/ops/composite/multitype_ops/_compile_utils.py | 1 + mindspore/ops/composite/multitype_ops/_constexpr_utils.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/mindspore/ops/composite/multitype_ops/_compile_utils.py b/mindspore/ops/composite/multitype_ops/_compile_utils.py index 45bb1340c5..a87773265f 100644 --- a/mindspore/ops/composite/multitype_ops/_compile_utils.py +++ b/mindspore/ops/composite/multitype_ops/_compile_utils.py @@ -365,6 +365,7 @@ def tensor_index_by_tuple(data, tuple_index): """Tensor getitem by tuple of various types with None""" if len(tuple_index) == 1: return data[tuple_index[0]] + tuple_index = _transform_ellipsis_to_slice(tuple_index, data, const_utils.TENSOR_GETITEM) indexes_types = hyper_map(F.typeof, tuple_index) contain_type = const_utils.tuple_index_type_cnt(indexes_types, const_utils.TENSOR_GETITEM) if contain_type == const_utils.ALL_TENSOR: diff --git a/mindspore/ops/composite/multitype_ops/_constexpr_utils.py b/mindspore/ops/composite/multitype_ops/_constexpr_utils.py index ce3284d13f..3972f94f7d 100644 --- a/mindspore/ops/composite/multitype_ops/_constexpr_utils.py +++ b/mindspore/ops/composite/multitype_ops/_constexpr_utils.py @@ -776,8 +776,8 @@ def separate_mixed_tensors_index(indexes_types, op_name): elif isinstance(ele_type, mstype.ellipsis_type): ellipsis_position = i else: - raise TypeError(f"For '{op_name}', the index elements only support " - f"'Tensor', 'int32', 'int64', 'Slice', 'Ellipsis', but got {ele_type}.") + raise IndexError(f"For '{op_name}', the index elements only support " + f"'Tensor', 'int32', 'int64', 'Slice', 'Ellipsis', but got {ele_type}.") return tensor_positions, slice_positions, ellipsis_position