| 213 | using DLTensorNumpyResource = DLTensorResource<PyArrayPayload>; |
| 214 | |
| 215 | auto GetDLTensorResource(const py::array &array) { |
| 216 | auto rsrc = DLTensorNumpyResource::Create(array); |
| 217 | auto &tensor = rsrc->dlm_tensor.dl_tensor; |
| 218 | auto buffer = rsrc->payload.array.request(); |
| 219 | tensor.data = buffer.ptr; |
| 220 | tensor.shape = rsrc->payload.shape.data(); |
| 221 | tensor.ndim = rsrc->payload.shape.size(); |
| 222 | tensor.strides = rsrc->payload.strides.empty() ? nullptr : rsrc->payload.strides.data(); |
| 223 | tensor.device = ToDLDevice(false, false, 0); |
| 224 | tensor.dtype = ToDLType(TypeFromFormatStr(buffer.format).id()); |
| 225 | return rsrc; |
| 226 | } |
| 227 | |
| 228 | |
| 229 | PYBIND11_MODULE(python_function_plugin, m, py::mod_gil_not_used()) { |
no test coverage detected