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

(Prototype) Generate the frontend AST when traversing the Python one #3038

Closed
78 tasks done
k-ye opened this issue Sep 28, 2021 · 0 comments · Fixed by #3527
Closed
78 tasks done

(Prototype) Generate the frontend AST when traversing the Python one #3038

k-ye opened this issue Sep 28, 2021 · 0 comments · Fixed by #3527
Assignees
Labels
c++ C++ engineering related discussion Welcome discussion! experimental The feature is experimental, no grantee feature request Suggest an idea on this project python Python engineering related

Comments

@k-ye
Copy link
Member

k-ye commented Sep 28, 2021

Concisely describe the proposed feature

Right now Taichi generates its C++ AST in the following steps:

  1. Traverse the Python AST, substitutes many parts into function calls to build the C++ AST
  2. Compile this transformed Python AST back to a Python function
  3. Invoke the Python function, so that the C++ AST is built

Describe the solution you'd like (if any)

Build the C++ AST directly while traversing the Python AST.

AST Node Implementation Progress

Based on https://docs.python.org/3.9/library/ast.html#abstract-grammar

mod

  • Module
  • Interactive
  • Expression
  • FunctionType

stmt

  • FunctionDef

    • return value
    • kernel arguments
      • ti.template
      • ti.sparse_matrix_builder
      • ti.any_arr
      • scalar
    • function arguments
  • AsyncFunctionDef

  • ClassDef

  • Return

  • Delete

  • Assign

    • static assign
    • normal assign
  • AugAssign

  • AnnAssign

  • For

    • static range/ndrange for
    • static grouped for
    • range for
    • ndrange for
    • grouped ndrange for
    • struct for
    • grouped struct for
  • AsyncFor

  • While

  • If

    • static if
    • normal if
  • With

  • AsyncWith

  • Raise

  • Try

  • Assert

  • Import

  • ImportFrom

  • Global

  • Nonlocal

  • Expr

  • Pass

  • Break

  • Continue

expr

  • BoolOp

  • NamedExpr

  • BinOp

  • UnaryOp

  • Lambda

  • IfExp

  • Dict

  • Set

  • ListComp

  • SetComp

  • DictComp

  • GeneratorExp

  • Await

  • Yield

  • YieldFrom

  • Compare

    • Chain comparison (left op[0] comparators[0]) and (comparators[0] op[1] comparators[1]) and ...
  • Call

    • basic function call
    • built-in to ti functions
  • FormattedValue

  • JoinedStr

  • Constant

  • Attribute

  • Subscript

  • Starred

  • Name

  • List

  • Tuple

  • Slice

other

  • real function support
@k-ye k-ye added feature request Suggest an idea on this project python Python engineering related c++ C++ engineering related discussion Welcome discussion! experimental The feature is experimental, no grantee labels Sep 28, 2021
@strongoier strongoier added this to In progress in Lang Features & Python Oct 27, 2021
Lang Features & Python automation moved this from In progress to Done Nov 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ C++ engineering related discussion Welcome discussion! experimental The feature is experimental, no grantee feature request Suggest an idea on this project python Python engineering related
Development

Successfully merging a pull request may close this issue.

2 participants