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

[RFC] Implementation plan for MatrixField refactor #5959

Open
strongoier opened this issue Sep 2, 2022 · 0 comments
Open

[RFC] Implementation plan for MatrixField refactor #5959

strongoier opened this issue Sep 2, 2022 · 0 comments
Labels

Comments

@strongoier
Copy link
Contributor

strongoier commented Sep 2, 2022

Sub-task of #5819. The following image shows the ideal state we would like to achieve:

MatrixField_Plan_v2

@strongoier strongoier added the feature request Suggest an idea on this project label Sep 2, 2022
@taichi-gardener taichi-gardener moved this to Untriaged in Taichi Lang Sep 2, 2022
@strongoier strongoier added RFC and removed feature request Suggest an idea on this project labels Sep 2, 2022
@strongoier strongoier moved this from Untriaged to In Progress in Taichi Lang Sep 2, 2022
strongoier added a commit that referenced this issue Sep 15, 2022
Related issue = #5959

This PR adds definition of `MatrixFieldExpression`, which serves as the
representation of a matrix field in C++. Currently only
`dynamic_index_stride` has been completely moved there. Others will get
migrated in future PRs.

<!--
Thank you for your contribution!

If it is your first time contributing to Taichi, please read our
Contributor Guidelines:
  https://docs.taichi-lang.org/docs/contributor_guide

- Please always prepend your PR title with tags such as [CUDA], [Lang],
[Doc], [Example]. For a complete list of valid PR tags, please check out
https://github.com/taichi-dev/taichi/blob/master/misc/prtags.json.
- Use upper-case tags (e.g., [Metal]) for PRs that change public APIs.
Otherwise, please use lower-case tags (e.g., [metal]).
- More details:
https://docs.taichi-lang.org/docs/contributor_guide#pr-title-format-and-tags

- Please fill in the issue number that this PR relates to.
- If your PR fixes the issue **completely**, use the `close` or `fixes`
prefix so that GitHub automatically closes the issue when the PR is
merged. For example,
    Related issue = close #2345
- If the PR does not belong to any existing issue, free to leave it
blank.
-->

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
strongoier added a commit that referenced this issue Sep 16, 2022
…tion (#6074)

Related issue = #5959, #4857

Support for different element types of matrix fields was introduced in
#2135 for quant. As discussed in
#4857 (comment),
the only case we need to support is different element types with **same
compute type**. This PR adds the validity check and removes test cases
which are actually not allowed.

<!--
Thank you for your contribution!

If it is your first time contributing to Taichi, please read our
Contributor Guidelines:
  https://docs.taichi-lang.org/docs/contributor_guide

- Please always prepend your PR title with tags such as [CUDA], [Lang],
[Doc], [Example]. For a complete list of valid PR tags, please check out
https://github.com/taichi-dev/taichi/blob/master/misc/prtags.json.
- Use upper-case tags (e.g., [Metal]) for PRs that change public APIs.
Otherwise, please use lower-case tags (e.g., [metal]).
- More details:
https://docs.taichi-lang.org/docs/contributor_guide#pr-title-format-and-tags

- Please fill in the issue number that this PR relates to.
- If your PR fixes the issue **completely**, use the `close` or `fixes`
prefix so that GitHub automatically closes the issue when the PR is
merged. For example,
    Related issue = close #2345
- If the PR does not belong to any existing issue, free to leave it
blank.
-->

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
strongoier added a commit that referenced this issue Sep 21, 2022
… into CHI IR (#6119)

Issue: #5959

### Brief Summary

This PR lowers access of matrix field element into CHI IR. To verify its
functionality, this PR also makes the following path of #5959 running
end-to-end (currently only enabled when `real_matrix=True`):


![MatrixField_Part5](https://user-images.githubusercontent.com/3251060/191258468-d3b0237f-6e0e-47ce-844f-5516103d05de.png)

Key steps:
- Python: when running into subscript of `MatrixField`, create
`IndexExpression` in C++ instead of building `_MatrixFieldElement` in
Python
- Frontend IR: allow `IndexExpression` to take `MatrixFieldExpression`
- CHI IR: add `MatrixOfGlobalPtrStmt`; add `lower_matrix_ptr` pass,
which demotes `PtrOffsetStmt(MatrixOfGlobalPtrStmt)` into
`GlobalPtrStmt` in the case of constant index - this is incomplete and
only aims at supporting the above path

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
strongoier added a commit that referenced this issue Sep 22, 2022
…ion (#6137)

Issue: #5959

### Brief Summary

This PR demonstrates that the following path of #5959 can also run
end-to-end:


![MatrixField_Part6](https://user-images.githubusercontent.com/3251060/191686873-839fd9c2-11fb-4fea-b648-3350a3992779.png)
strongoier added a commit that referenced this issue Sep 28, 2022
…cation and access (#6169)

Issue: #5959

### Brief Summary

This PR enforces that the return value of
`AllocaStmt(TensorType)/GlobalTemporaryStmt(TensorType)` is a pointer to
a `VectorType/ArrayType` (we no longer use a primitive type ptr for
`TensorType`) so that the codegen can be simplified a lot.

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
strongoier added a commit that referenced this issue Sep 28, 2022
…6187)

Issue: #5959

### Brief Summary

`PtrOffsetStmt` is for getting a pointer to an element of a matrix.
Let's make it follow the naming convention (`XXXPtrStmt`) for clarity.
strongoier added a commit that referenced this issue Sep 29, 2022
…when real_matrix=True (#6194)

Issue: #5959

### Brief Summary

This PR makes the rightmost path of #5959 running end-to-end.

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: In Progress
Development

No branches or pull requests

1 participant