Commit 54a09384 authored by charlie's avatar charlie
Browse files

Comments fix

parent 8f76125c
...@@ -32,8 +32,14 @@ inline std::vector<int64_t> sort_permutation(const Vector& data, Op op) ...@@ -32,8 +32,14 @@ inline std::vector<int64_t> sort_permutation(const Vector& data, Op op)
return result; return result;
} }
/*!
* Returns the permutation needed to apply to the shape to undo the current permutation
*/
std::vector<int64_t> invert_permutation(const std::vector<int64_t>& permutation); std::vector<int64_t> invert_permutation(const std::vector<int64_t>& permutation);
/*!
* Finds the permutation most likely from a transpose operator that has been applied to the shape.
*/
std::vector<int64_t> find_permutation(const shape& s); std::vector<int64_t> find_permutation(const shape& s);
std::vector<int64_t> find_permutation(const std::vector<shape>& shapes); std::vector<int64_t> find_permutation(const std::vector<shape>& shapes);
......
...@@ -13,18 +13,11 @@ shape reorder_shape(const shape& s, const std::vector<int64_t>& permutation) ...@@ -13,18 +13,11 @@ shape reorder_shape(const shape& s, const std::vector<int64_t>& permutation)
return {s.type(), reorder_dims(s.lens(), permutation), reorder_dims(s.strides(), permutation)}; return {s.type(), reorder_dims(s.lens(), permutation), reorder_dims(s.strides(), permutation)};
} }
/*!
* Inverts the permutation using the less_than operator
*/
std::vector<int64_t> invert_permutation(const std::vector<int64_t>& permutation) std::vector<int64_t> invert_permutation(const std::vector<int64_t>& permutation)
{ {
return sort_permutation(permutation, std::less<>{}); return sort_permutation(permutation, std::less<>{});
} }
/*!
* Computes a permutation for the lengths based on decesending stride order.
* Compares the lengths if the strides are the same.
*/
std::vector<int64_t> find_permutation(const shape& s) std::vector<int64_t> find_permutation(const shape& s)
{ {
std::vector<std::int64_t> result(s.lens().size()); std::vector<std::int64_t> result(s.lens().size());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment