Interop Dlpack#
- group interop_dlpack
Functions
-
std::unique_ptr<table> from_dlpack(DLManagedTensor const *managed_tensor, rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref())#
Convert a DLPack DLTensor into a cudf table.
The
device_type
of the DLTensor must bekDLCPU
,kDLCuda
, orkDLCUDAHost
, anddevice_id
must match the current device. Thendim
must be set to 1 or 2. Thedtype
must have 1 lane and the bitsize must match a supportedcudf::data_type
.Note
The managed tensor is not deleted by this function.
- Throws:
cudf::logic_error – if the any of the DLTensor fields are unsupported
- Parameters:
managed_tensor – a 1D or 2D column-major (Fortran order) tensor
mr – Device memory resource used to allocate the returned table’s device memory
- Returns:
Table with a copy of the tensor data
-
DLManagedTensor *to_dlpack(table_view const &input, rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref())#
Convert a cudf table into a DLPack DLTensor.
All columns must have the same data type and this type must be numeric. The columns may be nullable, but the null count must be zero. If the input table is empty or has zero rows, the result will be nullptr.
Note
The
deleter
method of the returnedDLManagedTensor
must be used to free the memory allocated for the tensor.- Throws:
cudf::logic_error – if the data types are not equal or not numeric, or if any of columns have non-zero null count
- Parameters:
input – Table to convert to DLPack
mr – Device memory resource used to allocate the returned DLPack tensor’s device memory
- Returns:
1D or 2D DLPack tensor with a copy of the table data, or nullptr
-
std::unique_ptr<table> from_dlpack(DLManagedTensor const *managed_tensor, rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref())#