com.microsoft.LinearAttentionGate

com.microsoft · ONNX Runtime contrib operator · contrib since_version 1

Description

Fuses the gate projections used by com.microsoft.LinearAttention's gated-delta recurrence: decay = decay_scale * softplus(a + dt_bias) and, when requested, beta = sigmoid(b). The last input axis is the head axis; dt_bias and decay_scale are float32 per-head vectors. Gate arithmetic is performed in float32 and narrowed only on store. Requesting beta requires b; an unconsumed b is permitted when beta is omitted.

See the ONNX Runtime LinearAttentionGate contrib-operator spec for the reference semantics.

Inputs

Name Bind key Logical dtype Rank Shape Description Presence
a aT T Decay gate projection with shape (B, T, H). Any rank of at least 1 is accepted; the last axis is the head count and the leading axes are folded. required
dt_bias dtBiasT TF 1 Per-head float32 bias added to a, with shape (H). required
decay_scale decayScaleT TF 1 Per-head float32 multiplier applied to softplus(a + dt_bias), with shape (H). For gated DeltaNet this is -exp(A_log). required
b bT T Update-rate projection with the same shape as a when beta is requested. It is accepted but unused when beta is omitted. optional

Outputs

Name Bind key Logical dtype Rank Shape Description Presence
decay decayT T same as a same as a decay_scale * softplus(a + dt_bias), with the same shape as a. required
beta betaT T same as a same as a sigmoid(b), with the same shape as a. Requires the b input. optional

Type constraints

Variable Allowed dtypes
T float32, float16
TF float32

Files

Use with @huggingface/kernels

The loader derives every required output's shape and logical dtype from the manifest contract and this call. It then allocates the result tensors automatically.

The version: 1 option selects the published kernel contract; it is independent of any operator opset, contrib since_version, or model version.

Replace each *Data placeholder with a typed array containing the corresponding input data.

import { getKernel } from "@huggingface/kernels";

const kernel = await getKernel("webgpu-kernels/com.microsoft.LinearAttentionGate", { version: 1 });
const { decayT } = await kernel({
  aT: { data: aTData, shape: [5] },
  dtBiasT: { data: dtBiasTData, shape: [5] },
  decayScaleT: { data: decayScaleTData, shape: [5] },
});
Downloads last month
-
kernel
webgpu
wgsl
apache-2.0
WebGPU

Requires WebGPU support. See the compatibility table.