-
Notifications
You must be signed in to change notification settings - Fork 137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ABI break] Append new fields to DLManagedTensor #105
Conversation
@@ -222,6 +222,12 @@ typedef struct DLManagedTensor { | |||
* The destructors deletes the argument self as well. | |||
*/ | |||
void (*deleter)(struct DLManagedTensor * self); | |||
/* The version of the DLManagedTensor */ | |||
int32_t version; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of introducing a new struct with a DLPack and ABI version, we can just export the DLPack version since it uniquely determines the ABI version. (cc @mattip)
/*! \brief Mark the data readonly. */ | ||
uint8_t readonly; | ||
/*! \brief 128-bytes of padding to preserve ABI compatibility in the future. */ | ||
uint8_t __padding[128]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is 128 bytes of padding enough (or is it too much)?
I think this need to include the |
I thought the reason to append new fields to |
closed in favor of #113 We would like to thanks @tirthasheshpatel for your effort on bringing in this change onward |
Alternative to #101
Addresses #34 and #104
Implements the A1 alternative in #104 (comment)
Instead of appending the new fields to the
DLTesor
which changes the layout ofDLManagedTensor
in a backward incompatible manner, we can add the fields at the end ofDLManagedTensor
itself. This way we won't require new structs to maintain backward compatibility.On Python front: should we add the
__dlpack_info__
dunder and a version keyword as proposed in #101? I'd say yes because, without knowing the requested version, the producer (exporter) cannot tell if it can export a certain type of array e.g. NumPy throws an error if one tries to export a readonly array with the old ABI. On the consumer (importer) side, it can't tell which fields are safe to access without knowing what version is being imported.cc @tqchen @mattip @seberg @rgommers @leofang