-
Notifications
You must be signed in to change notification settings - Fork 14
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
Add CMake build flag for generating Python bindings #1
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some minor changes, and a bit of a question mark on using cmake 3.14. but I'll leave that up to your discretion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job on this. Just a few quick questions:
- Would it make sense to leave object ownership in the C++ layer for the Tensor objects? Assuming so, ensuring Python never grabs them by setting the return policy to reference might be much faster (though this is speculative and would require some testing). https://pybind11.readthedocs.io/en/stable/advanced/functions.html#return-value-policies
- Curious if we need a
setup.py
for the generated.so
to be installable in the existing Python environment? - Lastly, just wondering if a separate CMake subproject rather than Makefile would be a good fit?
I'm not sure this applies to the In general, since we're not using raw pointers, pybind11 already seems to do the right thing. That said, I 100% agree that we should keep the return value policies in mind as we write more bindings and run benchmarks when we're not sure.
All you need to do is add the Jet build directory to your
Hmm, that sounds like an interesting idea although I've never used CMake to "build" a Python project before. How would this look like? Is there a way to automatically set up and use a virtual environment? For the time being, I created a CMake script inside the |
Sounds good to me!
Sure, that's fine. The build, install, etc. can be set as a CMake custom command, and allow it all to be handled by the global CMake in the root directory. But I agree not important yet. This can always be iterated on. |
Oh, I see! In that case, I agree that we should do this in the long run; I'll create a story to track this task. |
Context:
One of the major features scheduled for an upcoming Jet release is a set of Python bindings for the Jet C++ interface. The first step towards implementing this feature is creating a build flag for generating these bindings.
Description of the Change:
FetchContent_MakeAvailable
.BUILD_PYTHON
option in the CMake script which generates an.so
file implementing the Python interface for Jet using pybind11.python/
directory is now included in the Format workflow.Benefits:
FetchContent_MakeAvailable
.Possible Drawbacks:
Related GitHub Issues:
None.