ONNX039: ref-attr-outside-function¶
Code: ONNX039
Name: ref-attr-outside-function
Severity: error
Category: spec
Target: graph
Fixable: No
Message¶
Reference attribute can only appear in function nodes, not in the main graph or its subgraphs.
Suggestion¶
Use a regular attribute instead, or move this node into a function.
Details¶
Reference attributes (attr_ref in ONNX protobuf, is_ref() in onnx_ir) are
placeholders that refer to function parameters. They are only valid inside
function bodies where they bind to attributes passed when the function is called.
Using a reference attribute in the main graph or a subgraph is invalid because
there is no enclosing function to provide the referenced value.