diff --git a/mindspore/common/tensor.py b/mindspore/common/tensor.py index 0906f12967..2977063d77 100644 --- a/mindspore/common/tensor.py +++ b/mindspore/common/tensor.py @@ -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)