| 53 | } |
| 54 | |
| 55 | py::object ExternalBuffer::Create(DLPackTensor &&dlPackTensor, py::object wrappedObj) |
| 56 | { |
| 57 | std::shared_ptr<ExternalBuffer> buf(new ExternalBuffer(std::move(dlPackTensor))); |
| 58 | |
| 59 | // We must make the returned object keep wrappedObj alive. |
| 60 | // Using py::return_value_policy::reference_internal in py::cast doesn't work |
| 61 | // because buf is a shared_ptr. |
| 62 | py::object o = py::cast(buf); |
| 63 | py::detail::keep_alive_impl(o, wrappedObj); |
| 64 | |
| 65 | // If we expose cuda array interface, |
| 66 | if (auto iface = buf->cudaArrayInterface()) |
| 67 | { |
| 68 | o.attr("__cuda_array_interface__") = *iface; |
| 69 | } |
| 70 | |
| 71 | return o; |
| 72 | } |
| 73 | |
| 74 | ExternalBuffer::ExternalBuffer(DLPackTensor &&dlTensor) |
| 75 | { |
nothing calls this directly
no test coverage detected