jorisvandenbossche commented on code in PR #8510: URL: https://github.com/apache/arrow/pull/8510#discussion_r1131057402
########## cpp/src/arrow/extension/fixed_shape_tensor.h: ########## @@ -0,0 +1,121 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#include <numeric> +#include <sstream> + +#include "arrow/extension_type.h" + +namespace arrow { +namespace extension { + +const std::shared_ptr<DataType> GetStorageType( + const std::shared_ptr<DataType>& value_type, const std::vector<int64_t>& shape); + +class ARROW_EXPORT FixedShapeTensorArray : public ExtensionArray { + public: + using ExtensionArray::ExtensionArray; +}; + +/// \brief Concrete type class for constant-size Tensor data. +class ARROW_EXPORT FixedShapeTensorType : public ExtensionType { + public: + FixedShapeTensorType(const std::shared_ptr<DataType>& value_type, + const std::vector<int64_t>& shape, + const std::vector<int64_t>& permutation = {}, + const std::vector<std::string>& dim_names = {}) + : ExtensionType(GetStorageType(value_type, shape)), + value_type_(value_type), + shape_(shape), + permutation_(permutation), + dim_names_(dim_names) {} + + std::string extension_name() const override { return "arrow.fixed_shape_tensor"; } + + /// Number of dimensions of tensor elements + size_t ndim() { return shape_.size(); } + + /// Shape of tensor elements + const std::vector<int64_t>& shape() const { return shape_; } + + /// Strides of tensor elements. Strides state offset in bytes between adjacent + /// elements along each dimension. + const std::vector<int64_t>& strides(); Review Comment: Can you clarify the documentation here that this is about _permuted_ strides in case permutation is non-empty (and so not the strides matching the physical layout, which is always row major contiguous) -- 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]
