| 33 | #endif |
| 34 | |
| 35 | CustomLib::CustomLib(const std::string& path, int mode = RTLD_LAZY) |
| 36 | : m_handle(nullptr, [](void* handle) { dlclose(handle); }) { |
| 37 | auto op_list_before_load = CustomOpManager::inst()->op_name_list(); |
| 38 | std::unordered_set<std::string> op_set_before_load( |
| 39 | op_list_before_load.begin(), op_list_before_load.end()); |
| 40 | |
| 41 | m_handle.reset(dlopen(path.c_str(), mode)); |
| 42 | mgb_assert( |
| 43 | m_handle != nullptr, "open custom op lib failed, error type: %s", |
| 44 | dlerror()); |
| 45 | |
| 46 | auto op_list_after_load = CustomOpManager::inst()->op_name_list(); |
| 47 | for (auto& op : op_list_after_load) { |
| 48 | if (op_set_before_load.find(op) == op_set_before_load.end()) { |
| 49 | m_ops.emplace_back(op); |
| 50 | } |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | CustomLib::~CustomLib() { |
| 55 | for (auto& op : m_ops) { |
nothing calls this directly
no test coverage detected