Browse Source

add the data rank district to [0,8])

tags/v1.2.0-rc1
yepei6 5 years ago
parent
commit
10cf3f1524
1 changed files with 7 additions and 0 deletions
  1. +7
    -0
      mindspore/ops/composite/multitype_ops/_compile_utils.py

+ 7
- 0
mindspore/ops/composite/multitype_ops/_compile_utils.py View File

@@ -161,6 +161,13 @@ def tensor_index_by_slice(data, slice_index):

def tensor_index_by_number(data, number):
"""Tensor getitem by a Number which may be integer/float/bool value"""
data_type = F.typeof(data)
if const_utils.judge_index_type(data_type, mstype.tensor_type):
data_shape = F.shape(data)
data_rank = len(data_shape)
min_data_rank, max_data_rank = 0, 8
const_utils.judge_data_rank(data_rank, min_data_rank, max_data_rank)

number_type = const_utils.check_number_index_type(number)
if number_type == const_utils.BOOL_:
return _tensor_index_by_bool(data, number)


Loading…
Cancel
Save