Jump to content

NormalizeOp

From RidgeRun Developer Wiki

🚧 Documentation is under development

The Holoscan SDK guide is currently under active development. Some sections may be incomplete or change without notice.

Questions? Contact RidgeRun or email to support@ridgerun.com.

Contents Pin





NormalizeOp

NormalizeOp centers and scales values in a CUDA image using either shared parameters or separate parameters for each channel. It preserves shape, layout, scalar type, and capture metadata.

Choose the numeric type before normalization. U8 input still produces U8 output; use ConvertToOp to convert to F32 first when the result needs floating-point values.


Output Dtype
NormalizeOp preserves dtype. Use ConvertToOp for an explicit conversion before normalization when the result needs floating-point storage.


Input arguments

In ordinary mode, each value becomes (input − base) × scale × global_scale + shift. When scale_is_stddev is true, the channel multiplier is 1 / sqrt(scale² + epsilon). NormalizeOpParams declares:

Parameter Default and Rule
base {0.F}; nonempty finite vector, at most four values. One broadcasts; otherwise use exactly one per channel.
scale {1.F}; same vector rule, interpreted as a multiplier or standard deviation.
global_scale, shift 1.F and 0.F; finite scalar gain and bias.
epsilon 0.F; finite nonnegative variance regularizer.
scale_is_stddev false; enables the standard-deviation interpretation.

All fields are CompileTime, frozen for the accepted plan. Set the aggregate before compilation; OperatorHandle::set_params() is an authoring operation, not a runtime update. A zero standard deviation with zero epsilon rejects in setup/compute. Positive epsilon allows that case, subject to normal numeric behavior. Vector length must match the actual image channels or be one; merely fitting the four-element schema bound is insufficient.

Ports and data contract

Port Memory Queue Trigger Contract
input CUDA device 1 OnEach Interleaved HWC or NHWC image with one, three or four channels and a supported scalar type.
output CUDA device, contiguous N/A Same activation Same dtype and geometry as the input after channel-wise normalization.

F64 and two-channel images are not supported. The output is a new contiguous tensor on the same CUDA device.

Example

Include <holoscan/vision/convert_to_op.hpp> and <holoscan/vision/normalize_op.hpp>. With graph already declared, this composition fragment prepares U8 values for floating-point normalization:

auto convert = graph.op<holoscan::vision::ConvertToOp>("to-f32");
convert.set_params(holoscan::vision::ConvertToOpParams{
    .output_type = holoscan::vision::VisionElementType::kF32,
    .alpha = 1.0 / 255.0,
});
auto normalize = graph.op<holoscan::vision::NormalizeOp>("normalize");
normalize.set_params(holoscan::vision::NormalizeOpParams{
    .base = {0.5F},
    .scale = {2.F},
});
graph.add_flow(convert->output, normalize->input);

Connect the CUDA source to convert->input and the consumer to normalize->output. The one-element vectors broadcast to every channel: an F32 value of 0, 0.5 or 1 after conversion becomes −1, 0 or 1. This fragment configures the processing path; the complete source and validating sinks are in the linked pipeline.

Build

Follow Build the SDK on AGX Orin for the SDK build and installation. Link the installed holoscan::vision target in the application.


Related examples and concepts

Examples

Concepts

Source You can find the source code at NormalizeOp.

Official documentation

NVIDIA Holoscan SDK User Guide provides the official operator and application reference.


Cookies help us deliver our services. By using our services, you agree to our use of cookies.