-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Conversation
# Conflicts: # python/taichi/lang/ast/ast_transformer.py # taichi/backends/cc/codegen_cc.cpp # taichi/backends/metal/codegen_metal.cpp # taichi/backends/opengl/codegen_opengl.cpp # taichi/codegen/codegen_llvm.cpp # taichi/codegen/spirv/spirv_codegen.cpp # taichi/inc/constants.h # taichi/ir/statements.h # taichi/transforms/lower_ast.cpp # taichi/transforms/type_check.cpp
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/taichi-api-docs-preview/taichi/5AJpZJ3nC1X27PZk1e5LHLeK81QM [Deployment for df16c95 failed] |
✔️ 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 |
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), |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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.
/rerun |
/format |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Related issue = #909