| 38 | #endif |
| 39 | |
| 40 | PYBIND11_MODULE(_dlib_pybind11, m) |
| 41 | { |
| 42 | // Attempt to give users that have compiled dlib to use SIMD instructions but then tried to use |
| 43 | // it on a CPU that doesn't support them a more informative warning that many systems generate |
| 44 | // by default in such events. Note that this may or may not be able to print a warning before |
| 45 | // some unavailable SIMD instruction is used. It depends on what SIMD instructions your |
| 46 | // compiler may or may not have inserted into other parts of the code that it compiles. Which |
| 47 | // is entirely up to your compiler. And by the nature of this user error, we can't control how |
| 48 | // this plays out. So on some systems/setups/compilers they will get this nicer error message |
| 49 | // and sometimes they don't. |
| 50 | warn_about_unavailable_but_used_cpu_instructions(); |
| 51 | |
| 52 | |
| 53 | #define DLIB_QUOTE_STRING(x) DLIB_QUOTE_STRING2(x) |
| 54 | #define DLIB_QUOTE_STRING2(x) #x |
| 55 | m.attr("__version__") = DLIB_QUOTE_STRING(DLIB_VERSION); |
| 56 | m.attr("__time_compiled__") = std::string(__DATE__) + " " + std::string(__TIME__); |
| 57 | |
| 58 | #ifdef DLIB_USE_CUDA |
| 59 | m.attr("DLIB_USE_CUDA") = true; |
| 60 | #else |
| 61 | m.attr("DLIB_USE_CUDA") = false; |
| 62 | #endif |
| 63 | #ifdef DLIB_USE_BLAS |
| 64 | m.attr("DLIB_USE_BLAS") = true; |
| 65 | #else |
| 66 | m.attr("DLIB_USE_BLAS") = false; |
| 67 | #endif |
| 68 | #ifdef DLIB_USE_LAPACK |
| 69 | m.attr("DLIB_USE_LAPACK") = true; |
| 70 | #else |
| 71 | m.attr("DLIB_USE_LAPACK") = false; |
| 72 | #endif |
| 73 | #ifdef DLIB_HAVE_AVX |
| 74 | m.attr("USE_AVX_INSTRUCTIONS") = true; |
| 75 | #else |
| 76 | m.attr("USE_AVX_INSTRUCTIONS") = false; |
| 77 | #endif |
| 78 | #ifdef DLIB_HAVE_NEON |
| 79 | m.attr("USE_NEON_INSTRUCTIONS") = true; |
| 80 | #else |
| 81 | m.attr("USE_NEON_INSTRUCTIONS") = false; |
| 82 | #endif |
| 83 | |
| 84 | |
| 85 | |
| 86 | // Note that the order here matters. We need to do the basic types first. If we don't |
| 87 | // then what happens is the documentation created by sphinx will use horrible big |
| 88 | // template names to refer to C++ objects rather than the python names python users |
| 89 | // will expect. For instance, if bind_basic_types() isn't called early then when |
| 90 | // routines take a std::vector<double>, rather than saying dlib.array in the python |
| 91 | // docs it will say "std::vector<double, std::allocator<double> >" which is awful and |
| 92 | // confusing to python users. |
| 93 | // |
| 94 | // So when adding new things always add them to the end of the list. |
| 95 | bind_matrix(m); |
| 96 | bind_vector(m); |
| 97 | bind_basic_types(m); |
nothing calls this directly
no test coverage detected