VVAS XInfer Buffer Allocation Strategies - VVAS XInfer Buffer Allocation Strategies - 6.2 English - XD056

Vitis Video Analytics SDK (VVAS) 6.2 User Guide (XD056)

Document_ID
XD056
Release_Date
2026-06-12
Version
6.2 English

vvas_xinfer negotiates sink caps, an input buffer pool, and an allocator with its upstream peer. The selected path depends on model input requirements, the infer JSON, and the memory type produced by upstream.

This document summarizes the allocation and synchronization behavior for the supported vvas_xinfer operating modes.

Allocator Negotiation

Negotiation Inputs

vvas_xinfer derives the allocation contract from:

  • model input format, dimensions, layout, stride, and normalization;

  • preprocess-config presence or absence;

  • in-mem-bank and out-mem-bank values;

  • inference-backend-runtime selection;

  • upstream caps and allocation-query support.

Sink Caps

With preprocess-config, sink caps include the model input requirements and the formats accepted by the selected image-processing library. Upstream may provide source-resolution video formats accepted by the library; PPE converts them to the model input tensor.

Without preprocess-config, sink caps are restricted to the model input shape. Upstream must provide the exact format, dimensions, layout, and tensor size required by the model.

Allocator Proposal

If the allocation query already carries allocator parameters, vvas_xinfer preserves them and contributes only the pool. If the allocator is not a GstVvasAllocator, PPE-enabled mode copies each input frame into an internal VVAS pool before running the HW PPE kernel.

When HW PPE is enabled, vvas_xinfer proposes:

  • GstVvasAllocator on the preprocess device;

  • allocation on config in-mem-bank;

  • DMA-BUF export enabled;

  • stride-aligned GstVvasBufferPool;

  • video alignment metadata for upstream stride handling.

When PPE is disabled and the backend is VART, vvas_xinfer proposes:

  • GstVvasAllocator on the inference device;

  • DMA-BUF export enabled;

  • GstVvasBufferPool without PPE stride constraints.

For SW preprocessing and ONNX Runtime, vvas_xinfer proposes no custom allocator and uses a plain GstVideoBufferPool.

Additional query rules:

  • proposed pool size is batch_size + 1;

  • GST_VIDEO_META_API_TYPE is added to the query;

  • PPE input zero-copy requires matching device index and memory bank;

  • no-PPE inference uses the bank carried by the upstream allocator.

Scenario Matrix

Mode

Upstream memory

vvas_xinfer action

Copy behavior

PPE enabled

System memory

Copy to internal VVAS pool

Copy

PPE enabled

Compatible VVAS

Consume in place

Zero copy

PPE enabled

Incompatible VVAS

Copy to internal VVAS pool

Copy

PPE enabled

Generic DMA-BUF

Import on PPE device

Zero copy if importable

PPE disabled, VART HW

System memory

Copy to internal VVAS pool

Copy

PPE disabled, VART HW

VVAS memory

Consume in place

Zero copy

PPE disabled, VART HW

Generic DMA-BUF

Import on inference device

Zero copy if importable

PPE disabled, ONNX Runtime

System memory

Runtime-managed staging

Runtime copy path

Compatible / Incompatible VVAS: see VVAS-Memory Input under PPE Enabled for the device-index and memory-bank match criteria.

PPE Enabled

System-Memory Input

Plain system-memory buffers cannot be consumed by the HW PPE kernel. prepare_ppe_input_frame() copies the input frame into an internal GstVvasBufferPool on the configured PPE input bank. The internal buffer is then synchronized to device memory before PPE execution.

Applicable sources include filesrc ! rawvideoparse and other upstream elements that cannot consume a downstream-proposed allocator.

VVAS-Memory Input

If upstream uses vvas_xinfer’s proposed allocator, or produces compatible GstVvasMemory, PPE reads the input in place.

Compatibility requires:

  • GstVvasMemory;

  • matching XRT device index;

  • matching memory bank;

  • valid synchronization flags.

If the device index or bank is incompatible, prepare_ppe_input_frame() falls back to the internal-copy path. The pipeline remains functional.

