1 /** 2 * Copyright 2021-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_OPS_CUSTOM_H_ 18 #define MINDSPORE_CORE_OPS_CUSTOM_H_ 19 #include <map> 20 #include <memory> 21 #include <string> 22 #include <vector> 23 24 #include "ops/base_operator.h" 25 26 namespace mindspore { 27 namespace ops { 28 constexpr auto kNameCustom = "Custom"; 29 /// \brief Custom defined user-defined operator prototype. 30 class MIND_API Custom : public BaseOperator { 31 public: 32 MIND_API_BASE_MEMBER(Custom); 33 /// \brief Constructor. Custom()34 Custom() : BaseOperator(kNameCustom) {} 35 36 /// \brief Method to init the op's attributes. 37 /// 38 /// \param[in] type Define the concrete type of the custom op, which is used to distinguish different custom op. 39 /// \param[in] attrs Define the attributes of the custom op. 40 void Init(const std::string &type, const std::map<std::string, std::vector<uint8_t>> &attrs); 41 42 /// \brief Method to set type attribute. 43 /// 44 /// \param[in] type Define the concrete type of the custom op, which is used to distinguish different custom op. 45 void set_type(const std::string &type); 46 47 /// \brief Method to get type attribute. 48 /// 49 /// \return a string 50 std::string get_type() const; 51 52 /// \brief Method to set attr attribute. 53 /// 54 /// \param[in] attrs Define the attributes of the custom op. 55 void set_attr(const std::map<std::string, std::vector<uint8_t>> &attrs); 56 57 /// \brief Method to get attr attribute. 58 /// 59 /// \return a map which contains all attributes of the custom op. 60 std::map<std::string, std::vector<uint8_t>> get_attr() const; 61 }; 62 } // namespace ops 63 } // namespace mindspore 64 65 #endif // MINDSPORE_CORE_OPS_CUSTOM_H_ 66