Skip to content

Commit

Permalink
scal2sym: Try to symbolically simplify expressions on promotion
Browse files Browse the repository at this point in the history
  • Loading branch information
tbennun committed Aug 7, 2023
1 parent 245b028 commit 38e623f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions dace/transformation/passes/scalar_to_symbol.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import collections
import re
from dataclasses import dataclass
import sympy as sp
from typing import Any, DefaultDict, Dict, Set, Tuple

import dace
Expand Down Expand Up @@ -661,6 +662,13 @@ def apply_pass(self, sdfg: SDFG, _: Dict[Any, Any]) -> Set[str]:
elif input.language is dtypes.Language.CPP:
newcode = translate_cpp_tasklet_to_python(input.code.as_string.strip())

# Try to symbolically simplify expression
try:
symcode = symbolic.pystr_to_symbolic(newcode)
newcode = symbolic.symstr(symcode)
except (TypeError, sp.SympifyError):
pass

# Replace tasklet inputs with incoming edges
for e in new_state.in_edges(input):
memlet_str: str = e.data.data
Expand Down

0 comments on commit 38e623f

Please sign in to comment.