Skip to content

Commit

Permalink
[Relay][Testing][Bugfix] py_converter should use correct AST for ve…
Browse files Browse the repository at this point in the history
…rsions above 3.8 too (apache#13635)

Currently, `relay.testing.py_converter` is checking for using _exactly_ Python 3.8 in order to use certain updated signatures in the `ast` library. However, those signatures are also correct for versions _above_ 3.8. This PR changes the bounds checks so that the converter will work above 3.8.
  • Loading branch information
slyubomirsky authored and Mikael Sevenier committed Dec 29, 2022
1 parent 211ea15 commit 8eb6ab3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions python/tvm/relay/testing/py_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def convert(self, prog: Expr):
body.append(Assign([Name(OUTPUT_VAR_NAME, Store())], prog_body))
global __MAJOR__, __MINOR__

if __MAJOR__ == 3 and __MINOR__ == 8:
if __MAJOR__ == 3 and __MINOR__ >= 8:
return ast.fix_missing_locations(ast.Module(body=body, type_ignores=[]))
else:
return ast.fix_missing_locations(ast.Module(body=body))
Expand Down Expand Up @@ -224,7 +224,7 @@ def create_def(self, func_name: str, arguments: [str], body):
inner_args = [ast.arg(argument, None) for argument in arguments]

global __MAJOR__, __MINOR__
if __MAJOR__ == 3 and __MINOR__ == 8:
if __MAJOR__ == 3 and __MINOR__ >= 8:
arguments = ast.arguments([], inner_args, None, [], [], None, [])
else:
arguments = ast.arguments(inner_args, None, [], [], None, [])
Expand Down

0 comments on commit 8eb6ab3

Please sign in to comment.