Browse Source

!11103 fix bug in getitem when index is True

From: @zhangbuxue
Reviewed-by: @ginfung,@zh_qh
Signed-off-by: @zh_qh
tags/v1.2.0-rc1
mindspore-ci-bot Gitee 4 years ago
parent
commit
198d3b09eb
1 changed files with 1 additions and 1 deletions
  1. +1
    -1
      mindspore/common/tensor.py

+ 1
- 1
mindspore/common/tensor.py View File

@@ -191,7 +191,7 @@ class Tensor(Tensor_):
return out

def __getitem__(self, index):
if isinstance(index, int) and self.shape and index >= self.shape[0]:
if isinstance(index, int) and not isinstance(index, bool) and self.shape and index >= self.shape[0]:
raise IndexError("index {} is out of bounds for axis 0 with size {}".format(index, self.shape[0]))
out = tensor_operator_registry.get('__getitem__')(self, index)
return out


Loading…
Cancel
Save