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 part13: Add scalarization for TernaryOpStmt #6314

Merged
merged 3 commits into from
Oct 17, 2022

Conversation

jim19930609
Copy link
Contributor

Related issue = #5873, #5819

This PR is working "Part ④" in #5873.

Before scalarization:

TensorType<4 x i32> val = TernaryStmt(TensorType<4 x i32> cond,
                                           TensorType<4 x i32> lhs,
                                           TensorType<4 x i32> rhs)

After scalarization:

i32 val0 = TernaryStmt(cond->cast<MatrixInitStmt>()->val[0],
                       lhs->cast<MatrixInitStmt>()->val[0],
                       rhs->cast<MatrixInitStmt>()->val[0])

i32 val1 = TernaryStmt(cond->cast<MatrixInitStmt>()->val[1],
                       lhs->cast<MatrixInitStmt>()->val[1],
                       rhs->cast<MatrixInitStmt>()->val[1])

i32 val2 = TernaryStmt(cond->cast<MatrixInitStmt>()->val[2],
                       lhs->cast<MatrixInitStmt>()->val[2],
                       rhs->cast<MatrixInitStmt>()->val[2])

i32 val3 = TernaryStmt(cond->cast<MatrixInitStmt>()->val[3],
                       lhs->cast<MatrixInitStmt>()->val[3],
                       rhs->cast<MatrixInitStmt>()->val[3])

tmp = MatrixInitStmt(val0, val1, val2, val3)

stmt->replace_all_usages_with(tmp)

@netlify
Copy link

netlify bot commented Oct 13, 2022

Deploy Preview for docsite-preview canceled.

Name Link
🔨 Latest commit 8080e7b
🔍 Latest deploy log https://app.netlify.com/sites/docsite-preview/deploys/634cdf6405d4e10009901b9a

@jim19930609 jim19930609 assigned AD1024 and unassigned AD1024 Oct 13, 2022
@jim19930609 jim19930609 requested a review from AD1024 October 13, 2022 10:14
taichi/ir/frontend_ir.cpp Outdated Show resolved Hide resolved
taichi/transforms/scalarize.cpp Show resolved Hide resolved
@jim19930609 jim19930609 merged commit 20b67ff into taichi-dev:master Oct 17, 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.

3 participants