Skip to content

Commit 0d28793

Browse files
committed
Revert "cinn(py-dsl): skip eval string in python-dsl (PaddlePaddle#61380) (PaddlePaddle#61586)"
This reverts commit a37f6fb.
1 parent 3cb02eb commit 0d28793

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

python/cinn/compiler/expr_executor.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,14 @@ def visit(self, node):
8181
value = exec_func(cls_fields)
8282
else:
8383
new_node = node.__class__(**cls_fields)
84+
ast.copy_location(new_node, node)
85+
new_node = ast.Expression(new_node)
8486
value = self.exec_expr(new_node)
8587
return self.save_temp_value(value)
8688

8789
def exec_expr(self, node):
88-
assert isinstance(node, ast.expr)
89-
if type(node).__name__ == "Constant":
90-
return node.value
91-
92-
node = ast.Expression(node)
90+
if isinstance(node, ast.expr):
91+
node = ast.Expression(body=node)
9392
node = ast.fix_missing_locations(node)
9493
exec = compile(node, filename="<ast>", mode="eval")
9594
return eval(exec, self.var_table)

0 commit comments

Comments
 (0)