-
Notifications
You must be signed in to change notification settings - Fork 4.2k
GH-33923: [Docs] Tensor canonical extension type specification #33925
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
Changes from 11 commits
af571cb
8231150
884d871
83edd70
16ef6f1
4f4ccce
92fd7c6
7873676
a4219e3
37e83db
5c92ff0
cb5e2dd
b562b8d
c44101b
24e7c28
333ae67
4086dfb
bd2a515
bc07d7a
68c6244
3e2bb25
a49f14f
89d8042
4ff7a65
1daf820
70059d9
6f44296
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -72,4 +72,30 @@ same rules as laid out above, and provide backwards compatibility guarantees. | |
| Official List | ||
| ============= | ||
|
|
||
| No canonical extension types have been standardized yet. | ||
| Fixed shape tensor | ||
| ================== | ||
|
|
||
| * Extension name: `arrow.fixed_shape_tensor`. | ||
|
|
||
| * The storage type of the extension: ``FixedSizeList`` where: | ||
|
|
||
| * **value_type** is the data type of individual tensors and | ||
| is an instance of ``pyarrow.DataType`` or ``pyarrow.Field``. | ||
| * **list_size** is the product of all the elements in tensor shape. | ||
|
|
||
| * Extension type parameters: | ||
|
|
||
| * **value_type** = Arrow DataType of the tensor elements | ||
| * **shape** = shape of the contained tensors as a tuple | ||
|
AlenkaF marked this conversation as resolved.
Outdated
|
||
|
|
||
| * Description of the serialization: | ||
|
|
||
| The metadata must be a valid JSON object including shape of | ||
| the contained tensors as an array with key "shape". | ||
|
|
||
| For example: `{ "shape": [2, 5]}` | ||
|
|
||
| .. note:: | ||
|
|
||
| Elements in an fixed shape tensor extension array are stored | ||
|
AlenkaF marked this conversation as resolved.
Outdated
|
||
| in row-major/C-contiguous order. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just a note that this will prevent storing R matrices as zero-copy. I seem to remember an earlier version of this had an option for storing column-major tensors zero-copy?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is also the case for Julia: https://docs.julialang.org/en/v1/manual/performance-tips/#man-performance-column-major
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you have the same problem right now with FixedSizeList arrays? Or what is this converted to in R now? (can you convert that to a single matrix?) Also, even if we allow a different order or custom strides for each individual tensor, the full array backing the FixedSizeListArray (the flat values child array) still needs the first dimension (with size == length of the logical array) with the biggest strides. So if R doesn't support that, I don't think zero-copy conversion is ever possible?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We'd just have to make a chunked array where every chunk had a single element. We don't currently support converting a fixed-size list as a matrix (if we did it would be faster -- even if it wouldn't be zero copy).
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On further thinking, I am also not sure this is actually a problem. Languages like Julia and R can still create an array/matrix from the raw memory of the ListArray zero-copy. This array will only look transposed to their users if you need to prevent the copy. It's then up to the application/user to decide if you want to keep that or not (have a strided view in expected dimension order, or create a copy)?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see the argument for standardization, too, but I also want to make sure that the less represented languages (R, Julia, Matlab) aren't being marginalized here (I get that the heavy hitters here are TensorFlow and Torch, both of which are uncompromizingly row-major).
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Users have always been able to transport tensors if they are willing to keep track of that kind of metadata themselves. One potential use of this is communicating a single view of one very large tensor, for which case copies are expensive and in most cases unnecessary.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, if you have only one tensor, then both ways would work anyway, right? |
||
Uh oh!
There was an error while loading. Please reload this page.