-
Notifications
You must be signed in to change notification settings - Fork 89
Migrate ir_builder to use onnx_ir #2457
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
69b08fb
7e0a767
8c7abc6
370a9f5
10473a9
3889e70
e09fdcc
fa60de6
3aff171
761451a
882af66
852cc42
be610e9
98754ab
22eeddc
c74b854
2c43e9a
c53b8f3
c84ad91
0af0707
2196f99
b56a161
359eb0b
b04a455
e4c9576
11a735e
0cd1f20
d98e8b5
38b1c03
f1c10c6
ce2428f
7f2fd2b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,7 @@ | |
| import unittest | ||
| from typing import Any | ||
|
|
||
| from onnxscript._internal import analysis, ast_utils | ||
| from onnxscript._internal import _analysis, ast_utils | ||
| from onnxscript.onnx_opset import opset15 as op | ||
| from onnxscript.sourceinfo import formatter | ||
|
|
||
|
|
@@ -30,7 +30,7 @@ | |
| class TestLivenessAnalysis(unittest.TestCase): | ||
| def analyze(self, fun): | ||
| source, parse_tree = ast_utils.get_src_and_ast(fun) | ||
| analysis.do_liveness_analysis(parse_tree, formatter(source)) | ||
| _analysis.do_liveness_analysis(parse_tree, formatter(source)) | ||
Check failureCode scanning / lintrunner PYLINT/E1120 Error
No value for argument 'meta' in function call (no-value-for-parameter)
See no-value-for-parameter. To disable, use # pylint: disable=no-value-for-parameter |
||
| visitor = AnalysisResultsVisitor() | ||
| visitor.visit(parse_tree) | ||
| return visitor.results | ||
|
|
@@ -113,7 +113,7 @@ | |
| class TestExposedUses(unittest.TestCase): | ||
| def assertUses(self, f, expected): | ||
| source, parse_tree = ast_utils.get_src_and_ast(f) | ||
| result = analysis.exposed_uses(parse_tree.body, formatter(source)) | ||
| result = _analysis.exposed_uses(parse_tree.body, formatter(source)) | ||
| self.assertEqual(result, set(expected)) | ||
|
|
||
| def test_basic(self): | ||
|
|
@@ -190,7 +190,7 @@ | |
| class TestAssignedVarAnalysis(unittest.TestCase): | ||
| def assert_assigned_vars(self, f, expected: set[str]): | ||
| source, parse_tree = ast_utils.get_src_and_ast(f) | ||
| result = analysis.assigned_vars(parse_tree.body, formatter(source)) | ||
| result = _analysis.assigned_vars(parse_tree.body, formatter(source)) | ||
| self.assertEqual(result, expected) | ||
|
|
||
| def test_basic_defs(self): | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ | |
| from __future__ import annotations | ||
|
|
||
| import collections.abc | ||
| import copy | ||
Check warningCode scanning / lintrunner PYLINT/W0611 Warning
Unused import copy (unused-import)
See unused-import. To disable, use # pylint: disable=unused-import Check warningCode scanning / lintrunner RUFF/F401 Warning
copy imported but unused.
See https://docs.astral.sh/ruff/rules/unused-import |
||
| import dataclasses | ||
| import inspect | ||
| import logging | ||
|
|
@@ -210,7 +211,7 @@ | |
| return False | ||
|
|
||
|
|
||
| def _get_attr_type(type_: type) -> ir.AttributeType: | ||
| def get_attr_type(type_: type) -> ir.AttributeType: | ||
| """Obtain the type of the attribute from a Python class.""" | ||
| try: | ||
| if type_ in _PY_TYPE_TO_ATTR_TYPE: | ||
|
|
@@ -455,7 +456,7 @@ | |
| ) | ||
| else: | ||
| type_ = type_hints[param.name] | ||
| if (attr_type := _get_attr_type(type_)) != ir.AttributeType.UNDEFINED: | ||
| if (attr_type := get_attr_type(type_)) != ir.AttributeType.UNDEFINED: | ||
| # Construct the default attribute | ||
| if param.default is not inspect.Parameter.empty: | ||
| # TODO: Use ir_convenience instead to handle int as float | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,7 @@ | |
| from typing_extensions import ParamSpec | ||
|
|
||
| import onnxscript | ||
| from onnxscript import converter, ir, irbuilder, values | ||
| from onnxscript import _converter, ir, irbuilder, values | ||
| from onnxscript._internal import ast_utils | ||
|
|
||
| _R = TypeVar("_R") | ||
|
|
@@ -29,7 +29,7 @@ | |
| # See if conversion succeeds. | ||
| # TODO: cleanup Converter interface/API, separating checker from | ||
| # converter | ||
| convert = converter.Converter( | ||
| convert = _converter.Converter( | ||
Check failureCode scanning / lintrunner PYLINT/E1120 Error
No value for argument 'root' in constructor call (no-value-for-parameter)
See no-value-for-parameter. To disable, use # pylint: disable=no-value-for-parameter |
||
| opset=opset, | ||
| global_names=global_names, | ||
| source=source, | ||
|
|
||
Check failure
Code scanning / lintrunner
PYLINT/E1120 Error