-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
[TIR] Return error code from kernels in SplitHostDevice #15241
[TIR] Return error code from kernels in SplitHostDevice #15241
Conversation
Prior to this commit, the return type of all internal function calls was hard-coded as `"void"`. After this commit, the `GlobalVar` representing the internal function has type annotation based on the callee's signature, which is then used as the return type of the internal call.
Thanks for contributing to TVM! Please refer to the contributing guidelines https://tvm.apache.org/docs/contribute/ for useful information and tips. Please request code reviews from Reviewers by @-ing them in a comment.
Generated by tvm-bot |
Some codegen types delegate to `CodeGenCPU` for their compute kernels, as they may delegate work to packed functions. Because `CodeGenCPU` assumes that it can return an error code at any point (e.g. when launching a parallel for loop), the compute kernel should return an error code.
032ced1
to
af722ad
Compare
@Lunderberg can you clarify an example that leverages CodegenCPU for kernel. Just want to make sure that our existing path of GPU kernel separated codegen continues to function as error there are propagated by call packed mechanism |
@tqchen Certainly. This mainly comes up in a few edge cases found when debugging a single-module lowering flow (#14985), used for #14862. The issue arose when a These cases are mostly suppressed by the fix in #15102, but can still happen if there's an explicit
Definitely agreed. I updated the original PR to limit the |
* [TVMScript] Handle parsing of PrimFunc calls with non-void return Prior to this commit, the return type of all internal function calls was hard-coded as `"void"`. After this commit, the `GlobalVar` representing the internal function has type annotation based on the callee's signature, which is then used as the return type of the internal call. * Update CallNode return type in MakeUnpackedAPI * [TIR] Return error code from kernels in SplitHostDevice Some codegen types delegate to `CodeGenCPU` for their compute kernels, as they may delegate work to packed functions. Because `CodeGenCPU` assumes that it can return an error code at any point (e.g. when launching a parallel for loop), the compute kernel should return an error code. * [TIR] Remove builtin::ret(0) from device-side kernel * Restrict the int32 return type to targets that need to propagate errors * Updated unit tests for CPU-specific checks
* [TVMScript] Handle parsing of PrimFunc calls with non-void return Prior to this commit, the return type of all internal function calls was hard-coded as `"void"`. After this commit, the `GlobalVar` representing the internal function has type annotation based on the callee's signature, which is then used as the return type of the internal call. * Update CallNode return type in MakeUnpackedAPI * [TIR] Return error code from kernels in SplitHostDevice Some codegen types delegate to `CodeGenCPU` for their compute kernels, as they may delegate work to packed functions. Because `CodeGenCPU` assumes that it can return an error code at any point (e.g. when launching a parallel for loop), the compute kernel should return an error code. * [TIR] Remove builtin::ret(0) from device-side kernel * Restrict the int32 return type to targets that need to propagate errors * Updated unit tests for CPU-specific checks
* [TVMScript] Handle parsing of PrimFunc calls with non-void return Prior to this commit, the return type of all internal function calls was hard-coded as `"void"`. After this commit, the `GlobalVar` representing the internal function has type annotation based on the callee's signature, which is then used as the return type of the internal call. * Update CallNode return type in MakeUnpackedAPI * [TIR] Return error code from kernels in SplitHostDevice Some codegen types delegate to `CodeGenCPU` for their compute kernels, as they may delegate work to packed functions. Because `CodeGenCPU` assumes that it can return an error code at any point (e.g. when launching a parallel for loop), the compute kernel should return an error code. * [TIR] Remove builtin::ret(0) from device-side kernel * Restrict the int32 return type to targets that need to propagate errors * Updated unit tests for CPU-specific checks
Some codegen types delegate to
CodeGenCPU
for their compute kernels, as they may delegate work to packed functions. BecauseCodeGenCPU
assumes that it can return an error code at any point (e.g. when launching a parallel for loop), the compute kernel should return an error code.This PR resolves a potential bug introduced in #15127, which removed the hard-coded override of return type.
The unit tests in this PR rely on changes made in #15239, to allow TVMScript to represent the call into a compute kernel with non-void return type.