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_REF_H_ 18 #define MINDSPORE_CORE_IR_DTYPE_REF_H_ 19 20 #include <memory> 21 #include <string> 22 23 #include "base/base.h" 24 #include "ir/named.h" 25 #include "ir/dtype/type.h" 26 #include "ir/dtype/tensor_type.h" 27 28 namespace mindspore { 29 // TypeRefKey type 30 class MS_CORE_API RefKeyType : public Object { 31 public: RefKeyType()32 RefKeyType() : Object(kObjectTypeRefKey) {} ~RefKeyType()33 ~RefKeyType() override {} MS_DECLARE_PARENT(RefKeyType,Object)34 MS_DECLARE_PARENT(RefKeyType, Object) 35 36 TypeId generic_type_id() const override { return kObjectTypeRefKey; } DeepCopy()37 TypePtr DeepCopy() const override { return std::make_shared<RefKeyType>(); } ToReprString()38 std::string ToReprString() const override { return "type_refkey"; } DumpText()39 std::string DumpText() const override { return "RefKeyType"; } 40 }; 41 42 // TypeRef type 43 class MS_CORE_API RefType : public TensorType { 44 public: RefType()45 RefType() : TensorType() {} RefType(const TensorTypePtr & subtype)46 explicit RefType(const TensorTypePtr &subtype) : TensorType(subtype->element()) {} ~RefType()47 ~RefType() override {} 48 MS_DECLARE_PARENT(RefType, TensorType) 49 50 TypePtr DeepCopy() const override; 51 std::string ToString() const override; 52 std::string DumpText() const override; 53 }; 54 using RefTypePtr = std::shared_ptr<RefType>; 55 56 inline const TypePtr kRefKeyType = std::make_shared<RefKeyType>(); 57 inline const TypePtr kRefType = std::make_shared<RefType>(); 58 } // namespace mindspore 59 60 #endif // MINDSPORE_CORE_IR_DTYPE_REF_H_ 61