1 /** 2 * Copyright 2020 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_SIGNATURE_H_ 18 #define MINDSPORE_CORE_IR_SIGNATURE_H_ 19 20 #include <string> 21 #include "ir/value.h" 22 23 namespace mindspore { 24 // Input signature, support type 25 enum SignatureEnumRW { 26 // describe the arguments action on read and write 27 kRWRead = 0, // use the value of the input 28 kRWWrite, // use the key of the input 29 kRWRef, // use the ref of the input 30 kRWEmptyDefaultValue, 31 kRWDefault = kRWRead 32 }; 33 enum SignatureEnumKind { 34 kKindPositionalKeyword = 0, // use value of the input start from this arg 35 kKindVarPositional, // use key of the input start from this arg 36 kKindKeywordOnly, 37 kKindVarKeyword, // use ref of the input start from this arg 38 kKindEmptyDefaultValue, 39 kKindDefault = kKindPositionalKeyword 40 }; 41 enum SignatureEnumDType { 42 kDType = 0, 43 kDType1, 44 kDType2, 45 kDType3, 46 kDType4, 47 kDType5, 48 kDType6, 49 kDType7, 50 kDType8, 51 kDType9, 52 kDTypeEmptyDefaultValue 53 }; 54 struct Signature { 55 std::string name; 56 SignatureEnumRW rw; 57 SignatureEnumKind kind; 58 ValuePtr default_value; // nullptr for no default value 59 SignatureEnumDType dtype; SignatureSignature60 Signature(const std::string &arg_name, const SignatureEnumRW &rw_tag, const SignatureEnumKind &arg_kind, 61 const ValuePtr &arg_default, const SignatureEnumDType &arg_dtype) 62 : name(arg_name), rw(rw_tag), kind(arg_kind), default_value(arg_default), dtype(arg_dtype) {} SignatureSignature63 Signature(const std::string &arg_name, const SignatureEnumRW &rw_tag, const SignatureEnumKind &arg_kind) 64 : Signature(arg_name, rw_tag, arg_kind, nullptr, SignatureEnumDType::kDTypeEmptyDefaultValue) {} 65 }; 66 } // namespace mindspore 67 68 #endif // MINDSPORE_CORE_IR_SIGNATURE_H_ 69