Skip to navigation

holoscan::ops::TensorPreprocessorOp

Beta
View as Markdown

GPU-native resize + optional normalize + optional HWC->CHW transpose.

All work runs on the CUDA device against the Holoscan stream, using NVIDIA Performance Primitives (NPP): nppiResize_8u_C3R_Ctx for bilinear resize, nppiConvert_8u32f_C3R_Ctx for the u8->f32 dtype cast, nppiMulC_32f_C3IR_Ctx / nppiSubC_32f_C3IR_Ctx / nppiDivC_32f_C3IR_Ctx for the x = (x/255 - mean) / ``std normalization, and nppiCopy_8u_C3P3R_Ctx / nppiCopy_32f_C3P3R_Ctx for the HWC->CHW plane split. Only the device memory kind (kCudaDevice / kCudaManaged) is supported for both input and output; requesting a host-side output raises an error.

#include <holoscan/ops/tensor_preprocessor.hpp>

Inherits from: holoscan::Operator< TensorPreprocessorOpParams > (public)


Constructors

TensorPreprocessorOp

holoscan::ops::TensorPreprocessorOp::TensorPreprocessorOp() = default

Destructor

~TensorPreprocessorOp

holoscan::ops::TensorPreprocessorOp::~TensorPreprocessorOp() override

Assignment operators

operator=

TensorPreprocessorOp & holoscan::ops::TensorPreprocessorOp::operator=(
) = delete

Methods

setup

void holoscan::ops::TensorPreprocessorOp::setup(
) override

Declare stable ports and other cold metadata by reference.

Repeated calls receive fresh specs and must describe the same deterministic contract.

Parameters

spec
OperatorSpec &

Fresh declaration pass owned by the compiler or private conformance fixture.

start

void holoscan::ops::TensorPreprocessorOp::start() override

Enter steady-state execution after admitted startup barriers.

An override must remain public and keep the exact void start() signature. Graph authoring lowers it into the single required LifecycleStage::kStart checkpoint; an Operator cannot also register an advanced callback for that stage. Cold preparation belongs to explicit lifecycle stages added by their owning component. For a typed session-owned Operator, params() exposes the exact parameter generation selected for this phase.

stop

void holoscan::ops::TensorPreprocessorOp::stop() override

Leave steady-state execution before resource release.

An override must remain public and keep the exact void stop() signature. Graph authoring lowers it into the single required LifecycleStage::kStop checkpoint; an Operator cannot also register an advanced callback for that stage. For a typed session-owned Operator, params() exposes the exact parameter generation selected for this phase, including the restored old-published view during rollback.

compute

expected<void, Error> holoscan::ops::TensorPreprocessorOp::compute(
) override

Process one frozen activation candidate.

The callback is invoked at most once for one activation tag. It must not wait for or recursively trigger another activation.

Returns: Success after Operator work completes, or a typed failure for Runtime policy.

Parameters

context
ExecutionContext &

Borrowed callback-lifetime runtime services and activation evidence.

contract

Contract holoscan::ops::TensorPreprocessorOp::contract() const override

Return this Operator type’s complete cold temporal contract.

Runtime does not retain this authoring object’s address. Compilation calls this operation while replaying an owning Operator factory and freezes the validated descriptor into pointer-free plan records.

Returns: Fresh deep-owning descriptor; an empty value requests the inputful compile-time OnAnyInput default and is invalid for a zero-input Operator.

input_port

Input<Tensor> * holoscan::ops::TensorPreprocessorOp::input_port() const

The single dynamically-named Input<Tensor> port (declared when params()``.input_kind == "tensor").

Non-null even when the ImageT port is active, so downstream graph.add_flow() calls that reach through input_port() produce a clear declared-nowhere diagnostic instead of a null-dereference.

image_input_port

Input<schema::ImageT> * holoscan::ops::TensorPreprocessorOp::image_input_port() const

The single dynamically-named Input<schema::ImageT> port (declared when params()``.input_kind == "image").

output_port

Output<Tensor> * holoscan::ops::TensorPreprocessorOp::output_port() const

The single dynamically-named output port (declared in setup() as params()``.output_port_name).

params

const Params & holoscan::Operator<TensorPreprocessorOpParams>::params() const noexcept

Return this Operator instance’s currently stored parameter aggregate.

Before session binding, the aggregate is the authoring default. During a legacy start() or stop() callback on a session-owned instance, it is the exact generation selected for that lifecycle phase. Advanced lifecycle callbacks must use LifecycleContext and compute callbacks must use ExecutionContext::params<ParamsT>() for their pinned views. Runtime may replace the stored aggregate between quiesced lifecycle callbacks, so callers must not retain the returned reference across callback boundaries. This operation does not allocate or synchronize.

Returns: Process-static shared NoParams value, or a stable reference to this instance’s aggregate.

host_metadata

virtual OperatorHostMetadata holoscan::OperatorBase::host_metadata() const noexcept

Return cold compiler-visible callback-host metadata.

Returns: Native hosting without a serialization constraint by default.


Types

Typedefs

NameDefinitionDescription
ParamsTensorPreprocessorOpParamsName the exact immutable parameter aggregate type.

Member variables

NameTypeDescription
input_Input< Tensor >
image_input_Input< schema::ImageT >
output_Output< Tensor >
channels_int32_t
output_shape_std::vector< int64_t >
output_frame_bytes_std::size_t
d_resized_u8_void *
d_resized_f32_void *
d_resized_u8_bytes_std::size_t
d_resized_f32_bytes_std::size_t
d_yuv_rgb_u8_void *
d_yuv_rgb_u8_bytes_std::size_t
npp_ctx_void *