-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
GH-41126: [Python] Basic bindings for Device and MemoryManager classes #41685
GH-41126: [Python] Basic bindings for Device and MemoryManager classes #41685
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.
LGTM!
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.
Is it possible to add tests to test_cuda.py
to test a non-cpu path?
""" | ||
Return the DeviceAllocationType of this device. | ||
""" | ||
return _wrap_device_allocation_type(self.device.get().device_type()) |
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.
Why do we wrap device_type, but not other properties like is_cpu?
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.
is_cpu
is a simple bool, and cython takes care of returning that as a python object. For the type here I wanted to return a python enum (and not just an integer)
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.
Thanks for the explanation!
|
||
The returned singleton instance uses the default MemoryPool. | ||
""" | ||
return MemoryManager.wrap(c_default_cpu_memory_manager()) |
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.
Do you plan to later subclass Device
with CPUDevice
and MemoryManager
with CPUMemoryManager
, respectively?
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.
Not necessarily, for now, if not needed? For CPU I am not sure if it is worth it, as looking at device.h, it seems the main thing the subclass provides is allowing to specify a memory pool when creating (which we could also expose through default_cpu_memory_manager
if we want to expose this?
For CUDA there might be more CUDA-specific methods/attributes where it might be more worth providing a subclass.
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.
Indeed, we can do add them later when desired.
We should certainly do that, but we were planning to do that in a follow-up |
Ah, fair enough. |
Rationale for this change
Add bindings for the C++
arrow::Device
andarrow::MemoryManager
classes.What changes are included in this PR?
Basic bindings by adding the
pyarrow.Device
andpyarrow.MemoryManager
classes, and just tested for CPU.What is not included here are additional methods on the
MemoryManager
class (eg to allocate or copy buffers), and this is also not yet tested for CUDA. Planning to do this as follow-ups, and first doing those basic bindings should enable further enhancements to be done in parallel.Are these changes tested?
Yes, for the CPU device only.