| // Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved | |
| namespace groundingdino { | |
| extern int get_cudart_version(); | |
| std::string get_cuda_version() { | |
| std::ostringstream oss; | |
| // copied from | |
| // https://github.com/pytorch/pytorch/blob/master/aten/src/ATen/cuda/detail/CUDAHooks.cpp#L231 | |
| auto printCudaStyleVersion = [&](int v) { | |
| oss << (v / 1000) << "." << (v / 10 % 100); | |
| if (v % 10 != 0) { | |
| oss << "." << (v % 10); | |
| } | |
| }; | |
| printCudaStyleVersion(get_cudart_version()); | |
| return oss.str(); | |
| return std::string("not available"); | |
| } | |
| // similar to | |
| // https://github.com/pytorch/pytorch/blob/master/aten/src/ATen/Version.cpp | |
| std::string get_compiler_version() { | |
| std::ostringstream ss; | |
| { ss << "GCC " << __GNUC__ << "." << __GNUC_MINOR__; } | |
| { | |
| ss << "clang " << __clang_major__ << "." << __clang_minor__ << "." | |
| << __clang_patchlevel__; | |
| } | |
| { ss << "MSVC " << _MSC_FULL_VER; } | |
| return ss.str(); | |
| } | |
| PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) { | |
| m.def("ms_deform_attn_forward", &ms_deform_attn_forward, "ms_deform_attn_forward"); | |
| m.def("ms_deform_attn_backward", &ms_deform_attn_backward, "ms_deform_attn_backward"); | |
| } | |
| } // namespace groundingdino |