From 9c7cdcf1e9d9f957ccd7728c62269e25b1ddad09 Mon Sep 17 00:00:00 2001 From: buxue Date: Wed, 12 Aug 2020 18:12:33 +0800 Subject: [PATCH] support bool tensor and bool do equal --- mindspore/common/tensor.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mindspore/common/tensor.py b/mindspore/common/tensor.py index 733eae4a2da..155f62e5b5e 100644 --- a/mindspore/common/tensor.py +++ b/mindspore/common/tensor.py @@ -85,7 +85,9 @@ class Tensor(Tensor_): return False # bool type is not supported for `Equal` operator in backend. 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) def __ne__(self, other):