Skip to content

Commit

Permalink
Revert "cinn(py-dsl): skip eval string in python-dsl (PaddlePaddle#61380
Browse files Browse the repository at this point in the history
) (PaddlePaddle#61586)"

This reverts commit a37f6fb.
  • Loading branch information
hanhaowen-mt committed May 13, 2024
1 parent 3cb02eb commit 0d28793
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions python/cinn/compiler/expr_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,14 @@ def visit(self, node):
value = exec_func(cls_fields)
else:
new_node = node.__class__(**cls_fields)
ast.copy_location(new_node, node)
new_node = ast.Expression(new_node)
value = self.exec_expr(new_node)
return self.save_temp_value(value)

def exec_expr(self, node):
assert isinstance(node, ast.expr)
if type(node).__name__ == "Constant":
return node.value

node = ast.Expression(node)
if isinstance(node, ast.expr):
node = ast.Expression(body=node)
node = ast.fix_missing_locations(node)
exec = compile(node, filename="<ast>", mode="eval")
return eval(exec, self.var_table)
Expand Down

0 comments on commit 0d28793

Please sign in to comment.