| 51 | } |
| 52 | |
| 53 | Status IsPermutationValid(std::span<const int64_t> permutation) { |
| 54 | const auto size = static_cast<int64_t>(permutation.size()); |
| 55 | std::vector<uint8_t> dim_seen(size, 0); |
| 56 | |
| 57 | for (const auto p : permutation) { |
| 58 | if (p < 0 || p >= size || dim_seen[p] != 0) { |
| 59 | return Status::Invalid( |
| 60 | "Permutation indices for ", size, |
| 61 | " dimensional tensors must be unique and within [0, ", size - 1, |
| 62 | "] range. Got: ", ::arrow::internal::PrintVector{permutation, ","}); |
| 63 | } |
| 64 | dim_seen[p] = 1; |
| 65 | } |
| 66 | return Status::OK(); |
| 67 | } |
| 68 | |
| 69 | Result<std::vector<int64_t>> ComputeStrides(const std::shared_ptr<DataType>& value_type, |
| 70 | std::span<const int64_t> shape, |
no test coverage detected