Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
gaoqiong
MIGraphX
Commits
54a09384
Commit
54a09384
authored
May 11, 2022
by
charlie
Browse files
Comments fix
parent
8f76125c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
7 deletions
+6
-7
src/include/migraphx/permutation.hpp
src/include/migraphx/permutation.hpp
+6
-0
src/permutation.cpp
src/permutation.cpp
+0
-7
No files found.
src/include/migraphx/permutation.hpp
View file @
54a09384
...
@@ -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
);
...
...
src/permutation.cpp
View file @
54a09384
...
@@ -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
());
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment