forked from mindspore-Ecosystem/mindspore
!10545 getitem fix bug
From: @yepei6 Reviewed-by: @zhunaipan,@zh_qh Signed-off-by: @zh_qh
This commit is contained in:
commit
660f2b8c33
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue