﻿# ONNX optional inputs: preserve positions when a middle argument is absent

Understand static optional input placeholders in ONNX and why removing a missing middle argument changes the meaning of later inputs in an exported graph.

Author: Retrivium editorial team
Updated: 2026-11-04
Canonical URL: https://retrivium.ai/journal/fg2-onnx-optional-input-empty-placeholder-position/
Language: en

## A graph editor silently moves the upper bound

Imagine a graph rewrite that keeps a clipping operation’s upper bound but removes its unused lower bound. If the tool compacts the input-name list, the remaining bound occupies the wrong formal position. The tensor itself can still have a valid type, so a superficial inspection may miss the change. Diagnose the correspondence between each input name and the operator schema before examining GPU kernels or attributing the output difference to numerical precision.

## Missing static inputs have an explicit representation

The [ONNX IR rules](https://onnx.ai/onnx/repo-docs/IR.html) allow trailing optional inputs to be omitted. A missing input before a later supplied argument needs an empty name in its position. That marker is not a tensor containing no elements and is not a request to allocate an empty device buffer. It represents absence at the graph interface. Preserve this distinction when serializing, cloning or rewriting nodes, rather than normalizing all empty-looking values into one representation.

## Consult the selected operator schema

The [Clip specification](https://onnx.ai/onnx/operators/onnx__Clip.html) provides a concrete case with optional bounds. Read the schema selected by the model’s imported operator set, because historical versions can express parameters differently. Associate names with that exact ordered signature. The [schema contract guide](/journal/data-guide-frictionless-table-schema/) offers a related lesson: structural positions carry meaning even when individual values look plausible. A syntactically valid list can still describe the wrong operation.

## Validate structure and observable behavior

Use the [ONNX checker](https://onnx.ai/onnx/api/checker.html) after editing the graph, then compare outputs against the untouched model. For the clipping example, include values below and above the intended bound and values that should pass unchanged. These examples distinguish a missing lower bound from a misplaced upper bound. Retain the rewritten node and the associated import information in the review evidence; a successful checker result alone does not establish that the rewrite preserved intent.

## Keep absence separate throughout the toolchain

Do not replace the missing argument with a fabricated constant merely to satisfy a generic list utility. That creates a different graph and can alter optimization or broadcasting behavior. Track the changed artifact through [release verification](/journal/artifact-signature-verification/) so the tested rewrite is the deployed rewrite. The practical outcome is a position-preserving serializer with behavioral evidence, rather than a rule that every omitted argument can be safely deleted from an ordered input list.
