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 kernel to return a matrix type value #4062

Merged
merged 79 commits into from
Mar 1, 2022

Conversation

mzmzm
Copy link
Contributor

@mzmzm mzmzm commented Jan 19, 2022

Related issue = #909

@vercel
Copy link

vercel bot commented Jan 19, 2022

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/taichi-api-docs-preview/taichi/5AJpZJ3nC1X27PZk1e5LHLeK81QM
✅ Preview: https://taichi-git-fork-mzmzm-matrixreturntype1-taichi-api-docs-preview.vercel.app

[Deployment for df16c95 failed]

@netlify
Copy link

netlify bot commented Jan 19, 2022

✔️ Deploy Preview for docsite-preview ready!

🔨 Explore the source changes: eedfc8b

🔍 Inspect the deploy log: https://app.netlify.com/sites/docsite-preview/deploys/621d8bac25217a000740397c

😎 Browse the preview: https://deploy-preview-4062--docsite-preview.netlify.app

@mzmzm mzmzm marked this pull request as ready for review February 18, 2022 06:15
@mzmzm mzmzm requested review from bobcao3 and strongoier February 18, 2022 06:50
@mzmzm mzmzm assigned mzmzm and unassigned mzmzm Feb 21, 2022
tests/python/test_matrix_return.py Show resolved Hide resolved
tests/python/test_matrix_return.py Outdated Show resolved Hide resolved
taichi/python/export_lang.cpp Outdated Show resolved Hide resolved
taichi/ir/type_utils.h Outdated Show resolved Hide resolved
taichi/program/kernel.cpp Outdated Show resolved Hide resolved
taichi/transforms/type_check.cpp Outdated Show resolved Hide resolved
taichi/codegen/codegen_llvm.cpp Outdated Show resolved Hide resolved
taichi/backends/cc/cc_program.cpp Show resolved Hide resolved
@mzmzm mzmzm requested a review from strongoier February 25, 2022 05:14
spirv::Value buffer_val = ir_->make_value(
spv::OpAccessChain,
ir_->get_storage_pointer_type(ir_->get_primitive_type(dt)),
get_buffer_value(BufferType::Rets, PrimitiveType::i32),
get_buffer_value(BufferType::Rets, dt),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Sorry I don't quite get it here. Why would this be able to return a matrix?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now we only support return one value, so if the return type is the matrix, its elements will be involved in stmt->values. Likewise, ctx_attribs_->rets()'s size will always be one. dt is the primitive type of the matrix element. And in the spir-v backend, I use a StructType to include an ArrayType, the matrix will be squeezed to an array when compiling. So to access the element, I change the argument of OpAccessChain, 0,i instead of i.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For the scalar return type, I also use an ArrayType to involve this return value. So I can do the same operations when dealing with matrix and scalar.

taichi/transforms/type_check.cpp Show resolved Hide resolved
taichi/backends/opengl/codegen_opengl.cpp Show resolved Hide resolved
taichi/codegen/spirv/kernel_utils.cpp Outdated Show resolved Hide resolved
taichi/codegen/spirv/spirv_codegen.cpp Outdated Show resolved Hide resolved
@bobcao3
Copy link
Collaborator

bobcao3 commented Feb 28, 2022

/rerun

mzmzm added 3 commits March 1, 2022 10:45
…_return_type1

# Conflicts:
#	taichi/codegen/spirv/spirv_codegen.cpp
@mzmzm
Copy link
Contributor Author

mzmzm commented Mar 1, 2022

/format

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!

@strongoier strongoier merged commit 46fc8f5 into taichi-dev:master Mar 1, 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.

4 participants