jorisvandenbossche commented on issue #38325:
URL: https://github.com/apache/arrow/issues/38325#issuecomment-2012412393

   Thanks for the feedback @kkraus14. I started a PR updating the documentation 
page about the PyCapsule protocol to expand with those two new dunder methods 
-> https://github.com/apache/arrow/pull/40708
   
   Apart from just defining `__arrow_c_device_array__` and 
`__arrow_c_device_stream__` and their return values, it might be useful to 
agree on and document some guidelines about when to implement which methods?
   
   * For a CPU-only library, it is encouraged to implement both the standard 
and device version of the protocol methods (i.e. both `__arrow_c_array__` and  
`__arrow_c_device_array__`, and/or both `__arrow_c_stream__` and 
`__arrow_c_device_stream__`)
   * The presence of only the standard version (e.g. only `__arrow_c_array__` 
and not `__arrow_c_device_array__`) means that this is a CPU-only data object.
   * For a device-aware library, and for data structures that can only reside 
in non-CPU memory, you should _only_ implement the device version of the 
protocol (e.g. only add `__arrow_c_device_array__`, and never add a 
`__arrow_c_array__`)
     * Libraries can of course have data structures that can live on both CPU 
or non-CPU, and for those it is fine that they implement both versions (and 
error in the non-device version if the data is not on the CPU)? 
   * Do we want to say something about expectations that no cross-device copies 
happen? Although we don't specify anything about a public consumer method (like 
`from_dlpack`), we could still give the guideline to not let such method do 
device copies? Although that is maybe fully up to the consumer library to 
decide, but at least in the pyarrow consumer methods, we will not do any copies.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to