[RFC]: DLPack based exchange of dtype and Device
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 35/100
Direzione di ricerca
Non sono specificati file di implementazione né test. Inizia esaminando le interfacce dtype e Device esistenti di array API insieme alle definizioni di DLDataType e DLDevice di DLPack, quindi determina se i metodi proposti e il supporto per from_dlpack rientrano nell’ambito. Il lavoro è completato quando l’ambito e la specifica dell’interfaccia sono stati concordati.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Background
As of now we have standard interface for exchanging tensors through DLPack. One minor but still useful thing is to also provide a mechanism for solutions. Motivating example
import numpy
import torch
# results in error
torch.empty((1, 2), dtype=numpy.float16)
# results in error
numpy.empty((1, 2), dtype=torch.float16)
It could be useful for the package.dtype and package.Device to be able to provide an interface for exchange such information. Given we already have DLDataType and DLDevice in dlpack, it might be helpful to bringup interfaces to transparently expose them. Such information can also be helpful for bindings to implement generic support for these types
Proposal
# defined in dtype
class dtype:
def __dlpack_data_type__():
"""Return a tuple (code, bits, lanes) in DLDataType format
"""
# defined in Device
class Device:
def __dlpack_device__():
"""Return a tuple of (device_type, device_id) """
Then if desirable, the interface could implement something like
def empty(shape, dtype):
if hasattr(dtype, "___dlpack_data_type__"):
convert
There is also possibility of trying to run general value conversion. I do not think we have to update from_dlpack to also support these values, but there is an option to do so
def from_dlpack(src):
if hasattr(src, "__dlpack__"):
# this is an array
if hasattr(src, "__dlpack_data_type__"):
# this is a dtype
if hasattr(src, "__dlpack_device__"):
# this is a device
- Lingua principale
- Python
- Stelle
- 281
- Fork
- 52
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di data-apis/array-api
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 88/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
-
Maintenance
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
Tutte le issue di data-apis/array-api
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
use-agent-os/agent-os#3314 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
BasedHardware/omi#15662 · 1 commento ·
-
documentation help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 90/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
AiursoftWeb/AnduinOS-2#19 ·