• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2019-2022 Huawei Technologies Co., Ltd
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef MINDSPORE_CORE_IR_DTYPE_EMPTY_H_
18 #define MINDSPORE_CORE_IR_DTYPE_EMPTY_H_
19 
20 #include <iostream>
21 #include <map>
22 #include <memory>
23 #include <sstream>
24 #include <string>
25 
26 #include "utils/hash_map.h"
27 #include "base/base.h"
28 #include "ir/named.h"
29 #include "ir/dtype/type.h"
30 
31 namespace mindspore {
32 /// \brief TypeAny defines a Type class whose type is Any.
33 class MS_CORE_API TypeAny : public Type {
34  public:
35   /// \brief Default constructor for TypeAny.
TypeAny()36   TypeAny() : Type(kMetaTypeAny) {}
37 
38   /// \brief Destructor of TypeAny.
~TypeAny()39   ~TypeAny() override {}
MS_DECLARE_PARENT(TypeAny,Type)40   MS_DECLARE_PARENT(TypeAny, Type)
41 
42   TypeId generic_type_id() const override { return kMetaTypeAny; }
43   TypePtr DeepCopy() const override;
DumpText()44   std::string DumpText() const override { return "TypeAny"; }
45 };
46 using TypeAnyPtr = std::shared_ptr<TypeAny>;
47 
48 /// \brief TypeNone defines a Type class whose type is None.
49 class MS_CORE_API TypeNone : public Type {
50  public:
51   /// \brief Default constructor for TypeNone.
TypeNone()52   TypeNone() : Type(kMetaTypeNone) {}
53 
54   /// \brief Destructor of TypeNone.
~TypeNone()55   ~TypeNone() override {}
MS_DECLARE_PARENT(TypeNone,Type)56   MS_DECLARE_PARENT(TypeNone, Type)
57 
58   TypeId generic_type_id() const override { return kMetaTypeNone; }
DeepCopy()59   TypePtr DeepCopy() const override { return std::make_shared<TypeNone>(); }
ToReprString()60   std::string ToReprString() const override { return "type_none"; }
DumpText()61   std::string DumpText() const override { return "NoneType"; }
62 };
63 using TypeNonePtr = std::shared_ptr<TypeNone>;
64 
65 /// \brief TypeNull defines a Type class whose type is Null.
66 class MS_CORE_API TypeNull : public Type {
67  public:
68   /// \brief Default constructor for TypeNull.
TypeNull()69   TypeNull() : Type(kMetaTypeNull) {}
70 
71   /// \brief Destructor of TypeNull.
~TypeNull()72   ~TypeNull() override {}
MS_DECLARE_PARENT(TypeNull,Type)73   MS_DECLARE_PARENT(TypeNull, Type)
74 
75   TypeId generic_type_id() const override { return kMetaTypeNull; }
DeepCopy()76   TypePtr DeepCopy() const override { return std::make_shared<TypeNull>(); }
DumpText()77   std::string DumpText() const override { return "NullType"; }
78 };
79 using TypeNullPtr = std::shared_ptr<TypeNull>;
80 
81 /// \brief TypeEllipsis defines a Type class whose type is Ellipsis.
82 class MS_CORE_API TypeEllipsis : public Type {
83  public:
84   /// \brief Default constructor for TypeEllipsis.
TypeEllipsis()85   TypeEllipsis() : Type(kMetaTypeEllipsis) {}
86 
87   /// \brief Destructor of TypeEllipsis.
~TypeEllipsis()88   ~TypeEllipsis() override {}
MS_DECLARE_PARENT(TypeEllipsis,Type)89   MS_DECLARE_PARENT(TypeEllipsis, Type)
90 
91   TypeId generic_type_id() const override { return kMetaTypeEllipsis; }
DeepCopy()92   TypePtr DeepCopy() const override { return std::make_shared<TypeEllipsis>(); }
ToReprString()93   std::string ToReprString() const override { return "Ellipsis"; }
DumpText()94   std::string DumpText() const override { return "Ellipsis"; }
95 };
96 using TypeEllipsisPtr = std::shared_ptr<TypeEllipsis>;
97 
98 GVAR_DEF(TypePtr, kTypeNone, std::make_shared<TypeNone>());
99 GVAR_DEF(TypePtr, kTypeNull, std::make_shared<TypeNull>());
100 GVAR_DEF(TypePtr, kTypeEllipsis, std::make_shared<TypeEllipsis>());
101 GVAR_DEF(TypePtr, kTypeAny, std::make_shared<TypeAny>());
102 }  // namespace mindspore
103 
104 #endif  // MINDSPORE_CORE_IR_DTYPE_EMPTY_H_
105