Generic DMA-BUF Input

For generic GstDmabufMemory, prepare_ppe_input_frame() imports the DMA-BUF file descriptor as an XRT BO on the preprocess device. PPE reads the imported BO directly.

If import fails, vvas_xinfer falls back to the system-memory copy path.

PPE Disabled

VART HW Backend

The input buffer must already contain the model tensor in the required format, dimensions, and layout. No resize, color conversion, layout conversion, or normalization is performed by vvas_xinfer.

Supported input memory:

  • compatible GstVvasMemory from an upstream scaler or tensor producer;

  • generic DMA-BUF that can be imported on the inference device;

  • system memory — vvas_xinfer_ensure_xrt_input_buffer() lazily allocates an internal VVAS pool on the inference device (XDNA_DEVICE_IDX, vart_info.mbank_idx, stride_align = 1) and vvas_xinfer_copy_input_buffer() memcpy’s the sysmem frame into a buffer drawn from that pool. VVAS_SYNC_TO_DEVICE is set and gst_vvas_memory_sync_bo() flushes before the VART runner reads. Same mechanism as the PPE-enabled sysmem path, just on the inference device. The buffer payload must already match the model tensor format, dimensions, and layout; no resize, conversion, or normalization is applied on this path.

For VVAS-memory input, prepare_infer_input_frame() extracts the allocator context and memory bank from the input buffer. The bank is passed to the inference path; vart-config.in-mem-bank does not gate this path.

For generic DMA-BUF input, vvas_videoframe_from_gstbuffer() imports the DMA-BUF as an XRT BO on the inference device.

ONNX Runtime Backend

ONNX Runtime uses runtime-managed staging. vvas_xinfer does not advertise a custom VVAS allocator for ONNX Runtime. System-memory input is valid when the buffer matches the model tensor layout.

No GStreamer-level zero-copy contract is implied for ONNX Runtime.

Synchronization

VVAS DMA-BUF memory uses the following cache-coherency flags:

VVAS_SYNC_TO_DEVICE

CPU wrote the buffer; flush before device read.

VVAS_SYNC_FROM_DEVICE

Device wrote the buffer; no CPU-to-device flush is required for another device reader.

PPE input synchronization:

  • if VVAS_SYNC_FROM_DEVICE is not set, prepare_ppe_input_frame() sets VVAS_SYNC_TO_DEVICE and calls gst_vvas_memory_sync_bo();

  • if VVAS_SYNC_FROM_DEVICE is set, the sync-to-device path is skipped;

  • system-memory buffers have no sync flags and are handled through the internal copy path.

Inference input synchronization is delegated through vvas_videoframe_from_gstbuffer().

VVAS_SYNC_TO_DEVICE and VVAS_SYNC_FROM_DEVICE must not be set simultaneously.

Operational Notes

  • PPE runs whenever preprocess-config is present. Matching input and output dimensions or formats may skip resize or conversion internally, but configured normalization still applies.

  • External preprocessing must configure resize, layout, color conversion, normalization, and quantization upstream of vvas_xinfer.

  • PPE input bank mismatch causes an internal copy and performance loss; it is not a negotiation failure.

Validation Checklist

Verify the following for each documented pipeline:

  • sink caps match the intended preprocessing mode;

  • preprocess-config is present only for internal PPE;

  • PPE input buffers are compatible VVAS memory or importable DMA-BUF;

  • no-PPE VART HW input is not system memory;

  • external preprocessing produces the exact model tensor;

  • CPU-written DMA-BUF input is synchronized before device read;

  • repeated runs with identical input produce deterministic output.

Implementation Points

Relevant vvas_xinfer code paths:

  • propose_allocation();

  • prepare_ppe_input_frame();

  • prepare_infer_input_frame();

  • vvas_xinfer_ensure_xrt_input_buffer();

  • vvas_xinfer_copy_input_buffer();

  • vvas_xinfer_allocate_sink_internal_pool();

  • vvas_videoframe_from_gstbuffer();

  • gst_vvas_memory_sync_bo().