Skip to navigation

holoscan::TensorOutputLoan

Beta
View as Markdown

Hold sole unpublished authority for one plan-owned tensor output allocation.

The loan is move-constructible but neither copyable nor assignable. It exposes bounded metadata and an explicit host or CUDA write phase; it never converts to an owning Tensor or DLPack handle. Destruction abandons an unpublished live loan. Every terminal tensor publication or cancellation attempt consumes the loan, including an error result.

#include <holoscan/tensor_output_loan.hpp>

Constructors

TensorOutputLoan

) noexcept

Transfer unpublished authority from another loan.

Parameters

other
TensorOutputLoan &&

Loan whose authority becomes moved-from.

Destructor

~TensorOutputLoan

holoscan::TensorOutputLoan::~TensorOutputLoan() noexcept

Abandon an unpublished live allocation without throwing.


Assignment operators

operator=

The following overloads are deleted to prevent misuse:

TensorOutputLoan & holoscan::TensorOutputLoan::operator=(const TensorOutputLoan &other) = delete;
TensorOutputLoan & holoscan::TensorOutputLoan::operator=(TensorOutputLoan &&other) = delete;

Methods

shape

TensorShapeView holoscan::TensorOutputLoan::shape() const noexcept

Return the allocation shape.

Returns: Borrowed shape view valid while this loan remains live.

byte_strides

TensorByteStridesView holoscan::TensorOutputLoan::byte_strides() const noexcept

Return the allocation byte strides.

Returns: Borrowed explicit strides, or the empty/implicit-stride representation.

dtype

DLDataType holoscan::TensorOutputLoan::dtype() const noexcept

Return the allocation element type.

Returns: DLPack element type frozen at allocation.

device_id

DeviceId holoscan::TensorOutputLoan::device_id() const noexcept

Return the resolved CUDA device identity.

Returns: Device identity, or an invalid value for host-only/unresolved storage.

memory_kind

MemoryKind holoscan::TensorOutputLoan::memory_kind() const noexcept

Return the concrete storage classification.

Returns: Memory kind frozen by the compiled allocation plan.

byte_size

std::size_t holoscan::TensorOutputLoan::byte_size() const noexcept

Return the bounded allocation byte span.

Returns: Number of accessible bytes, including any explicit stride span.

write

::cuda::stream_ref producer_stream
) &

Begin a CUDA-stream-ordered write phase.

This operation borrows the loan; the returned guard must be committed or destroyed before the loan is otherwise used.

Returns: A sole write guard, or a typed state/capability error.

Parameters

producer_stream
::cuda::stream_ref

Stream on which producer writes will be ordered.

write_and_commit

template <typename Fill>
expected<void, Error> holoscan::TensorOutputLoan::write_and_commit(
::cuda::stream_ref producer_stream,
Fill &&fill
) &

Run one CUDA fill callback and commit its write phase.

A callback error abandons the active write and makes this loan nonpublishable. The callback must not retain the borrowed guard or its data pointer beyond the invocation.

Returns: Success after callback and commit, or the exact acquisition, callback, or commit error.

Throws: Any exception propagated by fill; the active write is abandoned during unwinding.

Template parameters

Fill
typename

Callable accepting const TensorOutputWriteGuard& and returning either void or expected<void, Error>.

Parameters

producer_stream
::cuda::stream_ref

Stream on which producer writes will be ordered.

fill
Fill &&

Callback invoked exactly once after acquiring write authority.

write_host

Begin a host write phase.

Host write is admitted only for host-accessible placement frozen by the plan.

Returns: A sole write guard, or a typed state/capability error.

write_host_and_commit

template <typename Fill>
expected<void, Error> holoscan::TensorOutputLoan::write_host_and_commit(
Fill &&fill
) &

Run one host fill callback and commit its write phase.

A callback error abandons the active write and makes this loan nonpublishable. The callback must not retain the borrowed guard or its data pointer beyond the invocation.

Returns: Success after callback and commit, or the exact acquisition, callback, or commit error.

Throws: Any exception propagated by fill; the active write is abandoned during unwinding.

Template parameters

Fill
typename

Callable accepting const TensorOutputWriteGuard& and returning either void or expected<void, Error>.

Parameters

fill
Fill &&

Callback invoked exactly once after acquiring host write authority.

cancel

expected<void, Error> holoscan::TensorOutputLoan::cancel() &&

Cancel unpublished tensor authority.

The terminal attempt consumes this loan for both success and failure. If a write guard is active, the allocation remains unavailable and tombstoned until that guard commits or is destroyed; the guard cannot publish and its commit returns kInvalidArgument.

Returns: Success when bounded retirement begins, or an error for invalid authority.


Member variables

NameTypeDescription
state_void *
ops_const detail::TensorOutputLoanOps *
state_owner_std::shared_ptr< void >