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