jorisvandenbossche commented on code in PR #34797:
URL: https://github.com/apache/arrow/pull/34797#discussion_r1160518144
##########
cpp/src/arrow/extension/fixed_shape_tensor.h:
##########
@@ -23,6 +23,25 @@ namespace extension {
class ARROW_EXPORT FixedShapeTensorArray : public ExtensionArray {
public:
using ExtensionArray::ExtensionArray;
+
+ /// \brief Create a FixedShapeTensorArray from a Tensor
+ ///
+ /// This method will create a FixedShapeTensorArray from a Tensor, taking
its first
+ /// dimension as the number of elements in the resulting array and the
remaining
+ /// dimensions as the shape of the individual tensors. If Tensor provides
strides,
+ /// they will be used to determine dimension permutation. Otherwise,
row-major layout
+ /// (i.e. no permutation) will be assumed.
+ ///
+ /// \param[in] tensor The Tensor to convert to a FixedShapeTensorArray
+ static Result<std::shared_ptr<FixedShapeTensorArray>> FromTensor(
+ const std::shared_ptr<Tensor>& tensor);
+
+ /// \brief Create a Tensor from FixedShapeTensorArray
+ ///
+ /// This method will create a Tensor from a FixedShapeTensorArray, setting
its
+ /// first dimension as length equal to the FixedShapeTensorArray's length
and the
+ /// remaining dimensions as the FixedShapeTensorType's shape.
Review Comment:
Can you add here to the docstring that this will automatically reshape the
resulting Tensor according to the `permutation` metadata of the
FixedShapeTensorArray?
##########
cpp/src/arrow/extension/fixed_shape_tensor.h:
##########
@@ -74,10 +98,17 @@ class ARROW_EXPORT FixedShapeTensorType : public
ExtensionType {
const std::vector<int64_t>& permutation = {},
const std::vector<std::string>& dim_names = {});
+ /// \brief Compute strides of FixedShapeTensorType
+ static Status ComputeStrides(const FixedWidthType& type,
Review Comment:
Is there a need for having this public in addition to `strides()` ?
--
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]