Skip to navigation

holoscan::Output< Tensor >

Beta
View as Markdown

Specialize output publication for shaped Tensor allocation.

Tensor output deliberately omits generic allocate(): direct allocation requires shape, type, and stride metadata and returns one TensorOutputLoan. Existing owning Tensor values and forwarded Tensor samples remain separate pass-through paths.

#include <holoscan/port.hpp>

Inherits from: holoscan::OutputBase (public), holoscan::OutputBase (public)


Methods

Output

holoscan::Output<Tensor>::Output() = default

Construct an unnamed unbound tensor output declaration.

Destructor

~Output< Tensor >

holoscan::Output<Tensor>::~Output() override = default

Destroy this stable Tensor output after all runtime bindings have retired.

allocate_tensor

expected<TensorOutputLoan, Error> holoscan::Output<Tensor>::allocate_tensor(
)

Request one shaped allocation from the compiled tensor pool.

Returns: Sole tensor loan, or a typed bounds/capacity/state error.

Parameters

request
TensorLoanRequest

Logical shape, element type, and optional byte strides.

emit

expected<void, Error> holoscan::Output<Tensor>::emit(
EmitOptions options = {}
)

Publish one terminal tensor loan attempt.

Returns: Publication result.

Parameters

loan
TensorOutputLoan

Sole shaped tensor authority; consumed for success and every error.

options
EmitOptionsDefaults to {}

Optional semantic metadata.

emit_ref

expected<void, Error> holoscan::Output<T>::emit_ref(
const T &value,
EmitOptions options = {}
) noexcept

Encode and publish one ordinary generated schema without copying its native value.

Runtime encodes into owned bounded storage before returning. The caller may then edit, reset, or destroy its value, even while consumers have not yet received the encoded message. Framework-owned sequence, publication time, byte size, and classification are stamped by Runtime. Semantic metadata must be supplied explicitly through options.

The caller retains its value on every outcome. This does not make partial or indeterminate publication retryable; ordinary publication authority rules still apply.

This is not zero-copy transport, input mutation, or an escaping receive loan. It does not require prepared scratch for unchanged pass-through. A generated scratch value is useful for bounded edits; by-value emit still copies an lvalue. Encoder/transport costs remain.

Tensor descriptors are excluded: use emit_tensor or emit_tensors with separately authoritative output loans. Existing owning and generic-loan APIs are unchanged.

Returns: Success after accepted publication, or the same typed publication error as emit.

Parameters

value
const T &

Caller-owned value, unchanged and valid throughout this call, including objects reachable through its shared pointers. No reference to this value escapes the call.

options
EmitOptionsDefaults to {}

Optional capture time, frame identity, trace, and semantic flags.

allocate

expected<LoanedSample<T>, Error> holoscan::Output<T>::allocate() noexcept

Acquire one already-constructed value from a finite output pool.

This operation never blocks, grows a pool, or falls back to heap allocation.

This overload participates only for supported inline POD or generated-schema payloads that are default-initializable, assignable from T, and no-throw default-constructible and destructible. Other admitted payloads remain available through the ordinary emit(T) path.

Returns: Sole unpublished authority, or an immediate bounded allocation/state error.

emit_tensor

expected<void, Error> holoscan::Output<T>::emit_tensor(
const T &descriptor,
EmitOptions options = {}
)

Publish provider-backed Tensor storage with descriptor-schema metadata.

The overload participates only for descriptor-backed Tensor schema payloads. Neither the descriptor object nor its strings may be mutated concurrently with this call.

Returns: Publication result.

Parameters

loan
TensorOutputLoan

Sole shaped Tensor authority; consumed for success and every error.

descriptor
const T &

Schema value whose non-Tensor fields are encoded synchronously. Its embedded Tensor member is ignored; the provider-owned Tensor from loan is authoritative.

options
EmitOptionsDefaults to {}

Optional semantic sample metadata.

allocate_tensors

expected<TensorSchemaOutputLoan<T>, Error> holoscan::Output<T>::allocate_tensors(
std::span<const TensorFieldLoanRequest<T>> requests
)

Transactionally request provider-backed storage for every Tensor schema field.

The overload participates only for descriptor-backed Tensor schema payloads. Requests may be supplied in any order; Runtime canonicalizes them by generated Tensor index.

Returns: One sole multi-field publication bundle, or a typed validation, capacity, or state error. No partial bundle escapes on failure.

Parameters

requests
std::span<const TensorFieldLoanRequest<T>>

Exactly one generated field selector and shaped request per schema field.

emit_tensors

expected<void, Error> holoscan::Output<T>::emit_tensors(
const T &descriptor,
EmitOptions options = {}
)

Publish one provider-backed Tensor field bundle with descriptor-schema metadata.

Returns: Publication result.

Parameters

loan
TensorSchemaOutputLoan<T>

Sole multi-field authority; consumed for success and every error.

descriptor
const T &

Schema value whose non-Tensor fields are encoded synchronously. Embedded Tensor members are ignored; the bundle fields are authoritative.

options
EmitOptionsDefaults to {}

Optional semantic sample metadata.

project

ProjectedTensorOutput<T> holoscan::Output<T>::project(
TensorFieldSelector<T> selector
) const noexcept

Name one Tensor field of this schema output for a Tensor-typed edge.

The returned view borrows this declaration and must not outlive it. Naming the field is required rather than inferred whenever the schema carries more than one Tensor, so the choice appears in the Graph instead of following from declaration order.

Returns: Borrowing projection usable as an add_flow source.

Parameters

selector
TensorFieldSelector<T>

Generated field constant, such as schema::ImageTensorFields::data.

name

std::string_view holoscan::OutputBase::name() const noexcept

Return the cold declaration name.

Returns: View valid until this port is destroyed.

tensor_output_binding

detail::TensorOutputBinding & holoscan::OutputBase::tensor_output_binding() noexcept

Return the private shaped-allocation binding for a Tensor-backed output.

Returns: Mutable binding used only by exact typed output specializations.


Member variables

NameTypeDescription
binding_detail::OutputBinding< Tensor >