| 645 | } |
| 646 | |
| 647 | AccessOrder AccessOrderFromPythonStreamObj(const py::object &cuda_stream) { |
| 648 | AccessOrder order; |
| 649 | if (!cuda_stream.is_none()) { |
| 650 | auto cuda_stream_interface = getattr(cuda_stream, "__cuda_stream__", py::none()); |
| 651 | if (!cuda_stream_interface.is_none()) { |
| 652 | auto [version, stream_ptr] = cuda_stream_interface().cast<std::tuple<int, uintptr_t>>(); |
| 653 | cudaStream_t stream = reinterpret_cast<cudaStream_t>(stream_ptr); |
| 654 | order = AccessOrder(stream); |
| 655 | } else if (py::isinstance<py::int_>(cuda_stream)) { |
| 656 | cudaStream_t stream = reinterpret_cast<cudaStream_t>(py::cast<uintptr_t>(cuda_stream)); |
| 657 | order = AccessOrder(stream); |
| 658 | } else if (py::hasattr(cuda_stream, "value")) { |
| 659 | cudaStream_t stream = static_cast<cudaStream_t>(ctypes_void_ptr(cuda_stream)); |
| 660 | order = AccessOrder(stream); |
| 661 | } else if (auto cuda_stream_prop = getattr(cuda_stream, "cuda_stream", py::none())) { |
| 662 | return AccessOrderFromPythonStreamObj(cuda_stream_prop); |
| 663 | } else if (auto handle_prop = getattr(cuda_stream, "handle", py::none())) { |
| 664 | return AccessOrderFromPythonStreamObj(handle_prop); |
| 665 | } |
| 666 | } else { |
| 667 | order = AccessOrder::host(); |
| 668 | } |
| 669 | return order; |
| 670 | } |
| 671 | |
| 672 | /** |
| 673 | * Pipeline output descriptor. |
no test coverage detected