| 3082 | } |
| 3083 | |
| 3084 | PYBIND11_MODULE(backend_impl, m, py::mod_gil_not_used()) { |
| 3085 | dali::InitOperatorsLib(); |
| 3086 | m.doc() = "Python bindings for the C++ portions of DALI"; |
| 3087 | |
| 3088 | // DALI Init function |
| 3089 | m.def("Init", &DALIInit); |
| 3090 | |
| 3091 | ExposeBufferPolicyFunctions(m); |
| 3092 | |
| 3093 | m.def("LoadLibrary", &PluginManager::LoadLibrary, |
| 3094 | py::arg("lib_path"), |
| 3095 | py::arg("global_symbols") = false, |
| 3096 | py::arg("allow_fail") = false); |
| 3097 | |
| 3098 | m.def("LoadDirectory", &PluginManager::LoadDirectory, |
| 3099 | py::arg("dir_path"), |
| 3100 | py::arg("global_symbols") = false, |
| 3101 | py::arg("allow_fail") = false); |
| 3102 | |
| 3103 | m.def("LoadDefaultPlugins", &PluginManager::LoadDefaultPlugins); |
| 3104 | |
| 3105 | m.def("GetCxx11AbiFlag", &GetCxx11AbiFlag); |
| 3106 | |
| 3107 | m.def("IsDriverInitialized", [] { |
| 3108 | // we just want to check if cuda has been loaded already |
| 3109 | if (dlopen("libcuda.so", RTLD_NOLOAD | RTLD_NOW) || |
| 3110 | dlopen("libcuda.so.1", RTLD_NOLOAD | RTLD_NOW)) { |
| 3111 | int place_holder = -1; |
| 3112 | // call cuDeviceGetCount only if cuda is loaded, if not there is not point in calling |
| 3113 | // a check that would load it |
| 3114 | return CUDA_SUCCESS == cuDeviceGetCount(&place_holder); |
| 3115 | } |
| 3116 | return false; |
| 3117 | }); |
| 3118 | |
| 3119 | m.def("GetCudaVersion", [] { |
| 3120 | int version = -1; |
| 3121 | auto ret = cudaDriverGetVersion(&version); |
| 3122 | if (ret != cudaSuccess) { |
| 3123 | return -1; |
| 3124 | } else { |
| 3125 | return version; |
| 3126 | } |
| 3127 | }); |
| 3128 | |
| 3129 | m.def("GetCufftVersion", [] { |
| 3130 | int ret = -1; |
| 3131 | try { |
| 3132 | // we don't want to throw when it is not available, just return -1 |
| 3133 | ret = GetCufftVersion(); |
| 3134 | } catch (const std::runtime_error &) {} |
| 3135 | return ret; |
| 3136 | }); |
| 3137 | |
| 3138 | m.def("GetNppVersion", [] { |
| 3139 | int ret = -1; |
| 3140 | try { |
| 3141 | // we don't want to throw when it is not available, just return -1 |
nothing calls this directly
no test coverage detected