Implement schema-based input/attribute partitioning in GraphBuilder#2837
Implement schema-based input/attribute partitioning in GraphBuilder#2837gramalingam wants to merge 1 commit intomainfrom
Conversation
gramalingam
commented
Mar 3, 2026
- Convert onnx.defs.OpSchema to ir.schemas.OpSignature via from_op_schema and delegate to separate_input_attributes_from_arguments
- Add allow_extra_args parameter to separate_input_attributes_from_arguments for rejecting unexpected positional arguments (default True for compat)
- Builder uses strict mode: allow_extra_kwargs=False, allow_extra_args=False
- Refactor _build test helper: accept TypeSpec, optional trace_function, return ir.Graph directly
- Add comprehensive tests for input/attribute partitioning
- Convert onnx.defs.OpSchema to ir.schemas.OpSignature via from_op_schema and delegate to separate_input_attributes_from_arguments - Add allow_extra_args parameter to separate_input_attributes_from_arguments for rejecting unexpected positional arguments (default True for compat) - Builder uses strict mode: allow_extra_kwargs=False, allow_extra_args=False - Refactor _build test helper: accept TypeSpec, optional trace_function, return ir.Graph directly - Add comprehensive tests for input/attribute partitioning Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
| ) | ||
|
|
||
| onnx_model = ir.Model(graph=graph, ir_version=10) | ||
| resolved_inputs = [builder._resolve_type_spec(t) for t in input_types] |
Check warning
Code scanning / lintrunner
PYLINT/W0212 Warning
| output.type = output_type.type # TODO: need merge_type method in ir.Value | ||
| output.merge_shapes(output_type.shape) | ||
| if output_types is not None: | ||
| resolved_outputs = [builder._resolve_type_spec(t) for t in output_types] |
Check warning
Code scanning / lintrunner
PYLINT/W0212 Warning
| trace_function=_dummy, | ||
| ) | ||
| x, y = graph.inputs | ||
| node = list(graph)[0] |
Check warning
Code scanning / lintrunner
RUFF/RUF015 Warning
| trace_function=_add, | ||
| ) | ||
| x, y = graph.inputs | ||
| node = list(graph)[0] |
Check warning
Code scanning / lintrunner
RUFF/RUF015 Warning
| trace_function=_gemm, | ||
| ) | ||
| a, b, c = graph.inputs | ||
| node = list(graph)[0] |
Check warning
Code scanning / lintrunner
RUFF/RUF015 Warning
| trace_function=_gemm_no_c, | ||
| ) | ||
| a, b = graph.inputs | ||
| node = list(graph)[0] |
Check warning
Code scanning / lintrunner
RUFF/RUF015 Warning
| input_types=[FLOAT[3, 4], FLOAT[4, 5]], | ||
| trace_function=_gemm_no_attrs, | ||
| ) | ||
| node = list(graph)[0] |
Check warning
Code scanning / lintrunner
RUFF/RUF015 Warning
| trace_function=_concat, | ||
| ) | ||
| x, y, z = graph.inputs | ||
| node = list(graph)[0] |
Check warning
Code scanning / lintrunner
RUFF/RUF015 Warning
| ) | ||
| data, starts, ends, axes, steps = graph.inputs | ||
|
|
||
| slice_node = list(graph)[0] |
Check warning
Code scanning / lintrunner
RUFF/RUF015 Warning
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2837 +/- ##
==========================================
+ Coverage 71.79% 71.87% +0.07%
==========================================
Files 239 239
Lines 29019 29092 +73
Branches 2864 2867 +3
==========================================
+ Hits 20834 20909 +75
+ Misses 7213 7210 -3
- Partials 972 973 +1 ☔ View full report in Codecov by Sentry. |
| # Not implemented yet | ||
| del schema | ||
| return inputs, kwargs | ||
| if schema is None: |
There was a problem hiding this comment.
The Op object has the signature cached. Would it be possible to use that?
There was a problem hiding this comment.
Pull request overview
This PR activates schema-based input/attribute partitioning in GraphBuilder, which was previously stubbed out. It also adds an allow_extra_args parameter to separate_input_attributes_from_arguments for strict positional-argument validation, and refactors the _build test helper to return ir.Graph directly (removing the intermediate ir.Model wrapper).
Changes:
- Added
allow_extra_argsparameter toseparate_input_attributes_from_argumentsinparam_manipulation.py, enforcing a check for extra positional arguments when a schema is known and no variadic parameter exists. - Implemented
GraphBuilder._partition_inputs_attributesinbuilder.pyto delegate toseparate_input_attributes_from_argumentsviair.schemas.OpSignature.from_op_schema, using strict mode (fill_defaults=False,allow_extra_args=False). - Refactored the
_buildtest helper inbuilder_test.pyto acceptTypeSpecinputs, maketrace_functionoptional, returnir.Graphdirectly, and added a comprehensivePartitionInputsAttributesTestsuite.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
onnxscript/_internal/param_manipulation.py |
Adds allow_extra_args parameter and validates extra positional args after the main loop |
onnxscript/_internal/builder.py |
Implements _partition_inputs_attributes using schema-based partitioning instead of a no-op stub |
onnxscript/_internal/builder_test.py |
Refactors _build helper and adds PartitionInputsAttributesTest covering 9 new test cases |