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] MatrixNdarray refactor part4: Lowered TensorType to CHI IR level for elementwise-indexed MatrixNdarray #5936

Merged
merged 39 commits into from
Sep 6, 2022

Conversation

jim19930609
Copy link
Contributor

@jim19930609 jim19930609 commented Sep 1, 2022

Related issue = #5873, #5819

This PR is working on "Part ②", "Part ③" and "Part ④" in #5873.

[Overview]
When "real_matrix = True", suppose we have the following code with elementwise-indexed MatrixNdarray involved:

@ti.kernel
def func(a: ti.types.ndarray()):
    for i in range(5):
        for j in range(4):
            a[i][j * j] = j * j 

v = ti.Vector.ndarray(10, ti.i32, 5, layout=ti.AOS)
func(v)

The lowering pass will be:

NdarrayMatrix_Indexing drawio

[Major changes]

  1. Change on Frontend Language
    In python/taichi/lang/impl.py, we modified subscript methods to turn-off scalarization for ExternalTensorExpression.

  2. Change on IR (with real_matrix = True):

  • ArgLoadStmt: Now able to return TensorType
  • PtrOffsetStmt: Now able to take ExternalPtrStmt as base pointer
  • IndexExpression: Now able to index ExternalTensorExpression
  1. Change on CodeGen
    Adjusted codegen logic for ArgLoadStmt, PtrOffsetStmt and ExternalPtrStmt to correctly handle TensorType

…uction in Ndarray and refactored the use of element_shape
@netlify
Copy link

netlify bot commented Sep 1, 2022

Deploy Preview for docsite-preview ready!

Name Link
🔨 Latest commit 18cecc2
🔍 Latest deploy log https://app.netlify.com/sites/docsite-preview/deploys/631195a961c4580008fe7cda
😎 Deploy Preview https://deploy-preview-5936--docsite-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@jim19930609 jim19930609 changed the title [Lang] MatrixNdarray refactor part4: Lowered TensorType to CHI IR level for dual-indexed MatrixNdarray [Lang] MatrixNdarray refactor part4: Lowered TensorType to CHI IR level for elementwise-indexed MatrixNdarray Sep 1, 2022
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!! Only some nits.

@jim19930609 jim19930609 merged commit 20116c2 into taichi-dev:master Sep 6, 2022
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.

2 participants