Do we need from_dlpack when DLPack is supported by asarray?
See original GitHub issueI guess one possible advantage of from_dlpack()
is that it’s more explicit? If that’s desired, then perhaps we should add other explicit constructors like from_buffer()
. Otherwise, it seems redundant with the generic asarray()
, and I would lean towards removing it.
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (8 by maintainers)
Top Results From Across the Web
DLPack support for NumPy · Issue #19013 - GitHub
If I use numpy but import a JAX array (unknowingly where it came from), I should have to know about NUMPY only. And...
Read more >Interoperability — CuPy 11.4.0 documentation
It means you can pass CuPy arrays to kernels JITed with Numba. ... Tensor to cupy.from_dlpack() is only supported in the (new) DLPack...
Read more >How to transfer CuPy arrays to tensorflow - Stack Overflow
DLPack tensor structure is now supported in Tensorflow 2 in the tf.experimental.dlpack package. You can find the howto usage in this repo: ...
Read more >tf.experimental.dlpack.from_dlpack | TensorFlow v2.11.0
Returns the Tensorflow eager tensor. ... The returned tensor uses the memory shared by dlpack capsules from other framework. a = tf ...
Read more >torch.asarray — PyTorch 1.13 documentation
Converts obj to a tensor. obj can be one of: ... When obj is a tensor, NumPy array, or DLPack capsule the returned...
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
I’m not sure, maybe. I’m fine removing just DLPack as well, or leaving as is, or removing both. I think idiomatic code would use:
from_dlpack
for standard-compliant objectsasarray
for converting scalars or sequencesIt’s not great in a standard to have to deal with optional other protocols that are hard to test for. Saying the buffer protocol must/may be supported is not ideal in both cases. And
__array_interface__
or__cuda_array_interface__
the same. I’d lean towards an explicit “may” if we want to do anything, not a “must”.I’m not sure what this means, since the buffer protocol does not support GPUs. Do you mean
__cuda_array_interface__
maybe?Would it be better, then, to remove both DLPack and buffer protocol supports from
asarray()
, so it is more focused and has a separate responsibility fromfrom_dlpack()
?