Browse Source

!4352 support bool tensor and bool do equal in pynative mode

Merge pull request !4352 from zhangbuxue/support_bool_tensor_and_bool_do_equal
tags/v0.7.0-beta
mindspore-ci-bot Gitee 5 years ago
parent
commit
b337b15c9b
1 changed files with 3 additions and 1 deletions
  1. +3
    -1
      mindspore/common/tensor.py

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

@@ -85,7 +85,9 @@ class Tensor(Tensor_):
return False return False
# bool type is not supported for `Equal` operator in backend. # bool type is not supported for `Equal` operator in backend.
if self.dtype == mstype.bool_ or (isinstance(other, Tensor) and other.dtype == mstype.bool_): if self.dtype == mstype.bool_ or (isinstance(other, Tensor) and other.dtype == mstype.bool_):
return Tensor(np.array(self.asnumpy() == other.asnumpy()))
if isinstance(other, Tensor):
return Tensor(np.array(self.asnumpy() == other.asnumpy()))
return Tensor(np.array(self.asnumpy() == other))
return tensor_operator_registry.get('__eq__')(self, other) return tensor_operator_registry.get('__eq__')(self, other)


def __ne__(self, other): def __ne__(self, other):


Loading…
Cancel
Save