-
Notifications
You must be signed in to change notification settings - Fork 83
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
[BUG] Tensors are not "modifiable lvalue" in extended lambdas. #457
Comments
Hi @sksg, when you're passing a tensor to a device/global function the tensor must first be converted to MatX/include/matx/operators/set.h Line 66 in d9a32d5
So your code may be something like
I have not tried this yet to see if it works, but I will test and get back to you today. |
Hi @sksg, the issue is that there are two definitions of
And this works as well. Let me know if that suffices. |
Thanks for the speedy feedback. I did not know that lambdas were const by default. It then makes perfect sense. I did try it with a mutable lambda instead: #include <matx.h>
template<typename FUNC>
__global__ void kernel_launch(FUNC kernel) {
kernel();
}
int main() {
auto a = matx::make_tensor<float>({10});
kernel_launch<<<0, 10>>>([=] __device__() mutable { a(threadIdx.x) = threadIdx.x; }); // <-- No errors!
} Technically, I can verify that the device array Thanks for helping out. This is perfectly usable for me. |
Thanks for the report! |
Describe the bug
When using tensors inside extended lambdas, the tensor elements cannot be assigned to.
To Reproduce
This minimal example fails:
The build fails with
error: expression must be a modifiable lvalue
Expected behavior
The above expression should not fail, and
a
should be filled with numbers from 0..9.System details (please complete the following information):
The text was updated successfully, but these errors were encountered: