Files | Functions

Files

file  interop.hpp
 

Functions

std::unique_ptr< tablecudf::from_dlpack (DLManagedTensor const *managed_tensor, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
 Convert a DLPack DLTensor into a cudf table. More...
 
DLManagedTensor * cudf::to_dlpack (table_view const &input, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
 Convert a cudf table into a DLPack DLTensor. More...
 

Detailed Description

Function Documentation

◆ from_dlpack()

std::unique_ptr<table> cudf::from_dlpack ( DLManagedTensor const *  managed_tensor,
rmm::cuda_stream_view  stream = cudf::get_default_stream(),
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 be kDLCPU, kDLCuda, or kDLCUDAHost, and device_id must match the current device. The ndim must be set to 1 or 2. The dtype must have 1 lane and the bitsize must match a supported cudf::data_type.

Note
The managed tensor is not deleted by this function.
Exceptions
cudf::logic_errorif the any of the DLTensor fields are unsupported
Parameters
managed_tensora 1D or 2D column-major (Fortran order) tensor
streamCUDA stream used for device memory operations and kernel launches
mrDevice memory resource used to allocate the returned table's device memory
Returns
Table with a copy of the tensor data

◆ to_dlpack()

DLManagedTensor* cudf::to_dlpack ( table_view const &  input,
rmm::cuda_stream_view  stream = cudf::get_default_stream(),
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 returned DLManagedTensor must be used to free the memory allocated for the tensor.
Exceptions
cudf::logic_errorif the data types are not equal or not numeric, or if any of columns have non-zero null count
Parameters
inputTable to convert to DLPack
streamCUDA stream used for device memory operations and kernel launches
mrDevice 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