| 159 | |
| 160 | #ifdef PADDLE_WITH_CUSTOM_DEVICE |
| 161 | void LoadCustomDevice(const std::string &library_dir) { |
| 162 | LOG(INFO) << "Try loading custom device libs from: [" << library_dir << "]"; |
| 163 | std::vector<std::string> libs = phi::ListAllLibraries(library_dir); |
| 164 | for (const auto &lib_path : libs) { |
| 165 | auto dso_handle = dlopen(lib_path.c_str(), RTLD_LAZY); |
| 166 | PADDLE_ENFORCE_NOT_NULL( |
| 167 | dso_handle, |
| 168 | common::errors::InvalidArgument( |
| 169 | "Fail to open library: %s with error: %s", lib_path, dlerror())); |
| 170 | |
| 171 | paddle::LoadCustomLib(lib_path, dso_handle); |
| 172 | } |
| 173 | phi::CustomKernelMap::Instance().RegisterCustomKernels(); |
| 174 | LOG(INFO) << "Finished in LoadCustomDevice with libs_path: [" << library_dir |
| 175 | << "]"; |
| 176 | } |
| 177 | #endif |
| 178 | |
| 179 | static std::once_flag init_devices_flag; |
no test coverage detected