-
Notifications
You must be signed in to change notification settings - Fork 86
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?
Conversation
Signed-off-by: Justin Chu <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
❌ 176 Tests Failed:
View the top 3 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
Signed-off-by: Justin Chu <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
op_signature, args, kwargs | ||
) | ||
args = [self._translate_opt_expr(x) for x in args] | ||
onnx_inputs = [self._translate_opt_expr(x) for x in inputs] |
Check warning
Code scanning / lintrunner
PYLINT/W0612 Warning
See unused-variable. To disable, use # pylint: disable=unused-variable
op_signature, args, kwargs | ||
) | ||
args = [self._translate_opt_expr(x) for x in args] | ||
onnx_inputs = [self._translate_opt_expr(x) for x in inputs] |
Check warning
Code scanning / lintrunner
RUFF/F841 Warning
See https://docs.astral.sh/ruff/rules/unused-variable
elif kwargs.get(param.name) is not None: | ||
attribute = kwargs[param.name] # type: ignore[assignment] | ||
else: | ||
if param.required: |
Check notice
Code scanning / lintrunner
PYLINT/R1720 Note
See no-else-raise. To disable, use # pylint: disable=no-else-raise
from __future__ import annotations | ||
|
||
import collections.abc | ||
import copy |
Check warning
Code scanning / lintrunner
PYLINT/W0611 Warning
See unused-import. To disable, use # pylint: disable=unused-import
from __future__ import annotations | ||
|
||
import collections.abc | ||
import copy |
Check warning
Code scanning / lintrunner
RUFF/F401 Warning
See https://docs.astral.sh/ruff/rules/unused-import
Signed-off-by: Justin Chu <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
top_level_ast = ast.parse(source) | ||
f_ast = top_level_ast.body[0] | ||
cvt = converter.Converter( | ||
cvt = _converter.Converter( |
Check failure
Code scanning / lintrunner
PYLINT/E1120 Error
See no-value-for-parameter. To disable, use # pylint: disable=no-value-for-parameter
# TODO: cleanup Converter interface/API, separating checker from | ||
# converter | ||
convert = converter.Converter( | ||
convert = _converter.Converter( |
Check failure
Code scanning / lintrunner
PYLINT/E1120 Error
See no-value-for-parameter. To disable, use # pylint: disable=no-value-for-parameter
global_names = module.__dict__.copy() | ||
global_names.update(closure.nonlocals) | ||
converter = converter_module.Converter( | ||
converter = _converter.Converter( |
Check failure
Code scanning / lintrunner
PYLINT/E1120 Error
See no-value-for-parameter. To disable, use # pylint: disable=no-value-for-parameter
Signed-off-by: Justin Chu <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
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 failure
Code scanning / lintrunner
PYLINT/E1120 Error
See no-value-for-parameter. To disable, use # pylint: disable=no-value-for-parameter
Signed-off-by: Justin Chu <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
converter_: _converter.Converter, | ||
op_schema: Optional[OpSchema], | ||
args: Sequence[Optional[converter.Variable]], | ||
args: Sequence[Optional[_converter.Variable]], |
Check failure
Code scanning / lintrunner
MYPY/name-defined Error
""" | ||
|
||
def get_type_info(x: Optional[converter.Variable]) -> Optional[converter.Variable]: | ||
def get_type_info(x: Optional[_converter.Variable]) -> Optional[_converter.Variable]: |
Check failure
Code scanning / lintrunner
MYPY/name-defined Error
|
||
def cast_like( | ||
x: Optional[converter.Variable], y: Optional[converter.Variable] | ||
x: Optional[_converter.Variable], y: Optional[_converter.Variable] |
Check failure
Code scanning / lintrunner
MYPY/name-defined Error
Signed-off-by: Justin Chu <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
tensor = autocast.pyvalue_to_onnx_tensor(ovar, pyvalue) | ||
except ValueError as e: | ||
tensor = ir.tensor(pyvalue, name=var_name) | ||
except Exception as e: |
Check warning
Code scanning / lintrunner
PYLINT/W0718 Warning
See broad-exception-caught. To disable, use # pylint: disable=broad-exception-caught
preferred_name = f"return_val{suffix}" | ||
return_var = self._translate_expr(exp, preferred_name).name | ||
val = self._lookup(return_var, self._source_of(exp), False) | ||
assert type(val) is values.Dynamic |
Check notice
Code scanning / lintrunner
PYLINT/C0123 Note
See unidiomatic-typecheck. To disable, use # pylint: disable=unidiomatic-typecheck
Signed-off-by: Justin Chu <[email protected]>
return tuple(reversed(inputs_reversed)), named_attrs | ||
|
||
|
||
def _to_onnx_ref_attr(val: values.AttrRef, info: sourceinfo.SourceInfo | None) -> ir.Attr: |
Check failure
Code scanning / lintrunner
MYPY/name-defined Error
|
||
from onnxscript import converter as converter_module | ||
from onnxscript import irbuilder, sourceinfo, type_annotation | ||
from onnxscript import _converter, irbuilder, sourceinfo, type_annotation |
Check warning
Code scanning / lintrunner
PYLINT/W0611 Warning
See unused-import. To disable, use # pylint: disable=unused-import
|
||
from onnxscript import converter as converter_module | ||
from onnxscript import irbuilder, sourceinfo, type_annotation | ||
from onnxscript import _converter, irbuilder, sourceinfo, type_annotation |
Check warning
Code scanning / lintrunner
RUFF/F401 Warning
See https://docs.astral.sh/ruff/rules/unused-import
Signed-off-by: Justin Chu <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
Sequence, | ||
Tuple, | ||
Union, | ||
_GenericAlias |
Check warning
Code scanning / lintrunner
RUFF/F401 Warning
See https://docs.astral.sh/ruff/rules/unused-import
""" | ||
self.name = name | ||
self.is_castable = castable | ||
class DynamicKind(IntFlag): |
Check failure
Code scanning / lintrunner
PYLINT/E0602 Error
See undefined-variable. To disable, use # pylint: disable=undefined-variable
""" | ||
self.name = name | ||
self.is_castable = castable | ||
class DynamicKind(IntFlag): |
Check failure
Code scanning / lintrunner
RUFF/F821 Error
See https://docs.astral.sh/ruff/rules/undefined-name
""" | ||
self.name = name | ||
self.is_castable = castable | ||
class DynamicKind(IntFlag): |
Check failure
Code scanning / lintrunner
MYPY/name-defined Error
self._converter = converter | ||
|
||
def get_or_create_value( | ||
self, var: str, info: sourceinfo.SourceInfo |
Check warning
Code scanning / lintrunner
PYLINT/W0613 Warning
See unused-argument. To disable, use # pylint: disable=unused-argument
Signed-off-by: Justin Chu <[email protected]>
def is_base_type_bool(attr: ir.Attr) -> bool: | ||
"""Check if the attribute is a boolean type.""" | ||
# FIXME: Add meta to attributes | ||
attr.meta[_SOURCEINFO_FIELD] |
Check warning
Code scanning / lintrunner
PYLINT/W0104 Warning
See pointless-statement. To disable, use # pylint: disable=pointless-statement
Signed-off-by: Justin Chu [email protected]