UniVSTQkvTransform<T>

Models & Types · AiDotNet.Diffusion.StyleTransfer

Attaches UniVST’s attention-level steering to a frozen attention block: query blending at every timestep, and key/value AdaIN on the beta ramp (Song et al., arXiv:2410.20084, TPAMI 2025).

Implements: IQkvTransform<T>

How It Works

This is the attention half of UniVST’s stylization. It has to act on the PROJECTED Q/K/V rather than on the attention output, which is why it implements IQkvTransform instead of IAttentionBlockDecorator — the latter only sees the post-softmax result, where a Q/K/V-shaped operation would be transforming a different tensor entirely.

The reference tensors change every denoising step, because they come from the content and style branches running alongside the editing branch. The driver therefore sets ContentQuery, StyleKey, StyleValue and TimestepFraction before each UNet call. A reference left null means “nothing to blend against”, and that projection passes through untouched rather than being blended against a stale tensor from the previous step.

No gradient tape. UniVST is training-free — it steers a frozen model and never backpropagates — so these transforms build their results directly instead of composing Engine operations. Anything that needs gradients through attention must not use this.

Constructors

Constructor Summary
UniVSTQkvTransform(UniVSTAdaInStylization<T> stylization) Creates the transform.

Properties

Property Summary
Tensor<T> ContentQuery { get; set; } Gets or sets the content branch’s projected query for this step.
Tensor<T> StyleKey { get; set; } Gets or sets the style branch’s projected key.
Tensor<T> StyleValue { get; set; } Gets or sets the style branch’s projected value.
double TimestepFraction { get; set; } Gets or sets the current progress through the schedule, as a fraction of T.

Methods

Method Summary
Tensor<T> TransformKey(Tensor<T> key)
Tensor<T> TransformQuery(Tensor<T> query)
Tensor<T> TransformValue(Tensor<T> value)