!10545 getitem fix bug

From: @yepei6
Reviewed-by: @zhunaipan,@zh_qh
Signed-off-by: @zh_qh
This commit is contained in:
mindspore-ci-bot 2020-12-26 11:27:46 +08:00 committed by Gitee
commit 660f2b8c33
2 changed files with 3 additions and 2 deletions

View File

@ -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:

View File

@ -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