1 /** 2 * Copyright 2019 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 <cstddef> 21 #include <iostream> 22 #include <initializer_list> 23 #include <map> 24 #include <memory> 25 #include <utility> 26 #include <sstream> 27 #include <string> 28 #include <vector> 29 #include <type_traits> 30 #include <unordered_map> 31 #include <algorithm> 32 #include "base/base.h" 33 #include "ir/named.h" 34 #include "ir/dtype/type.h" 35 36 namespace mindspore { 37 class MS_CORE_API TypeAnything : public Type { 38 public: TypeAnything()39 TypeAnything() : Type(kMetaTypeAnything) {} ~TypeAnything()40 ~TypeAnything() override {} MS_DECLARE_PARENT(TypeAnything,Type)41 MS_DECLARE_PARENT(TypeAnything, Type) 42 43 TypeId generic_type_id() const override { return kMetaTypeAnything; } 44 TypePtr DeepCopy() const override; DumpText()45 std::string DumpText() const override { return "AnythingType"; } 46 }; 47 using TypeAnythingPtr = std::shared_ptr<TypeAnything>; 48 49 class MS_CORE_API TypeNone : public Type { 50 public: TypeNone()51 TypeNone() : Type(kMetaTypeNone) {} ~TypeNone()52 ~TypeNone() override {} MS_DECLARE_PARENT(TypeNone,Type)53 MS_DECLARE_PARENT(TypeNone, Type) 54 55 TypeId generic_type_id() const override { return kMetaTypeNone; } DeepCopy()56 TypePtr DeepCopy() const override { return std::make_shared<TypeNone>(); } ToReprString()57 std::string ToReprString() const override { return "type_none"; } DumpText()58 std::string DumpText() const override { return "NoneType"; } 59 }; 60 using TypeNonePtr = std::shared_ptr<TypeNone>; 61 62 class MS_CORE_API TypeNull : public Type { 63 public: TypeNull()64 TypeNull() : Type(kMetaTypeNull) {} ~TypeNull()65 ~TypeNull() override {} MS_DECLARE_PARENT(TypeNull,Type)66 MS_DECLARE_PARENT(TypeNull, Type) 67 68 TypeId generic_type_id() const override { return kMetaTypeNull; } DeepCopy()69 TypePtr DeepCopy() const override { return std::make_shared<TypeNull>(); } DumpText()70 std::string DumpText() const override { return "NullType"; } 71 }; 72 using TypeNullPtr = std::shared_ptr<TypeNull>; 73 74 class MS_CORE_API TypeEllipsis : public Type { 75 public: TypeEllipsis()76 TypeEllipsis() : Type(kMetaTypeEllipsis) {} ~TypeEllipsis()77 ~TypeEllipsis() override {} MS_DECLARE_PARENT(TypeEllipsis,Type)78 MS_DECLARE_PARENT(TypeEllipsis, Type) 79 80 TypeId generic_type_id() const override { return kMetaTypeEllipsis; } DeepCopy()81 TypePtr DeepCopy() const override { return std::make_shared<TypeEllipsis>(); } ToReprString()82 std::string ToReprString() const override { return "Ellipsis"; } DumpText()83 std::string DumpText() const override { return "Ellipsis"; } 84 }; 85 using TypeEllipsisPtr = std::shared_ptr<TypeEllipsis>; 86 87 inline const TypePtr kTypeNone = std::make_shared<TypeNone>(); 88 inline const TypePtr kTypeNull = std::make_shared<TypeNull>(); 89 inline const TypePtr kTypeEllipsis = std::make_shared<TypeEllipsis>(); 90 inline const TypePtr kAnyType = std::make_shared<TypeAnything>(); 91 } // namespace mindspore 92 93 #endif // MINDSPORE_CORE_IR_DTYPE_EMPTY_H_ 94