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

[Lang] Support annotated assignment #3709

Merged
merged 13 commits into from
Dec 7, 2021

Conversation

woooodyye
Copy link
Contributor

@woooodyye woooodyye commented Dec 4, 2021

Related issue = #2610

@netlify
Copy link

netlify bot commented Dec 4, 2021

✔️ Deploy Preview for jovial-fermat-aa59dc canceled.

🔨 Explore the source changes: 638fb92

🔍 Inspect the deploy log: https://app.netlify.com/sites/jovial-fermat-aa59dc/deploys/61ae6f0c4f2ad30008d6befc

@strongoier
Copy link
Contributor

Hi @woooodyye. Which PR is the version you would like to get reviewed, this or #3701?

@woooodyye
Copy link
Contributor Author

hi, can I get this PR draft reviewed ? I think #3701 has formatting issues. Thanks. @strongoier

Copy link
Contributor

@strongoier strongoier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

python/taichi/lang/ast/ast_transformer.py Outdated Show resolved Hide resolved
python/taichi/lang/ast/ast_transformer.py Outdated Show resolved Hide resolved
python/taichi/lang/ast/ast_transformer.py Show resolved Hide resolved
@strongoier strongoier changed the title [Lang] #2610 add typed build assign [Lang] Support annotated assignment Dec 5, 2021
@strongoier
Copy link
Contributor

/format

@woooodyye woooodyye marked this pull request as ready for review December 6, 2021 04:41
@woooodyye
Copy link
Contributor Author

please ignore the review request

@woooodyye
Copy link
Contributor Author

Right Now. Since annotations are not considered as variables, we need to explicitly define a primitive type as a value for the primitive types to be considered as variables.

For Instance:
a: ti.i32 = 1
would not work.

Instead, we need to do something like

my_int = ti.i32
a : my_int = 1

Note: the primitive type you declare doesn't necessarily need to be the type annotation you want to use, It's totally fine to do

my_int = ti.i32
a : ti.f32 = 1.
b : ti.f64 = 2
.......

The whole point of this my_int = ti.i32 declaration statement is to introduce ti.primitivetypes into the global variables.

Copy link
Contributor

@strongoier strongoier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! Only some nits.

python/taichi/lang/ast/ast_transformer.py Outdated Show resolved Hide resolved
python/taichi/lang/ast/ast_transformer.py Outdated Show resolved Hide resolved
python/taichi/lang/ast/ast_transformer.py Outdated Show resolved Hide resolved
python/taichi/lang/ast/ast_transformer.py Outdated Show resolved Hide resolved
tests/python/test_assign.py Outdated Show resolved Hide resolved
tests/python/test_assign.py Outdated Show resolved Hide resolved
tests/python/test_assign.py Outdated Show resolved Hide resolved
Copy link
Contributor

@strongoier strongoier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants