| 1478 | } |
| 1479 | |
| 1480 | void LoadCustomRuntimeLib(const CustomRuntimeParams& runtime_params, |
| 1481 | std::unique_ptr<C_DeviceInterface> device_interface, |
| 1482 | const std::string& dso_lib_path, |
| 1483 | void* dso_handle) { |
| 1484 | if (ValidCustomCustomRuntimeParams(&runtime_params)) { |
| 1485 | auto device = std::make_unique<CustomDevice>(runtime_params.device_type, |
| 1486 | 255, |
| 1487 | true, |
| 1488 | std::move(device_interface), |
| 1489 | dso_handle); |
| 1490 | if (false == DeviceManager::Register(std::move(device))) { |
| 1491 | LOG(WARNING) << "Skipped lib [" << dso_lib_path |
| 1492 | << "]. Register failed!!! there may be a " |
| 1493 | "Custom Runtime with the same name."; |
| 1494 | } |
| 1495 | if (runtime_params.pir_default_passes != nullptr) { |
| 1496 | CustomDevicePassManager::Instance()->SetCustomDevicePass( |
| 1497 | *(reinterpret_cast<std::vector<std::string>*>( |
| 1498 | runtime_params.pir_default_passes))); |
| 1499 | } |
| 1500 | } else { |
| 1501 | LOG(WARNING) << "Skipped lib [" << dso_lib_path |
| 1502 | << "]. Wrong Runtime parameters!!! please check the version " |
| 1503 | "compatibility between PaddlePaddle and Custom Runtime."; |
| 1504 | } |
| 1505 | } |
| 1506 | |
| 1507 | #undef INTERFACE_UNIMPLEMENT |
| 1508 | |