-
Notifications
You must be signed in to change notification settings - Fork 88
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
[FEA] Implementation of MATLAB's find() #147
Comments
Hi @akfite, you're in luck, and I just haven't updated the documentation yet. We do have a find function, and you can see how it's used in the unit tests here: https://github.com/NVIDIA/MatX/blob/main/test/00_operators/ReductionTests.cu#L520 Because it's C++, it's slightly clunkier than MATLAB's |
Awesome, thanks for the quick reply. I'll use your unit tests as a guide. Looking forward to using this code & I appreciate your help! |
As far as I can tell, this implementation of The desired functionality here is to get all the indices that match some selector, and then to be able to use those indices together with the input tensor to create a new tensor or view. That would open up all kinds of useful ways to slice & dice tensors. |
Hi @akfite, understood. This should be doable using different iterator types in CUB. We'll get back to you. |
@cliffburdick Sorry, you're right; I should have looked closer at the outstanding issues. I will say that #135 describes returning the indices as an optional output, but I think it would be more general-form to only return the indices. If one desired the masked values (as it returns now), it would be easily obtained by applying the indices to the input matrix. |
Understood. I have it working and will post the code/examples shortly for you. I was going to default to calling the functions |
Hi @akfite , you can find the test for it here: https://github.com/NVIDIA/MatX/blob/main/test/00_operators/ReductionTests.cu#L553 The one caveat is we'll be adding a way to select these items shortly. It looks like MATLAB's find will return an absolute index regardless of the rank of the array, so it's reasonable for us to do that as well. For example, if you have a 10x5 tensor, index 49 will be the last element and not an array of (9, 4). If you need to translate an absolute index into a coordinate index, we have the utility function |
Excellent! I think returning an absolute index is perfectly reasonable, especially if you have a function to do the conversion. Thanks for turning this around so quickly. |
Hi @akfite, please see the unit test here: This shows a complete example of both the
The slices are here to only select |
The example makes sense--thank you for that. I'm looking forward to trying it out. Unfortunately I still can't compile the unit tests, I've been at it for a few hours and at this point I'm just gonna have to pick it up again tomorrow. I'm trying to get it to work with VS2022 on Windows 10 but have some weird issues. I tried following the build instructions but it wasn't working for me--specifically, I used:
which fails in cmake because "No CMAKE_CUDA_COMPILER could be found", even though
it now successfully finds the CUDA compiler, but now cmake gives another error that:
So I tried
and that got me a .sln, but ultimately only 9 of 20 projects compile in VS2022. It seems some projects are failing because of Hopefully tomorrow I'll figure it out so I can actually test this out! 🤞 |
hi @akfite, officially we don't support Windows, mostly because it's not tested at all. that said, I can try some basic troubleshooting. which version of cmake is this? |
Hey, @cliffburdick I'm on cmake 3.22.1. I commented out
I'll keep fiddling with it. Worst case, I think I'd at least be able to use your code as a guide to implement the same calls to |
My best guess at the moment is that this is the root cause: pybind/pybind11#1710 |
@akfite I'll try that out, and as long as it doesn't affect the Linux builds, you can see if it works for you. Just out of curiosity, are you trying to build a native windows app, or could you use something like WSL instead? MatX compiles just find on WSL in our testing. |
Alright, thank you! My end goal is to use this library to accelerate some CPU-bound compute code in MATLAB with a MEX interface. I was able to compile in WSL but I can't get WSL to detect my GPU with For the most compute-heavy task I couldn't figure out how to return a dynamically-sized array of indices, so I think you've solved the hard part for me. But if I could get the library working I think it would let me do a lot more compute work in CUDA than I would normally do, so I'm still interested in figuring it out. |
Hi @akfite, understood. WSL seems like a separate issue, but it should work there. That being said, I looked at your issue and the solution proposed there doesn't work. I think the answer is that all of this should work if we provide the correct flags for windows, which that issue is supposed to do. The problem is not that nvcc is being passed an incorrect flag, but rather that It also appears that VS doesn't export symbols in the same way gcc does, so it's not as straightforward as simply passing a different flag to the compiler. I think to get proper Windows support we'll need to comb through all the compiler options and make sure they are appropriate for both Windows and Linux. I can't think of anything in the code that should be bound to Linux, so we shouldn't have to change much there. Do you mind opening an issue describing the use case? |
@cliffburdick Gotcha. Thanks for looking into this. Please see #153 |
First of all, let me just say that I'm excited to see this project. I'm a long-time user of MATLAB but very new to CUDA, and I love that you are lowering the barrier of entry to GPU programming.
Is your feature request related to a problem? Please describe.
Slicing a matrix is often paired with MATLAB's built-in find function. I think it would be a valuable addition to this project.
Describe the solution you'd like
Similar to how you have implemented
linspace
,meshgrid
, etc, it would be great to see a similar syntax & functionality to the above link.Describe alternatives you've considered
I just stumbled upon this library today--I read through all the help docs and didn't see this anywhere. Hopefully I didn't miss it!
The text was updated successfully, but these errors were encountered: