-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Open
Labels
core runtimeissues related to core runtimeissues related to core runtimemodel:transformerissues related to a transformer model: BERT, GPT2, Hugging Face, Longformer, T5, etc.issues related to a transformer model: BERT, GPT2, Hugging Face, Longformer, T5, etc.
Description
Describe the issue
Checked in
onnxruntime/onnxruntime/core/graph/graph.cc
Line 2843 in f8c1393
if (is_outer_scope_nodearg(input_def->Name())) |
onnxruntime/onnxruntime/python/tools/transformers/convert_generation.py
Lines 1077 to 1081 in f8c1393
# Add type info, otherwise ORT will raise error: "input arg (*) does not have type information set by parent node." | |
for initializer in moved_initializers: | |
shape = onnx.numpy_helper.to_array(initializer).shape | |
value_info = onnx.helper.make_tensor_value_info(initializer.name, initializer.data_type, shape) | |
graph.value_info.append(value_info) |
is_outer_scope_nodearg
doesn't seem to return true when the node input is an initializer defined in the outer graph (w/o having a value_info proto in the subgraph).
To reproduce
Produce a node with a subgraph that references an outer graph, and do not create a value_info for the initializer in the subgraph.
The node I observed was from
Urgency
No response
Platform
Linux
OS Version
N/A
ONNX Runtime Installation
Released Package
ONNX Runtime Version or Commit ID
1.22
ONNX Runtime API
Python
Architecture
X64
Execution Provider
Default CPU
Execution Provider Library Version
No response
Copilot
Metadata
Metadata
Assignees
Labels
core runtimeissues related to core runtimeissues related to core runtimemodel:transformerissues related to a transformer model: BERT, GPT2, Hugging Face, Longformer, T5, etc.issues related to a transformer model: BERT, GPT2, Hugging Face, Longformer, T5, etc.
Activity
justinchuby commentedon May 28, 2025
cc @skottmckay
skottmckay commentedon May 28, 2025
When programmatically building a subgraph you need to manually specify outer scope node args given they won't be known until the subgraph is added to its parent graph. That is done by calling AddOuterScopeNodeArg, and that is what is_outer_scope_nodearg is checking. That is expected to return false when the subgraph is within a parent graph as the type info should come from the real values in the parent graph.
Graph::InferAndVerifySubgraphTypes adds the type info. Any values consumed within the subgraph should be in the implicit inputs for the node that contains the subgraph.
onnxruntime/onnxruntime/core/graph/graph.cc
Lines 2764 to 2787 in f8c1393