From ca84130080b33b12a49ecadbaf0427e34c6b9113 Mon Sep 17 00:00:00 2001 From: liangzelang Date: Tue, 22 Sep 2020 20:37:48 +0800 Subject: [PATCH] fix IsInstance op bug when input is tensor --- mindspore/core/ir/dtype/tensor_type.cc | 4 +++- mindspore/ops/operations/array_ops.py | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/mindspore/core/ir/dtype/tensor_type.cc b/mindspore/core/ir/dtype/tensor_type.cc index 31df37ebc2..4c1cd5b5dc 100644 --- a/mindspore/core/ir/dtype/tensor_type.cc +++ b/mindspore/core/ir/dtype/tensor_type.cc @@ -64,7 +64,9 @@ bool UndeterminedType::operator==(const Type &other) const { } TypePtr TensorType::DeepCopy() const { - MS_EXCEPTION_IF_NULL(element_type_); + if (element_type_ == nullptr) { + return std::make_shared(); + } if (IsGeneric()) { return std::make_shared(); } diff --git a/mindspore/ops/operations/array_ops.py b/mindspore/ops/operations/array_ops.py index 96384eafd2..6517a912ce 100644 --- a/mindspore/ops/operations/array_ops.py +++ b/mindspore/ops/operations/array_ops.py @@ -347,7 +347,8 @@ class IsInstance(PrimitiveWithInfer): sub_type_t = inst['dtype'] type_v = type_['value'] - validator.check_const_input("inst", inst['value'], self.name) + if not isinstance(inst, type(mstype.tensor)): + validator.check_const_input("inst", inst['value'], self.name) validator.check_value_type("type_", type_v, [mstype.Type], self.name) if type_v == mstype.list_: