MCPcopy Create free account
hub / github.com/NVIDIA/DALI / GetDLTensorResource

Function GetDLTensorResource

dali/operators/python_function/dltensor_function.cc:215–226  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

213using DLTensorNumpyResource = DLTensorResource<PyArrayPayload>;
214
215auto 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
229PYBIND11_MODULE(python_function_plugin, m, py::mod_gil_not_used()) {

Callers 1

PYBIND11_MODULEFunction · 0.85

Calls 7

CreateFunction · 0.85
ToDLDeviceFunction · 0.85
ToDLTypeFunction · 0.85
dataMethod · 0.45
sizeMethod · 0.45
emptyMethod · 0.45
idMethod · 0.45

Tested by

no test coverage detected