Browse Source

!10664 fix error in len of tensor in pynative mode

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

+ 4
- 3
mindspore/common/tensor.py View File

@@ -197,9 +197,10 @@ class Tensor(Tensor_):

def __len__(self):
out = tensor_operator_registry.get('shape')(self)
if not out:
return 1
return out[0]
if out:
return out[0]
raise TypeError("Not support len of a 0-D tensor")


def __mod__(self, other):
return tensor_operator_registry.get('__mod__')(self, other)


Loading…
Cancel
Save