diff --git a/mindspore/ccsrc/debug/anf_ir_utils.cc b/mindspore/ccsrc/debug/anf_ir_utils.cc index 2b8e61ab15932f69b33b885b1f1f1fa33422a68e..bde0c33cb75d06c02a36ecb891977b3d76a80944 100644 --- a/mindspore/ccsrc/debug/anf_ir_utils.cc +++ b/mindspore/ccsrc/debug/anf_ir_utils.cc @@ -400,7 +400,7 @@ std::string AnfExporter::GetValueText(const FuncGraphPtr &func_graph, const Valu } else if (value->isa()) { auto tensor_ptr = dyn_cast(value); oss << value->DumpText() << "@" << DumpObject(tensor_ptr->data(), "T"); - } else if (value->isa() || value->isa() || value->isa()) { + } else if (value->isa() || value->isa() || value->isa()) { oss << value->DumpText(); } else if (value->isa()) { oss << GetSequenceText(func_graph, value); diff --git a/mindspore/ccsrc/ir/dtype.h b/mindspore/ccsrc/ir/dtype.h index 104a2ec40af755907b7fe057dea885a5686e8d40..9659a27e3640dd9cb2f2fa084989f8ab4b440708 100644 --- a/mindspore/ccsrc/ir/dtype.h +++ b/mindspore/ccsrc/ir/dtype.h @@ -275,6 +275,11 @@ extern const TypePtr kTypeExternal; extern const TypePtr kTypeEnv; extern const TypePtr kTypeType; extern const TypePtr kString; +extern const TypePtr kList; +extern const TypePtr kTuple; +extern const TypePtr kDict; +extern const TypePtr kSlice; +extern const TypePtr kKeyword; extern const TypePtr kTensorType; } // namespace mindspore diff --git a/mindspore/ccsrc/ir/dtype/empty.cc b/mindspore/ccsrc/ir/dtype/empty.cc index 5cb3a91806f0c798b0f67961e9aa49b58401d355..c6abe9a408fc12aa7cceccfcc79618cbc0d4efba 100644 --- a/mindspore/ccsrc/ir/dtype/empty.cc +++ b/mindspore/ccsrc/ir/dtype/empty.cc @@ -18,5 +18,7 @@ namespace mindspore { const TypePtr kTypeNone = std::make_shared(); +const TypePtr kTypeNull = std::make_shared(); +const TypePtr kTypeEllipsis = std::make_shared(); const TypePtr kAnyType = std::make_shared(); } // namespace mindspore diff --git a/mindspore/ccsrc/ir/dtype/empty.h b/mindspore/ccsrc/ir/dtype/empty.h index 76cf8ea0ebcfc1f5cf453a05a836f7943c1a0ea2..e3b46ec7d9a28257f59f7e1d4fbc381830cf956b 100644 --- a/mindspore/ccsrc/ir/dtype/empty.h +++ b/mindspore/ccsrc/ir/dtype/empty.h @@ -71,20 +71,22 @@ class TypeNull : public Type { }; using TypeNullPtr = std::shared_ptr; -class Ellipsis : public Type { +class TypeEllipsis : public Type { public: - Ellipsis() : Type(kMetaTypeEllipsis) {} - ~Ellipsis() override {} - MS_DECLARE_PARENT(Ellipsis, Type) + TypeEllipsis() : Type(kMetaTypeEllipsis) {} + ~TypeEllipsis() override {} + MS_DECLARE_PARENT(TypeEllipsis, Type) TypeId generic_type_id() const override { return kMetaTypeEllipsis; } - TypePtr DeepCopy() const override { return std::make_shared(); } + TypePtr DeepCopy() const override { return std::make_shared(); } std::string ToReprString() const override { return "Ellipsis"; } std::string DumpText() const override { return "Ellipsis"; } }; -using EllipsisPtr = std::shared_ptr; +using TypeEllipsisPtr = std::shared_ptr; extern const TypePtr kTypeNone; +extern const TypePtr kTypeNull; +extern const TypePtr kTypeEllipsis; extern const TypePtr kAnyType; } // namespace mindspore diff --git a/mindspore/ccsrc/ir/dtype_extends.cc b/mindspore/ccsrc/ir/dtype_extends.cc index 697803fa462d1b215e7d1e5d762bb25370097699..e7af81292229aeadbc899838fa038d144edbba16 100644 --- a/mindspore/ccsrc/ir/dtype_extends.cc +++ b/mindspore/ccsrc/ir/dtype_extends.cc @@ -95,12 +95,30 @@ TypePtr TypeIdToType(TypeId id) { return kAnyType; case kMetaTypeNone: return kTypeNone; + case kMetaTypeNull: + return kTypeNull; + case kMetaTypeEllipsis: + return kTypeEllipsis; case kObjectTypeEnvType: return kTypeEnv; case kObjectTypeRefKey: return kRefKeyType; case kObjectTypeRef: return kRefType; + case kMetaTypeTypeType: + return kTypeType; + case kObjectTypeString: + return kString; + case kObjectTypeList: + return kList; + case kObjectTypeTuple: + return kTuple; + case kObjectTypeDictionary: + return kDict; + case kObjectTypeSlice: + return kSlice; + case kObjectTypeKeyword: + return kKeyword; case kTypeUnknown: return kTypeNone; default: @@ -274,7 +292,7 @@ TypePtr StringToType(const std::string &type_name) { if (type_name.compare("None") == 0) { type = std::make_shared(); } else if (type_name.compare("Ellipsis") == 0) { - type = std::make_shared(); + type = std::make_shared(); } else if (type_name.compare("TypeType") == 0) { type = std::make_shared(); } else if (type_name.compare("SymbolicKeyType") == 0) { @@ -476,7 +494,7 @@ REGISTER_PYBIND_DEFINE( (void)py::class_>(m_sub, "RefType").def(py::init()); (void)py::class_>(m_sub, "TypeAnything").def(py::init()); (void)py::class_>(m_sub, "Slice").def(py::init()); - (void)py::class_>(m_sub, "Ellipsis").def(py::init()); + (void)py::class_>(m_sub, "TypeEllipsis").def(py::init()); })); const TypePtr kTypeExternal = std::make_shared(); @@ -484,4 +502,9 @@ const TypePtr kTypeEnv = std::make_shared(); const TypePtr kTypeType = std::make_shared(); const TypePtr kTensorType = std::make_shared(); const TypePtr kString = std::make_shared(); +const TypePtr kList = std::make_shared(); +const TypePtr kTuple = std::make_shared(); +const TypePtr kDict = std::make_shared(); +const TypePtr kSlice = std::make_shared(); +const TypePtr kKeyword = std::make_shared(); } // namespace mindspore diff --git a/mindspore/ccsrc/ir/func_graph.cc b/mindspore/ccsrc/ir/func_graph.cc index cdca98fc6161fde78c70ba3d0f852124cd28c318..803c910d1d46ab41b26f1727a27b50c2da66de98 100644 --- a/mindspore/ccsrc/ir/func_graph.cc +++ b/mindspore/ccsrc/ir/func_graph.cc @@ -432,7 +432,7 @@ AnfNodePtr FuncGraph::GetDefaultValueByName(const std::string &name) { if (default_value == nullptr) { MS_LOG(EXCEPTION) << "Graph parameter " << name << " not exist"; } - if (IsValueNode(default_value)) { + if (IsValueNode(default_value)) { return nullptr; } return default_value; @@ -440,8 +440,8 @@ AnfNodePtr FuncGraph::GetDefaultValueByName(const std::string &name) { // set the default values void FuncGraph::SetDefaultValues(const std::vector &name_list, const std::vector &value_list) { - auto all_is_null = std::all_of(value_list.begin(), value_list.end(), - [](const AnfNodePtr &node) { return IsValueNode(node); }); + auto all_is_null = + std::all_of(value_list.begin(), value_list.end(), [](const AnfNodePtr &node) { return IsValueNode(node); }); if (value_list.empty()) { all_is_null = true; } @@ -457,7 +457,7 @@ void FuncGraph::ClearDefaultValues() { parameter_default_value_.clear(); } size_t FuncGraph::GetDefaultValueCount() { int null_count = std::count_if(parameter_default_value_.begin(), parameter_default_value_.end(), - [](const std::pair &pair) { return IsValueNode(pair.second); }); + [](const std::pair &pair) { return IsValueNode(pair.second); }); return parameter_default_value_.size() - IntToSize(null_count); } diff --git a/mindspore/ccsrc/ir/named.cc b/mindspore/ccsrc/ir/named.cc index 0a679e6011abee140928a60ac8923ea270e3e140..9e1a7968b8d3246ad06c3e192ec708b77ac4c83d 100644 --- a/mindspore/ccsrc/ir/named.cc +++ b/mindspore/ccsrc/ir/named.cc @@ -30,9 +30,9 @@ bool Named::operator==(const Value &other) const { abstract::AbstractBasePtr None::ToAbstract() { return std::make_shared(); } const NamedPtr kNone = std::make_shared(); -abstract::AbstractBasePtr NullObj::ToAbstract() { return std::make_shared(); } -const NamedPtr kNull = std::make_shared(); +abstract::AbstractBasePtr Null::ToAbstract() { return std::make_shared(); } +const NamedPtr kNull = std::make_shared(); -abstract::AbstractBasePtr EllipsisObj::ToAbstract() { return std::make_shared(); } -const NamedPtr kEllipsis = std::make_shared(); +abstract::AbstractBasePtr Ellipsis::ToAbstract() { return std::make_shared(); } +const NamedPtr kEllipsis = std::make_shared(); } // namespace mindspore diff --git a/mindspore/ccsrc/ir/named.h b/mindspore/ccsrc/ir/named.h index fbc7969cab3474272b91e1a8364d0187350c4f6b..40e544c1298a0c8d4c80a34d0c7c1bb81853dd16 100644 --- a/mindspore/ccsrc/ir/named.h +++ b/mindspore/ccsrc/ir/named.h @@ -71,20 +71,20 @@ class None : public Named { }; extern const NamedPtr kNone; -class NullObj : public Named { +class Null : public Named { public: - NullObj() : Named("Null") {} - ~NullObj() override = default; - MS_DECLARE_PARENT(NullObj, Named); + Null() : Named("Null") {} + ~Null() override = default; + MS_DECLARE_PARENT(Null, Named); abstract::AbstractBasePtr ToAbstract() override; }; extern const NamedPtr kNull; -class EllipsisObj : public Named { +class Ellipsis : public Named { public: - EllipsisObj() : Named("Ellipsis") {} - ~EllipsisObj() override = default; - MS_DECLARE_PARENT(EllipsisObj, Named); + Ellipsis() : Named("Ellipsis") {} + ~Ellipsis() override = default; + MS_DECLARE_PARENT(Ellipsis, Named); abstract::AbstractBasePtr ToAbstract() override; }; extern const NamedPtr kEllipsis; diff --git a/mindspore/ccsrc/pipeline/static_analysis/abstract_value.h b/mindspore/ccsrc/pipeline/static_analysis/abstract_value.h index f3375d22d6b66e14f07e3f52fd0ea3f86ecf9836..5b54c749b67df3b45348ef56bf58722a2648bbd3 100644 --- a/mindspore/ccsrc/pipeline/static_analysis/abstract_value.h +++ b/mindspore/ccsrc/pipeline/static_analysis/abstract_value.h @@ -515,11 +515,11 @@ using AbstractNullPtr = std::shared_ptr; class AbstractEllipsis : public AbstractBase { public: - AbstractEllipsis() : AbstractBase(kEllipsis) { set_type(std::make_shared()); } + AbstractEllipsis() : AbstractBase(kEllipsis) { set_type(std::make_shared()); } ~AbstractEllipsis() override = default; MS_DECLARE_PARENT(AbstractEllipsis, AbstractBase) - TypePtr BuildType() const override { return std::make_shared(); } + TypePtr BuildType() const override { return std::make_shared(); } bool operator==(const AbstractEllipsis &other) const; bool operator==(const AbstractBase &other) const override; AbstractBasePtr Clone() const override { return std::make_shared(); } diff --git a/mindspore/ccsrc/utils/convert_utils.cc b/mindspore/ccsrc/utils/convert_utils.cc index 6e28e38ed137f4535d581073325bd5ce24679131..44485cce817f5b2403bd73d52f9b677d87b52fec 100644 --- a/mindspore/ccsrc/utils/convert_utils.cc +++ b/mindspore/ccsrc/utils/convert_utils.cc @@ -105,7 +105,7 @@ py::object ValuePtrToPyData(const ValuePtr &value) { i++; } ret = rets; - } else if (value->isa()) { + } else if (value->isa()) { ret = py::ellipsis(); } else if (value->isa()) { auto slice = value->cast(); diff --git a/mindspore/common/dtype.py b/mindspore/common/dtype.py index 46b111d2f6485f3a57070716ed2bfb9d6073c9e3..73aa67f67ad56f555d557d1f04ed00ec5cee2a02 100644 --- a/mindspore/common/dtype.py +++ b/mindspore/common/dtype.py @@ -96,7 +96,7 @@ type_refkey = typing.RefKeyType() tensor_type = typing.TensorType anything_type = typing.TypeAnything slice_type = typing.Slice -ellipsis_type = typing.Ellipsis +ellipsis_type = typing.TypeEllipsis number_type = (int8, int16,