Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions onnxscript/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,14 +435,10 @@ def _is_constant_expr(self, node: ast.AST) -> None:
ast.BinOp,
ast.UnaryOp,
ast.Compare,
ast.Num,
ast.Str,
ast.Attribute,
ast.List,
ast.Load,
ast.NameConstant,
ast.Constant,
ast.Str,
),
):
return all(self._is_constant_expr(c) for c in ast.iter_child_nodes(node))
Expand Down Expand Up @@ -580,7 +576,7 @@ def _translate_opt_expr(self, node: ast.expr) -> Optional[Variable]:
"""Translation of an expression where "None" is permitted (eg., for an optional argument).
None is represented as a NameConstant in Python 3.7 and Constant in Python 3.9.
"""
if isinstance(node, (ast.NameConstant, ast.Constant)) and (node.value is None):
if isinstance(node, ast.Constant) and (node.value is None):
return None
return self._translate_expr(node)

Expand Down
2 changes: 1 addition & 1 deletion onnxscript/converter_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ def f1(A: FLOAT[...]) -> FLOAT[...]:
return r

ast_name = "_ast" if sys.version_info[:2] < (3, 9) else "ast"
self.check_failure(f1, f"Left term must be a tuple not '<class '{ast_name}.Name'>'")
self.check_failure(f1, f"Left term must be a tuple not '<class '{ast_name}.Constant'>'")

def check_run(self, onnxfn, inputs, expected_output):
# Test by converting to model and running with ORT
Expand Down
Loading