dace icon indicating copy to clipboard operation
dace copied to clipboard

pystr_to_symbolic cannot handle methods of the DaCe namespace

Open alexnick83 opened this issue 4 years ago • 1 comments

pystr_to_symbolic cannot handle expressions with method calls that include the module/namespace in their name. For example, A + dace.int64(5) will cause an exception because the symbol dace does not have an attribute int64.

The core issue might be very difficult to solve. Sympy does not seem to have any functionality to assist with this. For example, even if you add the methods to the locals dictionary, the exception still occurs. On the other hand, the main trigger appears to be scalar promotion. If a scalar that has its value set with such an expression is promoted, the expression ends up in an interstate edge. During validation of interstate edges, pystr_to_symbolic is called on the edge expressions, triggering the exception in the process.

There are 3 potential solutions:

  • Somehow make pystr_to_symbolic handle such expressions properly (unlikely, depends on Sympy).
  • Do not promote scalars that have their value set by such expressions (probably the easiest solution, hurts some optimizations).
  • Alter the validation of interstate edges (difficult, how to detect missing symbols without pystr_to_symbolic?)

alexnick83 avatar Dec 02 '20 14:12 alexnick83

As a temporary (it can become permanent) solution, I enhanced scalar promotion with a new Python AST NodeVisitor. Whenever a candidate scalar for promotion is found in a tasklet, the NodeVisitor is used to detect whether the tasklet code contains any attributed calls. The scalar promotion is aborted in such cases.

alexnick83 avatar Dec 03 '20 12:12 alexnick83

it did :)

tbennun avatar Feb 25 '24 23:02 tbennun