| 31 | using namespace py::literals; |
| 32 | |
| 33 | static void CheckValidCUDABuffer(const void *ptr) |
| 34 | { |
| 35 | if (ptr == nullptr) |
| 36 | { |
| 37 | throw std::runtime_error("NULL CUDA buffer not accepted"); |
| 38 | } |
| 39 | |
| 40 | cudaPointerAttributes attrs = {}; |
| 41 | cudaError_t err = cudaPointerGetAttributes(&attrs, ptr); |
| 42 | cudaGetLastError(); // reset the cuda error (if any) |
| 43 | if (err != cudaSuccess || attrs.type == cudaMemoryTypeUnregistered) |
| 44 | { |
| 45 | throw std::runtime_error("Buffer is not CUDA-accessible"); |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | static std::string ToFormatString(const DLDataType &dtype) |
| 50 | { |
no outgoing calls
no test coverage detected