1 /** 2 * Copyright 2023 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 #include "ops/op_def.h" 18 namespace mindspore::ops { 19 extern std::unordered_map<std::string, OpDefPtr> gOpDefTable; // defined in gen_ops_def.cc GetOpDef(const std::string & op_name)20OpDefPtr GetOpDef(const std::string &op_name) { 21 auto it = gOpDefTable.find(op_name); 22 if (it != gOpDefTable.end()) { 23 return it->second; 24 } 25 return nullptr; 26 } 27 AddOpDef(const std::string & op_name,const OpDefPtr op_def)28void AddOpDef(const std::string &op_name, const OpDefPtr op_def) { (void)gOpDefTable.emplace(op_name, op_def); } 29 IsPrimitiveFunction(const std::string & op_name)30bool IsPrimitiveFunction(const std::string &op_name) { return GetOpDef(op_name) != nullptr; } 31 } // namespace mindspore::ops 32