Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Python AST subset for algorithm definition #9

Open
4 tasks
hidmic opened this issue Sep 19, 2021 · 0 comments
Open
4 tasks

Use Python AST subset for algorithm definition #9

hidmic opened this issue Sep 19, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@hidmic
Copy link
Owner

hidmic commented Sep 19, 2021

Rationale

Alternative to #2. Algorithms are defined via sympy symbolic expressions solely to enable term permutation in summations. But such permutations would also be possible in a Python AST.

Why not ast.parse a function definition to extract its AST? Some feature (i.e. node) pruning is necessary as most Python features are way beyond scope and would be near impossible to transfer upon C or HDL generation, but otherwise this approach would greatly simplify algorithm definitions and potentially boost speed -- sympy is just too slow.

Definition of done

  • Define a Python language subset to support.
    • At the very least, variables, arithmetic operators, integer literals.
  • Implement a function (or decorator) to extract the AST.
  • Refactor ltitop.algorithm module to deal with the new AST.
  • Rewrite algorithm definitions in ltitop.topology using plain Python.

Additional considerations

Generators and list comprehensions would be super useful when defining sums and products, but, if supported, these have to be expanded upon AST extraction (or term permutation will not be possible). Also, the feature set must be kept at a minimum -- enough to guarantee that algorithms are simply describing operations on a data-flow (or code generation may not be possible).

@hidmic hidmic added the enhancement New feature or request label Sep 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant