Skip to navigation

holoscan::wrap_memory

Beta
View as Markdown
HOLOSCAN_CORE_EXPORT expected<void, Error> holoscan::wrap_memory(
Tensor &tensor,
DLDataType dtype,
TensorByteStridesView byte_strides,
MemoryStorageType storage_type,
void *pointer,
MemoryBuffer::release_function_t release_func = nullptr,
int32_t device_id = Allocator::kUnknownDeviceId
)

Wrap existing tensor storage and attach it to a Holoscan tensor.

The release function is optional; when provided, it is called when the tensor releases the backing MemoryBuffer. A nonnegative device_id is a caller assertion that device storage belongs to that CUDA ordinal; this skips the CUDA pointer-attribute query used for validation. Leave it as Allocator::kUnknownDeviceId (the default) for unknown provenance so Tensor construction derives and validates the ordinal from the backing pointer when the storage type requires it.