Interop#

#include <cuvs/core/interop.hpp>

namespace cuvs::core

inline bool is_dlpack_device_compatible(DLTensor tensor)#

Check if DLTensor has device accessible memory. This function returns true for DLDeviceType of values kDLCUDA, kDLCUDAHost, or kDLCUDAManaged

Parameters:

tensor[in] DLTensor object to check underlying memory type

Returns:

bool

inline bool is_dlpack_host_compatible(DLTensor tensor)#

Check if DLTensor has host accessible memory. This function returns true for DLDeviceType of values kDLCPU, kDLCUDAHost, or kDLCUDAManaged

Parameters:

tensor – DLTensor object to check underlying memory type

Returns:

bool

template<typename MdspanType, typename = raft::is_mdspan_t<MdspanType>>
inline MdspanType from_dlpack(DLManagedTensor *managed_tensor)#

Convert a DLManagedTensor to an mdspan NOTE: This function only supports compact row-major layouts.

#include <raft/core/device_mdspan.hpp>
#include <raft/core/interop.hpp>
// We have a `DLManagedTensor` with `DLDeviceType == kDLCUDA`,
// `DLDataType.code == kDLFloat` and `DLDataType.bits == 8`
DLManagedTensor tensor;
// declare the return type
using mdpsan_type = raft::device_mdspan<float, int64_t, raft::row_major>;
auto mds = raft::core::from_dlpack<mdspan_type>(&tensor);
Template Parameters:
  • MdspanType

  • typename

Parameters:

managed_tensor[in]

Returns:

MdspanType