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] Let kernel argument support matrix nested in a struct #7873

Closed
wants to merge 9 commits into from

Conversation

lin-hitonami
Copy link
Contributor

@lin-hitonami lin-hitonami commented Apr 23, 2023

Issue: fixes #7821
A matrix is compiled to a struct with n * m elements because the support for matrix arguments is not ready on SPIR-V based backends.

Deleted the test testing the error when the arguments exceed 64 because it doesn't have the limit anymore. I will remove the code that raises the error in another PR.

Refactored the argument passing logic of CGraph and C-API as well.

🤖 Generated by Copilot at a2ac2c9

Summary

🧮🛠️🚀

This pull request adds support for matrix and struct arguments in the C++ and C APIs, the AOT graph mode, and the SPIR-V based backends. It does this by introducing new types and functions to represent and handle tensor arguments, modifying the kernel argument processing and launching logic in Python and C++, and updating the code generation and offloading logic for SPIR-V. It also simplifies and fixes some issues with the initialization of the runtime context and the access chain creation for SPIR-V.

To pass tensors and matrices to kernels
We need to flatten them to structs or scalars
We use set_kernel_struct_args and get_type_for_kernel_args
To handle the different cases and casts
And update the codegen for SPIR-V and others

Walkthrough

  • Add support for tensor arguments in the C API (link, link, link, link, link, link)
  • Simplify the representation of matrix arguments in the graph data structure and the Python API (link, link, link, link, link)
  • Support the compilation of matrix and struct types to struct types in the SPIR-V based backends (link, link, link, link, link, link, link)
  • Avoid allocating a buffer for an argument that is not loaded in the offload pass (link)
  • Avoid repeating the logic for getting the buffer value for the args struct in the graph_data.cpp file (link)
  • Avoid potential issues with the lifetime of the Value objects in the spirv_ir_builder.cpp file (link)

@netlify
Copy link

netlify bot commented Apr 23, 2023

Deploy Preview for docsite-preview ready!

Name Link
🔨 Latest commit a2ac2c9
🔍 Latest deploy log https://app.netlify.com/sites/docsite-preview/deploys/64463fbe1dcf230008bf283f
😎 Deploy Preview https://deploy-preview-7873--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.

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.

Struct with Vector field in kernel argument error
1 participant