MCPcopy Create free account
hub / github.com/apache/arrow / IsPermutationValid

Function IsPermutationValid

cpp/src/arrow/extension/tensor_internal.cc:53–67  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

51}
52
53Status 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
69Result<std::vector<int64_t>> ComputeStrides(const std::shared_ptr<DataType>& value_type,
70 std::span<const int64_t> shape,

Callers 2

DeserializeMethod · 0.85

Calls 3

InvalidFunction · 0.50
OKFunction · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected