question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

stream in `__dlpack__` should not be required to be integers

See original GitHub issue

https://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:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:13 (13 by maintainers)

github_iconTop GitHub Comments

2reactions
rgommerscommented, May 24, 2021

Thanks for the explanation @oleksandr-pavlyk.

as long as it is allowed to be a Python object such that passing dpctl.SyclQueue or PyCapsule would be permitted.

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-order cl::sycl::queue. This may be standardized in a future version of this API standard”.

0reactions
rgommerscommented, May 25, 2021

then unfortunately this runtime check is a price I have to pay, since DLPack attempts to cover all these device types.

I agree, not really a way around that. It’s better than have separate methods like:

  • CPU: __dlpack__(self)
  • CUDA/ROCm: __dlpack__(self, stream : Optional[int] = None)
  • SYCL: __dlpack__(self, queue : TBD)

Because then you’re back to “what do I do if my library supports multiple device types”.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found