-
Notifications
You must be signed in to change notification settings - Fork 51
Nanobind build #2147
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
base: master
Are you sure you want to change the base?
Nanobind build #2147
Conversation
Some notes: Additionally, the cpp code can likely simplified somewhat drastically. The interface right now accepts numpy arrays directly, and to make it simple, I just get the underlying pointer to the arrays instead of modifying the code to use whatever nice methods the numpy array types have, since the previous code directly operated on the pointers. |
thanks @purepani; I can fix this after #2148 & #2145. Just a quick note for now - could you use |
Yeah I can try doing those |
d35bd1c
to
43e454e
Compare
Rebased on #2145, got it at least building a wheel on my computer. Also added a commit to move the folder I didn't make any attempt to clean up the code yet. It's just been rebased |
43e454e
to
c41c357
Compare
Switched to |
3b01400
to
bd450f6
Compare
Have no clue why the conda build is failing, but I'll fix that later |
bd450f6
to
60d2bbc
Compare
Note that this updates IPP and removes the need for the fallback IPP introduced in the other pr |
What are the reasons you want to house (See https://nanobind.readthedocs.io/en/latest/ndarray.html) |
As per #2132 (and #1912 #1126 #572 etc.) we're looking to support arbitrary (non-numpy) arrays, so buffer protocol is safest.
You are right that some basic checks must be done manually, e.g. if (info.format != pybind11::format_descriptor<float>::format())
throw std::runtime_error("expected float32"); but tbh even I don't bother1 Footnotes
|
I certainly don't mind doing it either way(since, well, I already did both 😊), but if the main reason is the buffer protocol, then the nanobind code I had should already have worked for that, as well as supporting the DLPack protocol, which is a more modern version of the buffer protocol(i.e. supporting GPU data-backed arrays). Particularly, pybind11 doesn't support DLPack so this is a strict advantage to using nanobind(and a significant one if you want to consider adding some GPU support). Certainly nanobind is less featureful in general, so if there are other features that matter a lot, then it makes more sense to go with pybind11. It just sounded like the buffer protocol was one of the important reasons, so I wanted to clarify nanobind is better than pybind11 in that regard(and arguably with cleaner code since it's a single type for both DLPack and the buffer protocol). |
I'm uncertain; have you tried casting a custom (non-numpy/cupy etc) object (such as the |
Just tested in AMYPAD/NumCu#9 and it looks like
|
Not sure what's up with the |
21dbb34
to
c29e9d5
Compare
I've been trying to remove the requirement to have dependency list duplicated in I have no idea why the normal |
c29e9d5
to
e54c005
Compare
@casperdcl How are you getting IPP through conda in #2145? The intel conda repo doesn't seem to be declared in CI over there. Is it mirrored through the tomographic imaging conda repo? I'm asking just to update IPP so the FindIPP.cmake file can be removed(I think there was some reason I needed to do that, but I forgot what it was) |
5858dfe
to
57e01fe
Compare
I updated the code to use the I went back to nanobind for now, but I still have the pybind commit and can add that easily if preferred. |
4add94e
to
28a2825
Compare
28a2825
to
12432ba
Compare
Rebased |
Not sure why the conda test failed. I'll look at either once I have more time, or this is closer to getting merged. |
12432ba
to
471fa67
Compare
Rebased on master since #2145 is merged! |
Actually, there's one part of this I think I can break off into a separate PR(Updating IPP, and removing the manual IPP discovery workaround). I can maybe break that out into a different PR but that would take more time than I have at this moment. |
I don't have the ability to investigate this at the moment; is there any obvious reason why that attribute doesn't exist? If not, I'll figure it out later. Might be due to conda and the |
471fa67
to
a89b905
Compare
Ok that was clearly it. Feel free to review! |
As a note, I believe this statically links libraries, so related to #2154 |
Use nanobind::ndarray for axpby interface Use nanobind::ndarray for FiniteDifferenceLibrary interface
a89b905
to
44cc9e7
Compare
Also as an alternative to renaming the folder, we could rename the library |
@casperdcl should I be keeping this up with the main branch, or will it be a while before this may get looked at a bit closer? |
Description
I pulled out the nanobind build stuff from #2105 into a separate PR. I haven't exactly figured out how change
Wrappers/Python/CMakeLists.txt
to install it, however. Regardless pulling this out separately is hopefully helpful :)cc @casperdcl