stream in `__dlpack__` should not be required to be integers
See original GitHub issuehttps://data-apis.org/array-api/latest/API_specification/array_object.html#dlpack-self-stream-none
says that stream
keyword argument in __dlpack__(self, /, *, stream=None)
should be an integer or None.
However, in dmlc/dlpack#57 discussion (see https://github.com/dmlc/dlpack/issues/57#issuecomment-771854478) in the case of working with SYCL, the stream
may need to be a class representing an in-order sycl queue.
Can we remove the requirements for stream
to be an integer ?
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:13 (13 by maintainers)
Top Results From Across the Web
Specify synchronization semantics · Issue #57 · dmlc/dlpack
Optionally, libraries have a defined way to avoid synchronization (by not giving a stream pointer) if it fits the library's semantics.
Read more >__dlpack__ — Python array API ...
The pointer must be a positive integer or -1 . If stream is -1 , the value may be used by the consumer...
Read more >Python Specification for DLPack - DMLC
The Python specification for DLPack is a part of the Python array API standard. More details about the spec can be found under...
Read more >Stream — PyTorch 1.13 documentation
If device is None (default) or a negative integer, this will use the current device. priority (int, optional) – priority of the stream....
Read more >OrtValue — onnxcustom
Method ortvalue_from_numpy does not copy data, it borrows the data pointer. ... Returns a tuple of integers, (device, device index) (part of __dlpack__ ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for the explanation @oleksandr-pavlyk.
Then how about a type annotation
stream : Optional[Union[int, Any]]
and a note like “For other device types which do have a stream, queue or other synchronization mechanism, the most appropriate type is not yet determined. E.g., for SYCL one may want to use an object containing an in-ordercl::sycl::queue
. This may be standardized in a future version of this API standard”.I agree, not really a way around that. It’s better than have separate methods like:
__dlpack__(self)
__dlpack__(self, stream : Optional[int] = None)
__dlpack__(self, queue : TBD)
Because then you’re back to “what do I do if my library supports multiple device types”.