| 104 | } |
| 105 | |
| 106 | std::shared_ptr<CustomOp> CustomOpManager::insert( |
| 107 | const std::string& name, uint32_t version) { |
| 108 | MGB_LOCK_GUARD(m_op_mtx); |
| 109 | auto iter = m_name2op.find(name); |
| 110 | if (iter != m_name2op.end()) { |
| 111 | mgb_log_warn( |
| 112 | "Register Custom Op Failed! Op %s has been registered", name.c_str()); |
| 113 | return std::const_pointer_cast<CustomOp, const CustomOp>(iter->second); |
| 114 | } |
| 115 | std::shared_ptr<const CustomOp> op = |
| 116 | std::make_shared<const CustomOp>(name, version); |
| 117 | m_name2op[op->op_type()] = op; |
| 118 | m_id2op[op->runtime_id()] = op; |
| 119 | return std::const_pointer_cast<CustomOp, const CustomOp>(op); |
| 120 | } |
| 121 | |
| 122 | bool CustomOpManager::erase(const std::string& name) { |
| 123 | MGB_LOCK_GUARD(m_op_mtx); |