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

Function IsPermutationValid

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

Source from the content-addressed store, hash-verified

65}
66
67Status IsPermutationValid(std::span<const int64_t> permutation) {
68 const auto size = static_cast<int64_t>(permutation.size());
69 std::vector<uint8_t> dim_seen(size, 0);
70
71 for (const auto p : permutation) {
72 if (p < 0 || p >= size || dim_seen[p] != 0) {
73 return Status::Invalid(
74 "Permutation indices for ", size,
75 " dimensional tensors must be unique and within [0, ", size - 1,
76 "] range. Got: ", ::arrow::internal::PrintVector{permutation, ","});
77 }
78 dim_seen[p] = 1;
79 }
80 return Status::OK();
81}
82
83Result<std::vector<int64_t>> ComputeStrides(const std::shared_ptr<DataType>& value_type,
84 std::span<const int64_t> shape,

Callers 4

DeserializeMethod · 0.85
MakeMethod · 0.85
DeserializeMethod · 0.85
MakeMethod · 0.85

Calls 3

InvalidFunction · 0.50
OKFunction · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected