Skip to content

Conversation

@justinchuby
Copy link
Collaborator

Continuation of #2457

Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Copy link
Contributor

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lintrunner found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
result = self._converter.op(
"Constant", [], attrs=[attr]
)
if is_base_type_bool(attr):
Comment on lines +479 to +485
# for pyvar, previous in val.outer_scope_variables:
# current = self._lookup(pyvar, self._source_of(expr))
# if current.value != previous.value:
# self.fail(
# expr,
# f"Outer scope variable '{pyvar}' referenced by function "
# f"'{expr.id!r}' modified.",
# First separate inputs from attributes. This is needed because in Python
# it is possible to pass onnx inputs as kwargs
inputs, attrs = _separate_inputs_and_attrs(op_signature, args, kwargs)
onnx_inputs = [self._translate_opt_expr(x) for x in inputs]
@codecov
Copy link

codecov bot commented Oct 29, 2025

Codecov Report

❌ Patch coverage is 7.86517% with 246 lines in your changes missing coverage. Please review.
✅ Project coverage is 10.79%. Comparing base (ee9a6e8) to head (7a0b016).

Files with missing lines Patch % Lines
onnxscript/_converter.py 5.15% 239 Missing ⚠️
onnxscript/_converter_test.py 0.00% 3 Missing ⚠️
onnxscript/_internal/autocast.py 0.00% 1 Missing ⚠️
onnxscript/ir/_schemas.py 50.00% 1 Missing ⚠️
onnxscript/main.py 50.00% 1 Missing ⚠️
onnxscript/values.py 50.00% 1 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (ee9a6e8) and HEAD (7a0b016). Click for more details.

HEAD has 19 uploads less than BASE
Flag BASE (ee9a6e8) HEAD (7a0b016)
21 2
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #2665       +/-   ##
===========================================
- Coverage   70.42%   10.79%   -59.64%     
===========================================
  Files         224      214       -10     
  Lines       26729    25160     -1569     
  Branches     2673     2564      -109     
===========================================
- Hits        18825     2715    -16110     
- Misses       6973    22434    +15461     
+ Partials      931       11      -920     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

"""
self.name = name
self.is_castable = castable
class DynamicKind(IntFlag):

Check failure

Code scanning / lintrunner

PYLINT/E0602 Error

Undefined variable 'IntFlag' (undefined-variable)
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

"""
self.name = name
self.is_castable = castable
class DynamicKind(IntFlag):

Check failure

Code scanning / lintrunner

MYPY/name-defined Error

Name "IntFlag" is not defined To disable, use # type: ignore[name-defined]
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

Statement seems to have no effect (pointless-statement)
See pointless-statement. To disable, use # pylint: disable=pointless-statement
self._converter = converter

def get_or_create_value(
self, var: str, info: sourceinfo.SourceInfo

Check warning

Code scanning / lintrunner

PYLINT/W0613 Warning

Unused argument 'info' (unused-argument)
See unused-argument. To disable, use # pylint: disable=unused-argument
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

Name "_converter.Variable" is not defined To disable, use # type: ignore[name-defined]
"""

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

Name "_converter.Variable" is not defined To disable, use # type: ignore[name-defined]

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

Name "_converter.Variable" is not defined To disable, use # type: ignore[name-defined]
# TODO: cleanup Converter interface/API, separating checker from
# converter
convert = converter.Converter(
convert = _converter.Converter(

Check failure

Code 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
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

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
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]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

? Why is this related to SOURCE_INFO?


class Variable:
"""Represents an ONNX variable.
_CASTABLE_FIELD = "pkg.onnxscript.converter.castable"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: why not just call these _CASTABLE and _SOURCEINFO ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also: I wonder about the use "pkg" ... while a conflict seems unlikely, it would be good to set and follow some conventions for the metadata key strings to avoid conflicts between different tools metadata. The ONNX spec says use reverse domain name, just like for custom domain names for opsets: https://github.com/onnx/onnx/blob/main/docs/IR.md#other-metadata
Of course, too bad we dont have onnxscript.ai domain, but we could in ONNX standard reserve names like that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think pkg. is a legitimate reverse domain (style) name?

attr.meta[_SOURCEINFO_FIELD]

@dataclasses.dataclass
class ASTMeta:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is no longer needed


class _ValueEnvironment:
def __init__(self, converter: Converter):
self._py_var_name_to_ir_values: dict[str, ir.Value] = {}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I see the value in splitting this map into three maps?

self._current_fn: irbuilder.IRFunction = None
# TODO(justinchuby): Update ir version to be user defined
# TODO(justinchuby): Maybe just store a list of functions
self._model = ir.Model(ir.Graph((), (), nodes=()), ir_version=10)
Copy link
Collaborator

@gramalingam gramalingam Oct 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit (can be fixed later too): not sure we need to create an ir.Model ahead of time ... eg., if this is just intended to be used as a function/FunctionProto

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

3 participants