yongster opened a new issue, #11248:
URL: https://github.com/apache/arrow-rs/issues/11248

   ### Is your feature request related to a problem or challenge?
   
   `FixedShapeTensor` stores a physical `shape` and an optional `permutations` 
vector, but nothing exposes the logical shape.
   
   The canonical extension defines the permutation as a map from logical 
dimensions to physical dimensions: logical dimension `i` is physical dimension 
`permutations[i]`. The type's own documentation gives the example. Physical 
shape `[100, 200, 500]` and permutation `[2, 0, 1]` have logical shape `[500, 
100, 200]`. Callers currently have to apply that index themselves, and they can 
get it backwards.
   
   Arrow C++ uses this reordered shape when converting a fixed-shape tensor 
extension to a dense tensor. Without it, a `FixedShapeTensor` to `Tensor` 
bridge has to repeat the same indexing in every caller.
   
   This is separate from exposing the physical shape. `dimensions()` and 
`list_size()` still do not identify either shape.
   
   ### Describe the solution you'd like
   
   Add `logical_shape(&self) -> Vec<usize>` on both `FixedShapeTensor` and 
`FixedShapeTensorMetadata`.
   
   - When `permutations` is set, index `i` of the result is 
`shape[permutations[i]]`.
   - When `permutations` is absent, the result is the physical shape.
   
   `try_new` already rejects a permutation that is not a rearrangement of 
`0..n-1`, so the index is in range. No serialization or validation change.
   
   ### Describe alternatives you've considered
   
   - Returning a reference. The logical shape is computed, not stored, so the 
accessor has to return an owned `Vec`.
   - Also returning permuted dimension names or cell strides in the same 
change. Those are useful for a tensor bridge, but they are separate helpers. 
This issue is only the shape reorder.
   - Leaving the reorder to each caller. The mapping is easy to invert, and the 
extension docs are the only place it is written down.
   
   ### Additional context
   
   No open issue covers this. It does not rename the metadata key 
`permutations` to the spec's `permutation`.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to