Skip to content

Commit e00221e

Browse files
gramalingamCopilot
andcommitted
Always declare all 6 inputs unconditionally
Address review comment: declare decay and beta as ir.Value unconditionally so the ir.Function signature is truly fixed at 6 inputs regardless of update_rule. The body's conditional logic simply ignores unused trailing inputs. Co-authored-by: Copilot <[email protected]> Signed-off-by: G Ramalingam <[email protected]>
1 parent 16d3ce7 commit e00221e

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

‎src/mobius/functions/linear_attention.py‎

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,16 +110,20 @@ def linear_attention(
110110
uses_beta = update_rule in ("delta", "gated_delta")
111111

112112
# --- Define function inputs ---
113-
# All 6 inputs are always declared. Call sites that don't need
114-
# trailing inputs (decay, beta) simply omit them — onnx-shape-inference
115-
# >=0.1.9 accepts trailing optional inputs (matching ONNX C++ behavior).
116-
inputs: list[ir.Value | None] = [
113+
# Always declare the full 6-input signature:
114+
# (query, key, value, past_state, decay, beta).
115+
# Update-rule-specific paths inside the function body ignore unused
116+
# trailing inputs so every variant exposes the same ir.Function
117+
# interface. Call sites that don't need trailing inputs (decay, beta)
118+
# simply omit them — onnx-shape-inference >=0.1.9 accepts trailing
119+
# optional inputs (matching ONNX C++ behavior).
120+
inputs: list[ir.Value] = [
117121
ir.Value(name="query"), # (B, T, q_num_heads * d_k)
118122
ir.Value(name="key"), # (B, T, q_num_heads * d_k)
119123
ir.Value(name="value"), # (B, T, kv_num_heads * d_v)
120124
ir.Value(name="past_state"),
121-
ir.Value(name="decay") if uses_decay else None,
122-
ir.Value(name="beta") if uses_beta else None,
125+
ir.Value(name="decay"),
126+
ir.Value(name="beta"),
123127
]
124128

125129
def body(op, query_v, key_v, value_v, past_state_v, decay_v, beta_v):

0 commit comments

Comments
 (0)